Search in sources :

Example 11 with InvalidSmilesException

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));
}
Also used : IMolecule(org.openscience.cdk.interfaces.IMolecule) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) Test(org.junit.Test)

Example 12 with InvalidSmilesException

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));
}
Also used : IMolecule(org.openscience.cdk.interfaces.IMolecule) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) Test(org.junit.Test)

Example 13 with InvalidSmilesException

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();
    }
}
Also used : SmilesParser(org.openscience.cdk.smiles.SmilesParser) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) File(java.io.File) Before(org.junit.Before)

Example 14 with InvalidSmilesException

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;
            }
        }
    }
/**/
}
Also used : IMolecule(org.openscience.cdk.interfaces.IMolecule) CDKException(org.openscience.cdk.exception.CDKException) ArrayList(java.util.ArrayList) List(java.util.List) InvalidSmilesException(org.openscience.cdk.exception.InvalidSmilesException) RMap(org.openscience.cdk.isomorphism.mcss.RMap)

Aggregations

InvalidSmilesException (org.openscience.cdk.exception.InvalidSmilesException)14 IMolecule (org.openscience.cdk.interfaces.IMolecule)8 Polymer (model.Polymer)4 Test (org.junit.Test)4 CDKException (org.openscience.cdk.exception.CDKException)4 MonomersDB (db.MonomersDB)3 PolymersDB (db.PolymersDB)3 PolymersJsonLoader (io.loaders.json.PolymersJsonLoader)3 File (java.io.File)3 ArrayList (java.util.ArrayList)3 HashMap (java.util.HashMap)3 List (java.util.List)3 Monomer (model.Monomer)3 BufferedWriter (java.io.BufferedWriter)2 FileWriter (java.io.FileWriter)2 IOException (java.io.IOException)2 HashSet (java.util.HashSet)2 Molecule (org.openscience.cdk.Molecule)2 RMap (org.openscience.cdk.isomorphism.mcss.RMap)2 StructureDiagramGenerator (org.openscience.cdk.layout.StructureDiagramGenerator)2