/** * Collapse a graph with specified atom properties to one with organic * subset atoms. * * @param g a chemical graph * @return the chemical graph expanded */ public static Graph collapse(Graph g) { return eti.apply(tsa.apply(ite.apply(g))); }
/** * Given a chemical graph and an edge in that graph, return the implicit * form of that edge. Neither the graph or the edge is modified, if the edge * is already explicit then 'e' is returned. * * @param g chemical graph * @param e an edge of g * @return the edge with specified explicit bond type */ static Edge toImplicitEdge(final Graph g, final Edge e) { final int u = e.either(), v = e.other(u); if (e.bond() == Bond.SINGLE || e.bond() == Bond.AROMATIC) { return new Edge(u, v, type(g.atom(u), g.atom(v), e.bond())); } return e; }
/** * Transform all explicit to implicit bonds. The original graph is * unmodified. * * @param g a chemical graph * @return new chemical graph but with all explicit bonds */ public Graph apply(final Graph g) { Graph h = new Graph(g.order()); // atom/topology information doesn't change for (int u = 0; u < g.order(); u++) { h.addAtom(g.atom(u)); h.addTopology(g.topologyOf(u)); } // transform edges for (int u = 0; u < g.order(); u++) { for (final Edge e : g.edges(u)) { if (e.other(u) > u) h.addEdge(toImplicitEdge(g, e)); } } return h; }
/** * Convert a graph with atom-based double-bond stereo configuration to * bond-based specification (direction UP and DOWN bonds). * * @param g chemical graph graph * @return a copy of the original graph but with bond-based * stereo-chemistry */ public static Graph bondBasedDBStereo(Graph g) { return eti.apply(ftt.apply(ite.apply(g))); }
/** * Expand a graph with organic subsets to one with specified atom * properties. * * @param g a chemical graph * @return the chemical graph expanded */ public static Graph expand(Graph g) { return eti.apply(fsa.apply(ite.apply(g))); }
/** * Convert any directional bond based stereo configuration to atom-based * specification. * * @param g chemical graph graph * @return a copy of the original graph but with directional bonds removed * and atom-based double-bond stereo configruation. */ public static Graph atomBasedDBStereo(Graph g) { return eti.apply(ttt.apply(ite.apply(g))); }