/** * 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))); }
private Atom asBracketAtom(int u, Graph g) { Atom a = g.atom(u); int sum = a.aromatic() ? 1 : 0; for (Edge e : g.edges(u)) { sum += e.bond().order(); } return new AtomImpl.BracketAtom(-1, a.element(), a.aromatic() ? a.element().aromaticImplicitHydrogens(sum) : a.element().implicitHydrogens(sum), 0, 0, a.aromatic()); }
private static void traverse(State s, int idx) { s.visit[idx] = true; int mapIdx = s.g.atom(idx).atomClass(); if (mapIdx != 0) { if (s.map[mapIdx] == 0) s.map[mapIdx] = ++s.nMaps; mapIdx = s.map[mapIdx]; s.g.setAtom(idx, AtomBuilder.fromExisting(s.g.atom(idx)).atomClass(mapIdx).build()); } for (Edge e : s.g.edges(idx)) { int nbr = e.other(idx); if (!s.visit[nbr]) traverse(s, nbr); } }
public Graph apply(Graph g) { Graph h = new Graph(g.order()); for (int u = 0; u < g.order(); u++) { h.addAtom(fromSubset(g.atom(u), g.bondedValence(u), g.degree(u))); h.addTopology(g.topologyOf(u)); } // edges are unchanged for (Edge e : g.edges()) h.addEdge(e); return h; }
Edge firstDirectionalLabel(Graph g, int u) { Edge first = null; final int d = g.degree(u); for (int j = 0; j < d; ++j) { final Edge f = g.edgeAt(u, j); if (f.bond() == Bond.UP || f.bond() == Bond.DOWN) { if (first == null || ordering[f.other(u)] < ordering[first.other(u)]) first = f; } } return first; }
private boolean hasAdjDirectionalLabels(Graph g, int u) { final int d = g.degree(u); for (int j = 0; j < d; ++j) { final Edge f = g.edgeAt(u, j); if (f.bond().directional()) return true; } return false; }
private boolean hasAdjDirectionalLabels(Graph g, Edge e) { int u = e.either(); int v = e.other(u); return hasAdjDirectionalLabels(g, u) && hasAdjDirectionalLabels(g, v); }
/** * 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))); }
/** * Renumbers atom-atom maps using a depth-first traversal. Note this function * modifies the input graph. * @param g the graph * @return the input graph */ public static Graph renumberAtomMaps(final Graph g) { RenumberAtomMaps.renumber(g); return g; }