Skip to content

Commit

Permalink
Merge pull request #194 from rajarshi/master
Browse files Browse the repository at this point in the history
Fixes the LargestChainDescriptor to correctly find all paths
  • Loading branch information
johnmay committed Feb 11, 2016
2 parents 35e874e + bc35c05 commit 7bcbe4f
Show file tree
Hide file tree
Showing 2 changed files with 38 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,11 @@ public DescriptorValue calculate(IAtomContainer atomContainer) {
//IAtom[] atoms = container.getAtoms();
ArrayList<IAtom> startSphere;
ArrayList<IAtom> path;
//Set all VisitedFlags to False
for (int i = 0; i < container.getAtomCount(); i++) {
container.getAtom(i).setFlag(CDKConstants.VISITED, false);
}

//logger.debug("Set all atoms to Visited False");
for (int i = 0; i < container.getAtomCount(); i++) {
for (IAtom a : container.atoms()) a.setFlag(CDKConstants.VISITED, false);

IAtom atomi = container.getAtom(i);
// chain sp3
//logger.debug("atom:"+i+" maxBondOrder:"+container.getMaximumBondOrder(atoms[i])+" Aromatic:"+atoms[i].getFlag(CDKConstants.ISAROMATIC)+" Ring:"+atoms[i].getFlag(CDKConstants.ISINRING)+" FormalCharge:"+atoms[i].getFormalCharge()+" Charge:"+atoms[i].getCharge()+" Flag:"+atoms[i].getFlag(CDKConstants.VISITED));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -115,4 +115,40 @@ public void testSingleOAtom() throws ClassNotFoundException, CDKException, java.
Assert.assertEquals(0, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue());
}

@Test
public void test8LargestChainDescriptor() throws ClassNotFoundException, CDKException, java.lang.Exception {
Object[] params = {new Boolean(true), new Boolean(true)};
descriptor.setParameters(params);
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol = sp.parseSmiles("Cc1nn(c(c1)N)c1nc2c(s1)cccc2");
Assert.assertEquals(0, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue());
}

@Test
public void test9LargestChainDescriptor() throws ClassNotFoundException, CDKException, java.lang.Exception {
Object[] params = {new Boolean(true), new Boolean(true)};
descriptor.setParameters(params);
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol = sp.parseSmiles("Nc1c(cn[nH]1)C#N");
Assert.assertEquals(2, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue());
}

@Test
public void test10LargestChainDescriptor() throws ClassNotFoundException, CDKException, java.lang.Exception {
Object[] params = {new Boolean(true), new Boolean(true)};
descriptor.setParameters(params);
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol = sp.parseSmiles("OCc1ccccc1CN");
Assert.assertEquals(2, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue());
}

@Test
public void test11LargestChainDescriptor() throws ClassNotFoundException, CDKException, java.lang.Exception {
Object[] params = {new Boolean(true), new Boolean(true)};
descriptor.setParameters(params);
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
IAtomContainer mol = sp.parseSmiles("COc1ccc(cc1)c1noc(c1)Cn1nc(C)c(c(c1=O)C#N)C");
Assert.assertEquals(2, ((IntegerResult) descriptor.calculate(mol).getValue()).intValue());
}

}

0 comments on commit 7bcbe4f

Please sign in to comment.