Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Comparing changes

Choose two branches to see what's changed or to start a new pull request. If you need to, you can also compare across forks.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also compare across forks.
  • 2 commits
  • 2 files changed
  • 0 commit comments
  • 2 contributors
View
5 descriptor/fingerprint/src/main/java/org/openscience/cdk/fingerprint/CircularFingerprinter.java
@@ -956,7 +956,7 @@ private void calculateBioTypes()
}
// calculate each remaining property
- for (int n=0;n<na;n++)
+ for (int n=0;n<na;n++) if (amask[n])
{
maskDon[n]=determineDonor(n);
maskAcc[n]=determineAcceptor(n);
@@ -1070,7 +1070,6 @@ private boolean determinePositive(int aidx)
for (int n=0;n<atomAdj[aidx].length;n++) if (mol.getAtom(atomAdj[aidx][n]).getFormalCharge()<0) return false;
return true;
}
-
final String el=atom.getSymbol();
if (el.equals("N"))
@@ -1084,7 +1083,7 @@ private boolean determinePositive(int aidx)
// have to be without double bonds, i.e. R-N=C(R)NR2 or R-N=C(NR2)NR2 (R=not hydrogen)
if (hasDouble[aidx] && hcount[aidx]==0)
{
- int other=0;
+ int other=-1;
for (int n=0;n<atomAdj[aidx].length;n++) if (bondOrderBioType(bondAdj[aidx][n])==2) {other=atomAdj[aidx][n]; break;}
if (other>=0)
{
View
40 descriptor/fingerprint/src/test/java/org/openscience/cdk/fingerprint/CircularFingerprinterTest.java
@@ -37,11 +37,14 @@
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.exception.InvalidSmilesException;
+import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
+import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.io.ISimpleChemObjectReader;
import org.openscience.cdk.io.*;
import org.openscience.cdk.isomorphism.UniversalIsomorphismTester;
import org.openscience.cdk.iupac.parser.MoleculeBuilder;
+import org.openscience.cdk.silent.Atom;
import org.openscience.cdk.silent.SilentChemObjectBuilder;
import org.openscience.cdk.smiles.SmilesParser;
import org.openscience.cdk.tools.ILoggingTool;
@@ -51,6 +54,10 @@
import java.util.*;
import java.util.zip.*;
+import static org.hamcrest.CoreMatchers.is;
+import static org.hamcrest.MatcherAssert.assertThat;
+import static org.junit.Assert.assertNotNull;
+
/**
* @cdk.module test-standard
*/
@@ -264,5 +271,38 @@ private String formatFP(CircularFingerprinter.FP fp)
for (int n=0;n<fp.atoms.length;n++) str+=(n>0 ? "," : "")+fp.atoms[n];
return str+"}";
}
+
+ @Test public void protonsDontCauseNPE() throws Exception {
+ IAtomContainer proton = new AtomContainer(1, 0, 0, 0);
+ proton.addAtom(atom("H", +1, 0));
+ CircularFingerprinter circ = new CircularFingerprinter(CircularFingerprinter.CLASS_FCFP2);
+ assertThat(circ.getBitFingerprint(proton).cardinality(), is(0));
+ }
+
+ @Test public void iminesDetectionDoesntCauseNPE() throws Exception {
+ IAtomContainer pyrazole = new AtomContainer(6, 6, 0, 0);
+ pyrazole.addAtom(atom("H", 0, 0));
+ pyrazole.addAtom(atom("N", 0, 0));
+ pyrazole.addAtom(atom("C", 0, 1));
+ pyrazole.addAtom(atom("C", 0, 1));
+ pyrazole.addAtom(atom("C", 0, 1));
+ pyrazole.addAtom(atom("N", 0, 0));
+ pyrazole.addBond(0, 1, IBond.Order.SINGLE);
+ pyrazole.addBond(1, 2, IBond.Order.SINGLE);
+ pyrazole.addBond(2, 3, IBond.Order.DOUBLE);
+ pyrazole.addBond(3, 4, IBond.Order.SINGLE);
+ pyrazole.addBond(4, 5, IBond.Order.DOUBLE);
+ pyrazole.addBond(1, 5, IBond.Order.SINGLE);
+ CircularFingerprinter circ = new CircularFingerprinter(CircularFingerprinter.CLASS_FCFP2);
+ assertNotNull(circ.getBitFingerprint(pyrazole));
+ }
+
+ static IAtom atom(String symbol, int q, int h) {
+ IAtom a = new Atom(symbol);
+ a.setFormalCharge(q);
+ a.setImplicitHydrogenCount(h);
+ return a;
+ }
+
}

No commit comments for this range

Something went wrong with that request. Please try again.