Search in sources :

Example 11 with CDKException

use of org.openscience.cdk.exception.CDKException 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

CDKException (org.openscience.cdk.exception.CDKException)11 IMolecule (org.openscience.cdk.interfaces.IMolecule)7 IAtom (org.openscience.cdk.interfaces.IAtom)5 ArrayList (java.util.ArrayList)4 InvalidSmilesException (org.openscience.cdk.exception.InvalidSmilesException)4 HashSet (java.util.HashSet)3 List (java.util.List)3 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)3 StructureDiagramGenerator (org.openscience.cdk.layout.StructureDiagramGenerator)3 Residue (model.Residue)2 Molecule (org.openscience.cdk.Molecule)2 IBond (org.openscience.cdk.interfaces.IBond)2 RMap (org.openscience.cdk.isomorphism.mcss.RMap)2 Coverage (algorithms.utils.Coverage)1 Match (algorithms.utils.Match)1 BufferedReader (java.io.BufferedReader)1 BufferedWriter (java.io.BufferedWriter)1 File (java.io.File)1 FileReader (java.io.FileReader)1 FileWriter (java.io.FileWriter)1