_id
stringlengths
2
7
title
stringlengths
3
140
partition
stringclasses
3 values
text
stringlengths
73
34.1k
language
stringclasses
1 value
meta_information
dict
q156200
NotificationsActor.onBusEvent
train
@Override public void onBusEvent(Event event) { if (event instanceof AppVisibleChanged) { AppVisibleChanged visibleChanged = (AppVisibleChanged) event; if (visibleChanged.isVisible()) { onAppVisible(); } else { onAppHidden(); } ...
java
{ "resource": "" }
q156201
KuznechikCipher.encryptBlock
train
public void encryptBlock(byte[] data, int offset, byte[] dest, int destOffset) { // w128_t x; // x.q[0] = ((uint64_t *) blk)[0]; // x.q[1] = ((uint64_t *) blk)[1]; Kuz128 x = new Kuz128(); x.setQ(0, ByteStrings.bytesToLong(data, offset)); x.setQ(1, ByteStrings.bytesToLong...
java
{ "resource": "" }
q156202
KuznechikCipher.decryptBlock
train
@Override public void decryptBlock(byte[] data, int offset, byte[] dest, int destOffset) { // w128_t x; // x.q[0] = ((uint64_t *) blk)[0] ^ key->k[9].q[0]; // x.q[1] = ((uint64_t *) blk)[1] ^ key->k[9].q[1]; Kuz128 x = new Kuz128(); x.setQ(0, ByteStrings.bytesToLong(data, off...
java
{ "resource": "" }
q156203
KuznechikCipher.convertKey
train
static KuzIntKey convertKey(byte[] key) { if (key.length != 32) { throw new RuntimeException("Key might be 32 bytes length"); } KuzIntKey kuz = new KuzIntKey(); // w128_t c, x, y, z; Kuz128 c = new Kuz128(), x = new Kuz128(), y = new Kuz128(), z = new Kuz128(); ...
java
{ "resource": "" }
q156204
ActorSDK.waitForReady
train
public void waitForReady() { if (!isLoaded) { synchronized (LOAD_LOCK) { if (!isLoaded) { try { long start = Runtime.getActorTime(); LOAD_LOCK.wait(); Log.d(TAG, "Waited for startup in " + (Ru...
java
{ "resource": "" }
q156205
ActorSDK.getDelegatedFragment
train
public <T> T getDelegatedFragment(ActorIntent delegatedIntent, android.support.v4.app.Fragment baseFragment, Class<T> type) { if (delegatedIntent != null && delegatedIntent instanceof ActorIntentFragmentActivity && ((ActorIntentFragmentActivity) delegatedIntent).getFragment() !=...
java
{ "resource": "" }
q156206
Promises.tuple
train
@ObjectiveCName("tupleWithT1:withT2:") public static <T1, T2> Promise<Tuple2<T1, T2>> tuple(Promise<T1> t1, Promise<T2> t2) { return PromisesArray.ofPromises((Promise<Object>) t1, (Promise<Object>) t2) .zip() .map(src -> new Tuple2<>((T1) src.get(0), (T2) src.get(1))); }
java
{ "resource": "" }
q156207
Promises.tuple
train
@ObjectiveCName("tupleWithT1:withT2:withT3:") public static <T1, T2, T3> Promise<Tuple3<T1, T2, T3>> tuple(Promise<T1> t1, Promise<T2> t2, Promise<T3> t3) { return PromisesArray.ofPromises((Promise<Object>) t1, (Promise<Object>) t2, (Promise<Object>) t3) .zip() .map(src -> ne...
java
{ "resource": "" }
q156208
Promises.traverse
train
public static <T> Promise traverse(List<Supplier<Promise<T>>> queue) { if (queue.size() == 0) { return Promise.success(null); } return queue.remove(0).get() .flatMap(v -> traverse(queue)); }
java
{ "resource": "" }
q156209
Patterns.concatGroups
train
public static final String concatGroups(MatcherCompat matcher) { StringBuilder b = new StringBuilder(); final int numGroups = matcher.groupCount(); for (int i = 1; i <= numGroups; i++) { String s = matcher.group(i); if (s != null) { b.append(s); ...
java
{ "resource": "" }
q156210
Patterns.digitsAndPlusOnly
train
public static final String digitsAndPlusOnly(MatcherCompat matcher) { StringBuilder buffer = new StringBuilder(); String matchingRegion = matcher.group(); for (int i = 0, size = matchingRegion.length(); i < size; i++) { char character = matchingRegion.charAt(i); if (chara...
java
{ "resource": "" }
q156211
BitmapUtil.writeInt
train
private static byte[] writeInt(int value) throws IOException { byte[] b = new byte[4]; b[0] = (byte) (value & 0x000000FF); b[1] = (byte) ((value & 0x0000FF00) >> 8); b[2] = (byte) ((value & 0x00FF0000) >> 16); b[3] = (byte) ((value & 0xFF000000) >> 24); return b; }
java
{ "resource": "" }
q156212
Actor.reply
train
public void reply(Object message) { if (context.sender() != null) { context.sender().send(message, self()); } }
java
{ "resource": "" }
q156213
Actor.drop
train
public void drop(Object message) { if (system().getTraceInterface() != null) { system().getTraceInterface().onDrop(sender(), message, this); } reply(new DeadLetter(message)); }
java
{ "resource": "" }
q156214
ExponentialBackoff.exponentialWait
train
public synchronized long exponentialWait() { long maxDelayRet = minDelay + ((maxDelay - minDelay) / maxFailureCount) * currentFailureCount; return (long) (random.nextFloat() * maxDelayRet); }
java
{ "resource": "" }
q156215
Promise.then
train
@ObjectiveCName("then:") public synchronized Promise<T> then(final Consumer<T> then) { if (isFinished) { if (exception == null) { dispatcher.dispatch(() -> then.apply(result)); } } else { callbacks.add(new PromiseCallback<T>() { @Ov...
java
{ "resource": "" }
q156216
Promise.map
train
@ObjectiveCName("map:") public <R> Promise<R> map(final Function<T, R> res) { final Promise<T> self = this; return new Promise<>((PromiseFunc<R>) resolver -> { self.then(t -> { R r; try { r = res.apply(t); } catch (Excep...
java
{ "resource": "" }
q156217
Promise.flatMap
train
@ObjectiveCName("flatMap:") public <R> Promise<R> flatMap(final Function<T, Promise<R>> res) { final Promise<T> self = this; return new Promise<>((PromiseFunc<R>) resolver -> { self.then(t -> { Promise<R> promise; try { promise = res.ap...
java
{ "resource": "" }
q156218
Promise.chain
train
public <R> Promise<T> chain(final Function<T, Promise<R>> res) { final Promise<T> self = this; return new Promise<>(resolver -> { self.then(t -> { Promise<R> chained = res.apply(t); chained.then(t2 -> resolver.result(t)); chained.failure(e -> r...
java
{ "resource": "" }
q156219
Promise.after
train
public Promise<T> after(final ConsumerDouble<T, Exception> afterHandler) { then(t -> afterHandler.apply(t, null)); failure(e -> afterHandler.apply(null, e)); return this; }
java
{ "resource": "" }
q156220
Promise.pipeTo
train
@ObjectiveCName("pipeTo:") public Promise<T> pipeTo(PromiseResolver<T> resolver) { then(t -> resolver.result(t)); failure(e -> resolver.error(e)); return this; }
java
{ "resource": "" }
q156221
Hex.hex
train
public static String hex(byte[] bytes) { char[] hexChars = new char[bytes.length * 2]; for (int j = 0; j < bytes.length; j++) { int v = bytes[j] & 0xFF; hexChars[j * 2] = HEXES_SMALL[v >>> 4]; hexChars[j * 2 + 1] = HEXES_SMALL[v & 0x0F]; } return new S...
java
{ "resource": "" }
q156222
BubbleContainer.onMeasure
train
@Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { int topOffset = 0; View messageView = findMessageView(); int padding = Screen.dp(8); if (showAvatar) { padding += Screen.dp(48); } measureChildWithMargins(messageView, widt...
java
{ "resource": "" }
q156223
ActorApi.request
train
public synchronized <T extends Response> long request(Request<T> request, RpcCallback<T> callback, long timeout) { if (request == null) { throw new RuntimeException("Request can't be null"); } long rid = NEXT_RPC_ID.incrementAndGet(); this.apiBroker.send(new ApiBroker.Perform...
java
{ "resource": "" }
q156224
ActorBox.openBox
train
public static byte[] openBox(byte[] header, byte[] cipherText, ActorBoxKey key) throws IntegrityException { CBCHmacBox aesCipher = new CBCHmacBox(Crypto.createAES128(key.getKeyAES()), Crypto.createSHA256(), key.getMacAES()); CBCHmacBox kuzCipher = new CBCHmacBox(new Kuzne...
java
{ "resource": "" }
q156225
ActorBox.closeBox
train
public static byte[] closeBox(byte[] header, byte[] plainText, byte[] random32, ActorBoxKey key) throws IntegrityException { CBCHmacBox aesCipher = new CBCHmacBox(Crypto.createAES128(key.getKeyAES()), Crypto.createSHA256(), key.getMacAES()); CBCHmacBox kuzCipher = new CBCHmacBox(new KuznechikFastEngine(...
java
{ "resource": "" }
q156226
JavaUtil.contains
train
public static boolean contains(String[] vals, String value) { for (int i = 0; i < vals.length; i++) { if (vals[i].equals(value)) { return true; } } return false; }
java
{ "resource": "" }
q156227
JavaUtil.equalsE
train
public static <T> boolean equalsE(T a, T b) { if (a == null && b == null) { return true; } if (a != null && b == null) { return false; } if (a == null) { return false; } return a.equals(b); }
java
{ "resource": "" }
q156228
JavaUtil.last
train
public static <T> List<T> last(List<T> elements, int limit) { ArrayList<T> res = new ArrayList<T>(); for (int i = 0; i < elements.size(); i++) { if (res.size() >= limit) { break; } res.add(elements.get(elements.size() - 1 - i)); } retur...
java
{ "resource": "" }
q156229
JavaUtil.unbox
train
public static long[] unbox(List<Long> list) { long[] res = new long[list.size()]; for (int i = 0; i < res.length; i++) { res[i] = list.get(i); } return res; }
java
{ "resource": "" }
q156230
GlobalStateVM.onGlobalCounterChanged
train
public synchronized void onGlobalCounterChanged(int value) { globalCounter.change(value); if (!isAppVisible.get()) { globalTempCounter.change(value); } }
java
{ "resource": "" }
q156231
AsyncListEngine.addOrUpdateItem
train
@Override public void addOrUpdateItem(T item) { synchronized (LOCK) { // Update memory cache cache.onObjectUpdated(item.getEngineId(), item); List<T> items = new ArrayList<T>(); items.add(item); asyncStorageInt.addOrUpdateItems(items); ...
java
{ "resource": "" }
q156232
KeyManagerActor.fetchOwnIdentity
train
private Promise<OwnIdentity> fetchOwnIdentity() { return Promise.success(new OwnIdentity(ownKeys.getKeyGroupId(), ownKeys.getIdentityKey())); }
java
{ "resource": "" }
q156233
KeyManagerActor.fetchPreKey
train
private Promise<PrivateKey> fetchPreKey(byte[] publicKey) { try { return Promise.success(ManagedList.of(ownKeys.getPreKeys()) .filter(PrivateKey.PRE_KEY_EQUALS(publicKey)) .first()); } catch (Exception e) { Log.d(TAG, "Unable to find own pr...
java
{ "resource": "" }
q156234
KeyManagerActor.fetchPreKey
train
private Promise<PrivateKey> fetchPreKey(long keyId) { try { return Promise.success(ManagedList.of(ownKeys.getPreKeys()) .filter(PrivateKey.PRE_KEY_EQUALS_ID(keyId)) .first()); } catch (Exception e) { Log.d(TAG, "Unable to find own pre key #...
java
{ "resource": "" }
q156235
KeyManagerActor.fetchUserGroups
train
private Promise<UserKeys> fetchUserGroups(final int uid) { User user = users().getValue(uid); if (user == null) { throw new RuntimeException("Unable to find user #" + uid); } final UserKeys userKeys = getCachedUserKeys(uid); if (userKeys != null) { retur...
java
{ "resource": "" }
q156236
KeyManagerActor.fetchUserPreKey
train
private Promise<PublicKey> fetchUserPreKey(final int uid, final int keyGroupId, final long keyId) { User user = users().getValue(uid); if (user == null) { throw new RuntimeException("Unable to find user #" + uid); } return pickUserGroup(uid, keyGroupId) .fla...
java
{ "resource": "" }
q156237
KeyManagerActor.fetchUserPreKey
train
private Promise<PublicKey> fetchUserPreKey(final int uid, final int keyGroupId) { return pickUserGroup(uid, keyGroupId) .flatMap(new Function<Tuple2<UserKeysGroup, UserKeys>, Promise<PublicKey>>() { @Override public Promise<PublicKey> apply(final Tuple2<Us...
java
{ "resource": "" }
q156238
KeyManagerActor.onPublicKeysGroupAdded
train
private void onPublicKeysGroupAdded(int uid, ApiEncryptionKeyGroup keyGroup) { UserKeys userKeys = getCachedUserKeys(uid); if (userKeys == null) { return; } UserKeysGroup validatedKeysGroup = validateUserKeysGroup(uid, keyGroup); if (validatedKeysGroup != null) { ...
java
{ "resource": "" }
q156239
KeyManagerActor.onPublicKeysGroupRemoved
train
private void onPublicKeysGroupRemoved(int uid, int keyGroupId) { UserKeys userKeys = getCachedUserKeys(uid); if (userKeys == null) { return; } UserKeys updatedUserKeys = userKeys.removeUserKeyGroup(keyGroupId); cacheUserKeys(updatedUserKeys); context().getEnc...
java
{ "resource": "" }
q156240
ClcMessenger.clearPref
train
public void clearPref() { try { ((ClcJavaPreferenceStorage) modules.getPreferences()).getPref().clear(); } catch (BackingStoreException e) { logger.error("Cannot clear preferences", e); } }
java
{ "resource": "" }
q156241
ImageLoading.loadBitmap
train
public static Bitmap loadBitmap(Uri uri, Context context) throws ImageLoadException { return loadBitmap(new UriSource(uri, context)); }
java
{ "resource": "" }
q156242
ImageLoading.loadBitmapOptimized
train
public static Bitmap loadBitmapOptimized(Uri uri, Context context) throws ImageLoadException { return loadBitmapOptimized(uri, context, MAX_PIXELS); }
java
{ "resource": "" }
q156243
ImageLoading.save
train
public static byte[] save(Bitmap src) throws ImageSaveException { return save(src, Bitmap.CompressFormat.JPEG, JPEG_QUALITY); }
java
{ "resource": "" }
q156244
ImageLoading.saveHq
train
public static byte[] saveHq(Bitmap src) throws ImageSaveException { return save(src, Bitmap.CompressFormat.JPEG, JPEG_QUALITY_HQ); }
java
{ "resource": "" }
q156245
ImageLoading.save
train
public static void save(Bitmap src, String fileName) throws ImageSaveException { saveJpeg(src, fileName, JPEG_QUALITY); }
java
{ "resource": "" }
q156246
ImageLoading.saveLq
train
public static void saveLq(Bitmap src, String fileName) throws ImageSaveException { saveJpeg(src, fileName, JPEG_QUALITY_LOW); }
java
{ "resource": "" }
q156247
ImageLoading.savePng
train
public static void savePng(Bitmap src, String fileName) throws ImageSaveException { save(src, fileName, Bitmap.CompressFormat.PNG, 100); }
java
{ "resource": "" }
q156248
ImageLoading.saveBmp
train
public static void saveBmp(Bitmap src, String fileName) throws ImageSaveException { try { BitmapUtil.save(src, fileName); } catch (IOException e) { throw new ImageSaveException(e); } }
java
{ "resource": "" }
q156249
ImageLoading.bitmapSize
train
public static int bitmapSize(Bitmap bitmap) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { return bitmap.getByteCount(); } else { return bitmap.getRowBytes() * bitmap.getHeight(); } }
java
{ "resource": "" }
q156250
ImageLoading.loadBitmapReuseExact
train
private static ReuseResult loadBitmapReuseExact(ImageSource source, Bitmap dest) throws ImageLoadException { ImageMetadata metadata = source.getImageMetadata(); boolean tryReuse = false; if (dest.isMutable() && dest.getWidth() == metadata.getW() && dest.getHeight(...
java
{ "resource": "" }
q156251
ImageLoading.save
train
private static void save(Bitmap src, String fileName, Bitmap.CompressFormat format, int quality) throws ImageSaveException { FileOutputStream outputStream = null; try { outputStream = new FileOutputStream(fileName); src.compress(format, quality, outputStream); outputS...
java
{ "resource": "" }
q156252
CIPTool.getLigands
train
private static ILigand[] getLigands(IAtom atom, IAtomContainer container, IAtom exclude) { List<IAtom> neighbors = container.getConnectedAtomsList(atom); ILigand[] ligands = new ILigand[neighbors.size() - 1]; int i = 0; for (IAtom neighbor : neighbors) { if (!neighbor.equa...
java
{ "resource": "" }
q156253
CIPTool.getLigandLigands
train
public static ILigand[] getLigandLigands(ILigand ligand) { if (ligand instanceof TerminalLigand) return new ILigand[0]; IAtomContainer container = ligand.getAtomContainer(); IAtom ligandAtom = ligand.getLigandAtom(); IAtom centralAtom = ligand.getCentralAtom(); VisitedAtoms visi...
java
{ "resource": "" }
q156254
Gaussian03Reader.readCoordinates
train
private void readCoordinates(IChemModel model) throws CDKException, IOException { IAtomContainer container = model.getBuilder().newInstance(IAtomContainer.class); String line = input.readLine(); line = input.readLine(); line = input.readLine(); line = input.readLine(); wh...
java
{ "resource": "" }
q156255
Gaussian03Reader.readPartialCharges
train
private void readPartialCharges(IChemModel model) throws CDKException, IOException { logger.info("Reading partial atomic charges"); IAtomContainerSet moleculeSet = model.getMoleculeSet(); IAtomContainer molecule = moleculeSet.getAtomContainer(0); String line = input.readLine(); // skip f...
java
{ "resource": "" }
q156256
PeriodicTablePositionDescriptor.calculate
train
@Override public DescriptorValue calculate(IAtom atom, IAtomContainer container) { int period; String symbol = atom.getSymbol(); period = periodicTable.get(symbol); return new DescriptorValue(getSpecification(), getParameterNames(), getParameters(), new IntegerResult(period), ...
java
{ "resource": "" }
q156257
FormatStringBuffer.skipDigits
train
private int skipDigits() { char ch; int i = 0; while (index < format.length()) { if (Character.isDigit(ch = format.charAt(index))) { index++; i = i * 10 + Character.digit(ch, 10); } else { break; } } ...
java
{ "resource": "" }
q156258
AbstractDiscretePartitionRefiner.getAutomorphismPartition
train
public Partition getAutomorphismPartition() { final int n = group.getSize(); final DisjointSetForest forest = new DisjointSetForest(n); group.apply(new PermutationGroup.Backtracker() { boolean[] inOrbit = new boolean[n]; private int inOrbitCount = 0; ...
java
{ "resource": "" }
q156259
AbstractDiscretePartitionRefiner.getHalfMatrixString
train
private String getHalfMatrixString(Permutation permutation) { StringBuilder builder = new StringBuilder(permutation.size()); int size = permutation.size(); for (int indexI = 0; indexI < size - 1; indexI++) { for (int indexJ = indexI + 1; indexJ < size; indexJ++) { bui...
java
{ "resource": "" }
q156260
AbstractDiscretePartitionRefiner.refine
train
private void refine(PermutationGroup group, Partition coarser) { int vertexCount = getVertexCount(); Partition finer = equitableRefiner.refine(coarser); int firstNonDiscreteCell = finer.getIndexOfFirstNonDiscreteCell(); if (firstNonDiscreteCell == -1) { firstNonDiscreteCell...
java
{ "resource": "" }
q156261
AbstractDiscretePartitionRefiner.compareRowwise
train
private Result compareRowwise(Permutation perm) { int m = perm.size(); for (int i = 0; i < m - 1; i++) { for (int j = i + 1; j < m; j++) { int x = getConnectivity(best.get(i), best.get(j)); int y = getConnectivity(perm.get(i), perm.get(j)); if ...
java
{ "resource": "" }
q156262
PermutationGroup.order
train
public long order() { // A group may have a size larger than Integer.MAX_INTEGER // (2 ** 32 - 1) - for example sym(13) is larger. long total = 1; for (int i = 0; i < size; i++) { int sum = 0; for (int j = 0; j < size; j++) { if (this.permutations[...
java
{ "resource": "" }
q156263
PermutationGroup.transversal
train
public List<Permutation> transversal(final PermutationGroup subgroup) { final long m = this.order() / subgroup.order(); final List<Permutation> results = new ArrayList<Permutation>(); Backtracker transversalBacktracker = new Backtracker() { private boolean finished = false; ...
java
{ "resource": "" }
q156264
PermutationGroup.all
train
public List<Permutation> all() { final List<Permutation> permutations = new ArrayList<Permutation>(); Backtracker counter = new Backtracker() { @Override public void applyTo(Permutation p) { permutations.add(p); } @Override pu...
java
{ "resource": "" }
q156265
PermutationGroup.enter
train
public void enter(Permutation g) { int deg = size; int i = test(g); if (i == deg) { return; } else { permutations[i][g.get(base.get(i))] = new Permutation(g); } for (int j = 0; j <= i; j++) { for (int a = 0; a < deg; a++) { ...
java
{ "resource": "" }
q156266
DictionaryDatabase.readDictionary
train
public void readDictionary(Reader reader, String name) { name = name.toLowerCase(); logger.debug("Reading dictionary: ", name); if (!dictionaries.containsKey(name)) { try { Dictionary dictionary = Dictionary.unmarshal(reader); dictionaries.put(name, di...
java
{ "resource": "" }
q156267
DictionaryDatabase.hasEntry
train
public boolean hasEntry(String dictName, String entryID) { if (hasDictionary(dictName)) { Dictionary dictionary = (Dictionary) dictionaries.get(dictName); return dictionary.hasEntry(entryID.toLowerCase()); } else { return false; } }
java
{ "resource": "" }
q156268
Strand.removeMonomer
train
@Override public void removeMonomer(String name) { if (monomers.containsKey(name)) { Monomer monomer = (Monomer) monomers.get(name); this.remove(monomer); monomers.remove(name); } }
java
{ "resource": "" }
q156269
IsProtonInConjugatedPiSystemDescriptor.calculate
train
@Override public DescriptorValue calculate(IAtom atom, IAtomContainer atomContainer) { IAtomContainer clonedAtomContainer; try { clonedAtomContainer = (IAtomContainer) atomContainer.clone(); } catch (CloneNotSupportedException e) { return new DescriptorValue(getSpecif...
java
{ "resource": "" }
q156270
PharmacophoreMatcher.matches
train
public boolean matches(IAtomContainer atomContainer, boolean initializeTarget) throws CDKException { if (!GeometryUtil.has3DCoordinates(atomContainer)) throw new CDKException("Molecule must have 3D coordinates"); if (pharmacophoreQuery == null) throw new CDKException("Must set the query pharmacophore be...
java
{ "resource": "" }
q156271
PharmacophoreMatcher.getMatchingPharmacophoreBonds
train
public List<List<IBond>> getMatchingPharmacophoreBonds() { if (mappings == null) return null; // XXX: re-subsearching the query List<List<IBond>> bonds = new ArrayList<>(); for (Map<IBond,IBond> map : mappings.toBondMap()) { bonds.add(new ArrayList<>(map.values())); ...
java
{ "resource": "" }
q156272
PharmacophoreMatcher.getTargetQueryBondMappings
train
public List<HashMap<IBond, IBond>> getTargetQueryBondMappings() { if (mappings == null) return null; List<HashMap<IBond,IBond>> bondMap = new ArrayList<>(); // query -> target so need to inverse the mapping // XXX: re-subsearching the query for (Map<IBond,IBond>...
java
{ "resource": "" }
q156273
PharmacophoreMatcher.getMatchingPharmacophoreAtoms
train
public List<List<PharmacophoreAtom>> getMatchingPharmacophoreAtoms() { if (pharmacophoreMolecule == null || mappings == null) return null; return getPCoreAtoms(mappings); }
java
{ "resource": "" }
q156274
PharmacophoreMatcher.getUniqueMatchingPharmacophoreAtoms
train
public List<List<PharmacophoreAtom>> getUniqueMatchingPharmacophoreAtoms() { if (pharmacophoreMolecule == null || mappings == null) return null; return getPCoreAtoms(mappings.uniqueAtoms()); }
java
{ "resource": "" }
q156275
DeAromatizationTool.deAromatize
train
public static boolean deAromatize(IRing ring) { boolean allaromatic = true; for (int i = 0; i < ring.getBondCount(); i++) { if (!ring.getBond(i).getFlag(CDKConstants.ISAROMATIC)) allaromatic = false; } if (!allaromatic) return false; for (int i = 0; i < ring.getBondCo...
java
{ "resource": "" }
q156276
RDFProtonDescriptor_GSR.calculateAngleBetweenTwoLines
train
private double calculateAngleBetweenTwoLines(Vector3d a, Vector3d b, Vector3d c, Vector3d d) { Vector3d firstLine = new Vector3d(); firstLine.sub(a, b); Vector3d secondLine = new Vector3d(); secondLine.sub(c, d); Vector3d firstVec = new Vector3d(firstLine); Vector3d secon...
java
{ "resource": "" }
q156277
RDFProtonDescriptor_GSR.calculateDistanceBetweenTwoAtoms
train
private double calculateDistanceBetweenTwoAtoms(IAtom atom1, IAtom atom2) { double distance; Point3d firstPoint = atom1.getPoint3d(); Point3d secondPoint = atom2.getPoint3d(); distance = firstPoint.distance(secondPoint); return distance; }
java
{ "resource": "" }
q156278
RDFProtonDescriptor_GSR.calculateDistanceBetweenAtomAndBond
train
private double[] calculateDistanceBetweenAtomAndBond(IAtom proton, IBond theBond) { Point3d middlePoint = theBond.get3DCenter(); Point3d protonPoint = proton.getPoint3d(); double[] values = new double[4]; values[0] = middlePoint.distance(protonPoint); values[1] = middlePoint.x; ...
java
{ "resource": "" }
q156279
RDFProtonDescriptor_GSR.getParameterType
train
@Override public Object getParameterType(String name) { if (name.equals("checkAromaticity")) return Boolean.TRUE; return null; }
java
{ "resource": "" }
q156280
AdductFormula.add
train
@Override public void add(IMolecularFormulaSet formulaSet) { for (IMolecularFormula mf : formulaSet.molecularFormulas()) { addMolecularFormula(mf); } }
java
{ "resource": "" }
q156281
AdductFormula.contains
train
@Override public boolean contains(IIsotope isotope) { for (Iterator<IIsotope> it = isotopes().iterator(); it.hasNext();) { IIsotope thisIsotope = it.next(); if (isTheSame(thisIsotope, isotope)) { return true; } } return false; }
java
{ "resource": "" }
q156282
AdductFormula.getCharge
train
@Override public Integer getCharge() { Integer charge = 0; Iterator<IMolecularFormula> componentIterator = components.iterator(); while (componentIterator.hasNext()) { charge += componentIterator.next().getCharge(); } return charge; }
java
{ "resource": "" }
q156283
AdductFormula.getIsotopeCount
train
@Override public int getIsotopeCount(IIsotope isotope) { int count = 0; Iterator<IMolecularFormula> componentIterator = components.iterator(); while (componentIterator.hasNext()) { count += componentIterator.next().getIsotopeCount(isotope); } return count; }
java
{ "resource": "" }
q156284
AdductFormula.isotopes
train
@Override public Iterable<IIsotope> isotopes() { return new Iterable<IIsotope>() { @Override public Iterator<IIsotope> iterator() { return isotopesList().iterator(); } }; }
java
{ "resource": "" }
q156285
AdductFormula.isotopesList
train
private List<IIsotope> isotopesList() { List<IIsotope> isotopes = new ArrayList<IIsotope>(); Iterator<IMolecularFormula> componentIterator = components.iterator(); while (componentIterator.hasNext()) { Iterator<IIsotope> compIsotopes = componentIterator.next().isotopes().iterator(); ...
java
{ "resource": "" }
q156286
ChargeRule.setParameters
train
@Override public void setParameters(Object[] params) throws CDKException { if (params.length != 1) throw new CDKException("ChargeRule expects only one parameter"); if (!(params[0] instanceof Double)) throw new CDKException("The parameter must be of type Double"); charge = (Double) params[0...
java
{ "resource": "" }
q156287
ChargeRule.validate
train
@Override public double validate(IMolecularFormula formula) throws CDKException { logger.info("Start validation of ", formula); if (formula.getCharge() == null) { return 0.0; } else if (formula.getCharge() == charge) { return 1.0; } else { return ...
java
{ "resource": "" }
q156288
BeamToCDK.findDirectionalEdge
train
private Edge findDirectionalEdge(Graph g, int u) { List<Edge> edges = g.edges(u); if (edges.size() == 1) return null; Edge first = null; for (Edge e : edges) { Bond b = e.bond(); if (b == Bond.UP || b == Bond.DOWN) { if (first == null) ...
java
{ "resource": "" }
q156289
BeamToCDK.newTetrahedral
train
private IStereoElement newTetrahedral(int u, int[] vs, IAtom[] atoms, Configuration c) { // no way to handle tetrahedral configurations with implicit // hydrogen or lone pair at the moment if (vs.length != 4) { // sanity check if (vs.length != 3) return null; ...
java
{ "resource": "" }
q156290
BeamToCDK.insert
train
private static int[] insert(int v, int[] vs) { final int n = vs.length; final int[] ws = Arrays.copyOf(vs, n + 1); ws[n] = v; // insert 'u' in to sorted position for (int i = n; i > 0 && ws[i] < ws[i - 1]; i--) { int tmp = ws[i]; ws[i] = ws[i - 1]; ...
java
{ "resource": "" }
q156291
BeamToCDK.createAtom
train
private IAtom createAtom(Element element) { IAtom atom = builder.newAtom(); atom.setSymbol(element.symbol()); atom.setAtomicNumber(element.atomicNumber()); return atom; }
java
{ "resource": "" }
q156292
SmilesValencyChecker.saturate
train
@Override public void saturate(IAtomContainer atomContainer) throws CDKException { logger.info("Saturating atomContainer by adjusting bond orders..."); boolean allSaturated = allSaturated(atomContainer); if (!allSaturated) { logger.info("Saturating bond orders is needed..."); ...
java
{ "resource": "" }
q156293
SmilesValencyChecker.saturate
train
public boolean saturate(IBond[] bonds, IAtomContainer atomContainer) throws CDKException { logger.debug("Saturating bond set of size: ", bonds.length); boolean bondsAreFullySaturated = false; if (bonds.length > 0) { IBond bond = bonds[0]; // determine bonds left ...
java
{ "resource": "" }
q156294
SmilesValencyChecker.saturateByIncreasingBondOrder
train
public boolean saturateByIncreasingBondOrder(IBond bond, IAtomContainer atomContainer) throws CDKException { IAtom[] atoms = BondManipulator.getAtomArray(bond); IAtom atom = atoms[0]; IAtom partner = atoms[1]; logger.debug(" saturating bond: ", atom.getSymbol(), "-", partner.getSymbol()...
java
{ "resource": "" }
q156295
SmilesValencyChecker.couldMatchAtomType
train
public boolean couldMatchAtomType(IAtom atom, double bondOrderSum, IBond.Order maxBondOrder, IAtomType type) { logger.debug("couldMatchAtomType: ... matching atom ", atom, " vs ", type); int hcount = atom.getImplicitHydrogenCount(); int charge = atom.getFormalCharge(); if (charge == ty...
java
{ "resource": "" }
q156296
SmilesValencyChecker.calculateNumberOfImplicitHydrogens
train
public int calculateNumberOfImplicitHydrogens(IAtom atom, double bondOrderSum, IBond.Order maxBondOrder, int neighbourCount) throws CDKException { int missingHydrogens = 0; if (atom instanceof IPseudoAtom) { logger.debug("don't figure it out... it simply does not lack H's"); ...
java
{ "resource": "" }
q156297
SmilesValencyChecker.isSaturated
train
@Override public boolean isSaturated(IAtom atom, IAtomContainer container) throws CDKException { if (atom instanceof IPseudoAtom) { logger.debug("don't figure it out... it simply does not lack H's"); return true; } IAtomType[] atomTypes = getAtomTypeFactory(atom.getB...
java
{ "resource": "" }
q156298
IonizationPotentialTool.familyHalogen
train
private static boolean familyHalogen(IAtom atom) { String symbol = atom.getSymbol(); if (symbol.equals("F") || symbol.equals("Cl") || symbol.equals("Br") || symbol.equals("I")) return true; else return false; }
java
{ "resource": "" }
q156299
IonizationPotentialTool.familyBond
train
private static boolean familyBond(IAtomContainer container, IBond bond) { List<String> normalAt = new ArrayList<String>(); normalAt.add("C"); normalAt.add("H"); if (getDoubleBondNumber(container) > 30) // taking to long return false; StructureResonanceGenerator gRN ...
java
{ "resource": "" }