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;
154 private DefaultUndirectedGraph<Vertex, UndirectedEdge>
160 private DefaultUndirectedGraph<Node, NodeConnection>
179 for (
Vertex v : this.gVertices)
180 v.setGraphOwner(
this);
182 gRings =
new ArrayList<>();
202 List<SymmetricVertexes> symSets)
206 this.symVertices = symSets;
226 gEdges =
new ArrayList<>();
227 gRings =
new ArrayList<>();
337 List<Vertex> lst =
new ArrayList<Vertex>();
342 ss.stream().forEach(i -> lst.add((
Vertex) i));
378 Set<Vertex> alreadyAssignedVrtxs =
new HashSet<Vertex>();
383 Map<SymmetricAPs,List<Vertex>> symVrtxsFromAnyBranch =
384 new HashMap<SymmetricAPs,List<Vertex>>();
389 List<Vertex> vrtxsSymToVrtx =
new ArrayList<Vertex>();
390 for (List<Vertex> tmpSymSets : symVrtxsFromAnyBranch.values())
392 if (tmpSymSets.contains(vrtx))
394 vrtxsSymToVrtx.addAll(tmpSymSets);
397 if (vrtxsSymToVrtx.size()==0)
398 vrtxsSymToVrtx.add(vrtx);
400 for (
Vertex symToVrtx : vrtxsSymToVrtx)
402 Map<SymmetricAPs,List<Vertex>> symChildenSetsOnSymToVrtxs =
404 alreadyAssignedVrtxs);
406 for (
SymmetricAPs key : symChildenSetsOnSymToVrtxs.keySet())
409 boolean foundSymmetricBranch =
false;
411 symVrtxsFromAnyBranch.keySet()))
413 foundSymmetricBranch =
true;
417 keyOnMaster.get(0),
new HashSet<Vertex>()))
421 symVrtxsFromAnyBranch.get(keyOnMaster).addAll(
422 symChildenSetsOnSymToVrtxs.get(key));
427 foundSymmetricBranch =
false;
430 if (!foundSymmetricBranch)
434 List<Vertex> lst =
new ArrayList<Vertex>();
435 lst.addAll(symChildenSetsOnSymToVrtxs.get(key));
436 symVrtxsFromAnyBranch.put(key, lst);
442 for (List<Vertex> symVertexes : symVrtxsFromAnyBranch.values())
444 if (symVertexes.size()<2)
451 alreadyAssignedVrtxs.addAll(symVertexes);
461 Vertex vrtx, Set<Vertex> alreadyAssignedVrtxs)
463 Map<SymmetricAPs,List<Vertex>> symSetsOfChildVrtxs =
464 new HashMap<SymmetricAPs,List<Vertex>>();
466 Set<AttachmentPoint> doneAPs =
new HashSet<AttachmentPoint>();
470 boolean addSymAPsAreUsed =
true;
473 if (ap.isAvailableThroughout())
475 addSymAPsAreUsed =
false;
479 if (!addSymAPsAreUsed)
485 boolean setSymmetryRelation =
true;
486 List<Vertex> symVertexes =
new ArrayList<Vertex>();
496 alreadyAssignedVrtxs);
497 if (!setSymmetryRelation)
501 symVertexes.add(ap.getLinkedAPThroughout().getOwner());
504 if (setSymmetryRelation)
506 symSetsOfChildVrtxs.put(symAPs,symVertexes);
507 alreadyAssignedVrtxs.addAll(symVertexes);
519 if (doneAPs.contains(ap) || ap.isAvailableThroughout())
522 Vertex user = ap.getLinkedAPThroughout().getOwner();
523 if (alreadyAssignedVrtxs.contains(user))
532 List<Vertex> symVertexes =
new ArrayList<Vertex>();
533 symVertexes.add(user);
535 symSetsOfChildVrtxs.put(soloSymAps,symVertexes);
536 alreadyAssignedVrtxs.addAll(symVertexes);
538 return symSetsOfChildVrtxs;
570 boolean userOfApAIsFragment =
Fragment.class.isInstance(userOfApA);
576 if (!apUserOfApA.
sameAs(apUserOfApB))
584 if (alreadyAssignedVrtxs.contains(userOfApB))
591 if (!userOfApB.
sameAs(userOfApA))
600 if (userOfApAIsFragment)
649 this.symVertices.clear();
666 if (!Collections.disjoint(oldSS, symSet))
669 +
"there is already one that contains some of the same "
752 if (e.getTrgAP().getOwner() == v0)
754 ArrayList<Vertex> parentTree =
new ArrayList<>();
756 return parentTree.get(parentTree.size()-1);
786 List<Edge> edges =
new ArrayList<Edge>();
789 if (e.getSrcAP().getOwner() == v)
807 List<Edge> edges =
new ArrayList<Edge>();
810 if (e.getTrgAP().getOwner() == v)
828 ArrayList<Ring> rings =
new ArrayList<Ring>();
849 ArrayList<Ring> rings =
new ArrayList<Ring>();
852 boolean matchesAll =
true;
853 for (
int i=0; i<vs.length; i++)
855 if (!r.contains(vs[i]))
873 ArrayList<Ring> rings =
new ArrayList<Ring>();
876 if (r.containsID(vid))
926 boolean result =
false;
929 if (r.containsID(vid))
942 boolean result =
false;
964 ArrayList<Vertex> rcvLst =
new ArrayList<Vertex>();
987 ArrayList<Vertex> free =
new ArrayList<Vertex>();
1009 ArrayList<Vertex> used =
new ArrayList<Vertex>();
1050 BondType bndTypI = vI.getEdgeToParent().getBondType();
1051 BondType bndTypJ = vJ.getEdgeToParent().getBondType();
1052 if (bndTypI != bndTypJ)
1054 String s =
"Attempt to close rings is not compatible "
1055 +
"to the different bond type specified by the "
1056 +
"head and tail APs: (" + bndTypI +
"!="
1057 + bndTypJ +
" for vertices " + vI +
" "
1078 ArrayList<Vertex> arrLst =
new ArrayList<Vertex>();
1101 +
"unique within the graph. VertexID '"
1102 + vertex.getVertexId()+
"' already present in graph "
1104 vertex.setGraphOwner(
this);
1133 for (
Ring r : rToRm)
1140 ArrayList<Edge> eToDel =
new ArrayList<>();
1141 for (
int i=0; i<
gEdges.size(); i++)
1154 for (
Edge e : eToDel)
1160 List<SymmetricVertexes> ssToRemove =
new ArrayList<SymmetricVertexes>();
1163 if (ss.contains(vertex))
1204 if (symSites.size() == 0)
1206 symSites.add(vertex);
1210 for (
Vertex oldLink : symSites)
1227 .getSrcAPThroughout();
1229 .getSrcAPThroughout();
1260 boolean foundLinkToParent =
false;
1263 if (ap.isAvailable() && !ap.isAvailableThroughout())
1265 if (!ap.isSrcInUserThroughout())
1266 foundLinkToParent =
true;
1269 if (!foundLinkToParent)
1282 ArrayList<AttachmentPoint> needyAPsOnChildren =
1283 new ArrayList<AttachmentPoint>();
1285 ArrayList<AttachmentPoint> freeAPsOnParent =
1286 new ArrayList<AttachmentPoint>();
1288 Map<AttachmentPoint,AttachmentPoint> apOnOldToNeedyAP =
1289 new HashMap<AttachmentPoint,AttachmentPoint>();
1292 if (!apOnOld.isAvailableThroughout())
1294 if (apOnOld.isSrcInUserThroughout())
1301 needyAPsOnChildren.add(needyAP);
1302 apOnOldToNeedyAP.put(apOnOld, needyAP);
1308 freeAPsOnParent.add(apOnParent);
1309 freeAPsOnParent.addAll(apOnParent.
getOwner()
1316 List<APMapping> mappings = fragSpace.mapAPClassCompatibilities(
1317 freeAPsOnParent, needyAPsOnChildren, 500);
1318 if (mappings.size() == 0)
1327 List<Integer> preferences =
new ArrayList<Integer>();
1329 for (
int i=0; i<needyAPsOnChildren.size(); i++)
1339 Vertex lastBeforeOwnerOfNeedy =
1341 if (r.contains(lastBeforeOwnerOfNeedy))
1343 preferences.set(i, preferences.get(i) + 1);
1349 int maxScore = Integer.MIN_VALUE;
1356 score = score + preferences.get(needyAPsOnChildren.indexOf(ap));
1358 if (score > maxScore)
1361 bestScoringMapping = apm;
1366 for (Entry<AttachmentPoint, AttachmentPoint> e :
1367 bestScoringMapping.entrySet())
1369 bestScoringMappingReverse.put(e.getValue(), e.getKey());
1374 ArrayList<Ring> ringsToRemove =
new ArrayList<Ring>();
1375 for (
Ring r : rToEdit)
1377 r.removeVertex(vertex);
1378 if (r.getSize() < 3)
1379 ringsToRemove.add(r);
1381 for (
Ring r : ringsToRemove)
1388 LinkedHashMap<AttachmentPoint,AttachmentPoint> newInReplaceOldInInTmpl =
1389 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
1390 List<AttachmentPoint> oldAPToRemoveFromTmpl =
1391 new ArrayList<AttachmentPoint>();
1394 if (oldAP.isAvailable())
1402 if (!oldAP.isAvailableThroughout())
1406 if (bestScoringMapping.keySet().contains(lAP))
1408 newInReplaceOldInInTmpl.put(
1409 bestScoringMapping.get(lAP), oldAP);
1410 }
else if (bestScoringMapping.values().contains(lAP))
1412 newInReplaceOldInInTmpl.put(
1413 bestScoringMappingReverse.get(lAP), oldAP);
1415 oldAPToRemoveFromTmpl.add(oldAP);
1418 oldAPToRemoveFromTmpl.add(oldAP);
1430 List<SymmetricVertexes> ssToRemove =
new ArrayList<SymmetricVertexes>();
1432 while (ssIter.hasNext())
1435 if (ss.contains(vertex))
1446 vertex.resetGraphOwner();
1449 List<AttachmentPoint> reconnettedApsOnChilds =
1450 new ArrayList<AttachmentPoint>();
1451 for (Entry<AttachmentPoint,AttachmentPoint> e :
1452 bestScoringMapping.entrySet())
1459 Edge edge =
new Edge(apOnParent,apOnChild,
1462 reconnettedApsOnChilds.add(apOnChild);
1469 newInReplaceOldInInTmpl.get(apOnParent),
1471 reconnettedApsOnChilds.add(apOnChild);
1476 newInReplaceOldInInTmpl.get(apOnChild),
1478 reconnettedApsOnChilds.add(apOnChild);
1485 + apOnChild +
"' seems connected to a template, "
1486 +
"no template was found. Possible bug!");
1505 if (!reconnettedApsOnChilds.contains(apOnChild))
1529 List<Vertex> rcvToReplace =
new ArrayList<Vertex>();
1530 List<AttachmentPoint> apToCap =
new ArrayList<AttachmentPoint>();
1534 && v.getEdgeToParent()!=
null)
1536 rcvToReplace.add(v);
1537 apToCap.add(v.getEdgeToParent().getSrcAP());
1540 for (
int i=0; i<rcvToReplace.size(); i++)
1542 Vertex v = rcvToReplace.get(i);
1546 APClass cappAPClass = fragSpace.getAPClassOfCappingVertex(
1549 if (cappAPClass !=
null)
1551 Vertex capVrt = fragSpace.getCappingVertexWithAPClass(
1576 while (ssIter.hasNext())
1579 String symmLabel = ss.hashCode() +
"-" + i;
1602 Map<String,List<Vertex>> collectedLabels =
new HashMap<>();
1607 String label = v.getProperty(
1609 if (collectedLabels.containsKey(label))
1611 collectedLabels.get(label).add(v);
1613 List<Vertex> lst =
new ArrayList<Vertex>();
1615 collectedLabels.put(label, lst);
1621 for (String label : collectedLabels.keySet())
1623 List<Vertex> symmvertices = collectedLabels.get(label);
1625 if (symmvertices.size()>1)
1628 for (
Vertex v : symmvertices)
1639 for (
Vertex v : symmvertices)
1644 for (
Vertex v : symmvertices)
1682 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap,
1685 for (
Vertex vToRemove : subGrpVrtxs)
1694 subGrpVrtxs.stream().filter(v -> v.getBuildingBlockType()==
BBType.
CAP)
1696 subGrpVrtxs.removeIf(v -> v.getBuildingBlockType()==
BBType.
CAP);
1697 if (subGrpVrtxs.size() == 0)
1700 +
"vertex in a subgraph to replace.");
1705 incomingGraph.reassignSymmetricLabels();
1712 List<List<Vertex>> compatibleSymSubGrps =
new ArrayList<List<Vertex>>();
1715 boolean skip =
false;
1716 for (
int iv=0; iv<subGrpVrtxs.size(); iv++)
1720 Vertex oriVs = subGrpVrtxs.get(iv);
1721 Vertex symVs = symmetricSubGrpVrtx.get(iv);
1728 oriVsChildren.removeIf(v -> v.getBuildingBlockType()==
BBType.
CAP);
1729 symVsChildren.removeIf(v -> v.getBuildingBlockType()==
BBType.
CAP);
1730 if (oriVsChildren.size()!=symVsChildren.size())
1736 for (
int ic=0; ic<oriVsChildren.size(); ic++)
1741 if (subGrpVrtxs.contains(oriVsChildren.get(ic)))
1748 if (oriVsChildren.get(ic).getBuildingBlockType()
1749 != symVsChildren.get(ic).getBuildingBlockType())
1757 compatibleSymSubGrps.add(symmetricSubGrpVrtx);
1759 if (compatibleSymSubGrps.size()==0)
1762 for (List<Vertex> verticesToRemove : compatibleSymSubGrps)
1767 List<Vertex> vertexAddedToThis =
new ArrayList<Vertex>(
1774 LinkedHashMap<AttachmentPoint,AttachmentPoint> localApMap =
1775 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
1780 int vrtPosOnOld = subGrpVrtxs.indexOf(e.getKey().getOwner());
1781 int apPosOnOld = e.getKey().getIndexInOwner();
1783 vrtPosOnOld).getAP(apPosOnOld);
1785 int vrtPosOnNew = incomingGraph.indexOf(e.getValue().getOwner());
1788 vrtPosOnNew).
getAP(apPosOnNew);
1789 localApMap.put(apOnOld,apOnNew);
1819 if (subGrpVrtxs.stream().anyMatch(v -> v.getBuildingBlockType()==
BBType.
CAP))
1821 +
"symmetric subgraphs");
1823 List<List<Vertex>> symSites =
new ArrayList<List<Vertex>>();
1825 if (subGrpVrtxs.size()==1)
1829 ArrayList<Vertex> lst =
new ArrayList<Vertex>();
1833 if (symSites.size()==0)
1835 symSites.add(subGrpVrtxs);
1841 List<Vertex> thoseWithoutParent =
new ArrayList<Vertex>();
1842 for (
Vertex v : subGrpVrtxs)
1844 if (!subGrpVrtxs.contains(v.getParent()))
1845 thoseWithoutParent.add(v);
1847 if (thoseWithoutParent.size()!=1)
1852 Vertex sourceOfSubGraph = thoseWithoutParent.get(0);
1854 if (numSymmetricSubGraphs==0)
1856 symSites.add(subGrpVrtxs);
1861 List<Vertex> thoseWithoutChildren =
new ArrayList<Vertex>();
1862 for (
Vertex v : subGrpVrtxs)
1864 if (Collections.disjoint(v.getChilddren(),subGrpVrtxs))
1865 thoseWithoutChildren.add(v);
1873 Set<Vertex> upperLimits =
new HashSet<Vertex>();
1874 Set<Vertex> doneBySymmetry =
new HashSet<Vertex>();
1875 for (
Vertex upperLimit : thoseWithoutChildren)
1879 int numInSubGraphReplicas = 1;
1881 if (doneBySymmetry.contains(upperLimit))
1885 Set<Vertex> symmSitesOnBranch =
new HashSet<Vertex>(
1887 symmSitesOnBranch.retainAll(subGrpVrtxs);
1888 if (symmSitesOnBranch.size()>0)
1890 numInSubGraphReplicas = symmSitesOnBranch.size();
1891 doneBySymmetry.addAll(symmSitesOnBranch);
1895 if (lst.size() != numInSubGraphReplicas*numSymmetricSubGraphs)
1898 symSites.add(subGrpVrtxs);
1901 upperLimits.addAll(lst);
1906 List<Vertex> symSubGraph =
new ArrayList<Vertex>();
1908 symSubGraph.add(symSources);
1911 symSubGraph.removeIf(v -> v.getBuildingBlockType()==
BBType.
CAP);
1912 if (symSubGraph.size()!=subGrpVrtxs.size())
1914 symSites =
new ArrayList<List<Vertex>>();
1915 symSites.add(subGrpVrtxs);
1918 symSites.add(symSubGraph);
1956 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap)
1960 ||
gVertices.contains(newSubGraph.getVertexAtPosition(0)))
1966 ArrayList<Vertex> newvertices =
new ArrayList<Vertex>();
1967 newvertices.addAll(newSubGraph.getVertexList());
1972 List<AttachmentPoint> interfaceApsOnOldBranch =
1973 new ArrayList<AttachmentPoint>();
1974 for (
Vertex vToDel : subGrpVrtxs)
1978 if (ap.isAvailable())
1982 interfaceApsOnOldBranch.add(ap);
1984 Vertex user = ap.getLinkedAP().getOwner();
1985 if (!subGrpVrtxs.contains(user))
1987 interfaceApsOnOldBranch.add(ap);
1993 List<AttachmentPoint> interfaceApsOnNewBranch =
1994 new ArrayList<AttachmentPoint>();
1995 for (
Vertex v : newSubGraph.getVertexList())
1999 if (ap.isAvailable())
2003 interfaceApsOnNewBranch.add(ap);
2011 LinkedHashMap<AttachmentPoint,AttachmentPoint>
2012 linksToRecreate =
new LinkedHashMap<>();
2013 LinkedHashMap<AttachmentPoint,BondType>
2014 linkTypesToRecreate =
new LinkedHashMap<>();
2015 LinkedHashMap<AttachmentPoint,AttachmentPoint>
2016 inToOutAPForTemplate =
new LinkedHashMap<>();
2017 List<AttachmentPoint> oldAPToRemoveFromTmpl =
new ArrayList<>();
2021 if (oldAP.isAvailable())
2028 if (oldAP.isAvailableThroughout())
2030 if (!apMap.containsKey(oldAP))
2034 oldAPToRemoveFromTmpl.add(oldAP);
2038 inToOutAPForTemplate.put(apMap.get(oldAP),oldAP);
2041 if (!apMap.containsKey(oldAP))
2044 +
"if a used AP has no mapping.");
2048 inToOutAPForTemplate.put(apMap.get(oldAP),oldAP);
2055 if (!apMap.containsKey(oldAP))
2058 +
"AP has no mapping. Missing mapping for AP "
2059 + oldAP.getIndexInOwner() +
" in "
2060 + oldAP.getOwner().getVertexId());
2067 if (!oldAP.isSrcInUser())
2069 trgAPOnNewLink = newAP;
2074 Map<Ring,List<Vertex>> ringsOverSubGraph =
2075 new HashMap<Ring,List<Vertex>>();
2076 for (
int iA=0; iA<interfaceApsOnOldBranch.size(); iA++)
2083 for (
int iB=(iA+1); iB<interfaceApsOnOldBranch.size(); iB++)
2097 List<Vertex> vPair =
new ArrayList<Vertex>();
2098 vPair.add(r.getCloserToHead(vLinkedOnA, vLinkedOnB));
2099 vPair.add(r.getCloserToTail(vLinkedOnA, vLinkedOnB));
2100 ringsOverSubGraph.put(r, vPair);
2106 for (
Ring r : ringsOverSubGraph.keySet())
2108 List<Vertex> vPair = ringsOverSubGraph.get(r);
2111 for (
int i=1; i<(verticesInPath.size()-1); i++)
2113 r.removeVertex(verticesInPath.get(i));
2120 if (!oldAP.isAvailable())
2125 for (
Vertex vToDel : subGrpVrtxs)
2132 for (
Vertex incomingVrtx : newSubGraph.getVertexList())
2138 for (
Edge incomingEdge : newSubGraph.getEdgeList())
2144 for (
Ring incomingRing : newSubGraph.getRings())
2156 List<AttachmentPoint> doneApsOnNew =
2157 new ArrayList<AttachmentPoint>();
2160 if (trgAPOnNewLink !=
null)
2165 linksToRecreate.get(trgAPOnNewLink),
2167 linkTypesToRecreate.get(trgAPOnNewLink));
2169 doneApsOnNew.add(trgAPOnNewLink);
2177 if (apOnNew == trgAPOnNewLink)
2182 Edge edge =
new Edge(apOnNew,trgOnChild,
2183 linkTypesToRecreate.get(apOnNew));
2185 doneApsOnNew.add(apOnNew);
2189 for (
Ring r : ringsOverSubGraph.keySet())
2191 List<Vertex> vPair = ringsOverSubGraph.get(r);
2193 int initialInsertPoint = r.getPositionOf(vPair.get(0));
2195 for (
int i=1; i<(verticesInPath.size()-1); i++)
2197 r.insertVertex(initialInsertPoint+i, verticesInPath.get(i));
2208 inToOutAPForTemplate.get(apOnNew),apOnNew);
2209 doneApsOnNew.add(apOnNew);
2215 if (!doneApsOnNew.contains(apOnNew))
2231 for (
Vertex vOld : subGrpVrtxs)
2234 for (
Vertex vNew : newvertices)
2259 LinkedHashMap<Integer, Integer> apIdMap,
FragmentSpace fragSpace)
2262 return replaceVertex(vertex, bbId, bbt, apIdMap,
true, fragSpace);
2283 LinkedHashMap<Integer, Integer> apIdMap,
boolean symmetry,
2292 List<Vertex> symSites =
new ArrayList<Vertex>();
2297 if (symSites.size() == 0)
2299 symSites.add(vertex);
2309 for (
Vertex oldLink : symSites)
2313 oldLink.getUnfilteredMutationTypes());
2316 ArrayList<Vertex> oldVertex =
new ArrayList<Vertex>();
2317 oldVertex.add(oldLink);
2318 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap =
2319 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
2320 for (Map.Entry<Integer,Integer> e : apIdMap.entrySet())
2322 apMap.put(oldLink.getAP(e.getKey()),
2361 LinkedHashMap<AttachmentPoint,Integer> apMap,
2365 if (!
gEdges.contains(edge))
2370 List<Edge> symSites =
new ArrayList<Edge> ();
2371 List<LinkedHashMap<AttachmentPoint,Integer>> symApMaps =
2372 new ArrayList<LinkedHashMap<AttachmentPoint,Integer>>();
2374 edge.getTrgAP().getOwner());
2375 if (symTrgvertices.size() == 0)
2378 symApMaps.add(apMap);
2380 for (
Vertex trgVrtx : symTrgvertices)
2382 Edge symEdge = trgVrtx.getEdgeToParent();
2383 symSites.add(symEdge);
2385 LinkedHashMap<AttachmentPoint,Integer> locApMap =
new
2386 LinkedHashMap<AttachmentPoint,Integer>();
2387 locApMap.put(symEdge.
getSrcAP(), apMap.get(edge.getSrcAP()));
2388 locApMap.put(symEdge.
getTrgAP(), apMap.get(edge.getTrgAP()));
2389 symApMaps.add(locApMap);
2394 for (
int i=0; i<symSites.size(); i++)
2396 Edge symEdge = symSites.get(i);
2397 LinkedHashMap<AttachmentPoint,Integer> locApMap = symApMaps.get(i);
2403 LinkedHashMap<AttachmentPoint,AttachmentPoint> apToApMap =
2404 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
2407 apToApMap.put(apOnGraph, newLink.
getAP(locApMap.get(apOnGraph)));
2441 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap)
2467 Edge eSrcToLink =
new Edge(orisEdgeSrc,
2470 Edge eLinkToTrg =
new Edge(apMap.get(orisEdgeTrg),
2477 ArrayList<Ring> rToEdit =
new ArrayList<Ring>();
2480 for (
Ring r : rToEdit)
2482 r.insertVertex(newLink,srcVrtx,trgVrtx);
2493 if (ap.isAvailable())
2516 return ((pos >=
gVertices.size()) || pos < 0) ? null :
2622 if (
gEdges.contains(edge))
2639 if (
gRings.contains(ring))
2651 if ((pos >=
gEdges.size()) || pos < 0)
2682 StringBuilder sb =
new StringBuilder(512);
2684 sb.append(
graphId).append(
" ");
2688 sb.append(
gVertices.get(i).toString()).append(
",");
2693 for (
int i=0; i<
gEdges.size(); i++)
2695 sb.append(
gEdges.get(i).toString()).append(
",");
2700 for (
int i=0; i<
gRings.size(); i++)
2702 sb.append(
gRings.get(i).toString()).append(
" ");
2707 sb.append(
symVertices.get(i).toString()).append(
" ");
2710 return sb.toString();
2729 for (
int i = 0; i < n; i++)
2740 && dap_idx_v1 == dapidx)
2780 if (!children.contains(child))
2782 children.add(child);
2805 boolean markBranches)
2813 AtomicInteger branchIdGenerator =
new AtomicInteger(0);
2814 List<Integer> thisBranchId =
new ArrayList<Integer>();
2815 thisBranchId.add(branchIdGenerator.getAndIncrement());
2826 if (!children.contains(child))
2828 children.add(child);
2836 List<Integer> newBranchId =
new ArrayList<>(thisBranchId);
2837 newBranchId.add(branchIdGenerator.getAndIncrement());
2862 AtomicInteger branchIdGenerator, List<Integer> prevBranchId)
2871 if (!children.contains(child))
2873 children.add(child);
2881 List<Integer> newBranchId =
new ArrayList<>(prevBranchId);
2882 newBranchId.add(branchIdGenerator.getAndIncrement());
2907 List<Vertex> children,
int numLayers,
boolean stopBeforeRCVs)
2920 if (children.contains(child))
2923 if (stopBeforeRCVs && child.isRCV())
2926 children.add(child);
2957 @SuppressWarnings(
"unchecked")
2982 for (Integer i : lst)
3004 if (bIdSrc==
null || bIdTrg==
null)
3006 if (bIdSrc.size()>bIdTrg.size())
3008 int sharedSubBranches = 0;
3009 for (
int i=0; i<bIdSrc.size(); i++)
3011 if (bIdSrc.get(i)==bIdTrg.get(i))
3012 sharedSubBranches++;
3014 return sharedSubBranches==bIdSrc.size();
3029 List<Vertex> children,
boolean stopBeforeRCVs)
3038 if (children.contains(child))
3041 if (stopBeforeRCVs && child.isRCV())
3044 children.add(child);
3061 List<Vertex> children, Set<Vertex> limits)
3070 if (!children.contains(child))
3072 children.add(child);
3073 if (!limits.contains(child))
3093 List<Vertex> children, List<Vertex> limitsInClone,
3094 boolean stopBeforeRCVs)
3103 if (children.contains(child))
3106 if (stopBeforeRCVs && child.isRCV())
3109 children.add(child);
3110 if (!limitsInClone.contains(child))
3126 int shortest = Integer.MAX_VALUE;
3127 for (
Vertex vertex : list)
3129 List<Vertex> parentTree =
new ArrayList<Vertex>();
3131 if (parentTree.size()<shortest)
3133 shortest = parentTree.size();
3150 List<Vertex> parentTree)
3157 if (parentTree.contains(parent))
3160 throw new IllegalArgumentException();
3162 parentTree.add(parent);
3190 ArrayList<Vertex> cListVrtx =
new ArrayList<>();
3191 Map<Long, Vertex> vidsInClone =
new HashMap<Long, Vertex>();
3195 cListVrtx.add(vClone);
3199 ArrayList<Edge> cListEdges =
new ArrayList<>();
3202 long srcVrtxId = e.getSrcVertex();
3206 long trgVrtxId = e.getTrgVertex();
3211 srcVrtxId).getAP(srcApId);
3213 trgVrtxId).getAP(trgApId);
3215 cListEdges.add(
new Edge(srcAPClone, trgAPClone,
3222 ArrayList<Ring> cListRings =
new ArrayList<>();
3226 for (
int iv=0; iv<ring.getSize(); iv++)
3228 Vertex origVrtx = ring.getVertexAtPosition(iv);
3233 cListRings.add(cRing);
3238 ArrayList<ClosableChain> cListClosableChains =
3242 cListClosableChains.add(cc.clone());
3247 List<SymmetricVertexes> cSymVertices =
new ArrayList<>();
3251 for (
Vertex origVrt : ss)
3255 cSymVertices.add(clonedSS);
3293 ArrayList<Integer> lstEdges =
new ArrayList<>();
3316 ArrayList<Edge> lstEdges =
new ArrayList<>();
3336 long mval = Long.MIN_VALUE;
3338 mval = Math.max(mval, v.getVertexId());
3351 boolean result =
false;
3354 if (l == v.getVertexId())
3458 if (other.
jGraph ==
null)
3480 Comparator<Vertex> vComp =
new Comparator<Vertex>() {
3482 Map<Vertex,Set<Vertex>> symmetryShortCuts =
3483 new HashMap<Vertex,Set<Vertex>>();
3489 if (symmetryShortCuts.containsKey(v1)
3490 && symmetryShortCuts.get(v1).contains(v2))
3497 StringBuilder sb =
new StringBuilder();
3500 Set<Vertex> symToV2 =
new HashSet<Vertex>();
3502 Set<Vertex> symToV1 =
new HashSet<Vertex>();
3504 for (
Vertex v1s : symToV1)
3506 if (symmetryShortCuts.containsKey(v1s))
3508 symmetryShortCuts.get(v1s).addAll(symToV2);
3510 symmetryShortCuts.put(v1s,symToV2);
3520 if (Integer.compare(v1.hashCode(),
3522 return Integer.compare(v1.hashCode(),
3530 Comparator<UndirectedEdge> eComp =
3556 VF2GraphIsomorphismInspector<Vertex, UndirectedEdge> vf2 =
3557 new VF2GraphIsomorphismInspector<>(this.
jGraph, other.
jGraph,
3560 return vf2.isomorphismExists();
3590 Comparator<Node> vComp =
new Comparator<Node>() {
3592 Map<Node,Set<Node>> symmetryShortCuts =
3593 new HashMap<Node,Set<Node>>();
3596 public int compare(
Node v1,
Node v2) {
3599 if (symmetryShortCuts.containsKey(v1)
3600 && symmetryShortCuts.get(v1).contains(v2))
3610 if (dv1==
null && dv2==
null)
3615 Set<Node> symToV2 =
new HashSet<Node>();
3618 symToV2.add((
Node) sv.getProperty(
3622 Set<Node> symToV1 =
new HashSet<Node>();
3625 symToV1.add((
Node) sv.getProperty(
3629 for (
Node v1s : symToV1)
3631 if (symmetryShortCuts.containsKey(v1s))
3633 symmetryShortCuts.get(v1s).addAll(symToV2);
3635 symmetryShortCuts.put(v1s,symToV2);
3646 VF2GraphIsomorphismInspector<Node, NodeConnection> vf2 =
3650 return vf2.isomorphismExists();
3669 reason.append(
"Different number of edges ("+this.
getEdgeCount()+
":"
3676 reason.append(
"Different number of vertices ("+this.
getVertexCount()+
":"
3683 reason.append(
"Different number of symmetric sets ("
3691 reason.append(
"Different number of Rings ("+this.
getRingCount()+
":"
3697 Map<Vertex,Vertex> vertexMap =
3698 new HashMap<Vertex,Vertex>();
3713 e.printStackTrace();
3714 reason.append(
"Exception");
3720 while (ssIter.hasNext())
3725 vertexMap.get(ssT.get(0)));
3726 if (ssO.size() == 0)
3731 reason.append(
"Symmetric set not found for vertex ("
3732 + ssT.get(0) +
")");
3736 if (ssT.size() != ssO.size())
3738 reason.append(
"Different number of symmetric sets on vertex "
3739 + ssT.get(0) +
"("+ssT.size()+
":"+ssO.size()+
")");
3743 Set<Vertex> mappedVrtxFromThis =
new HashSet<>();
3744 ssT.stream().forEach(v -> mappedVrtxFromThis.add(vertexMap.get(v)));
3746 Set<Vertex> vrtxFromOther =
new HashSet<>();
3747 ssO.stream().forEach(v -> vrtxFromOther.add(v));
3748 if (!vrtxFromOther.equals(mappedVrtxFromThis))
3750 reason.append(
"Difference in symmetric set " + ssT +
" vs " + ssO);
3758 Vertex vhT = rT.getHeadVertex();
3759 Vertex vtT = rT.getTailVertex();
3760 boolean hasRing = other
3763 .anyMatch(rO ->
sameAsRings(reason, vertexMap, rT, vhT,
3779 reason.append(
"Different ring size (").append(rT.
getSize())
3780 .append(
":").append(rO.
getSize()).append(
")");
3786 for (
int i = 1; i < rT.
getSize(); i++) {
3789 reason.append(
"Rings differ (A) (").append(rT).append(
":")
3790 .append(rO).append(
")");
3796 for (
int i = 1; i < rT.
getSize(); i++) {
3800 reason.append(
"Rings differ (B) (").append(rT).append(
":")
3801 .append(rO).append(
")");
3806 reason.append(
"Rings differ (C) (").append(rT).append(
":")
3807 .append(rO).append(
")");
3830 Map<Vertex, Vertex> map =
new HashMap<>();
3831 map.put(thisV, otherV);
3833 new StringBuilder());
3851 Map<Vertex,Vertex> vertexMap, StringBuilder reason)
3854 if (!seedOnA.sameAs(seedOnB, reason))
3856 reason.append(
"Different vertex ("+seedOnA+
":"+seedOnB+
")");
3860 List<Edge> edgesFromThis = gA.getEdgesWithSrc(seedOnA);
3861 List<Edge> edgesFromOther = gB.getEdgesWithSrc(seedOnB);
3862 if (edgesFromThis.size() != edgesFromOther.size())
3864 reason.append(
"Different number of edges from vertex "+seedOnA+
" ("
3865 +edgesFromThis.size()+
":"
3866 +edgesFromOther.size()+
")");
3871 ArrayList<Vertex[]> pairs =
new ArrayList<Vertex[]>();
3873 for (
Edge et : edgesFromThis)
3875 boolean found =
false;
3877 StringBuilder innerSb =
new StringBuilder();
3879 for (
Edge e : edgesFromOther)
3881 innerSb.append(
" Edge"+otherEdgeI+
":");
3882 if (et.sameAs(e,innerSb))
3891 reason.append(
"Edge not found in other("+et+
"). "
3892 +
"Edges in othes: "+innerSb.toString());
3897 if (vertexMap.keySet().contains(
3898 gA.getVertexWithId(et.getTrgVertex())))
3902 vertexMap.put(gA.getVertexWithId(et.getTrgVertex()),
3906 gA.getVertexWithId(et.getTrgVertex()),
3912 for (
Vertex[] pair : pairs)
3939 if (v.containsAtoms())
3958 n += v.getHeavyAtomsCount();
3972 ArrayList<AttachmentPoint> lstAPs =
3973 new ArrayList<AttachmentPoint>();
3976 lstAPs.addAll(v.getAttachmentPoints());
3990 ArrayList<AttachmentPoint> lstFreeAPs =
3991 new ArrayList<AttachmentPoint>();
3994 if (ap.isAvailable())
4013 ArrayList<AttachmentPoint> lstFreeAPs =
4014 new ArrayList<AttachmentPoint>();
4017 if (ap.isAvailableThroughout())
4040 if (apCand.getID() ==
id)
4069 ap.getAPClass()) !=
null
4086 ArrayList<Vertex> toDel =
new ArrayList<Vertex>();
4089 if (vtx instanceof
Fragment ==
false)
4116 List<Long> rvids =
new ArrayList<>();
4117 for (
int i=0; i<lstVerts.size(); i++)
4119 Vertex vtx = lstVerts.get(i);
4120 if (vtx instanceof
Fragment ==
false)
4133 for (
int i=0; i<rvids.size(); i++)
4135 long vid = rvids.get(i);
4144 for (
Vertex v : lstVerts)
4171 if (!fragSpace.useAPclassBasedApproach())
4195 if (!fragSpace.useAPclassBasedApproach())
4198 for (
Vertex curVertex : vertexAddedToThis)
4210 if (curDap.isAvailableThroughout())
4212 APClass apcCap = fragSpace.getAPClassOfCappingVertex(
4213 curDap.getAPClass());
4216 int bbIdCap = fragSpace.getCappingFragment(apcCap);
4223 DGraph molGraph = curDap.getOwner()
4225 if (molGraph ==
null)
4226 throw new Error(
"Cannot add capping "
4227 +
"groups to a vertex that does not "
4228 +
"belong to a graph.");
4233 String msg =
"Capping is required but no proper "
4234 +
"capping fragment found with APCalss "
4236 throw new Error(msg);
4306 if (!this.gVertices.contains(seed))
4309 +
"a seed vertex that is not contained in this graph.");
4315 ArrayList<Vertex> subGrpVrtxs =
new ArrayList<Vertex>();
4316 subGrpVrtxs.add(seedClone);
4317 subGraph.
getChildrenTree(seedClone, subGrpVrtxs, numLayers, stopBeforeRCVs);
4318 ArrayList<Vertex> toRemove =
new ArrayList<Vertex>();
4321 if (!subGrpVrtxs.contains(v))
4327 for (
Vertex v : toRemove)
4355 List<Vertex> limits,
boolean stopBeforeRCVs)
4358 if (!this.gVertices.contains(seed))
4361 +
"a seed vertex that is not contained in this graph.");
4364 if (limits.size()==0)
4373 List<Vertex> limitsInClone =
new ArrayList<Vertex>();
4377 ArrayList<Vertex> subGrpVrtxs =
new ArrayList<Vertex>();
4378 subGrpVrtxs.add(seedClone);
4382 ArrayList<Vertex> toRemove =
new ArrayList<Vertex>();
4385 if (!subGrpVrtxs.contains(v))
4390 for (
Vertex v : toRemove)
4417 if (!this.gVertices.contains(seed))
4420 +
"a seed vertex that is not contained in this graph.");
4427 ArrayList<Vertex> subGrpVrtxs =
new ArrayList<Vertex>();
4428 subGrpVrtxs.add(seedClone);
4431 ArrayList<Vertex> toRemove =
new ArrayList<Vertex>();
4434 if (!subGrpVrtxs.contains(v))
4439 for (
Vertex v : toRemove)
4461 Collectors.toList());
4492 throw new IllegalArgumentException(
"Graph pattern " + pattern +
4496 List<Set<Vertex>> disjointMultiCycleVertices =
this
4501 .collect(Collectors.toList());
4505 Map<DGraph,ObjectPair> subGraphsAndConnections =
new LinkedHashMap<>();
4506 for (Set<Vertex> fusedRing : disjointMultiCycleVertices) {
4507 if (recordConnectivity)
4509 Set<Edge> connectionToSubgraph =
new HashSet<Edge>();
4510 Set<Edge> connectionFromSubgraph =
new HashSet<Edge>();
4512 connectionFromSubgraph);
4514 connectionFromSubgraph);
4515 subGraphsAndConnections.put(subGraph, connections);
4518 subGraphsAndConnections.put(subGraph,
null);
4522 for (
DGraph g : subGraphsAndConnections.keySet()) {
4523 g.storeCurrentVertexIDs();
4524 g.renumberGraphVertices();
4528 return subGraphsAndConnections;
4559 Set<Edge> connectionToSubgraph,
4560 Set<Edge> connectionFromSubgraph)
4565 Set<Vertex> complement = subgraph
4568 .filter(u -> definedOn
4570 .allMatch(v -> v.getVertexId() != u.getVertexId())
4571 ).collect(Collectors.toSet());
4573 Set<Long> vrtxIDsInComplement = complement.stream()
4574 .map(v -> v.getVertexId())
4575 .collect(Collectors.toSet());
4577 if (connectionToSubgraph!=
null && connectionFromSubgraph!=
null)
4579 for (
Vertex v : definedOn)
4583 if (e.getSrcAP().getOwner() == v &&
4584 vrtxIDsInComplement.contains(e.getTrgVertex()))
4586 connectionFromSubgraph.add(e);
4589 if (e.getTrgAP().getOwner() == v &&
4590 vrtxIDsInComplement.contains(e.getSrcVertex()))
4592 connectionToSubgraph.add(e);
4598 for (
Vertex v : complement) {
4656 DGraph subGraph = entry.getKey();
4668 LinkedHashMap<AttachmentPoint, AttachmentPoint> apMapOrigToTmpl =
4669 new LinkedHashMap<AttachmentPoint, AttachmentPoint>();
4670 @SuppressWarnings(
"unchecked")
4671 Set<Edge> edsToSubgrph = (Set<Edge>) entry.getValue().getFirst();
4672 for (
Edge e : edsToSubgrph)
4677 apMapOrigToTmpl.put(apOnOrig, apOnTmpl);
4679 @SuppressWarnings(
"unchecked")
4680 Set<Edge> edsFromSubGrph = (Set<Edge>) entry.getValue().getSecond();
4681 for (
Edge e : edsFromSubGrph)
4686 apMapOrigToTmpl.put(apOnOrig, apOnTmpl);
4690 List<Vertex> toReplaceByTemplate =
new ArrayList<>();
4702 apMapOrigToTmpl, fragSpace);
4720 if (newScaffold ==
null) {
4749 int visitedVertexEncounters = 0;
4755 boolean srcIsVisited = srcVertex != v.
getVertexId()
4756 && visited.contains(srcVertex);
4758 visitedVertexEncounters += srcIsVisited ? 1 : 0;
4759 if (visitedVertexEncounters >= 2) {
4760 throw new IllegalArgumentException(
"Invalid graph. "
4761 +
"Contains a cycle.");
4766 if (edgeIsWrongWay) {
4769 if (!srcIsVisited) {
4824 Edge edgeToParent = v.getEdgeToParent();
4825 if (edgeToParent !=
null)
4851 ArrayList<Vertex> children =
new ArrayList<Vertex>();
4855 for (
Vertex c : children) {
4882 if (rings.isEmpty())
4893 int minDist = Integer.MAX_VALUE;
4895 for (
Ring r : rings)
4897 int dist = Math.min(r.getDistance(r.getHeadVertex(),v),
4898 r.getDistance(r.getTailVertex(),v));
4903 replacedByEdge[0] = r.getHeadVertex();
4904 replacedByEdge[1] = r.getTailVertex();
4905 bt = r.getBondType();
4910 boolean frameHasBranching =
false;
4911 List<Integer> branchingPositions =
new ArrayList<Integer>();
4913 for (
int i=0; i<frame.
getSize(); i++)
4919 branchingPositions.add(i);
4927 branchingPositions.add(i);
4928 frameHasBranching =
true;
4933 if (rings.size()==1 && !frameHasBranching)
4941 int branchingDownstreamId = -1;
4942 for (
int i=0; i<frame.
getSize(); i++)
4944 int iTranslated = i + posOfFocusVrtInRing;
4945 if (iTranslated >= frame.
getSize())
4946 iTranslated = iTranslated - frame.
getSize();
4947 if (branchingPositions.contains(iTranslated))
4949 branchingDownstreamId = iTranslated;
4953 int branchingUpstreamId = -1;
4954 for (
int i=(frame.
getSize()-1); i>-1; i--)
4956 int iTranslated = i + posOfFocusVrtInRing;
4957 if (iTranslated >= frame.
getSize())
4958 iTranslated = iTranslated - frame.
getSize();
4959 if (branchingPositions.contains(iTranslated))
4961 branchingUpstreamId = iTranslated;
4969 List<Vertex> remainingChain =
new ArrayList<Vertex>();
4970 for (
int i=0; i<frame.
getSize(); i++)
4972 int iTranslated = i + branchingDownstreamId;
4973 if (iTranslated >= frame.
getSize())
4974 iTranslated = iTranslated - frame.
getSize();
4976 if (iTranslated == branchingUpstreamId)
4981 List<Vertex> toRemoveChain =
new ArrayList<Vertex>();
4982 for (
int i=0; i<frame.
getSize(); i++)
4984 int iTranslated = i + branchingUpstreamId + 1;
4985 if (iTranslated >= frame.
getSize())
4986 iTranslated = iTranslated - frame.
getSize();
4988 if (iTranslated == (branchingDownstreamId - 1))
4998 if (toRemoveChain.size() == 2)
5000 int countOrRCVs = 0;
5001 for (
Vertex vtr : toRemoveChain)
5006 if (countOrRCVs == 2)
5014 int deepestLevel = Integer.MAX_VALUE;
5015 Vertex deepestVrtRemainingChain =
null;
5016 for (
Vertex vint : remainingChain)
5019 if (lvl < deepestLevel)
5022 deepestVrtRemainingChain = vint;
5030 if (remainingChain.contains(replacedByEdge[0]))
5039 remainingChain.remove(replacedByEdge[0]);
5041 remainingChain.remove(replacedByEdge[1]);
5049 addEdge(
new Edge(apSrcOfNewEdge, apTrgOfNewEdge, bt));
5058 List<Vertex> chainToReverseA =
new ArrayList<Vertex>();
5059 List<Vertex> chainToReverseB =
new ArrayList<Vertex>();
5060 for (
int i=(remainingChain.indexOf(deepestVrtRemainingChain)+1);
5061 i<remainingChain.size(); i++)
5063 Vertex vPrev = remainingChain.get(i-1);
5064 Vertex vHere = remainingChain.get(i);
5069 if (chainToReverseA.size()==0)
5070 chainToReverseA.add(vPrev);
5071 chainToReverseA.add(vHere);
5074 for (
int i=(remainingChain.indexOf(deepestVrtRemainingChain)-1);i>-1;i--)
5076 Vertex vPrev = remainingChain.get(i+1);
5077 Vertex vHere = remainingChain.get(i);
5080 if (chainToReverseB.size()==0)
5081 chainToReverseB.add(vPrev);
5082 chainToReverseB.add(vHere);
5087 LinkedHashMap<Vertex,Vertex> chordsToRecreate =
5088 new LinkedHashMap<Vertex,Vertex>();
5089 LinkedHashMap<Vertex,BondType> chordsToRecreateBB =
5090 new LinkedHashMap<Vertex,BondType>();
5094 if (chainToReverseA.size()+chainToReverseB.size() > 1)
5096 List<Vertex> chainToWorkOn =
null;
5097 for (
int ic=0; ic<2; ic++)
5100 chainToWorkOn = chainToReverseA;
5102 chainToWorkOn = chainToReverseB;
5104 for (
int i=1; i<chainToWorkOn.size(); i++)
5106 Vertex vHere = chainToWorkOn.get(i);
5107 Vertex vPrev = chainToWorkOn.get(i-1);
5108 List<Ring> ringsToRecreate =
new ArrayList<>();
5111 ringsToRecreate.add(r);
5112 chordsToRecreate.put(r.getHeadVertex(),
5114 chordsToRecreateBB.put(r.getHeadVertex(),
5117 for (
Ring r : ringsToRecreate)
5123 if (edgeToPrevious ==
null)
5127 String debugFile =
"debug_"+v.getVertexId()+
".json";
5132 +
"removal of " + v +
" from ring " + frame
5133 +
" in graph " +
this.getGraphId()
5134 +
". See graph in " + debugFile);
5163 for (
Vertex vtr : toRemoveChain)
5168 if (remainingChain.contains(child)
5169 || toRemoveChain.contains(child))
5171 DGraph ownerOfChild = child.getGraphOwner();
5176 List<AttachmentPoint> apProjectionsToRemove =
5177 new ArrayList<AttachmentPoint>();
5185 apProjectionsToRemove.add(innerAP);
5195 for (
Vertex h : chordsToRecreate.keySet())
5197 addRing(h, chordsToRecreate.get(h), chordsToRecreateBB.get(h));
5209 List<SymmetricVertexes> ssToRemove =
new ArrayList<SymmetricVertexes>();
5211 while (ssIter.hasNext())
5254 HashMap<Long, Long> nmap =
new HashMap<>();
5259 nmap.put(vid, nvid);
5298 Map<Long, Long> nmap =
new HashMap<>();
5307 nmap.put(vid, nvid);
5328 ArrayList<Vertex> parentTree =
new ArrayList<>();
5330 return parentTree.size() - 1;
5402 settings.getRandomizer());
5407 String msg =
"Evaluation of graph: graph-to-mol returned null!"
5409 settings.getLogger().log(Level.FINE, msg);
5414 boolean isConnected = ConnectivityChecker.isConnected(mol);
5417 String msg =
"Evaluation of graph: Not all connected"
5419 settings.getLogger().log(Level.FINE, msg);
5424 String smiles =
null;
5428 String msg =
"Evaluation of graph: SMILES is null! "
5430 settings.getLogger().log(Level.FINE, msg);
5431 smiles =
"FAIL: NO SMILES GENERATED";
5434 if (smiles.contains(
".") && !permissive)
5436 String msg =
"Evaluation of graph: SMILES contains \".\"" + smiles;
5437 settings.getLogger().log(Level.FINE, msg);
5448 String msg =
"Evaluation of graph: Max atoms constraint "
5449 +
" violated: " + smiles;
5450 settings.getLogger().log(Level.FINE, msg);
5457 if (fsSettings.
getMaxMW()>0 && !permissive)
5461 String msg =
"Evaluation of graph: Molecular weight "
5462 +
"constraint violated: " + smiles +
" | MW: " + mw;
5463 settings.getLogger().log(Level.FINE, msg);
5467 mol.setProperty(
"MOL_WT", mw);
5475 String msg =
"Evaluation of graph: Max rotatable bonds "
5476 +
"constraint violated: "+ smiles;
5477 settings.getLogger().log(Level.FINE, msg);
5481 mol.setProperty(
"ROT_BND", nrot);
5488 String msg =
"Evaluation of graph: forbidden end in graph!";
5489 settings.getLogger().log(Level.FINE, msg);
5499 Set<String> doneType =
new HashSet<>();
5501 for (String rcaTyp : rcaTypes.keySet())
5503 if (doneType.contains(rcaTyp))
5512 if (v.containsAtoms())
5514 IAtom atm = v.getIAtomContainer().getAtom(0);
5519 rcaTypes.get(rcaTyp)))
5523 if (rcaTyp.equals(rcaTypes.get(rcaTyp)))
5534 String msg =
"Evaluation of graph: too many RCAs! "
5535 + rcaTyp +
":" + nThisType +
" "
5536 + rcaTypes.get(rcaTyp) +
":" + nCompType;
5537 settings.getLogger().log(Level.FINE, msg);
5543 String msg =
"Evaluation of graph: too few RCAs! "
5544 + rcaTyp +
":" + nThisType +
" "
5545 + rcaTypes.get(rcaTyp) +
":" + nCompType;
5546 settings.getLogger().log(Level.FINE, msg);
5550 nPossRings = nPossRings + Math.min(nThisType, nCompType);
5551 doneType.add(rcaTyp);
5552 doneType.add(rcaTypes.get(rcaTyp));
5556 String msg =
"Evaluation of graph: too few ring candidates";
5557 settings.getLogger().log(Level.FINE, msg);
5564 settings.getLogger());
5565 if (inchiKey ==
null)
5567 String msg =
"Evaluation of graph: InChI Key is null!";
5568 settings.getLogger().log(Level.WARNING, msg);
5569 inchiKey =
"UNDEFINED_INCHI";
5572 Object[] res =
new Object[3];
5605 ArrayList<DGraph> lstGraphs =
new ArrayList<>();
5618 settings.getRandomizer());
5625 settings.getLogger());
5630 ArrayList<List<Ring>> allCombsOfRings =
5636 ArrayList<List<Ring>> toRemove =
new ArrayList<>();
5637 for (List<Ring>
setRings : allCombsOfRings)
5644 allCombsOfRings.removeAll(toRemove);
5648 for (List<Ring> ringSet : allCombsOfRings)
5657 for (
Ring oldRing : ringSet)
5660 for (
int i=0; i<oldRing.getSize(); i++)
5662 long oldVId = oldRing.getVertexAtPosition(i).getVertexId();
5663 long newVId = vRenum.get(oldVId);
5671 lstGraphs.add(newGraph);
5689 Set<APClass> classOfForbEnds =
5691 boolean found =
false;
5692 for (
Vertex vtx : vertices)
5694 List<AttachmentPoint> daps = vtx.getAttachmentPoints();
5697 if (dp.isAvailable())
5699 APClass apClass = dp.getAPClass();
5700 if (classOfForbEnds.contains(apClass))
5703 String msg =
"Forbidden free AP for Vertex: "
5704 + vtx.getVertexId() +
" "
5706 +
"\n"+
this +
" \n "
5707 +
" AP class: " + apClass;
5708 fsSettings.
getLogger().log(Level.WARNING, msg);
5744 List<Integer> parentAPIdx,
5746 Vertex childVertex,
int childAPIdx,
5747 BondType bndType,
boolean onAllSymmAPs)
5751 Map<Vertex, SymmetricVertexes> newSymSets =
new HashMap<>();
5754 for (
int i=0; i<parentVertices.size(); i++)
5757 subGraph, childVertex, childAPIdx, bndType,
5758 newSymSets, onAllSymmAPs);
5779 if (!srcAP.isAvailable())
5782 +
"point " + srcAP +
" on vertex "
5783 + srcAP.getOwner().getVertexId());
5785 if ( !trgAP.isAvailable())
5788 +
"point " + trgAP +
" on vertex "
5789 + trgAP.getOwner().getVertexId());
5792 BondType btSrc = srcAP.getBondType();
5793 BondType btTrg = trgAP.getBondType();
5811 Edge edge =
new Edge(srcAP,trgAP, bndTyp);
5830 DGraph incomingGraph = apOnIncomingGraph.getOwner().getGraphOwner();
5833 Edge edge =
new Edge(apOnThisGraph, apOnIncomingGraph,
5882 Vertex childVertex,
int childAPIdx,
5884 Map<Vertex, SymmetricVertexes> newSymSets)
5891 childVertex.getVertexId());
5894 Edge edge =
new Edge(parentVertex.getAP(parentAPIdx),
5895 cvClone.
getAP(childAPIdx), bndType);
5902 Vertex origV = subGraph.getVertexList().get(i);
5910 if (subGraph.hasSymmetryInvolvingVertex(origV))
5912 if (newSymSets.containsKey(origV))
5914 newSymSets.get(origV).add(clonV);
5923 if (newSymSets.containsKey(origV))
5925 newSymSets.get(origV).add(clonV);
5931 newSymSets.put(origV, ss);
5936 for (
int i=0; i<sgClone.
getEdgeList().size(); i++)
5941 for (
int i=0; i<sgClone.
getRings().size(); i++)
5947 Set<SymmetricVertexes> doneTmpSymSets =
new HashSet<SymmetricVertexes>();
5951 if (doneTmpSymSets.contains(tmpSS))
5955 doneTmpSymSets.
add(tmpSS);
5956 boolean done =
false;
5960 while (iter.hasNext())
5962 oldSS = iter.next();
5963 if (oldSS.contains(tmpSS.get(0)))
5965 oldSS.addAll(tmpSS);
5972 if (tmpSS.size() <= 1)
5979 newSS.addAll(tmpSS);
6006 int parentAPIdx,
DGraph subGraph,
6007 Vertex childVertex,
int childAPIdx,
6009 Map<Vertex, SymmetricVertexes> newSymSets,
6010 boolean onAllSymmAPs)
6014 parentVertex.getAP(parentAPIdx));
6015 if (symAPs.size()!=0 && onAllSymmAPs)
6019 if (!symAP.isAvailable())
6024 subGraph, childVertex,
6025 childAPIdx, bndType, newSymSets);
6029 childAPIdx, bndType, newSymSets);
6044 List<Long> matches =
new ArrayList<>();
6047 matches.add(v.getVertexId());
6080 boolean purgeSym, Logger logger)
6082 ArrayList<Vertex> matches =
new ArrayList<>(
getVertexList());
6084 logger.log(Level.FINE,
"Candidates: " + matches);
6088 if (vidQuery !=
null)
6090 ArrayList<Vertex> newLst =
new ArrayList<>();
6093 if (v.getVertexId() == vidQuery.intValue())
6100 logger.log(Level.FINE,
" After filtering by vertex ID: " + matches);
6104 if (vtQuery !=
null)
6106 ArrayList<Vertex> newLst =
new ArrayList<>();
6109 if (v.getVertexType() == vtQuery)
6115 logger.log(Level.FINER,
" After filtering by vertex type: "
6121 if (bbtQuery !=
null)
6123 ArrayList<Vertex> newLst =
new ArrayList<>();
6126 if (v.getBuildingBlockType() == bbtQuery)
6132 logger.log(Level.FINER,
" After filtering by building block "
6133 +
"type: " + matches);
6140 ArrayList<Vertex> newLst =
new ArrayList<>();
6143 if (v.getBuildingBlockId() == bbID.intValue())
6149 logger.log(Level.FINER,
" After filtering by building block ID: "
6155 if (levelQuery !=
null)
6157 ArrayList<Vertex> newLst =
new ArrayList<Vertex>();
6166 logger.log(Level.FINER,
" After filtering by level: " + matches);
6169 logger.log(Level.FINE,
"After all vertex-based filters: " + matches);
6171 List<EdgeQuery> inAndOutEdgeQueries =
new ArrayList<>();
6174 for (
int i=0; i<2; i++)
6176 String inOrOut =
"";
6178 inOrOut =
"incoming";
6180 inOrOut =
"ourgoing";
6182 EdgeQuery edgeQuery = inAndOutEdgeQueries.get(i);
6183 if (edgeQuery ==
null)
6191 if (eTrgApIDx !=
null)
6193 ArrayList<Vertex> newLst =
new ArrayList<>();
6198 if (e.getTrgAPID() == eTrgApIDx)
6206 logger.log(Level.FINER,
" After " + inOrOut
6207 +
" edge trgAPID filter: " + matches);
6211 if (eInSrcApIDx !=
null)
6213 ArrayList<Vertex> newLst =
new ArrayList<>();
6218 if (e !=
null && e.getSrcAPID() == eInSrcApIDx)
6226 logger.log(Level.FINER,
" After " + inOrOut
6227 +
" edge srcAPID filter: " + matches);
6233 if (eSrcVrtID !=
null)
6235 ArrayList<Vertex> newLst =
new ArrayList<>();
6240 if(e.getSrcAP().getOwner().getVertexId()==eSrcVrtID)
6248 logger.log(Level.FINER,
" After " + inOrOut
6249 +
" edge src VertexID filter: " + matches);
6253 if (eTrgVrtID !=
null)
6255 ArrayList<Vertex> newLst =
new ArrayList<>();
6260 if(e.getTrgAP().getOwner().getVertexId()==eTrgVrtID)
6268 logger.log(Level.FINER,
" After " + inOrOut
6269 +
" edge trg VertexID filter: " + matches);
6274 if (btQuery !=
null)
6276 ArrayList<Vertex> newLst =
new ArrayList<>();
6281 if (e.getBondType() == btQuery)
6289 logger.log(Level.FINER,
" After " + inOrOut
6290 +
" edge bond type filter: " + matches);
6296 ArrayList<Vertex> newLst =
new ArrayList<>();
6301 if (e.getSrcAPClass().equals(srcAPC))
6314 ArrayList<Vertex> newLst =
new ArrayList<>();
6319 if (e.getTrgAPClass().equals(trgAPC))
6328 logger.log(Level.FINER,
"After all " + inOrOut
6329 +
" edge-based filters: " + matches);
6336 logger.log(Level.FINE,
"Final Matches (after symmetry): " + matches);
6365 List<Edge> edges =
new ArrayList<Edge>();
6369 if (eToParent !=
null)
6370 edges.add(eToParent);
6374 if (!ap.isAvailable() && ap.isSrcInUser())
6376 edges.add(ap.getEdgeUser());
6394 List<Vertex> symRedundant =
new ArrayList<>();
6396 while (itSymm.hasNext())
6401 if (symRedundant.contains(v))
6407 symRedundant.addAll(ss);
6408 symRedundant.remove(v);
6412 for (
Vertex v : symRedundant)
6427 ArrayList<Vertex> vList =
new ArrayList<>();
6428 for (
long vid : list) {
6434 list.add(v.getVertexId());
6461 logger.log(Level.FINE,
"Graph edit task: " + edit.getType());
6463 switch (edit.getType())
6467 DGraph inGraph = edit.getIncomingGraph();
6469 int idAPOnInGraph = -1;
6470 Vertex rootOfInGraph =
null;
6471 if (edit.getIncomingAPId() !=
null)
6474 edit.getIncomingAPId().intValue());
6477 String msg =
"Skipping " + edit.getType() +
" on "
6479 +
" graph has no AP with ID = "
6480 + edit.getIncomingAPId() +
". The IDs of "
6484 msg = msg +
" " + freeAP.getID();
6487 +
"Please, use one of those values in "
6488 +
"'idAPOnIncomingGraph'.";
6489 logger.log(Level.WARNING, msg);
6494 ArrayList<AttachmentPoint> freeAPs =
6496 if (freeAPs.size()==1)
6502 String geClsName =
GraphEdit.class.getSimpleName();
6503 String msg =
"Skipping " + edit.
getType() +
" on "
6505 +
" graph has more than one free AP ("
6506 + freeAPs.size() +
") and "
6507 +
"the " + geClsName +
" "
6508 +
"does not provide sufficient information "
6509 +
"to unambiguously choose one AP. "
6510 +
"Please, add 'idAPOnIncomingGraph' in "
6511 +
"the definition of " + geClsName +
".";
6512 logger.log(Level.WARNING, msg);
6516 ArrayList<Vertex> matches = modGraph.
findVertices(query,
6518 for (
Vertex vertexToReplace : matches)
6520 Edge edgeToParent = vertexToReplace.getEdgeToParent();
6521 if (edgeToParent ==
null)
6537 rootOfInGraph, idAPOnInGraph, bondType,
6538 new HashMap<Vertex, SymmetricVertexes>(), symmetry);
6545 if (edit.getIncomingBBId() > -1
6546 && edit.getIncomingBBType() !=
null
6547 && edit.getIncomingGraph() ==
null)
6550 edit.getVertexQuery(),
false, logger);
6551 for (
Vertex vertexToChange : matches)
6555 DGraph graph = vertexToChange.getGraphOwner();
6557 edit.getIncomingBBId(),
6558 edit.getIncomingBBType(),
6566 if (edit.getIncomingGraph() !=
null
6567 && edit.getIncomingBBType() ==
null)
6573 edit.getVertexQuery(),
false, logger);
6575 for (
Vertex vertexToChange : matches)
6577 DGraph graph = vertexToChange.getGraphOwner();
6581 LinkedHashMap<AttachmentPoint,AttachmentPoint> apMap =
6582 new LinkedHashMap<AttachmentPoint,AttachmentPoint>();
6583 for (Map.Entry<Integer,Integer> e :
6584 edit.getAPMappig().entrySet())
6586 apMap.put(vertexToChange.getAP(e.getKey()),
6591 List<Vertex> oldSubG =
new ArrayList<Vertex>();
6592 oldSubG.add(vertexToChange);
6602 edit.getVertexQuery(),
false, logger);
6603 for (
Vertex vertexToRemove : matches)
6624 List<Vertex> mutableSites =
new ArrayList<Vertex>();
6627 mutableSites.addAll(v.getMutationSites(
6628 new ArrayList<MutationType>()));
6630 return mutableSites;
6644 List<Vertex> mutableSites =
new ArrayList<Vertex>();
6647 mutableSites.addAll(v.getMutationSites(ignoredTypes));
6649 return mutableSites;
6663 String jsonOutput = gson.toJson(
this);
6713 implements JsonSerializer<DGraph>
6717 JsonSerializationContext context)
6719 boolean regenerateVrtxID =
false;
6720 boolean regenerateAP =
false;
6721 Set<Long> unqVrtxIDs =
new HashSet<Long>();
6722 Set<Integer> unqApIDs =
new HashSet<Integer>();
6725 if (!unqVrtxIDs.add(v.getVertexId()))
6727 regenerateVrtxID =
true;
6731 if (!unqApIDs.add(ap.getID()))
6733 regenerateAP =
true;
6738 if (regenerateVrtxID)
6747 JsonObject jsonObject =
new JsonObject();
6748 jsonObject.addProperty(
"graphId", g.
graphId);
6749 jsonObject.add(
"gVertices", context.serialize(g.
gVertices));
6750 jsonObject.add(
"gEdges", context.serialize(g.
gEdges));
6751 jsonObject.add(
"gRings", context.serialize(g.
gRings));
6752 jsonObject.add(
"symVertices", context.serialize(g.
symVertices));
6760 implements JsonDeserializer<DGraph>
6764 JsonDeserializationContext context)
throws JsonParseException
6766 JsonObject jsonObject = json.getAsJsonObject();
6769 JsonObject partialJsonObj =
new JsonObject();
6770 partialJsonObj.add(
"graphId", jsonObject.get(
"graphId"));
6771 partialJsonObj.add(
"gVertices", jsonObject.get(
"gVertices"));
6773 Gson gson =
new GsonBuilder()
6775 .registerTypeAdapter(
Vertex.class,
6778 .setPrettyPrinting()
6787 v.setGraphOwner(graph);
6798 JsonArray edgeArr = jsonObject.get(
"gEdges").getAsJsonArray();
6799 for (JsonElement e : edgeArr)
6801 JsonObject o = e.getAsJsonObject();
6803 o.get(
"srcAPID").getAsInt());
6805 o.get(
"trgAPID").getAsInt());
6808 context.deserialize(o.get(
"bondType"),
BondType.class));
6813 JsonArray ringArr = jsonObject.get(
"gRings").getAsJsonArray();
6814 for (JsonElement e : ringArr)
6816 JsonObject o = e.getAsJsonObject();
6818 for (JsonElement re : o.get(
"vertices").getAsJsonArray())
6822 ring.
setBondType(context.deserialize(o.get(
"bndTyp"),
6828 if (jsonObject.has(
"symVertices"))
6830 for (JsonElement elSet : jsonObject.get(
"symVertices").getAsJsonArray())
6833 for (JsonElement elId : elSet.getAsJsonArray())
6835 int id = context.deserialize(elId, Integer.class);
6843 e1.printStackTrace();
6844 throw new Error(
"Vertex listed in multiple symmetric "
6845 +
"sets. Check this: " + elSet);
6864 ArrayList<Vertex> newVertexList =
new ArrayList<>();
6866 Set<Long> visited =
new HashSet<>();
6867 Queue<Vertex> currLevel =
new ArrayDeque<>();
6868 Queue<Vertex> nextLevel =
new ArrayDeque<>();
6871 while (!currLevel.isEmpty()) {
6872 Vertex currVertex = currLevel.poll();
6875 if (!visited.contains(currId)) {
6876 visited.add(currId);
6878 newVertexList.add(currVertex);
6880 Iterable<Vertex> neighbors = currVertex
6884 .filter(e -> e !=
null)
6885 .map(e -> e.getSrcVertex() == currId ?
6886 e.getTrgAP() : e.getSrcAP())
6888 .collect(Collectors.toList());
6889 for (
Vertex adj : neighbors) {
6894 if (currLevel.isEmpty()) {
6895 currLevel = nextLevel;
6896 nextLevel =
new ArrayDeque<>();
6924 this.templateJacket =
template;
6967 List<Template> path =
new ArrayList<Template>();
7009 if ( v1==
null || v2 ==
null)
7058 if (!e.getTrgAPClass().isCPMapCompatibleWith(e.getSrcAPClass(),
7086 DGraph graphB, List<Template> path)
7090 Template currentLevelVertex =
null;
7091 DGraph currentLevelGraphEmdInB = graphB;
7092 DGraph currentLevelGraphEmbInY = graphY;
7095 currentLevelVertex = (
Template) currentLevelGraphEmbInY
7097 currentLevelGraphEmdInB = t.getInnerGraph();
7098 currentLevelGraphEmbInY = currentLevelVertex.
getInnerGraph();
7115 List<AttachmentPoint> interfaceAPs =
new ArrayList<AttachmentPoint>();
7116 for (
Vertex v : subGraphB)
7120 if (ap.isAvailableThroughout())
7122 if (ap.isAvailable())
7125 interfaceAPs.add(ap);
7127 Vertex user = ap.getLinkedAP().getOwner();
7128 if (!subGraphB.contains(user))
7131 interfaceAPs.add(ap);
7136 return interfaceAPs;
7149 List<Vertex> subGraphB)
7151 List<AttachmentPoint> aps =
new ArrayList<AttachmentPoint>();
7152 for (
Vertex v : subGraphB)
7156 if (ap.isAvailable())
7161 Vertex user = ap.getLinkedAP().getOwner();
7162 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.
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 sameAs(AttachmentPoint other)
Compares the features of this and another attachment point and decides if the two are same.
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...
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)
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)
Removed the given symmetric set, if present.
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.
Map< SymmetricAPs, List< Vertex > > findSymmetrySetsOfChildVertexes(Vertex vrtx, Set< Vertex > alreadyAssignedVrtxs)
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.
static boolean areApsUsedBySymmetricUsers(AttachmentPoint apA, AttachmentPoint apB, Set< Vertex > alreadyAssignedVrtxs)
Checks if the Vertexs that are attached to two given AttachmentPoints apA and apB satisfy these condi...
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)
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...
boolean detectSymVertexSets()
Tries to determine the set of symmetric vertices in this graph based on finding compatible Vertexes t...
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.
boolean isIsomorphicTo(Vertex other)
Checks for isomorphism of the graph representation of this and another fragment.
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",...
Set< SymmetricAPs > getAllSameAs(Set< SymmetricAPs > others)
Identifies any set of symmetric APs that, although it contains references to different instances of A...
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.
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()
abstract List< SymmetricAPs > getSymmetricAPSets()
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.