use of org._3pq.jgrapht.graph.SimpleGraph in project Smiles2Monomers by yoann-dufresne.
the class Planarity method testCycles.
private boolean testCycles(Biconnected bc) {
Set<SimpleCycle> cycles = bc.getSeparatedCycles();
Iterator<SimpleCycle> i = cycles.iterator();
if (!i.hasNext())
return true;
SimpleCycle mainCycle = i.next();
List<Segment> segments = bc.getSegments(mainCycle);
switch(segments.size()) {
case 0:
return true;
case 1:
Segment s = segments.get(0);
if (s.isStringIn(mainCycle))
return true;
else {
System.err.println("TODO : find separated cycle");
return false;
}
default:
SimpleGraph comp = new CompatibilityGraph(mainCycle, segments);
if (!this.tc.isTwoColorable(comp))
return false;
else {
for (Segment s2 : segments) if (!this.isPlanar(s2))
return false;
return true;
}
}
}
use of org._3pq.jgrapht.graph.SimpleGraph in project Smiles2Monomers by yoann-dufresne.
the class PlanarityTest method main.
public static void main(String[] args) {
String pepDBname = "datas/peptides.csv";
// Loading databases
PolymersJsonLoader pcl = new PolymersJsonLoader(new MonomersDB());
PolymersDB pepDB = pcl.loadFile(pepDBname);
// Tools
Planarity pt = new Planarity();
for (Polymer pep : pepDB.getObjects()) {
System.out.println(pep.getName() + " : ");
IMolecule mol = null;
try {
mol = SmilesConverter.conv.transform(pep.getSmiles());
} catch (InvalidSmilesException e) {
System.err.println("Impossible to parse " + pep.getName() + " id:" + pep.getId());
continue;
}
SimpleGraph g = MoleculeGraphs.getMoleculeGraph(mol);
System.out.println("planar : " + pt.isPlanar(g) + "\n");
}
}
Aggregations