use of org.openscience.cdk.exception.InvalidSmilesException in project Smiles2Monomers by yoann-dufresne.
the class LoadersTests method addaTest.
@Test
public void addaTest() {
String smiles = "CC(C=C(C)C=CC(C(C)C(=O)O)N)C(CC1=CC=CC=C1)OC";
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(smiles);
} catch (InvalidSmilesException e) {
System.err.println("Impossible to parse " + smiles);
}
Monomer adda = new Monomer("Adda", "Adda", smiles);
IMolecule mol = adda.getMolecule();
Assert.assertTrue("O=C(O)C(C)C(N)C=CC(=CC(C)C(OC)Cc1ccccc1)C".equals(SmilesConverter.conv.mol2Smiles(mol)));
}
use of org.openscience.cdk.exception.InvalidSmilesException in project Smiles2Monomers by yoann-dufresne.
the class TreeWidthTests method test.
@Test
public void test() {
MolTreeWidth mtw = new MolTreeWidth();
Polymer pep = null;
try {
pep = this.pepDB.getObject("250");
} catch (NullPointerException e) {
e.printStackTrace();
}
try {
assertEquals(2, mtw.calculateTreeWidth(SmilesConverter.conv.transform(pep.getSmiles())));
} catch (InvalidSmilesException e) {
System.err.println("Impossible to parse smiles");
}
}
use of org.openscience.cdk.exception.InvalidSmilesException in project Smiles2Monomers by yoann-dufresne.
the class OverlapData method main.
public static void main(String[] args) {
// Norine Loading
MonomersJsonLoader monosLoader = new MonomersJsonLoader();
MonomersDB norMonos = monosLoader.loadFile("data/monomers.json");
PolymersJsonLoader loader = new PolymersJsonLoader(norMonos);
PolymersDB norine = loader.loadFile("data/peptides_clean.json");
// CCD Loading
MonomersDB ccdMonos = monosLoader.loadFile("data/pdbe_monos_min.json");
loader = new PolymersJsonLoader(ccdMonos);
PolymersDB ccd = loader.loadFile("data/pdbe_polys_clean.json");
// Norine smiles generation
HashMap<String, Polymer> polymers = new HashMap<>();
for (Polymer poly : norine.getObjects()) {
String smiles = null;
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(poly.getSmiles());
} catch (InvalidSmilesException e) {
e.printStackTrace();
continue;
}
polymers.put(smiles, poly);
}
// Test overlapping peptides
int overlap = 0;
for (Polymer poly : ccd.getObjects()) {
String smiles = null;
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(poly.getSmiles());
} catch (InvalidSmilesException e) {
e.printStackTrace();
continue;
}
if (polymers.containsKey(smiles)) {
System.out.println(polymers.get(smiles).getName());
overlap++;
}
}
System.out.println("Total peptides overlapping : " + overlap);
// Norine smiles generation
HashMap<String, Monomer> monomers = new HashMap<>();
for (Monomer mono : norMonos.getObjects()) {
String smiles = null;
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(mono.getSmiles());
} catch (InvalidSmilesException e) {
e.printStackTrace();
continue;
}
monomers.put(smiles, mono);
}
// Test overlapping peptides
overlap = 0;
for (Monomer mono : ccdMonos.getObjects()) {
String smiles = null;
try {
smiles = SmilesConverter.conv.toCanonicalSmiles(mono.getSmiles());
} catch (InvalidSmilesException e) {
e.printStackTrace();
continue;
}
if (monomers.containsKey(smiles)) {
System.out.println(monomers.get(smiles).getName());
overlap++;
}
}
System.out.println("Total monomers overlapping : " + overlap + "/" + ccdMonos.size());
}
use of org.openscience.cdk.exception.InvalidSmilesException in project Smiles2Monomers by yoann-dufresne.
the class AbstractChemicalObject method getMol.
private Molecule getMol() {
if (this.mol == null) {
try {
boolean generateCoordinates = this.generateCoordinate == null ? false : this.generateCoordinate;
boolean explicite = this.explicitHydrogens == null ? false : this.explicitHydrogens;
if (this.generateH != null && this.generateH.equals(new Boolean(true)))
this.mol = SmilesConverter.conv.transform(this.smiles, false, generateCoordinates, explicite);
else
this.mol = SmilesConverter.conv.transform(this.smiles, true, generateCoordinates, explicite);
} catch (InvalidSmilesException e) {
System.err.println("Impossible to parse \"" + this.smiles + "\"");
Molecule mol = new Molecule();
return mol;
}
}
return this.mol;
}
use of org.openscience.cdk.exception.InvalidSmilesException in project Smiles2Monomers by yoann-dufresne.
the class ResidueCreator method getResiduesWithRule.
/*
* Search Residues for one monomer and one rule.
*/
private Set<Residue> getResiduesWithRule(Residue res, Rule rule) {
Set<Residue> residues = new HashSet<>();
IMolecule ruleMol = null;
try {
ruleMol = SmilesConverter.conv.transform(rule.getFormula(), false, false, true);
} catch (InvalidSmilesException e) {
System.err.println("Impossible to parse " + rule.getName() + " rule");
return residues;
}
boolean status = false;
try {
status = UniversalIsomorphismTester.isSubgraph(res.getMolecule(), ruleMol);
} catch (CDKException e) {
e.printStackTrace();
}
// If rule is found
if (status) {
List<List<RMap>> matches = null;
try {
matches = UniversalIsomorphismTester.getSubgraphAtomsMaps(res.getMolecule(), ruleMol);
} catch (CDKException e) {
e.printStackTrace();
}
if (!"".equals(rule.getExclusion()))
for (String exclusion : rule.getExclusion()) this.removeExclusions(matches, exclusion, res.getMolecule());
for (List<RMap> match : matches) {
Set<Residue> residuesByMatch = this.createResidue(match, rule, res);
residues.addAll(residuesByMatch);
}
}
return residues;
}
Aggregations