use of org.openscience.cdk.exception.InvalidSmilesException in project Smiles2Monomers by yoann-dufresne.
the class MySmilesTests method oxydoAromaticTest.
@Test
public void oxydoAromaticTest() {
String smiles = "c1ccccc1O";
String result = "O(c(c(c(c(c[1]))))(c[1]))";
IMolecule mol = null;
try {
mol = SmilesConverter.conv.transform(smiles);
} catch (InvalidSmilesException e) {
e.printStackTrace();
}
Assert.assertEquals(result, this.ms.convert(mol, false));
}
use of org.openscience.cdk.exception.InvalidSmilesException in project Smiles2Monomers by yoann-dufresne.
the class MySmilesTests method doubleLinkTest.
@Test
public void doubleLinkTest() {
String smiles = "CC(=O)O";
String result = "C(=O)(C)(O)";
IMolecule mol = null;
try {
mol = SmilesConverter.conv.transform(smiles);
} catch (InvalidSmilesException e) {
e.printStackTrace();
}
Assert.assertEquals(result, this.ms.convert(mol, false));
}
use of org.openscience.cdk.exception.InvalidSmilesException in project Smiles2Monomers by yoann-dufresne.
the class CDKMoleculesTests method setUp.
@Before
public void setUp() throws Exception {
this.testFile = new File("data_tests/pictureTest.png");
if (this.testFile.exists())
this.testFile.delete();
this.smiles = "c1ccccc1";
SmilesParser sp = new SmilesParser(DefaultChemObjectBuilder.getInstance());
this.imol = null;
try {
this.imol = sp.parseSmiles(this.smiles);
} catch (InvalidSmilesException e) {
e.printStackTrace();
}
}
use of org.openscience.cdk.exception.InvalidSmilesException in project Smiles2Monomers by yoann-dufresne.
the class ResidueCreator method removeExclusions.
/*
* Remove results corresponding to an exclusion in rule
*/
private void removeExclusions(List<List<RMap>> matches, String ex, IMolecule mol) {
// Verifying exclusions
boolean areExclusion = false;
IMolecule exclusionMol = null;
try {
exclusionMol = SmilesConverter.conv.transform(ex, false, false, true);
} catch (InvalidSmilesException e) {
System.err.println("Impossible to parse " + ex);
return;
}
try {
areExclusion = UniversalIsomorphismTester.isSubgraph(mol, exclusionMol);
} catch (CDKException e) {
e.printStackTrace();
}
if (areExclusion) {
List<RMap> toExclude = null;
boolean flag = false;
List<List<RMap>> exclusions = null;
try {
exclusions = UniversalIsomorphismTester.getSubgraphAtomsMaps(mol, exclusionMol);
} catch (CDKException e) {
e.printStackTrace();
}
for (List<RMap> exclusion : exclusions) {
for (List<RMap> match : matches) {
for (RMap rmMatch : match) {
for (RMap exId : exclusion) {
if (rmMatch.getId1() == exId.getId1()) {
flag = true;
break;
}
}
if (flag)
break;
}
if (flag) {
toExclude = match;
break;
}
}
if (flag) {
matches.remove(toExclude);
toExclude = null;
flag = false;
}
}
}
/**/
}
Aggregations