20package denoptim.graph;
24import java.lang.reflect.Type;
25import java.util.ArrayDeque;
26import java.util.ArrayList;
27import java.util.Collection;
28import java.util.Collections;
29import java.util.Comparator;
30import java.util.HashMap;
31import java.util.HashSet;
32import java.util.Iterator;
33import java.util.LinkedHashMap;
36import java.util.Map.Entry;
37import java.util.Queue;
39import java.util.concurrent.atomic.AtomicInteger;
40import java.util.function.Function;
41import java.util.logging.Level;
42import java.util.logging.Logger;
43import java.util.stream.Collectors;
45import org.jgrapht.alg.isomorphism.VF2GraphIsomorphismInspector;
46import org.jgrapht.graph.DefaultUndirectedGraph;
47import org.openscience.cdk.graph.ConnectivityChecker;
48import org.openscience.cdk.interfaces.IAtom;
49import org.openscience.cdk.interfaces.IAtomContainer;
51import com.google.gson.Gson;
52import com.google.gson.GsonBuilder;
53import com.google.gson.JsonArray;
54import com.google.gson.JsonDeserializationContext;
55import com.google.gson.JsonDeserializer;
56import com.google.gson.JsonElement;
57import com.google.gson.JsonObject;
58import com.google.gson.JsonParseException;
59import com.google.gson.JsonSerializationContext;
60import com.google.gson.JsonSerializer;
62import denoptim.constants.DENOPTIMConstants;
63import denoptim.exception.DENOPTIMException;
64import denoptim.fragspace.FragmentSpace;
65import denoptim.fragspace.FragmentSpaceParameters;
66import denoptim.graph.APClass.APClassDeserializer;
67import denoptim.graph.Edge.BondType;
68import denoptim.graph.Template.ContractLevel;
69import denoptim.graph.Vertex.BBType;
70import denoptim.graph.Vertex.DENOPTIMVertexDeserializer;
71import denoptim.graph.Vertex.VertexType;
72import denoptim.graph.rings.ClosableChain;
73import denoptim.graph.rings.CyclicGraphHandler;
74import denoptim.graph.rings.PathSubGraph;
75import denoptim.graph.rings.RingClosingAttractor;
76import denoptim.graph.rings.RingClosureParameters;
77import denoptim.graph.simplified.Node;
78import denoptim.graph.simplified.NodeConnection;
79import denoptim.graph.simplified.UndirectedEdge;
80import denoptim.io.DenoptimIO;
81import denoptim.json.DENOPTIMgson;
82import denoptim.json.DENOPTIMgson.DENOPTIMExclusionStrategyNoAPMap;
83import denoptim.molecularmodeling.ThreeDimTreeBuilder;
84import denoptim.programs.RunTimeParameters;
85import denoptim.programs.RunTimeParameters.ParametersType;
86import denoptim.utils.GeneralUtils;
87import denoptim.utils.GraphConversionTool;
88import denoptim.utils.GraphEdit;
89import denoptim.utils.GraphUtils;
90import denoptim.utils.MoleculeUtils;
91import denoptim.utils.MutationType;
92import denoptim.utils.ObjectPair;
93import denoptim.utils.RotationalSpaceUtils;
155 private DefaultUndirectedGraph<Vertex, UndirectedEdge>
161 private DefaultUndirectedGraph<Node, NodeConnection>
178 private static final String
SYM_ID =
"symmetryKey";
185 for (
Vertex v : this.gVertices)
186 v.setGraphOwner(
this);
188 gRings =
new ArrayList<>();
208 List<SymmetricVertexes> symSets)
212 this.symVertices = symSets;
232 gEdges =
new ArrayList<>();
233 gRings =
new ArrayList<>();
345 List<Vertex> lst =
new ArrayList<Vertex>();
350 ss.stream().forEach(i -> lst.add((
Vertex) i));
371 List<Vertex> uniqueVertices =
new ArrayList<>();
372 Map<String, List<Vertex>> pathMap =
new HashMap<>();
373 Set<Vertex> visited =
new HashSet<>();
376 AtomicInteger vrtxIdCounter =
new AtomicInteger();
377 AtomicInteger apIdCounter =
new AtomicInteger();
382 if (scaffold ==
null) scaffold = vertex;
384 boolean isVertexNew =
true;
385 Vertex matchedVertex =
null;
388 for (
Vertex uniqueVertex : uniqueVertices)
391 if (vertex.sameAs(uniqueVertex))
394 matchedVertex = uniqueVertex;
401 int vertexKey = vrtxIdCounter.getAndIncrement();
404 Map<AttachmentPoint, Integer> apKeys =
new HashMap<>();
409 if (!symAPs.isEmpty())
411 Integer sharedKey = apKeys.get(symAPs.get(0));
413 if (sharedKey ==
null) {
414 sharedKey = apIdCounter.getAndIncrement();
415 apKeys.put(symAPs.get(0), sharedKey);
418 symAp.setProperty(
SYM_ID, sharedKey);
423 int apKey = apIdCounter.getAndIncrement();
424 ap.setProperty(
SYM_ID, apKey);
429 uniqueVertices.
add(vertex);
439 for (
int i = 0; i < vertex.getAttachmentPoints().size(); i++) {
441 vertex.getAttachmentPoints().get(i);
450 if (scaffold ==
null) {
458 for (Map.Entry<String, List<Vertex>> entry : pathMap.entrySet()) {
492 if (visited.contains(current))
496 visited.add(current);
498 Integer vertexKey = (Integer) current.getProperty(
SYM_ID);
499 currentPath += vertexKey.toString();
502 pathMap.computeIfAbsent(currentPath, k ->
new ArrayList<>()).add(current);
508 if (ap.getEdgeUser()!=
null &&
509 !visited.contains(ap.getEdgeUser().getTrgAP().getOwner()))
511 Edge edge = ap.getEdgeUser();
877 this.symVertices.clear();
894 if (!Collections.disjoint(oldSS, symSet))
897 +
"there is already one that contains some of the same "
980 if (e.getTrgAP().getOwner() == v0)
982 ArrayList<Vertex> parentTree =
new ArrayList<>();
984 return parentTree.get(parentTree.size()-1);
1014 List<Edge> edges =
new ArrayList<Edge>();
1017 if (e.getSrcAP().getOwner() == v)
1035 List<Edge> edges =
new ArrayList<Edge>();
1038 if (e.getTrgAP().getOwner() == v)
1056 ArrayList<Ring> rings =
new ArrayList<Ring>();
1077 ArrayList<Ring> rings =
new ArrayList<Ring>();
1080 boolean matchesAll =
true;
1081 for (
int i=0; i<vs.length; i++)
1083 if (!r.contains(vs[i]))
1101 ArrayList<Ring> rings =
new ArrayList<Ring>();
1104 if (r.containsID(vid))
1122 return gRings.size() > 0;
1154 boolean result =
false;
1157 if (r.containsID(vid))
1170 boolean result =
false;
1192 ArrayList<Vertex> rcvLst =
new ArrayList<Vertex>();
1215 ArrayList<Vertex> free =
new ArrayList<Vertex>();
1237 ArrayList<Vertex> used =
new ArrayList<Vertex>();
1278 BondType bndTypI = vI.getEdgeToParent().getBondType();
1279 BondType bndTypJ = vJ.getEdgeToParent().getBondType();
1280 if (bndTypI != bndTypJ)
1282 String s =
"Attempt to close rings is not compatible "
1283 +
"to the different bond type specified by the "
1284 +
"head and tail APs: (" + bndTypI +
"!="
1285 + bndTypJ +
" for vertices " + vI +
" "
1306 ArrayList<Vertex> arrLst =
new ArrayList<Vertex>();
1329 +
"unique within the graph. VertexID '"
1330 + vertex.getVertexId()+
"' already present in graph "
1332 vertex.setGraphOwner(
this);
1361 for (
Ring r : rToRm)
1368 ArrayList<Edge> eToDel =
new ArrayList<>();
1369 for (
int i=0; i<
gEdges.size(); i++)
1382 for (
Edge e : eToDel)
1388 List<SymmetricVertexes> ssToRemove =
new ArrayList<SymmetricVertexes>();
1391 if (ss.contains(vertex))
1432 if (symSites.size() == 0)
1434 symSites.add(vertex);
1438 for (
Vertex oldLink : symSites)
1455 .getSrcAPThroughout();
1457 .getSrcAPThroughout();
1488 boolean foundLinkToParent =
false;
1491 if (ap.isAvailable() && !ap.isAvailableThroughout())
1493 if (!ap.isSrcInUserThroughout())
1494 foundLinkToParent =
true;
1497 if (!foundLinkToParent)
1510 ArrayList<AttachmentPoint> needyAPsOnChildren =
1511 new ArrayList<AttachmentPoint>();
1513 ArrayList<AttachmentPoint> freeAPsOnParent =
1514 new ArrayList<AttachmentPoint>();
1516 Map<AttachmentPoint,AttachmentPoint> apOnOldToNeedyAP =
1517 new HashMap<AttachmentPoint,AttachmentPoint>();
1520 if (!apOnOld.isAvailableThroughout())
1522 if (apOnOld.isSrcInUserThroughout())
1529 needyAPsOnChildren.add(needyAP);
1530 apOnOldToNeedyAP.put(apOnOld, needyAP);
1536 freeAPsOnParent.add(apOnParent);
1537 freeAPsOnParent.addAll(apOnParent.
getOwner()
1544 List<APMapping> mappings = fragSpace.mapAPClassCompatibilities(
1545 freeAPsOnParent, needyAPsOnChildren, 500);
1546 if (mappings.size() == 0)
1555 List<Integer> preferences =
new ArrayList<Integer>();
1557 for (
int i=0; i<needyAPsOnChildren.size(); i++)
1567 Vertex lastBeforeOwnerOfNeedy =
1569 if (r.contains(lastBeforeOwnerOfNeedy))
1571 preferences.set(i, preferences.get(i) + 1);
1577 int maxScore = Integer.MIN_VALUE;
1584 score = score + preferences.get(needyAPsOnChildren.indexOf(ap));
1586 if (score > maxScore)
1589 bestScoringMapping = apm;
1594 for (Entry<AttachmentPoint, AttachmentPoint> e :
1595 bestScoringMapping.entrySet())
1597 bestScoringMappingReverse.put(e.getValue(), e.getKey());
1602 ArrayList<Ring> ringsToRemove =
new ArrayList<Ring>();
1603 for (
Ring r : rToEdit)
1605 r.removeVertex(vertex);
1606 if (r.getSize() < 3)
1607 ringsToRemove.add(r);
1609 for (
Ring r : ringsToRemove)
1616 LinkedHashMap<AttachmentPoint,AttachmentPoint> newInReplaceOldInInTmpl =
1617 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
1618 List<AttachmentPoint> oldAPToRemoveFromTmpl =
1619 new ArrayList<AttachmentPoint>();
1622 if (oldAP.isAvailable())
1630 if (!oldAP.isAvailableThroughout())
1634 if (bestScoringMapping.keySet().contains(lAP))
1636 newInReplaceOldInInTmpl.put(
1637 bestScoringMapping.get(lAP), oldAP);
1638 }
else if (bestScoringMapping.values().contains(lAP))
1640 newInReplaceOldInInTmpl.put(
1641 bestScoringMappingReverse.get(lAP), oldAP);
1643 oldAPToRemoveFromTmpl.add(oldAP);
1646 oldAPToRemoveFromTmpl.add(oldAP);
1658 List<SymmetricVertexes> ssToRemove =
new ArrayList<SymmetricVertexes>();
1660 while (ssIter.hasNext())
1663 if (ss.contains(vertex))
1674 vertex.resetGraphOwner();
1677 List<AttachmentPoint> reconnettedApsOnChilds =
1678 new ArrayList<AttachmentPoint>();
1679 for (Entry<AttachmentPoint,AttachmentPoint> e :
1680 bestScoringMapping.entrySet())
1687 Edge edge =
new Edge(apOnParent,apOnChild,
1690 reconnettedApsOnChilds.add(apOnChild);
1697 newInReplaceOldInInTmpl.get(apOnParent),
1699 reconnettedApsOnChilds.add(apOnChild);
1704 newInReplaceOldInInTmpl.get(apOnChild),
1706 reconnettedApsOnChilds.add(apOnChild);
1713 + apOnChild +
"' seems connected to a template, "
1714 +
"no template was found. Possible bug!");
1733 if (!reconnettedApsOnChilds.contains(apOnChild))
1757 List<Vertex> rcvToReplace =
new ArrayList<Vertex>();
1758 List<AttachmentPoint> apToCap =
new ArrayList<AttachmentPoint>();
1762 && v.getEdgeToParent()!=
null)
1764 rcvToReplace.add(v);
1765 apToCap.add(v.getEdgeToParent().getSrcAP());
1768 for (
int i=0; i<rcvToReplace.size(); i++)
1770 Vertex v = rcvToReplace.get(i);
1774 APClass cappAPClass = fragSpace.getAPClassOfCappingVertex(
1777 if (cappAPClass !=
null)
1779 Vertex capVrt = fragSpace.getCappingVertexWithAPClass(
1804 while (ssIter.hasNext())
1807 String symmLabel = ss.hashCode() +
"-" + i;
1830 Map<String,List<Vertex>> collectedLabels =
new HashMap<>();
1835 String label = v.getProperty(
1837 if (collectedLabels.containsKey(label))
1839 collectedLabels.get(label).add(v);
1841 List<Vertex> lst =
new ArrayList<Vertex>();
1843 collectedLabels.put(label, lst);
1849 for (String label : collectedLabels.keySet())
1851 List<Vertex> symmvertices = collectedLabels.get(label);
1853 if (symmvertices.size()>1)
1856 for (
Vertex v : symmvertices)
1867 for (
Vertex v : symmvertices)
1872 for (
Vertex v : symmvertices)
1911 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap,
1914 for (
Vertex vToRemove : subGrpVrtxs)
1923 subGrpVrtxs.stream().filter(v -> v.getBuildingBlockType()==
BBType.
CAP)
1925 subGrpVrtxs.removeIf(v -> v.getBuildingBlockType()==
BBType.
CAP);
1926 if (subGrpVrtxs.size() == 0)
1929 +
"vertex in a subgraph to replace.");
1934 incomingGraph.reassignSymmetricLabels();
1941 List<List<Vertex>> compatibleSymSubGrps =
new ArrayList<List<Vertex>>();
1944 boolean skip =
false;
1945 for (
int iv=0; iv<subGrpVrtxs.size(); iv++)
1949 Vertex oriVs = subGrpVrtxs.get(iv);
1950 Vertex symVs = symmetricSubGrpVrtx.get(iv);
1957 oriVsChildren.removeIf(v -> v.getBuildingBlockType()==
BBType.
CAP);
1958 symVsChildren.removeIf(v -> v.getBuildingBlockType()==
BBType.
CAP);
1959 if (oriVsChildren.size()!=symVsChildren.size())
1965 for (
int ic=0; ic<oriVsChildren.size(); ic++)
1970 if (subGrpVrtxs.contains(oriVsChildren.get(ic)))
1977 if (oriVsChildren.get(ic).getBuildingBlockType()
1978 != symVsChildren.get(ic).getBuildingBlockType())
1986 compatibleSymSubGrps.add(symmetricSubGrpVrtx);
1988 if (compatibleSymSubGrps.size()==0)
1991 for (List<Vertex> verticesToRemove : compatibleSymSubGrps)
1996 List<Vertex> vertexAddedToThis =
new ArrayList<Vertex>(
2003 LinkedHashMap<AttachmentPoint,AttachmentPoint> localApMap =
2004 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
2009 int vrtPosOnOld = subGrpVrtxs.indexOf(e.getKey().getOwner());
2010 int apPosOnOld = e.getKey().getIndexInOwner();
2012 vrtPosOnOld).getAP(apPosOnOld);
2014 int vrtPosOnNew = incomingGraph.indexOf(e.getValue().getOwner());
2017 vrtPosOnNew).
getAP(apPosOnNew);
2018 localApMap.put(apOnOld,apOnNew);
2048 if (subGrpVrtxs.stream().anyMatch(v -> v.getBuildingBlockType()==
BBType.
CAP))
2050 +
"symmetric subgraphs");
2052 List<List<Vertex>> symSites =
new ArrayList<List<Vertex>>();
2054 if (subGrpVrtxs.size()==1)
2058 ArrayList<Vertex> lst =
new ArrayList<Vertex>();
2062 if (symSites.size()==0)
2064 symSites.add(subGrpVrtxs);
2070 List<Vertex> thoseWithoutParent =
new ArrayList<Vertex>();
2071 for (
Vertex v : subGrpVrtxs)
2073 if (!subGrpVrtxs.contains(v.getParent()))
2074 thoseWithoutParent.add(v);
2076 if (thoseWithoutParent.size()!=1)
2081 Vertex sourceOfSubGraph = thoseWithoutParent.get(0);
2083 if (numSymmetricSubGraphs==0)
2085 symSites.add(subGrpVrtxs);
2090 List<Vertex> thoseWithoutChildren =
new ArrayList<Vertex>();
2091 for (
Vertex v : subGrpVrtxs)
2093 if (Collections.disjoint(v.getChilddren(),subGrpVrtxs))
2094 thoseWithoutChildren.add(v);
2102 Set<Vertex> upperLimits =
new HashSet<Vertex>();
2103 Set<Vertex> doneBySymmetry =
new HashSet<Vertex>();
2104 for (
Vertex upperLimit : thoseWithoutChildren)
2108 int numInSubGraphReplicas = 1;
2110 if (doneBySymmetry.contains(upperLimit))
2114 Set<Vertex> symmSitesOnBranch =
new HashSet<Vertex>(
2116 symmSitesOnBranch.retainAll(subGrpVrtxs);
2117 if (symmSitesOnBranch.size()>0)
2119 numInSubGraphReplicas = symmSitesOnBranch.size();
2120 doneBySymmetry.addAll(symmSitesOnBranch);
2124 if (lst.size() != numInSubGraphReplicas*numSymmetricSubGraphs)
2127 symSites.add(subGrpVrtxs);
2130 upperLimits.addAll(lst);
2135 List<Vertex> symSubGraph =
new ArrayList<Vertex>();
2137 symSubGraph.add(symSources);
2140 symSubGraph.removeIf(v -> v.getBuildingBlockType()==
BBType.
CAP);
2141 if (symSubGraph.size()!=subGrpVrtxs.size())
2143 symSites =
new ArrayList<List<Vertex>>();
2144 symSites.add(subGrpVrtxs);
2147 symSites.add(symSubGraph);
2185 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap)
2189 ||
gVertices.contains(newSubGraph.getVertexAtPosition(0)))
2195 ArrayList<Vertex> newvertices =
new ArrayList<Vertex>();
2196 newvertices.addAll(newSubGraph.getVertexList());
2201 List<AttachmentPoint> interfaceApsOnOldBranch =
2202 new ArrayList<AttachmentPoint>();
2203 for (
Vertex vToDel : subGrpVrtxs)
2207 if (ap.isAvailable())
2211 interfaceApsOnOldBranch.add(ap);
2213 Vertex user = ap.getLinkedAP().getOwner();
2214 if (!subGrpVrtxs.contains(user))
2216 interfaceApsOnOldBranch.add(ap);
2222 List<AttachmentPoint> interfaceApsOnNewBranch =
2223 new ArrayList<AttachmentPoint>();
2224 for (
Vertex v : newSubGraph.getVertexList())
2228 if (ap.isAvailable())
2232 interfaceApsOnNewBranch.add(ap);
2240 LinkedHashMap<AttachmentPoint,AttachmentPoint>
2241 linksToRecreate =
new LinkedHashMap<>();
2242 LinkedHashMap<AttachmentPoint,BondType>
2243 linkTypesToRecreate =
new LinkedHashMap<>();
2244 LinkedHashMap<AttachmentPoint,AttachmentPoint>
2245 inToOutAPForTemplate =
new LinkedHashMap<>();
2246 List<AttachmentPoint> oldAPToRemoveFromTmpl =
new ArrayList<>();
2250 if (oldAP.isAvailable())
2257 if (oldAP.isAvailableThroughout())
2259 if (!apMap.containsKey(oldAP))
2263 oldAPToRemoveFromTmpl.add(oldAP);
2267 inToOutAPForTemplate.put(apMap.get(oldAP),oldAP);
2270 if (!apMap.containsKey(oldAP))
2273 +
"if a used AP has no mapping.");
2277 inToOutAPForTemplate.put(apMap.get(oldAP),oldAP);
2284 if (!apMap.containsKey(oldAP))
2287 +
"AP has no mapping. Missing mapping for AP "
2288 + oldAP.getIndexInOwner() +
" in "
2289 + oldAP.getOwner().getVertexId());
2296 if (!oldAP.isSrcInUser())
2298 trgAPOnNewLink = newAP;
2303 Map<Ring,List<Vertex>> ringsOverSubGraph =
2304 new HashMap<Ring,List<Vertex>>();
2305 for (
int iA=0; iA<interfaceApsOnOldBranch.size(); iA++)
2312 for (
int iB=(iA+1); iB<interfaceApsOnOldBranch.size(); iB++)
2326 List<Vertex> vPair =
new ArrayList<Vertex>();
2327 vPair.add(r.getCloserToHead(vLinkedOnA, vLinkedOnB));
2328 vPair.add(r.getCloserToTail(vLinkedOnA, vLinkedOnB));
2329 ringsOverSubGraph.put(r, vPair);
2335 for (
Ring r : ringsOverSubGraph.keySet())
2337 List<Vertex> vPair = ringsOverSubGraph.get(r);
2340 for (
int i=1; i<(verticesInPath.size()-1); i++)
2342 r.removeVertex(verticesInPath.get(i));
2349 if (!oldAP.isAvailable())
2354 for (
Vertex vToDel : subGrpVrtxs)
2361 for (
Vertex incomingVrtx : newSubGraph.getVertexList())
2367 for (
Edge incomingEdge : newSubGraph.getEdgeList())
2373 for (
Ring incomingRing : newSubGraph.getRings())
2385 List<AttachmentPoint> doneApsOnNew =
2386 new ArrayList<AttachmentPoint>();
2389 if (trgAPOnNewLink !=
null)
2394 linksToRecreate.get(trgAPOnNewLink),
2396 linkTypesToRecreate.get(trgAPOnNewLink));
2398 doneApsOnNew.add(trgAPOnNewLink);
2406 if (apOnNew == trgAPOnNewLink)
2411 Edge edge =
new Edge(apOnNew,trgOnChild,
2412 linkTypesToRecreate.get(apOnNew));
2414 doneApsOnNew.add(apOnNew);
2418 for (
Ring r : ringsOverSubGraph.keySet())
2420 List<Vertex> vPair = ringsOverSubGraph.get(r);
2422 int initialInsertPoint = r.getPositionOf(vPair.get(0));
2424 for (
int i=1; i<(verticesInPath.size()-1); i++)
2426 r.insertVertex(initialInsertPoint+i, verticesInPath.get(i));
2437 inToOutAPForTemplate.get(apOnNew),apOnNew);
2438 doneApsOnNew.add(apOnNew);
2444 if (!doneApsOnNew.contains(apOnNew))
2460 for (
Vertex vOld : subGrpVrtxs)
2463 for (
Vertex vNew : newvertices)
2488 LinkedHashMap<Integer, Integer> apIdMap,
FragmentSpace fragSpace)
2491 return replaceVertex(vertex, bbId, bbt, apIdMap,
true, fragSpace);
2512 LinkedHashMap<Integer, Integer> apIdMap,
boolean symmetry,
2521 List<Vertex> symSites =
new ArrayList<Vertex>();
2526 if (symSites.size() == 0)
2528 symSites.add(vertex);
2538 for (
Vertex oldLink : symSites)
2542 oldLink.getUnfilteredMutationTypes());
2545 ArrayList<Vertex> oldVertex =
new ArrayList<Vertex>();
2546 oldVertex.add(oldLink);
2547 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap =
2548 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
2549 for (Map.Entry<Integer,Integer> e : apIdMap.entrySet())
2551 apMap.put(oldLink.getAP(e.getKey()),
2590 LinkedHashMap<AttachmentPoint,Integer> apMap,
2594 if (!
gEdges.contains(edge))
2599 List<Edge> symSites =
new ArrayList<Edge> ();
2600 List<LinkedHashMap<AttachmentPoint,Integer>> symApMaps =
2601 new ArrayList<LinkedHashMap<AttachmentPoint,Integer>>();
2603 edge.getTrgAP().getOwner());
2604 if (symTrgvertices.size() == 0)
2607 symApMaps.add(apMap);
2609 for (
Vertex trgVrtx : symTrgvertices)
2611 Edge symEdge = trgVrtx.getEdgeToParent();
2612 symSites.add(symEdge);
2614 LinkedHashMap<AttachmentPoint,Integer> locApMap =
new
2615 LinkedHashMap<AttachmentPoint,Integer>();
2616 locApMap.put(symEdge.
getSrcAP(), apMap.get(edge.getSrcAP()));
2617 locApMap.put(symEdge.
getTrgAP(), apMap.get(edge.getTrgAP()));
2618 symApMaps.add(locApMap);
2623 for (
int i=0; i<symSites.size(); i++)
2625 Edge symEdge = symSites.get(i);
2626 LinkedHashMap<AttachmentPoint,Integer> locApMap = symApMaps.get(i);
2632 LinkedHashMap<AttachmentPoint,AttachmentPoint> apToApMap =
2633 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
2636 apToApMap.put(apOnGraph, newLink.
getAP(locApMap.get(apOnGraph)));
2670 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap)
2696 Edge eSrcToLink =
new Edge(orisEdgeSrc,
2699 Edge eLinkToTrg =
new Edge(apMap.get(orisEdgeTrg),
2706 ArrayList<Ring> rToEdit =
new ArrayList<Ring>();
2709 for (
Ring r : rToEdit)
2711 r.insertVertex(newLink,srcVrtx,trgVrtx);
2722 if (ap.isAvailable())
2745 return ((pos >=
gVertices.size()) || pos < 0) ? null :
2851 if (
gEdges.contains(edge))
2868 if (
gRings.contains(ring))
2880 if ((pos >=
gEdges.size()) || pos < 0)
2911 StringBuilder sb =
new StringBuilder(512);
2913 sb.append(
graphId).append(
" ");
2917 sb.append(
gVertices.get(i).toString()).append(
",");
2922 for (
int i=0; i<
gEdges.size(); i++)
2924 sb.append(
gEdges.get(i).toString()).append(
",");
2929 for (
int i=0; i<
gRings.size(); i++)
2931 sb.append(
gRings.get(i).toString()).append(
" ");
2936 sb.append(
symVertices.get(i).toString()).append(
" ");
2939 return sb.toString();
2958 for (
int i = 0; i < n; i++)
2969 && dap_idx_v1 == dapidx)
3009 if (!children.contains(child))
3011 children.add(child);
3034 boolean markBranches)
3042 AtomicInteger branchIdGenerator =
new AtomicInteger(0);
3043 List<Integer> thisBranchId =
new ArrayList<Integer>();
3044 thisBranchId.add(branchIdGenerator.getAndIncrement());
3055 if (!children.contains(child))
3057 children.add(child);
3065 List<Integer> newBranchId =
new ArrayList<>(thisBranchId);
3066 newBranchId.add(branchIdGenerator.getAndIncrement());
3091 AtomicInteger branchIdGenerator, List<Integer> prevBranchId)
3100 if (!children.contains(child))
3102 children.add(child);
3110 List<Integer> newBranchId =
new ArrayList<>(prevBranchId);
3111 newBranchId.add(branchIdGenerator.getAndIncrement());
3136 List<Vertex> children,
int numLayers,
boolean stopBeforeRCVs)
3149 if (children.contains(child))
3152 if (stopBeforeRCVs && child.isRCV())
3155 children.add(child);
3186 @SuppressWarnings(
"unchecked")
3211 for (Integer i : lst)
3233 if (bIdSrc==
null || bIdTrg==
null)
3235 if (bIdSrc.size()>bIdTrg.size())
3237 int sharedSubBranches = 0;
3238 for (
int i=0; i<bIdSrc.size(); i++)
3240 if (bIdSrc.get(i)==bIdTrg.get(i))
3241 sharedSubBranches++;
3243 return sharedSubBranches==bIdSrc.size();
3258 List<Vertex> children,
boolean stopBeforeRCVs)
3267 if (children.contains(child))
3270 if (stopBeforeRCVs && child.isRCV())
3273 children.add(child);
3290 List<Vertex> children, Set<Vertex> limits)
3299 if (!children.contains(child))
3301 children.add(child);
3302 if (!limits.contains(child))
3322 List<Vertex> children, List<Vertex> limitsInClone,
3323 boolean stopBeforeRCVs)
3332 if (children.contains(child))
3335 if (stopBeforeRCVs && child.isRCV())
3338 children.add(child);
3339 if (!limitsInClone.contains(child))
3355 int shortest = Integer.MAX_VALUE;
3356 for (
Vertex vertex : list)
3358 List<Vertex> parentTree =
new ArrayList<Vertex>();
3360 if (parentTree.size()<shortest)
3362 shortest = parentTree.size();
3379 List<Vertex> parentTree)
3386 if (parentTree.contains(parent))
3389 throw new IllegalArgumentException();
3391 parentTree.add(parent);
3419 ArrayList<Vertex> cListVrtx =
new ArrayList<>();
3420 Map<Long, Vertex> vidsInClone =
new HashMap<Long, Vertex>();
3424 cListVrtx.add(vClone);
3428 ArrayList<Edge> cListEdges =
new ArrayList<>();
3431 long srcVrtxId = e.getSrcVertex();
3435 long trgVrtxId = e.getTrgVertex();
3440 srcVrtxId).getAP(srcApId);
3442 trgVrtxId).getAP(trgApId);
3444 cListEdges.add(
new Edge(srcAPClone, trgAPClone,
3451 ArrayList<Ring> cListRings =
new ArrayList<>();
3455 for (
int iv=0; iv<ring.getSize(); iv++)
3457 Vertex origVrtx = ring.getVertexAtPosition(iv);
3462 cListRings.add(cRing);
3467 ArrayList<ClosableChain> cListClosableChains =
3471 cListClosableChains.add(cc.clone());
3476 List<SymmetricVertexes> cSymVertices =
new ArrayList<>();
3480 for (
Vertex origVrt : ss)
3484 cSymVertices.add(clonedSS);
3522 ArrayList<Integer> lstEdges =
new ArrayList<>();
3545 ArrayList<Edge> lstEdges =
new ArrayList<>();
3565 long mval = Long.MIN_VALUE;
3567 mval = Math.max(mval, v.getVertexId());
3580 boolean result =
false;
3583 if (l == v.getVertexId())
3687 if (other.
jGraph ==
null)
3709 Comparator<Vertex> vComp =
new Comparator<Vertex>() {
3711 Map<Vertex,Set<Vertex>> symmetryShortCuts =
3712 new HashMap<Vertex,Set<Vertex>>();
3718 if (symmetryShortCuts.containsKey(v1)
3719 && symmetryShortCuts.get(v1).contains(v2))
3726 StringBuilder sb =
new StringBuilder();
3729 Set<Vertex> symToV2 =
new HashSet<Vertex>();
3731 Set<Vertex> symToV1 =
new HashSet<Vertex>();
3733 for (
Vertex v1s : symToV1)
3735 if (symmetryShortCuts.containsKey(v1s))
3737 symmetryShortCuts.get(v1s).addAll(symToV2);
3739 symmetryShortCuts.put(v1s,symToV2);
3749 if (Integer.compare(v1.hashCode(),
3751 return Integer.compare(v1.hashCode(),
3759 Comparator<UndirectedEdge> eComp =
3785 VF2GraphIsomorphismInspector<Vertex, UndirectedEdge> vf2 =
3786 new VF2GraphIsomorphismInspector<>(this.
jGraph, other.
jGraph,
3789 return vf2.isomorphismExists();
3819 Comparator<Node> vComp =
new Comparator<Node>() {
3821 Map<Node,Set<Node>> symmetryShortCuts =
3822 new HashMap<Node,Set<Node>>();
3825 public int compare(
Node v1,
Node v2) {
3828 if (symmetryShortCuts.containsKey(v1)
3829 && symmetryShortCuts.get(v1).contains(v2))
3839 if (dv1==
null && dv2==
null)
3844 Set<Node> symToV2 =
new HashSet<Node>();
3847 symToV2.add((
Node) sv.getProperty(
3851 Set<Node> symToV1 =
new HashSet<Node>();
3854 symToV1.add((
Node) sv.getProperty(
3858 for (
Node v1s : symToV1)
3860 if (symmetryShortCuts.containsKey(v1s))
3862 symmetryShortCuts.get(v1s).addAll(symToV2);
3864 symmetryShortCuts.put(v1s,symToV2);
3875 VF2GraphIsomorphismInspector<Node, NodeConnection> vf2 =
3879 return vf2.isomorphismExists();
3898 reason.append(
"Different number of edges ("+this.
getEdgeCount()+
":"
3905 reason.append(
"Different number of vertices ("+this.
getVertexCount()+
":"
3912 reason.append(
"Different number of symmetric sets ("
3920 reason.append(
"Different number of Rings ("+this.
getRingCount()+
":"
3926 Map<Vertex,Vertex> vertexMap =
3927 new HashMap<Vertex,Vertex>();
3942 e.printStackTrace();
3943 reason.append(
"Exception");
3949 while (ssIter.hasNext())
3954 vertexMap.get(ssT.get(0)));
3955 if (ssO.size() == 0)
3960 reason.append(
"Symmetric set not found for vertex ("
3961 + ssT.get(0) +
")");
3965 if (ssT.size() != ssO.size())
3967 reason.append(
"Different number of symmetric sets on vertex "
3968 + ssT.get(0) +
"("+ssT.size()+
":"+ssO.size()+
")");
3972 Set<Vertex> mappedVrtxFromThis =
new HashSet<>();
3973 ssT.stream().forEach(v -> mappedVrtxFromThis.add(vertexMap.get(v)));
3975 Set<Vertex> vrtxFromOther =
new HashSet<>();
3976 ssO.stream().forEach(v -> vrtxFromOther.add(v));
3977 if (!vrtxFromOther.equals(mappedVrtxFromThis))
3979 reason.append(
"Difference in symmetric set " + ssT +
" vs " + ssO);
3987 Vertex vhT = rT.getHeadVertex();
3988 Vertex vtT = rT.getTailVertex();
3989 boolean hasRing = other
3992 .anyMatch(rO ->
sameAsRings(reason, vertexMap, rT, vhT,
4008 reason.append(
"Different ring size (").append(rT.
getSize())
4009 .append(
":").append(rO.
getSize()).append(
")");
4015 for (
int i = 1; i < rT.
getSize(); i++) {
4018 reason.append(
"Rings differ (A) (").append(rT).append(
":")
4019 .append(rO).append(
")");
4025 for (
int i = 1; i < rT.
getSize(); i++) {
4029 reason.append(
"Rings differ (B) (").append(rT).append(
":")
4030 .append(rO).append(
")");
4035 reason.append(
"Rings differ (C) (").append(rT).append(
":")
4036 .append(rO).append(
")");
4059 Map<Vertex, Vertex> map =
new HashMap<>();
4060 map.put(thisV, otherV);
4062 new StringBuilder());
4080 Map<Vertex,Vertex> vertexMap, StringBuilder reason)
4083 if (!seedOnA.sameAs(seedOnB, reason))
4085 reason.append(
"Different vertex ("+seedOnA+
":"+seedOnB+
")");
4089 List<Edge> edgesFromThis = gA.getEdgesWithSrc(seedOnA);
4090 List<Edge> edgesFromOther = gB.getEdgesWithSrc(seedOnB);
4091 if (edgesFromThis.size() != edgesFromOther.size())
4093 reason.append(
"Different number of edges from vertex "+seedOnA+
" ("
4094 +edgesFromThis.size()+
":"
4095 +edgesFromOther.size()+
")");
4100 ArrayList<Vertex[]> pairs =
new ArrayList<Vertex[]>();
4102 for (
Edge et : edgesFromThis)
4104 boolean found =
false;
4106 StringBuilder innerSb =
new StringBuilder();
4108 for (
Edge e : edgesFromOther)
4110 innerSb.append(
" Edge"+otherEdgeI+
":");
4111 if (et.sameAs(e,innerSb))
4120 reason.append(
"Edge not found in other("+et+
"). "
4121 +
"Edges in othes: "+innerSb.toString());
4126 if (vertexMap.keySet().contains(
4127 gA.getVertexWithId(et.getTrgVertex())))
4131 vertexMap.put(gA.getVertexWithId(et.getTrgVertex()),
4135 gA.getVertexWithId(et.getTrgVertex()),
4141 for (
Vertex[] pair : pairs)
4168 if (v.containsAtoms())
4187 n += v.getHeavyAtomsCount();
4201 ArrayList<AttachmentPoint> lstAPs =
4202 new ArrayList<AttachmentPoint>();
4205 lstAPs.addAll(v.getAttachmentPoints());
4219 ArrayList<AttachmentPoint> lstFreeAPs =
4220 new ArrayList<AttachmentPoint>();
4223 if (ap.isAvailable())
4242 ArrayList<AttachmentPoint> lstFreeAPs =
4243 new ArrayList<AttachmentPoint>();
4246 if (ap.isAvailableThroughout())
4269 if (apCand.getID() ==
id)
4298 ap.getAPClass()) !=
null
4315 ArrayList<Vertex> toDel =
new ArrayList<Vertex>();
4318 if (vtx instanceof
Fragment ==
false)
4345 List<Long> rvids =
new ArrayList<>();
4346 for (
int i=0; i<lstVerts.size(); i++)
4348 Vertex vtx = lstVerts.get(i);
4349 if (vtx instanceof
Fragment ==
false)
4362 for (
int i=0; i<rvids.size(); i++)
4364 long vid = rvids.get(i);
4373 for (
Vertex v : lstVerts)
4400 if (!fragSpace.useAPclassBasedApproach())
4424 if (!fragSpace.useAPclassBasedApproach())
4427 for (
Vertex curVertex : vertexAddedToThis)
4439 if (curDap.isAvailableThroughout())
4441 APClass apcCap = fragSpace.getAPClassOfCappingVertex(
4442 curDap.getAPClass());
4445 int bbIdCap = fragSpace.getCappingFragment(apcCap);
4452 DGraph molGraph = curDap.getOwner()
4454 if (molGraph ==
null)
4455 throw new Error(
"Cannot add capping "
4456 +
"groups to a vertex that does not "
4457 +
"belong to a graph.");
4462 String msg =
"Capping is required but no proper "
4463 +
"capping fragment found with APCalss "
4465 throw new Error(msg);
4535 if (!this.gVertices.contains(seed))
4538 +
"a seed vertex that is not contained in this graph.");
4544 ArrayList<Vertex> subGrpVrtxs =
new ArrayList<Vertex>();
4545 subGrpVrtxs.add(seedClone);
4546 subGraph.
getChildrenTree(seedClone, subGrpVrtxs, numLayers, stopBeforeRCVs);
4547 ArrayList<Vertex> toRemove =
new ArrayList<Vertex>();
4550 if (!subGrpVrtxs.contains(v))
4556 for (
Vertex v : toRemove)
4584 List<Vertex> limits,
boolean stopBeforeRCVs)
4587 if (!this.gVertices.contains(seed))
4590 +
"a seed vertex that is not contained in this graph.");
4593 if (limits.size()==0)
4602 List<Vertex> limitsInClone =
new ArrayList<Vertex>();
4606 ArrayList<Vertex> subGrpVrtxs =
new ArrayList<Vertex>();
4607 subGrpVrtxs.add(seedClone);
4611 ArrayList<Vertex> toRemove =
new ArrayList<Vertex>();
4614 if (!subGrpVrtxs.contains(v))
4619 for (
Vertex v : toRemove)
4646 if (!this.gVertices.contains(seed))
4649 +
"a seed vertex that is not contained in this graph.");
4656 ArrayList<Vertex> subGrpVrtxs =
new ArrayList<Vertex>();
4657 subGrpVrtxs.add(seedClone);
4660 ArrayList<Vertex> toRemove =
new ArrayList<Vertex>();
4663 if (!subGrpVrtxs.contains(v))
4668 for (
Vertex v : toRemove)
4690 Collectors.toList());
4721 throw new IllegalArgumentException(
"Graph pattern " + pattern +
4725 List<Set<Vertex>> disjointMultiCycleVertices =
this
4730 .collect(Collectors.toList());
4734 Map<DGraph,ObjectPair> subGraphsAndConnections =
new LinkedHashMap<>();
4735 for (Set<Vertex> fusedRing : disjointMultiCycleVertices) {
4736 if (recordConnectivity)
4738 Set<Edge> connectionToSubgraph =
new HashSet<Edge>();
4739 Set<Edge> connectionFromSubgraph =
new HashSet<Edge>();
4741 connectionFromSubgraph);
4743 connectionFromSubgraph);
4744 subGraphsAndConnections.put(subGraph, connections);
4747 subGraphsAndConnections.put(subGraph,
null);
4751 for (
DGraph g : subGraphsAndConnections.keySet()) {
4752 g.storeCurrentVertexIDs();
4753 g.renumberGraphVertices();
4757 return subGraphsAndConnections;
4788 Set<Edge> connectionToSubgraph,
4789 Set<Edge> connectionFromSubgraph)
4794 Set<Vertex> complement = subgraph
4797 .filter(u -> definedOn
4799 .allMatch(v -> v.getVertexId() != u.getVertexId())
4800 ).collect(Collectors.toSet());
4802 Set<Long> vrtxIDsInComplement = complement.stream()
4803 .map(v -> v.getVertexId())
4804 .collect(Collectors.toSet());
4806 if (connectionToSubgraph!=
null && connectionFromSubgraph!=
null)
4808 for (
Vertex v : definedOn)
4812 if (e.getSrcAP().getOwner() == v &&
4813 vrtxIDsInComplement.contains(e.getTrgVertex()))
4815 connectionFromSubgraph.add(e);
4818 if (e.getTrgAP().getOwner() == v &&
4819 vrtxIDsInComplement.contains(e.getSrcVertex()))
4821 connectionToSubgraph.add(e);
4827 for (
Vertex v : complement) {
4885 DGraph subGraph = entry.getKey();
4897 LinkedHashMap<AttachmentPoint, AttachmentPoint> apMapOrigToTmpl =
4898 new LinkedHashMap<AttachmentPoint, AttachmentPoint>();
4899 @SuppressWarnings(
"unchecked")
4900 Set<Edge> edsToSubgrph = (Set<Edge>) entry.getValue().getFirst();
4901 for (
Edge e : edsToSubgrph)
4906 apMapOrigToTmpl.put(apOnOrig, apOnTmpl);
4908 @SuppressWarnings(
"unchecked")
4909 Set<Edge> edsFromSubGrph = (Set<Edge>) entry.getValue().getSecond();
4910 for (
Edge e : edsFromSubGrph)
4915 apMapOrigToTmpl.put(apOnOrig, apOnTmpl);
4919 List<Vertex> toReplaceByTemplate =
new ArrayList<>();
4931 apMapOrigToTmpl, fragSpace);
4949 if (newScaffold ==
null) {
4978 int visitedVertexEncounters = 0;
4984 boolean srcIsVisited = srcVertex != v.
getVertexId()
4985 && visited.contains(srcVertex);
4987 visitedVertexEncounters += srcIsVisited ? 1 : 0;
4988 if (visitedVertexEncounters >= 2) {
4989 throw new IllegalArgumentException(
"Invalid graph. "
4990 +
"Contains a cycle.");
4995 if (edgeIsWrongWay) {
4998 if (!srcIsVisited) {
5053 Edge edgeToParent = v.getEdgeToParent();
5054 if (edgeToParent !=
null)
5080 ArrayList<Vertex> children =
new ArrayList<Vertex>();
5084 for (
Vertex c : children) {
5111 if (rings.isEmpty())
5122 int minDist = Integer.MAX_VALUE;
5124 for (
Ring r : rings)
5126 int dist = Math.min(r.getDistance(r.getHeadVertex(),v),
5127 r.getDistance(r.getTailVertex(),v));
5132 replacedByEdge[0] = r.getHeadVertex();
5133 replacedByEdge[1] = r.getTailVertex();
5134 bt = r.getBondType();
5139 boolean frameHasBranching =
false;
5140 List<Integer> branchingPositions =
new ArrayList<Integer>();
5142 for (
int i=0; i<frame.
getSize(); i++)
5148 branchingPositions.add(i);
5156 branchingPositions.add(i);
5157 frameHasBranching =
true;
5162 if (rings.size()==1 && !frameHasBranching)
5170 int branchingDownstreamId = -1;
5171 for (
int i=0; i<frame.
getSize(); i++)
5173 int iTranslated = i + posOfFocusVrtInRing;
5174 if (iTranslated >= frame.
getSize())
5175 iTranslated = iTranslated - frame.
getSize();
5176 if (branchingPositions.contains(iTranslated))
5178 branchingDownstreamId = iTranslated;
5182 int branchingUpstreamId = -1;
5183 for (
int i=(frame.
getSize()-1); i>-1; i--)
5185 int iTranslated = i + posOfFocusVrtInRing;
5186 if (iTranslated >= frame.
getSize())
5187 iTranslated = iTranslated - frame.
getSize();
5188 if (branchingPositions.contains(iTranslated))
5190 branchingUpstreamId = iTranslated;
5198 List<Vertex> remainingChain =
new ArrayList<Vertex>();
5199 for (
int i=0; i<frame.
getSize(); i++)
5201 int iTranslated = i + branchingDownstreamId;
5202 if (iTranslated >= frame.
getSize())
5203 iTranslated = iTranslated - frame.
getSize();
5205 if (iTranslated == branchingUpstreamId)
5210 List<Vertex> toRemoveChain =
new ArrayList<Vertex>();
5211 for (
int i=0; i<frame.
getSize(); i++)
5213 int iTranslated = i + branchingUpstreamId + 1;
5214 if (iTranslated >= frame.
getSize())
5215 iTranslated = iTranslated - frame.
getSize();
5217 if (iTranslated == (branchingDownstreamId - 1))
5227 if (toRemoveChain.size() == 2)
5229 int countOrRCVs = 0;
5230 for (
Vertex vtr : toRemoveChain)
5235 if (countOrRCVs == 2)
5243 int deepestLevel = Integer.MAX_VALUE;
5244 Vertex deepestVrtRemainingChain =
null;
5245 for (
Vertex vint : remainingChain)
5248 if (lvl < deepestLevel)
5251 deepestVrtRemainingChain = vint;
5259 if (remainingChain.contains(replacedByEdge[0]))
5268 remainingChain.remove(replacedByEdge[0]);
5270 remainingChain.remove(replacedByEdge[1]);
5278 addEdge(
new Edge(apSrcOfNewEdge, apTrgOfNewEdge, bt));
5287 List<Vertex> chainToReverseA =
new ArrayList<Vertex>();
5288 List<Vertex> chainToReverseB =
new ArrayList<Vertex>();
5289 for (
int i=(remainingChain.indexOf(deepestVrtRemainingChain)+1);
5290 i<remainingChain.size(); i++)
5292 Vertex vPrev = remainingChain.get(i-1);
5293 Vertex vHere = remainingChain.get(i);
5298 if (chainToReverseA.size()==0)
5299 chainToReverseA.add(vPrev);
5300 chainToReverseA.add(vHere);
5303 for (
int i=(remainingChain.indexOf(deepestVrtRemainingChain)-1);i>-1;i--)
5305 Vertex vPrev = remainingChain.get(i+1);
5306 Vertex vHere = remainingChain.get(i);
5309 if (chainToReverseB.size()==0)
5310 chainToReverseB.add(vPrev);
5311 chainToReverseB.add(vHere);
5316 LinkedHashMap<Vertex,Vertex> chordsToRecreate =
5317 new LinkedHashMap<Vertex,Vertex>();
5318 LinkedHashMap<Vertex,BondType> chordsToRecreateBB =
5319 new LinkedHashMap<Vertex,BondType>();
5323 if (chainToReverseA.size()+chainToReverseB.size() > 1)
5325 List<Vertex> chainToWorkOn =
null;
5326 for (
int ic=0; ic<2; ic++)
5329 chainToWorkOn = chainToReverseA;
5331 chainToWorkOn = chainToReverseB;
5333 for (
int i=1; i<chainToWorkOn.size(); i++)
5335 Vertex vHere = chainToWorkOn.get(i);
5336 Vertex vPrev = chainToWorkOn.get(i-1);
5337 List<Ring> ringsToRecreate =
new ArrayList<>();
5340 ringsToRecreate.add(r);
5341 chordsToRecreate.put(r.getHeadVertex(),
5343 chordsToRecreateBB.put(r.getHeadVertex(),
5346 for (
Ring r : ringsToRecreate)
5352 if (edgeToPrevious ==
null)
5356 String debugFile =
"debug_"+v.getVertexId()+
".json";
5361 +
"removal of " + v +
" from ring " + frame
5362 +
" in graph " +
this.getGraphId()
5363 +
". See graph in " + debugFile);
5392 for (
Vertex vtr : toRemoveChain)
5397 if (remainingChain.contains(child)
5398 || toRemoveChain.contains(child))
5400 DGraph ownerOfChild = child.getGraphOwner();
5405 List<AttachmentPoint> apProjectionsToRemove =
5406 new ArrayList<AttachmentPoint>();
5414 apProjectionsToRemove.add(innerAP);
5424 for (
Vertex h : chordsToRecreate.keySet())
5426 addRing(h, chordsToRecreate.get(h), chordsToRecreateBB.get(h));
5438 List<SymmetricVertexes> ssToRemove =
new ArrayList<SymmetricVertexes>();
5440 while (ssIter.hasNext())
5483 HashMap<Long, Long> nmap =
new HashMap<>();
5488 nmap.put(vid, nvid);
5527 Map<Long, Long> nmap =
new HashMap<>();
5536 nmap.put(vid, nvid);
5557 ArrayList<Vertex> parentTree =
new ArrayList<>();
5559 return parentTree.size() - 1;
5631 settings.getRandomizer());
5636 String msg =
"Evaluation of graph: graph-to-mol returned null!"
5638 settings.getLogger().log(Level.FINE, msg);
5643 boolean isConnected = ConnectivityChecker.isConnected(mol);
5646 String msg =
"Evaluation of graph: Not all connected"
5648 settings.getLogger().log(Level.FINE, msg);
5653 String smiles =
null;
5657 String msg =
"Evaluation of graph: SMILES is null! "
5659 settings.getLogger().log(Level.FINE, msg);
5660 smiles =
"FAIL: NO SMILES GENERATED";
5663 if (smiles.contains(
".") && !permissive)
5665 String msg =
"Evaluation of graph: SMILES contains \".\"" + smiles;
5666 settings.getLogger().log(Level.FINE, msg);
5677 String msg =
"Evaluation of graph: Max atoms constraint "
5678 +
" violated: " + smiles;
5679 settings.getLogger().log(Level.FINE, msg);
5686 if (fsSettings.
getMaxMW()>0 && !permissive)
5690 String msg =
"Evaluation of graph: Molecular weight "
5691 +
"constraint violated: " + smiles +
" | MW: " + mw;
5692 settings.getLogger().log(Level.FINE, msg);
5696 mol.setProperty(
"MOL_WT", mw);
5704 String msg =
"Evaluation of graph: Max rotatable bonds "
5705 +
"constraint violated: "+ smiles;
5706 settings.getLogger().log(Level.FINE, msg);
5710 mol.setProperty(
"ROT_BND", nrot);
5717 String msg =
"Evaluation of graph: forbidden end in graph!";
5718 settings.getLogger().log(Level.FINE, msg);
5728 Set<String> doneType =
new HashSet<>();
5730 for (String rcaTyp : rcaTypes.keySet())
5732 if (doneType.contains(rcaTyp))
5741 if (v.containsAtoms())
5743 IAtom atm = v.getIAtomContainer().getAtom(0);
5748 rcaTypes.get(rcaTyp)))
5752 if (rcaTyp.equals(rcaTypes.get(rcaTyp)))
5763 String msg =
"Evaluation of graph: too many RCAs! "
5764 + rcaTyp +
":" + nThisType +
" "
5765 + rcaTypes.get(rcaTyp) +
":" + nCompType;
5766 settings.getLogger().log(Level.FINE, msg);
5772 String msg =
"Evaluation of graph: too few RCAs! "
5773 + rcaTyp +
":" + nThisType +
" "
5774 + rcaTypes.get(rcaTyp) +
":" + nCompType;
5775 settings.getLogger().log(Level.FINE, msg);
5779 nPossRings = nPossRings + Math.min(nThisType, nCompType);
5780 doneType.add(rcaTyp);
5781 doneType.add(rcaTypes.get(rcaTyp));
5785 String msg =
"Evaluation of graph: too few ring candidates";
5786 settings.getLogger().log(Level.FINE, msg);
5793 settings.getLogger());
5794 if (inchiKey ==
null)
5796 String msg =
"Evaluation of graph: InChI Key is null!";
5797 settings.getLogger().log(Level.WARNING, msg);
5798 inchiKey =
"UNDEFINED_INCHI";
5801 Object[] res =
new Object[3];
5834 ArrayList<DGraph> lstGraphs =
new ArrayList<>();
5847 settings.getRandomizer());
5854 settings.getLogger());
5859 ArrayList<List<Ring>> allCombsOfRings =
5865 ArrayList<List<Ring>> toRemove =
new ArrayList<>();
5866 for (List<Ring>
setRings : allCombsOfRings)
5873 allCombsOfRings.removeAll(toRemove);
5877 for (List<Ring> ringSet : allCombsOfRings)
5886 for (
Ring oldRing : ringSet)
5889 for (
int i=0; i<oldRing.getSize(); i++)
5891 long oldVId = oldRing.getVertexAtPosition(i).getVertexId();
5892 long newVId = vRenum.get(oldVId);
5900 lstGraphs.add(newGraph);
5918 Set<APClass> classOfForbEnds =
5920 boolean found =
false;
5921 for (
Vertex vtx : vertices)
5923 List<AttachmentPoint> daps = vtx.getAttachmentPoints();
5926 if (dp.isAvailable())
5928 APClass apClass = dp.getAPClass();
5929 if (classOfForbEnds.contains(apClass))
5932 String msg =
"Forbidden free AP for Vertex: "
5933 + vtx.getVertexId() +
" "
5935 +
"\n"+
this +
" \n "
5936 +
" AP class: " + apClass;
5937 fsSettings.
getLogger().log(Level.WARNING, msg);
5973 List<Integer> parentAPIdx,
5975 Vertex childVertex,
int childAPIdx,
5976 BondType bndType,
boolean onAllSymmAPs)
5980 Map<Vertex, SymmetricVertexes> newSymSets =
new HashMap<>();
5983 for (
int i=0; i<parentVertices.size(); i++)
5986 subGraph, childVertex, childAPIdx, bndType,
5987 newSymSets, onAllSymmAPs);
6008 if (!srcAP.isAvailable())
6012 srcAP.getOwner().getGraphOwner().getOutermostGraphOwner());
6014 +
"attachment point " + srcAP +
" on vertex "
6015 + srcAP.getOwner().getVertexId() +
" as srcAP.");
6017 if ( !trgAP.isAvailable())
6020 +
"attachment point " + trgAP +
" on vertex "
6021 + trgAP.getOwner().getVertexId() +
" as trgAP.");
6024 BondType btSrc = srcAP.getBondType();
6025 BondType btTrg = trgAP.getBondType();
6043 Edge edge =
new Edge(srcAP,trgAP, bndTyp);
6062 DGraph incomingGraph = apOnIncomingGraph.getOwner().getGraphOwner();
6065 Edge edge =
new Edge(apOnThisGraph, apOnIncomingGraph,
6114 Vertex childVertex,
int childAPIdx,
6116 Map<Vertex, SymmetricVertexes> newSymSets)
6123 childVertex.getVertexId());
6126 Edge edge =
new Edge(parentVertex.getAP(parentAPIdx),
6127 cvClone.
getAP(childAPIdx), bndType);
6134 Vertex origV = subGraph.getVertexList().get(i);
6142 if (subGraph.hasSymmetryInvolvingVertex(origV))
6144 if (newSymSets.containsKey(origV))
6146 newSymSets.get(origV).add(clonV);
6155 if (newSymSets.containsKey(origV))
6157 newSymSets.get(origV).add(clonV);
6163 newSymSets.put(origV, ss);
6168 for (
int i=0; i<sgClone.
getEdgeList().size(); i++)
6173 for (
int i=0; i<sgClone.
getRings().size(); i++)
6179 Set<SymmetricVertexes> doneTmpSymSets =
new HashSet<SymmetricVertexes>();
6183 if (doneTmpSymSets.contains(tmpSS))
6187 doneTmpSymSets.
add(tmpSS);
6188 boolean done =
false;
6192 while (iter.hasNext())
6194 oldSS = iter.next();
6195 if (oldSS.contains(tmpSS.get(0)))
6197 oldSS.addAll(tmpSS);
6204 if (tmpSS.size() <= 1)
6211 newSS.addAll(tmpSS);
6238 int parentAPIdx,
DGraph subGraph,
6239 Vertex childVertex,
int childAPIdx,
6241 Map<Vertex, SymmetricVertexes> newSymSets,
6242 boolean onAllSymmAPs)
6246 parentVertex.getAP(parentAPIdx));
6247 if (symAPs.size()!=0 && onAllSymmAPs)
6251 if (!symAP.isAvailable())
6256 subGraph, childVertex,
6257 childAPIdx, bndType, newSymSets);
6261 childAPIdx, bndType, newSymSets);
6276 List<Long> matches =
new ArrayList<>();
6279 matches.add(v.getVertexId());
6312 boolean purgeSym, Logger logger)
6314 ArrayList<Vertex> matches =
new ArrayList<>(
getVertexList());
6316 logger.log(Level.FINE,
"Candidates: " + matches);
6320 if (vidQuery !=
null)
6322 ArrayList<Vertex> newLst =
new ArrayList<>();
6325 if (v.getVertexId() == vidQuery.intValue())
6332 logger.log(Level.FINE,
" After filtering by vertex ID: " + matches);
6336 if (vtQuery !=
null)
6338 ArrayList<Vertex> newLst =
new ArrayList<>();
6341 if (v.getVertexType() == vtQuery)
6347 logger.log(Level.FINER,
" After filtering by vertex type: "
6353 if (bbtQuery !=
null)
6355 ArrayList<Vertex> newLst =
new ArrayList<>();
6358 if (v.getBuildingBlockType() == bbtQuery)
6364 logger.log(Level.FINER,
" After filtering by building block "
6365 +
"type: " + matches);
6372 ArrayList<Vertex> newLst =
new ArrayList<>();
6375 if (v.getBuildingBlockId() == bbID.intValue())
6381 logger.log(Level.FINER,
" After filtering by building block ID: "
6387 if (levelQuery !=
null)
6389 ArrayList<Vertex> newLst =
new ArrayList<Vertex>();
6398 logger.log(Level.FINER,
" After filtering by level: " + matches);
6401 logger.log(Level.FINE,
"After all vertex-based filters: " + matches);
6403 List<EdgeQuery> inAndOutEdgeQueries =
new ArrayList<>();
6406 for (
int i=0; i<2; i++)
6408 String inOrOut =
"";
6410 inOrOut =
"incoming";
6412 inOrOut =
"ourgoing";
6414 EdgeQuery edgeQuery = inAndOutEdgeQueries.get(i);
6415 if (edgeQuery ==
null)
6423 if (eTrgApIDx !=
null)
6425 ArrayList<Vertex> newLst =
new ArrayList<>();
6430 if (e.getTrgAPID() == eTrgApIDx)
6438 logger.log(Level.FINER,
" After " + inOrOut
6439 +
" edge trgAPID filter: " + matches);
6443 if (eInSrcApIDx !=
null)
6445 ArrayList<Vertex> newLst =
new ArrayList<>();
6450 if (e !=
null && e.getSrcAPID() == eInSrcApIDx)
6458 logger.log(Level.FINER,
" After " + inOrOut
6459 +
" edge srcAPID filter: " + matches);
6465 if (eSrcVrtID !=
null)
6467 ArrayList<Vertex> newLst =
new ArrayList<>();
6472 if(e.getSrcAP().getOwner().getVertexId()==eSrcVrtID)
6480 logger.log(Level.FINER,
" After " + inOrOut
6481 +
" edge src VertexID filter: " + matches);
6485 if (eTrgVrtID !=
null)
6487 ArrayList<Vertex> newLst =
new ArrayList<>();
6492 if(e.getTrgAP().getOwner().getVertexId()==eTrgVrtID)
6500 logger.log(Level.FINER,
" After " + inOrOut
6501 +
" edge trg VertexID filter: " + matches);
6506 if (btQuery !=
null)
6508 ArrayList<Vertex> newLst =
new ArrayList<>();
6513 if (e.getBondType() == btQuery)
6521 logger.log(Level.FINER,
" After " + inOrOut
6522 +
" edge bond type filter: " + matches);
6528 ArrayList<Vertex> newLst =
new ArrayList<>();
6533 if (e.getSrcAPClass().equals(srcAPC))
6546 ArrayList<Vertex> newLst =
new ArrayList<>();
6551 if (e.getTrgAPClass().equals(trgAPC))
6560 logger.log(Level.FINER,
"After all " + inOrOut
6561 +
" edge-based filters: " + matches);
6568 logger.log(Level.FINE,
"Final Matches (after symmetry): " + matches);
6597 List<Edge> edges =
new ArrayList<Edge>();
6601 if (eToParent !=
null)
6602 edges.add(eToParent);
6606 if (!ap.isAvailable() && ap.isSrcInUser())
6608 edges.add(ap.getEdgeUser());
6626 List<Vertex> symRedundant =
new ArrayList<>();
6628 while (itSymm.hasNext())
6633 if (symRedundant.contains(v))
6639 symRedundant.addAll(ss);
6640 symRedundant.remove(v);
6644 for (
Vertex v : symRedundant)
6659 ArrayList<Vertex> vList =
new ArrayList<>();
6660 for (
long vid : list) {
6666 list.add(v.getVertexId());
6693 logger.log(Level.FINE,
"Graph edit task: " + edit.getType());
6695 switch (edit.getType())
6699 DGraph inGraph = edit.getIncomingGraph();
6701 int idAPOnInGraph = -1;
6702 Vertex rootOfInGraph =
null;
6703 if (edit.getIncomingAPId() !=
null)
6706 edit.getIncomingAPId().intValue());
6709 String msg =
"Skipping " + edit.getType() +
" on "
6711 +
" graph has no AP with ID = "
6712 + edit.getIncomingAPId() +
". The IDs of "
6716 msg = msg +
" " + freeAP.getID();
6719 +
"Please, use one of those values in "
6720 +
"'idAPOnIncomingGraph'.";
6721 logger.log(Level.WARNING, msg);
6726 ArrayList<AttachmentPoint> freeAPs =
6728 if (freeAPs.size()==1)
6734 String geClsName =
GraphEdit.class.getSimpleName();
6735 String msg =
"Skipping " + edit.
getType() +
" on "
6737 +
" graph has more than one free AP ("
6738 + freeAPs.size() +
") and "
6739 +
"the " + geClsName +
" "
6740 +
"does not provide sufficient information "
6741 +
"to unambiguously choose one AP. "
6742 +
"Please, add 'idAPOnIncomingGraph' in "
6743 +
"the definition of " + geClsName +
".";
6744 logger.log(Level.WARNING, msg);
6748 ArrayList<Vertex> matches = modGraph.
findVertices(query,
6750 for (
Vertex vertexToReplace : matches)
6752 Edge edgeToParent = vertexToReplace.getEdgeToParent();
6753 if (edgeToParent ==
null)
6769 rootOfInGraph, idAPOnInGraph, bondType,
6770 new HashMap<Vertex, SymmetricVertexes>(), symmetry);
6777 if (edit.getIncomingBBId() > -1
6778 && edit.getIncomingBBType() !=
null
6779 && edit.getIncomingGraph() ==
null)
6782 edit.getVertexQuery(),
false, logger);
6783 for (
Vertex vertexToChange : matches)
6787 DGraph graph = vertexToChange.getGraphOwner();
6789 edit.getIncomingBBId(),
6790 edit.getIncomingBBType(),
6798 if (edit.getIncomingGraph() !=
null
6799 && edit.getIncomingBBType() ==
null)
6805 edit.getVertexQuery(),
false, logger);
6807 for (
Vertex vertexToChange : matches)
6809 DGraph graph = vertexToChange.getGraphOwner();
6813 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap =
6814 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
6815 for (Map.Entry<Integer,Integer> e :
6816 edit.getAPMappig().entrySet())
6818 apMap.put(vertexToChange.getAP(e.getKey()),
6823 List<Vertex> oldSubG =
new ArrayList<Vertex>();
6824 oldSubG.add(vertexToChange);
6834 edit.getVertexQuery(),
false, logger);
6835 for (
Vertex vertexToRemove : matches)
6860 List<Vertex> mutableSites =
new ArrayList<Vertex>();
6863 mutableSites.addAll(v.getMutationSites(
6864 new ArrayList<MutationType>()));
6866 return mutableSites;
6884 List<Vertex> mutableSites =
new ArrayList<Vertex>();
6887 mutableSites.addAll(v.getMutationSites(ignoredTypes));
6889 return mutableSites;
6907 List<Vertex> mutableSites =
new ArrayList<Vertex>();
6910 v.getMutationSites()
6912 .filter(vrt -> vrt.getMutationTypes().contains(requestedType))
6913 .forEach(vrt -> mutableSites.add(vrt));
6915 return mutableSites;
6929 String jsonOutput = gson.toJson(
this);
6979 implements JsonSerializer<DGraph>
6983 JsonSerializationContext context)
6985 boolean regenerateVrtxID =
false;
6986 boolean regenerateAP =
false;
6987 Set<Long> unqVrtxIDs =
new HashSet<Long>();
6988 Set<Integer> unqApIDs =
new HashSet<Integer>();
6991 if (!unqVrtxIDs.add(v.getVertexId()))
6993 regenerateVrtxID =
true;
6997 if (!unqApIDs.add(ap.getID()))
6999 regenerateAP =
true;
7004 if (regenerateVrtxID)
7013 JsonObject jsonObject =
new JsonObject();
7014 jsonObject.addProperty(
"graphId", g.
graphId);
7015 jsonObject.add(
"gVertices", context.serialize(g.
gVertices));
7016 jsonObject.add(
"gEdges", context.serialize(g.
gEdges));
7017 jsonObject.add(
"gRings", context.serialize(g.
gRings));
7018 jsonObject.add(
"symVertices", context.serialize(g.
symVertices));
7026 implements JsonDeserializer<DGraph>
7030 JsonDeserializationContext context)
throws JsonParseException
7032 JsonObject jsonObject = json.getAsJsonObject();
7035 JsonObject partialJsonObj =
new JsonObject();
7036 partialJsonObj.add(
"graphId", jsonObject.get(
"graphId"));
7037 partialJsonObj.add(
"gVertices", jsonObject.get(
"gVertices"));
7039 Gson gson =
new GsonBuilder()
7041 .registerTypeAdapter(
Vertex.class,
7044 .setPrettyPrinting()
7053 v.setGraphOwner(graph);
7064 JsonArray edgeArr = jsonObject.get(
"gEdges").getAsJsonArray();
7065 for (JsonElement e : edgeArr)
7067 JsonObject o = e.getAsJsonObject();
7069 o.get(
"srcAPID").getAsInt());
7071 o.get(
"trgAPID").getAsInt());
7074 context.deserialize(o.get(
"bondType"),
BondType.class));
7079 JsonArray ringArr = jsonObject.get(
"gRings").getAsJsonArray();
7080 for (JsonElement e : ringArr)
7082 JsonObject o = e.getAsJsonObject();
7084 for (JsonElement re : o.get(
"vertices").getAsJsonArray())
7088 ring.
setBondType(context.deserialize(o.get(
"bndTyp"),
7094 if (jsonObject.has(
"symVertices"))
7096 for (JsonElement elSet : jsonObject.get(
"symVertices").getAsJsonArray())
7099 for (JsonElement elId : elSet.getAsJsonArray())
7101 int id = context.deserialize(elId, Integer.class);
7109 e1.printStackTrace();
7110 throw new Error(
"Vertex listed in multiple symmetric "
7111 +
"sets. Check this: " + elSet);
7130 ArrayList<Vertex> newVertexList =
new ArrayList<>();
7132 Set<Long> visited =
new HashSet<>();
7133 Queue<Vertex> currLevel =
new ArrayDeque<>();
7134 Queue<Vertex> nextLevel =
new ArrayDeque<>();
7137 while (!currLevel.isEmpty()) {
7138 Vertex currVertex = currLevel.poll();
7141 if (!visited.contains(currId)) {
7142 visited.add(currId);
7144 newVertexList.add(currVertex);
7146 Iterable<Vertex> neighbors = currVertex
7150 .filter(e -> e !=
null)
7151 .map(e -> e.getSrcVertex() == currId ?
7152 e.getTrgAP() : e.getSrcAP())
7154 .collect(Collectors.toList());
7155 for (
Vertex adj : neighbors) {
7160 if (currLevel.isEmpty()) {
7161 currLevel = nextLevel;
7162 nextLevel =
new ArrayDeque<>();
7190 this.templateJacket =
template;
7233 List<Template> path =
new ArrayList<Template>();
7275 if ( v1==
null || v2 ==
null)
7324 if (!e.getTrgAPClass().isCPMapCompatibleWith(e.getSrcAPClass(),
7352 DGraph graphB, List<Template> path)
7356 Template currentLevelVertex =
null;
7357 DGraph currentLevelGraphEmdInB = graphB;
7358 DGraph currentLevelGraphEmbInY = graphY;
7361 currentLevelVertex = (
Template) currentLevelGraphEmbInY
7363 currentLevelGraphEmdInB = t.getInnerGraph();
7364 currentLevelGraphEmbInY = currentLevelVertex.
getInnerGraph();
7381 List<AttachmentPoint> interfaceAPs =
new ArrayList<AttachmentPoint>();
7382 for (
Vertex v : subGraphB)
7386 if (ap.isAvailableThroughout())
7388 if (ap.isAvailable())
7391 interfaceAPs.add(ap);
7393 Vertex user = ap.getLinkedAP().getOwner();
7394 if (!subGraphB.contains(user))
7397 interfaceAPs.add(ap);
7402 return interfaceAPs;
7415 List<Vertex> subGraphB)
7417 List<AttachmentPoint> aps =
new ArrayList<AttachmentPoint>();
7418 for (
Vertex v : subGraphB)
7422 if (ap.isAvailable())
7427 Vertex user = ap.getLinkedAP().getOwner();
7428 if (!subGraphB.contains(user))
General set of constants used in DENOPTIM.
static final Object GRAPHBRANCHID
Property of Vertex used to record the identity of the graph branch holding that Vertex.
static final Object STOREDVID
Key of the property remembering vertex IDs.
static final Object VRTSYMMSETID
Property of Vertex used to keep mark symmetric vertexes during graph operations and before defining t...
Class defining a space of building blocks.
boolean useAPclassBasedApproach()
Check usage of APClass-based approach, i.e., uses attachment points with annotated data (i....
Set< APClass > getForbiddenEndList()
APClass getAPClassOfCappingVertex(APClass srcApClass)
Parameters defining the fragment space.
FragmentSpace getFragmentSpace()
int getMaxRotatableBond()
String getRotSpaceDefFile()
boolean isCPMapCompatibleWith(APClass other, FragmentSpace fragSpace)
Check compatibility as defined in the compatibility matrix considering this AP as source and the othe...
String toString()
Do not use this to make SDF representations.
Class representing a mapping between attachment points (APs).
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....
AttachmentPoint getLinkedAP()
Gets the attachment point (AP) that is connected to this AP via the edge user.
Object getProperty(Object description)
void setUser(Edge edge)
Sets the reference to the edge that is using this attachment point.
APClass getAPClass()
Returns the Attachment Point class.
int getID()
Returns a unique integer that is used to sort list of attachment points.
BondType getBondType()
Returns the bond type preferred by this attachment point as defined by the APClass,...
boolean isAvailable()
Check availability of this attachment point.
boolean hasConnectedSrcAtom(AttachmentPoint other)
Checks if this and another APs are rooted on atoms that are bonded in any way other than a possible c...
boolean hasSameSrcAtom(AttachmentPoint other)
AttachmentPoint getLinkedAPThroughout()
Gets the attachment point (AP) that is connected to this AP via the edge user or in any edge user tha...
void setProperty(Object key, Object property)
Edge getEdgeUser()
Gets the edge that is using this AP, or null if no edge is using this AP.
A candidate is the combination of a denoptim graph with molecular representation and may include also...
DGraph deserialize(JsonElement json, Type typeOfT, JsonDeserializationContext context)
We expect unique IDs for vertices.
JsonElement serialize(DGraph g, Type typeOfSrc, JsonSerializationContext context)
Utility to make selection of edges to a vertex tunable by a parameter.
List< Edge > apply(Vertex v)
Container for the list of vertices and the edges that connect them.
boolean removeVertexAndWeld(Vertex vertex, FragmentSpace fragSpace)
Remove a given vertex belonging to this graph and re-connects the resulting graph branches as much as...
List< ClosableChain > getClosableChains()
void getChildrenTree(Vertex vertex, List< Vertex > children, int numLayers, boolean stopBeforeRCVs)
Gets all the children of the current vertex recursively.
void setTemplateJacket(Template template)
Sets the reference to a template that embeds this graph, i.e., this graph's "jacket" template.
void setVertexList(ArrayList< Vertex > vertices)
String toJson()
Produces a string that represents this graph and that adheres to the JSON format.
void getChildTreeLimited(Vertex vertex, List< Vertex > children, Set< Vertex > limits)
Gets all the children of the current vertex recursively until it finds one of the vertices listed as ...
ArrayList< Integer > getIndexOfEdgesWithChild(int vid)
Candidate candidate
Reference to the candidate entity owning this graph, or null.
boolean replaceVertex(Vertex vertex, int bbId, BBType bbt, LinkedHashMap< Integer, Integer > apIdMap, FragmentSpace fragSpace)
Replaced a given vertex belonging to this graph with a new vertex generated specifically for this pur...
AttachmentPoint getAPOnLeftVertexID(long nbrVid, long vid)
Finds the AP that is on the first given parameter and that is used to make a connection to the second...
Vertex getVertexWithId(long vid)
Searches for a vertex with the given identifier.
int getSymmetricSetCount()
Returns the number of symmetric sets of vertices.
Vertex getSourceVertex()
Identifies and return the vertex from which the spanning tree originates.
List< Integer > getBranchIdOfVertex(Vertex v)
Returns the branch identifier.
Edge getEdgeAtPosition(int pos)
void getChildrenTree(Vertex vertex, List< Vertex > children, boolean markBranches)
Gets all the children of the current vertex recursively.
DGraph embedPatternsInTemplates(GraphPattern pattern, FragmentSpace fragSpace, ContractLevel contract)
Searches for the given pattern type and generated a new graph where each set of (clones of) vertexes ...
DGraph extractSubgraph(int index)
Creates a new graph that corresponds to the subgraph of this graph when exploring the spanning tree f...
void removeRing(Ring ring)
ArrayList< AttachmentPoint > getAttachmentPoints()
Returns the list of all attachment points contained in this graph.
boolean containsVertexID(long l)
Checks if a number is already used as VertexIDs within the graph.
boolean containsVertex(Vertex v)
Check if this graph contains the specified vertex.
boolean isIsomorphicTo(DGraph other)
Checks if this graph is "DENOPTIM-isomorphic" to the other one given.
ArrayList< AttachmentPoint > getAvailableAPs()
Returns the list of available attachment points contained in this graph.
void setCandidateClosableChains(ArrayList< ClosableChain > closableChains)
ArrayList< Ring > getRingsInvolvingVertex(Vertex v)
Returns the list of rings that include the given vertex in their fundamental cycle.
void addVertex(Vertex vertex)
Appends a vertex to this graph without creating any edge.
ArrayList< Ring > getRingsInvolvingVertexID(int vid)
int indexOfVertexWithID(long vid)
Returns the position of the first vertex that has the given ID.
boolean removeSingleVertexAndWeld(Vertex vertex, FragmentSpace fragSpace)
Remove a given vertex belonging to this graph and re-connects the resulting graph branches as much as...
List< ClosableChain > closableChains
The potentially closable chains of vertices.
DefaultUndirectedGraph< Vertex, UndirectedEdge > jGraph
JGraph representation used to detect DENOPTIM-isomorphism.
DGraph embedPatternsInTemplates(GraphPattern pattern, FragmentSpace fragSpace)
Searches for the given pattern type and generated a new graph where each set of (clones of) vertexes ...
DGraph(List< Vertex > gVertices, List< Edge > gEdges)
void getChildrenTree(Vertex vertex, List< Vertex > children)
Gets all the children of the current vertex recursively.
boolean graphNeedsCappingGroups(FragmentSpace fragSpace)
Checks the graph for unused APs that need to be capped.
AttachmentPoint getAPWithId(int id)
Returns the attachment point with the given identifier, or null if no AP is found with the given iden...
void removeVertex(Vertex vertex)
Remove a vertex from this graph.
Iterator< SymmetricVertexes > getSymSetsIterator()
Get an iterator for the sets of symmetrically related vertices.
void removeSymmetryRedundance(List< Vertex > list)
Remove all but one of the symmetry-related partners in a list of vertices.
static void reorderVertexList(DGraph g)
Sets the vertex at the lowest level as the scaffold, changes the directions of edges so that the sc...
DGraph extractSubgraph(Vertex seed)
Creates a new graph that corresponds to the subgraph of this graph when exploring the spanning tree f...
ArrayList< Vertex > getRCVertices()
Search for ring closing vertices: vertices that contain only a RingClosingAttractor
ArrayList< Vertex > getFreeRCVertices()
Search for unused ring closing vertices: vertices that contain only a RingClosingAttractor and are no...
void setCandidateOwner(Candidate candidate)
Sets the reference to the candidate item that is defined by this graph.
List< List< Vertex > > getSymmetricSubGraphs(List< Vertex > subGrpVrtxs)
We assume that the subgraph is a continuously connected, directed graph.
DGraph extractSubgraph(Vertex seed, int numLayers, boolean stopBeforeRCVs)
Creates a new graph that corresponds to the subgraph of this graph when exploring the spanning tree f...
int indexOf(Vertex v)
Returns the index of a vertex in the list of vertices of this graph.
DGraph editGraph(ArrayList< GraphEdit > edits, boolean symmetry, FragmentSpace fragSpace, Logger logger)
Edit this graph according to a given list of edit tasks.
List< Vertex > gVertices
The vertices belonging to this graph.
boolean hasScaffoldTypeVertex()
Checks if this graph contains a scaffold vertex.
void setRings(ArrayList< Ring > rings)
Object[] checkConsistency(RunTimeParameters settings)
Peeks into this graph to derive a preliminary chemical representation with SMILES and InChIKey.
Vertex getVertexAtPosition(int pos)
Returns the vertex that is in the given position of the list of vertices belonging to this graph.
boolean containsAtoms()
Returns true if this graph has any vertex that contains atoms.
List< Edge > getEdgesWithTrg(Vertex v)
Returns the list of edges that arrive from the given vertex, i.e., edges where the trgAP is owned by ...
static DGraph getEmbeddedGraphInClone(DGraph graphY, DGraph graphB, List< Template > path)
Searches for a graphs (X) embedded at any level in a graph (Y) by knowing.
List< Ring > gRings
The rings defined in this graph.
int getBondingAPIndex(Vertex srcVert, int dapidx, Vertex dstVert)
void setSymmetricVertexSets(List< SymmetricVertexes > symVertices)
AtomicInteger apCounter
Generator of unique AP identifiers within this graph.
Vertex getDeepestAmongThese(List< Vertex > list)
Identify the oldest ancestor (i.e., most great grandparent) in the given collection.
void appendGraphOnAP(AttachmentPoint apOnThisGraph, AttachmentPoint apOnIncomingGraph, BondType bndType)
Appends a graph onto this graph.
static void setScaffold(Vertex v)
Update the graph so that the vertex argument is at the scaffold level i.e.
Map< DGraph, ObjectPair > extractPattern(GraphPattern pattern, boolean recordConnectivity)
Extracts subgraphs that match the provided pattern.
boolean isReversible(FragmentSpace fragSpace)
Checks is the every edge in the graph can be defined in the opposite direction according to the APCla...
String getBranchIdOfVertexAsStr(Vertex v)
Returns the branch identifier as a literal string.
List< AttachmentPoint > getAvailableAPsThroughout()
Returns the list of attachment points contained in this graph that are available throughout the templ...
boolean directedPathExists(Vertex src, Vertex trg)
Uses branch identifiers to define is two vertices are in such a relation that allows the drawing of a...
void appendVertexOnAP(AttachmentPoint srcAP, AttachmentPoint trgAP)
Append a vertex to this graph: adds the new vertex to the list of vertices belonging to the graph,...
List< Vertex > getVertexList()
boolean removeBranchStartingAt(Vertex v)
Deletes the branch, i.e., the specified vertex and its children.
static boolean compareGraphNodes(Vertex thisV, DGraph thisG, Vertex otherV, DGraph otherG)
Compares graphs by spanning vertices starting from the given vertex and following the direction of ed...
void convertSymmetricLabelsToSymmetricSets()
Looks for any symmetric labels, creates symmetric sets that collect the same information,...
DGraph(List< Vertex > gVertices, List< Edge > gEdges, List< Ring > gRings, List< ClosableChain > closableChains, List< SymmetricVertexes > symVertices)
List< AttachmentPoint > getInterfaceAPs(List< Vertex > subGraphB)
Searches for all AttachmentPoints that represent the interface between a subgraph,...
DGraph clone()
Returns almost "deep-copy" of this graph.
boolean hasForbiddenEnd(FragmentSpaceParameters fsSettings)
Check if there are forbidden ends: free attachment points that are not suitable for capping and not a...
List< DGraph > extractPattern(GraphPattern pattern)
Extracts subgraphs that match the provided pattern.
void removeCappingGroups(List< Vertex > lstVerts)
Remove capping groups that belong to this graph and are in the given list.
ArrayList< Vertex > getChildVertices(Vertex vertex)
boolean sameAsRings(StringBuilder reason, Map< Vertex, Vertex > vertexMap, Ring rT, Vertex vhT, Vertex vtT, Ring rO)
DGraph extractSubgraph(Vertex seed, boolean stopBeforeRCVs)
Creates a new graph that corresponds to the subgraph of this graph when exploring the spanning tree f...
void renumberGraphVertices()
Reassign vertex IDs to all vertices of this graph.
boolean containsOrEmbedsVertex(Vertex v)
Check if the specified vertex is contained in this graph as a node or in any inner graphs that may be...
ArrayList< DGraph > makeAllGraphsWithDifferentRingSets(RunTimeParameters settings)
Evaluates the possibility of closing rings in this graph and generates all alternative graphs resulti...
static DGraph fromJson(Reader reader)
Reads a JSON string and returns an instance of this class.
void addRing(Vertex vI, Vertex vJ, BondType bndTyp)
Adds a chord between the given vertices, thus adding a ring in this graph.
List< Vertex > getSymVerticesForVertex(Vertex v)
static final String SYM_ID
Key used to uniquely identify vertices and attachment points for symmetry detection.
boolean replaceSubGraph(List< Vertex > subGrpVrtxs, DGraph incomingGraph, LinkedHashMap< AttachmentPoint, AttachmentPoint > apMap, FragmentSpace fragSpace)
Replaced the subgraph represented by a given collection of vertices that belong to this graph.
void changeSignOfVertexID()
Change all vertex IDs to the corresponding negative value.
static boolean compareGraphNodes(Vertex seedOnA, DGraph gA, Vertex seedOnB, DGraph gB, Map< Vertex, Vertex > vertexMap, StringBuilder reason)
Compares graphs by spanning vertices starting from the given vertex and following the direction of ed...
boolean insertSingleVertex(Edge edge, Vertex newLink, LinkedHashMap< AttachmentPoint, AttachmentPoint > apMap)
Inserts a given vertex in between two vertices connected by the given edge.
void getChildTreeLimited(Vertex vertex, List< Vertex > children, List< Vertex > limitsInClone, boolean stopBeforeRCVs)
Gets all the children of the current vertex recursively until it finds one of the vertices listed as ...
void reassignSymmetricLabels()
Marks the vertices of this graph with a string that is consistent for all vertices that belong to sym...
List< Edge > gEdges
The edges belonging to this graph.
void replaceUnusedRCVsWithCapps(FragmentSpace fragSpace)
Removes unused ring-closing vertices.
void appendGraphOnGraph(List< Vertex > parentVertices, List< Integer > parentAPIdx, DGraph subGraph, Vertex childVertex, int childAPIdx, BondType bndType, boolean onAllSymmAPs)
Append a graph (incoming=I) onto this (receiving=R).
void setEdgeList(ArrayList< Edge > edges)
boolean sameAs(DGraph other, StringBuilder reason)
Compare this and another graph ignoring the vertex IDs.
int getLevel(Vertex v)
Calculates the level of a vertex in this graph.
Vertex getParent(Vertex v)
void removeSymmetryRedundantIds(ArrayList< Long > list)
Remove all but one of the symmetry-related partners in a given list of vertex IDs.
void removeSymmetrySet(SymmetricVertexes ss)
Tries to determine the set of symmetric vertices in this graph based on finding compatible Vertexes t...
void storeCurrentVertexIDs()
Copies the current vertexID of each vertex into a property of the vertex itself.
void appendGraphOnAP(Vertex parentVertex, int parentAPIdx, DGraph subGraph, Vertex childVertex, int childAPIdx, BondType bndType, Map< Vertex, SymmetricVertexes > newSymSets)
Append a subgraph (I) to this graph (R) specifying which vertex and attachment point to use for the c...
static void fixEdgeDirections(DGraph graph)
Flips edges in the graph so that the scaffold is the only source vertex.
DGraph getOutermostGraphOwner()
void removeCappingGroupsOn(Vertex vertex)
Remove capping groups on the given vertex of this graph.
List< Long > findVerticesIds(VertexQuery query, Logger logger)
Search a graph for vertices that match the criteria defined in a query vertex.
static DGraph fromJson(String json)
Reads a JSON string and returns an instance of this class.
List< Edge > getEdgesWithSrc(Vertex v)
Returns the list of edges that depart from the given vertex, i.e., edges where the srcAP is owned by ...
void addRing(Vertex vI, Vertex vJ)
Adds a chord between the given vertices, thus adding a ring in this graph.
DGraph extractSubgraph(Collection< Vertex > definedOn, Set< Edge > connectionToSubgraph, Set< Edge > connectionFromSubgraph)
Returns a clone of the subgraph defined by the a collection of vertices belonging to this graph.
boolean isVertexIDInRing(int vid)
void addSymmetricSetOfVertices(SymmetricVertexes symSet)
Adds a symmetric set of vertices to this graph.
SymmetricVertexes getSymSetForVertex(Vertex v)
Returns the set of vertexes symmetric to the given one.
void getParentTree(Vertex vertex, List< Vertex > parentTree)
Traverse the graph until it identifies the source of the directed path reachable from the given verte...
void addCappingGroups(FragmentSpace fragSpace)
Add a capping groups on free unused attachment points.
DGraph(List< Vertex > gVertices, List< Edge > gEdges, List< Ring > gRings)
List< Edge > getEdgeList()
DGraph(List< Vertex > gVertices, List< Edge > gEdges, List< Ring > gRings, List< SymmetricVertexes > symSets)
void removeCappingGroups()
Remove all capping groups on this graph.
void cleanup()
Wipes the data in this graph.
boolean hasRings()
Check for rings in this graph.
void removeCappingGroupsFromChilds(List< Vertex > lstVerts)
Object[] checkConsistency(RunTimeParameters settings, boolean permissive)
Peeks into this graph to derive a preliminary chemical representation with SMILES and InChIKey.
List< Vertex > getMutableSites(List< MutationType > ignoredTypes)
A list of mutation sites from within this graph.
DefaultUndirectedGraph< Node, NodeConnection > jGraphKernel
JGraph representation used to detect DENOPTIM-isostructural graphs.
ArrayList< Edge > getEdgesWithChild(int vid)
ArrayList< Vertex > findVertices(VertexQuery vrtxQuery, boolean purgeSym, Logger logger)
Filters a list of vertices according to a query.
boolean isVertexInRing(Vertex v)
List< AttachmentPoint > getSubgraphAPs(List< Vertex > subGraphB)
Searches for all AttachmentPoints that are owned by vertices in a subgraph but either available or us...
Candidate getCandidateOwner()
Returns the reference of the candidate item that is defined by this graph.
List< SymmetricVertexes > symVertices
ArrayList< Ring > getRingsInvolvingVertex(Vertex[] vs)
Returns the list of rings that include the given list of vertices in their fundamental cycle.
Map< Long, Long > renumberVerticesGetMap()
Reassign vertex IDs to a graph.
boolean hasSymmetryInvolvingVertex(Vertex v)
static void fixEdgeDirections(Vertex v, Set< Long > visited)
Recursive utility method for fixEdgeDirections(graph).
boolean replaceVertex(Vertex vertex, int bbId, BBType bbt, LinkedHashMap< Integer, Integer > apIdMap, boolean symmetry, FragmentSpace fragSpace)
Replaced a given vertex belonging to this graph with a new vertex generated specifically for this pur...
ArrayList< Vertex > getUsedRCVertices()
Search for used ring closing vertices: vertices that contain only a RingClosingAttractor and are part...
boolean insertVertex(Edge edge, int bbId, BBType bbt, LinkedHashMap< AttachmentPoint, Integer > apMap, FragmentSpace fragSpace)
Inserts a given vertex in between two vertices connected by the given edge.
Edge getEdgeWithParent(long l)
Looks for an edge that points to a vertex with the given vertex id.
void getChildrenTree(Vertex vertex, List< Vertex > children, AtomicInteger branchIdGenerator, List< Integer > prevBranchId)
Gets all the children of the current vertex recursively.
void removeEdge(Edge edge)
Removes an edge and update the free valences of the attachment points that were originally involved i...
void getChildTreeLimited(Vertex vertex, List< Vertex > children, boolean stopBeforeRCVs)
Gets all the children of the current vertex recursively.
Template templateJacket
Reference to the Template embedding this graph.
boolean removeBranchStartingAt(Vertex v, boolean symmetry)
Deletes the branch, i.e., the specified vertex and its children.
int getHeavyAtomsCount()
Calculate the number of atoms from the graph representation.
DGraph extractSubgraph(Collection< Vertex > definedOn)
Returns a clone of the subgraph defined by the a collection of vertices belonging to this graph.
boolean removeOrphanBranchStartingAt(Vertex v)
Deletes the branch, i.e., the specified vertex and its children.
List< Vertex > getMutableSites()
A list of mutation sites from within this graph.
String localMsg
A free-format string used to record simple properties in the graph.
void addEdge(Edge edge)
Adds the edge to the list of edges belonging to this graph.
boolean replaceSingleSubGraph(List< Vertex > subGrpVrtxs, DGraph newSubGraph, LinkedHashMap< AttachmentPoint, AttachmentPoint > apMap)
Replaced the subgraph represented by a given collection of vertices that belong to this graph.
List< Template > getEmbeddingPath()
Find the path that one has to traverse to reach this graph from any template-embedding structure.
void addCappingGroups(List< Vertex > vertexAddedToThis, FragmentSpace fragSpace)
Add a capping group on the given vertices, if needed.
Template getTemplateJacket()
boolean removeChainUpToBranching(Vertex v, FragmentSpace fragSpace)
Mutates the graph by removing the chain where a given vertex is located up to the first branching (i....
List< Integer > getBranchIdOfVertexAtPosition(int i)
Returns the branch identifier.
void setLocalMsg(String msg)
List< Vertex > getSelectedMutableSites(MutationType requestedType)
A list of mutation sites from within this graph.
void appendGraphOnGraph(Vertex parentVertex, int parentAPIdx, DGraph subGraph, Vertex childVertex, int childAPIdx, BondType bndType, Map< Vertex, SymmetricVertexes > newSymSets, boolean onAllSymmAPs)
Append a graph (incoming=I) onto this graph (receiving=R).
boolean isIsostructuralTo(DGraph other)
Checks if this graph is "DENOPTIM-isostructural" to the other one given.
DGraph extractSubgraph(Vertex seed, List< Vertex > limits, boolean stopBeforeRCVs)
Creates a new graph that corresponds to the subgraph of this graph when exploring the spanning tree f...
boolean hasOrEmbedsRings()
Check for rings in this graph and in any graph that is embedded at any level in any vertex of this gr...
void dfsEncodePaths(Vertex current, String currentPath, Set< Vertex > visited, Map< String, List< Vertex > > pathMap)
Performs a depth-first search (DFS) starting from a given Vertex to encode paths in the graph.
boolean detectSymVertexSets()
Detects and groups symmetric sets of Vertexes in the graph based on unique identification and path en...
ArrayList< Vertex > findVertices(VertexQuery vrtxQuery, Logger logger)
Filters a list of vertices according to a query.
This class represents the edge between two vertices.
AttachmentPoint getTrgAP()
void flipEdge()
Exchanges source and target vertices and respective APs of this edge.
AttachmentPoint getSrcAP()
A query for edges: a list of properties that target edges should possess in order to match this query...
APClass getSourceAPClass()
APClass getTargetAPClass()
Class representing a continuously connected portion of chemical object holding attachment points.
This class represents the closure of a ring in a spanning tree.
int getPositionOf(Vertex v)
void addVertex(Vertex v)
Append a DENOPTIMVertex to the list.
Vertex getVertexAtPosition(int i)
void setBondType(BondType bndType)
Set the bond type (i.e., bond order) of the chord connecting the head and the tail vertices.
List< Vertex > getVertices()
A collection of AttachmentPoints that are related by a relation that we call "symmetry",...
boolean add(T item)
Adds an item to this list, if not already present.
A collection of Vertexs that are related by a relation that we call "symmetry", even though this clas...
void removeProjectionOfInnerAP(AttachmentPoint oldInnerAP)
Removes the mapping of the given inner AP from this template's surface, if such mapping exists.
void setInnerGraph(DGraph innerGraph)
void updateInnerApID(AttachmentPoint oldInnerAP, AttachmentPoint newInnerAP)
Replaces a given link between APs on the surface of this template (i.e., outerAP) and the correspondi...
void addInnerToOuterAPMapping(AttachmentPoint newInnerAP)
Adds the projection of an AP in the template's inner graph (i.e., innerAP) to the list of APs visible...
ArrayList< AttachmentPoint > getAttachmentPoints()
Return the list of attachment points visible from outside the template, i.e., the so-called outer APs...
void clearIAtomContainer()
Removes the molecular representation.
void setContractLevel(ContractLevel contract)
Imposes the given contract to this template.
AttachmentPoint getOuterAPFromInnerAP(AttachmentPoint innerAP)
AttachmentPoint getInnerAPFromOuterAP(AttachmentPoint outerAP)
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
ArrayList< Vertex > getChildrenThroughout()
Looks into the edges that use any of the APs that belong to this vertex and returns the list of verti...
abstract Vertex clone()
Returns a deep-copy of this vertex.
void setMutationTypes(List< MutationType > lst)
int getBuildingBlockId()
Returns the index of the building block that should correspond to the position of the building block ...
Edge getEdgeToParent()
Looks into the edges that use any of the APs that belong to this vertex and returns the edge that has...
void setVertexId(long vertexId2)
int getFreeAPCountThroughout()
Counts the number of attachment points that are availability throughout the graph level,...
int getIndexOfAP(AttachmentPoint ap)
Returns the position of the given AP in the list of APs of this vertex.
String toString()
Produces a human readable, short string to represent the vertex by its vertex ID, building block ID (...
Vertex getParent()
Looks into the edges that use any of the APs that belong to this vertex and returns the vertex which ...
Vertex.BBType getBuildingBlockType()
DGraph getGraphOwner()
Returns the graph this vertex belongs to or null.
ArrayList< Vertex > getChilddren()
Looks into the edges that use any of the APs that belong to this vertex and returns the list of verti...
abstract List< AttachmentPoint > getAttachmentPoints()
Object getProperty(Object property)
boolean sameAs(Vertex other)
Compares this and another vertex ignoring vertex IDs.
int getCappedAPCountThroughout()
Counts the number of attachment points that are used by BBType#CAP vertex.
void setProperty(Object key, Object property)
ArrayList< AttachmentPoint > getFreeAPThroughout()
Gets attachment points that are availability throughout the graph level, i.e., checks also across the...
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
static Vertex newVertexFromLibrary(int bbId, Vertex.BBType bbt, FragmentSpace fragSpace)
Builds a new molecular fragment kind of vertex.
Edge getEdgeWith(Vertex other)
Finds the edge between this and the other vertex, if it exists.
Query for searching vertices.
Integer getVertexBBIDQuery()
Integer getVertexLevelQuery()
VertexType getVertexTypeQuery()
EdgeQuery getInEdgeQuery()
EdgeQuery getOutEdgeQuery()
BBType getVertexBBTypeQuery()
ClosableChain represents a chain of fragments (chain links) that is closable (or candidate closable).
This is a tool to identify and manage vertices' connections not included in the DGraph,...
boolean checkChelatesGraph(DGraph molGraph, List< Ring > ringsSet)
Evaluates the combination of a DENOPTIMGraph and a set of DENOPTIMRings and decides whether it's a pr...
ArrayList< List< Ring > > getPossibleCombinationOfRings(IAtomContainer mol, DGraph molGraph)
Identifies all possible ring closing paths and returns them as list of DENOPTIMRings ready to be appe...
This object represents a path in a DGraph.
List< Vertex > getVertecesPath()
Returns the list of verteces involved.
The RingClosingAttractor represent the available valence/connection that allows to close a ring.
static final Map< String, String > RCATYPEMAP
Recognized types of RingClosingAttractor and compatible types.
Parameters and setting related to handling ring closures.
int getMaxRcaPerType(String type)
int getMinRcaPerType(String type)
boolean buildChelatesMode
Flag activating procedures favoring formation of chelates.
void allowRingClosures(boolean value)
int compare(NodeConnection other)
This class represents a subgraph feature that defined the structure of a graph.
static final String REFTOVERTEXKERNEL
Property if Vertex used to store the reference to the corresponding Node.
int compare(UndirectedEdge other)
Utility methods for input/output.
static void writeGraphToJSON(File file, DGraph graph)
Writes the graph to JSON file.
Class for de/serializing DENOPTIM graphs from/to JSON format.
Tool to build build three-dimensional (3D) tree-like molecular structures from DGraph.
void setAlignBBsIn3D(boolean align)
Sets the flag that controls whether building blocks have to be aligned according to the AP vectors or...
IAtomContainer convertGraphTo3DAtomContainer(DGraph graph)
Created a three-dimensional molecular representation from a given DGraph.
Collection of parameters controlling the behavior of the software.
RunTimeParameters getParameters(ParametersType type)
Logger getLogger()
Get the name of the program specific logger.
static< T > void unionOfIntersectingSets(List< Set< T > > list)
Takes the union of any two sets in this list that intersect.
Definition of a graph editing task.
static synchronized void ensureVertexIDConsistency(long l)
Method used to ensure consistency between internal atomic integer and vertex id from imported graphs.
static synchronized long getUniqueVertexIndex()
Unique counter for the number of graph vertices generated.
static synchronized int getUniqueGraphIndex()
Unique counter for the number of graphs generated.
Utilities for molecule conversion.
static String getInChIKeyForMolecule(IAtomContainer mol, Logger logger)
Generates the InChI key for the given atom container.
static int getNumberOfRotatableBonds(IAtomContainer mol)
Count number of rotatable bonds.
static String getSMILESForMolecule(IAtomContainer mol, Logger logger)
Returns the SMILES representation of the molecule.
static double getMolecularWeight(IAtomContainer mol)
static String getSymbolOrLabel(IAtom atm)
Gets either the elemental symbol (for standard atoms) of the label (for pseudo-atoms).
static int getHeavyAtomCount(IAtomContainer mol)
The heavy atom count.
This class is the equivalent of the Pair data structure used in C++ Although AbstractMap....
Tool box for definition and management of the rotational space, which is given by the list of rotatab...
static ArrayList< ObjectPair > defineRotatableBonds(IAtomContainer mol, String defRotBndsFile, boolean addIterfragBonds, boolean excludeRings, Logger logger)
Define the rotational space (also torsional space) for a given molecule.
Possible chemical bond types an edge can represent.
Enum specifying to what extent the template's inner graph can be changed.
FREE
Inner graphs are free to change within the confines of the required AttachmentPoints.
The type of building block.
Flag declaring the type of Vertex implementation.
Identifier of the type of parameters.
FS_PARAMS
Parameters pertaining the definition of the fragment space.
RC_PARAMS
Parameters pertaining to ring closures in graphs.
Types of mutation defined in relation to what happens to the target vertex (i.e., the actual mutation...