$darkmode
DENOPTIM
PathSubGraph.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.graph.rings;
20
21import java.util.ArrayList;
22import java.util.Arrays;
23import java.util.Collections;
24import java.util.HashSet;
25import java.util.Iterator;
26import java.util.List;
27import java.util.Map;
28import java.util.Set;
29import java.util.logging.Logger;
30
31import javax.vecmath.Point3d;
32
33import org.openscience.cdk.graph.ShortestPaths;
34import org.openscience.cdk.interfaces.IAtom;
35import org.openscience.cdk.interfaces.IAtomContainer;
36import org.openscience.cdk.interfaces.IBond;
37
38import denoptim.constants.DENOPTIMConstants;
39import denoptim.exception.DENOPTIMException;
40import denoptim.graph.AttachmentPoint;
41import denoptim.graph.DGraph;
42import denoptim.graph.Edge;
43import denoptim.graph.Vertex;
44import denoptim.io.DenoptimIO;
45import denoptim.molecularmodeling.ThreeDimTreeBuilder;
46import denoptim.utils.Randomizer;
47
48
56public class PathSubGraph
57{
62 private DGraph graph;
63
67 private String chainID;
68 private String revChainID;
69 private ArrayList<String> allPossibleChainIDs = new ArrayList<String>();
70
74 private Vertex vA;
75
79 private Vertex vB;
80
86
90 private List<Vertex> vertPathVAVB;
91
95 private List<Edge> edgesPathVAVB;
96
100 private IAtomContainer iacPathVAVB;
101
105 private List<IAtom> atomsPathVAVB;
106
112 private List<IBond> bondsPathVAVB;
113
117 private ArrayList<ArrayList<Point3d>> dihedralRefPts;
118
123 private boolean hasMolRepr = false;
124
128 private String atmNumStr;
129
134
135 // Set to true to write useful debug data to file and log
136 private boolean debug = false;
137
138//-----------------------------------------------------------------------------
139
146 {
147 this.vA = vA;
148 this.vB = vB;
149
150 // Identify the path between vA/vB and the seed of the spanning tree
151 List<Vertex> vAToSeed = new ArrayList<Vertex>();
152 molGraph.getParentTree(vA, vAToSeed);
153 vAToSeed.add(0, vA);
154 List<Vertex> vBToSeed = new ArrayList<Vertex>();
155 molGraph.getParentTree(vB, vBToSeed);
156 vBToSeed.add(0, vB);
157
158 if (Collections.disjoint(vAToSeed, vBToSeed))
159 {
160 vertPathVAVB = new ArrayList<Vertex>();
161 edgesPathVAVB = new ArrayList<Edge>();
162 return;
163 }
164
165 // find XOR plus junction vertex (turning point)
166 vertPathVAVB = new ArrayList<Vertex>();
167 edgesPathVAVB = new ArrayList<Edge>();
168 turningPointVert = null;
169 for (int i=0; i<vAToSeed.size(); i++)
170 {
171 // We dig from vA towards the seed of the graph
172 if (vBToSeed.contains(vAToSeed.get(i)))
173 {
174 // We are at the turning point vertex: were the vA->seed path
175 // meets the vB->seed path
176 turningPointVert = vAToSeed.get(i);
177 vertPathVAVB.add(vAToSeed.get(i));
178
179 int idStart = vBToSeed.indexOf(vAToSeed.get(i))-1;
180
181 for (int j=idStart; j>-1; j--)
182 {
183 // we climb towards vB
184 vertPathVAVB.add(vBToSeed.get(j));
185 edgesPathVAVB.add(vBToSeed.get(j).getEdgeToParent());
186 }
187 break;
188 }
189 else
190 {
191 vertPathVAVB.add(vAToSeed.get(i));
192 edgesPathVAVB.add(vAToSeed.get(i).getEdgeToParent());
193 }
194 }
195
196 // Build the DENOPTIMGraph and ID of this sub graph
197 chainID = "";
198 revChainID = "";
199 int tpId = -1;
200 int tpIdRev = -1;
201 Vertex vertBack;
202 Vertex vertHere;
203 Vertex vertFrnt;
204 boolean insideOut = false;
205 ArrayList<Vertex> gVertices = new ArrayList<Vertex>();
206 ArrayList<Edge> gEdges = new ArrayList<Edge>();
207 for (int i=1; i < vertPathVAVB.size()-1; i++)
208 {
209 vertBack = vertPathVAVB.get(i-1);
210 vertHere = vertPathVAVB.get(i);
211 vertFrnt = vertPathVAVB.get(i+1);
212 Edge edgeToBack = edgesPathVAVB.get(i-1);
213 Edge edgeToFrnt = edgesPathVAVB.get(i);
214
215 // Avoid assumption that all paths need to go via scaffold
216 if (edgeToBack.getSrcAP().getOwner()==vertBack)
217 insideOut = true;
218
219 int apIdBack2Here = -1;
220 int apIdHere2Back = -1;
221 int apIdHere2Frnt = -1;
222 int apIdFrnt2Here = -1;
223 if (vertHere == turningPointVert)
224 {
225 insideOut = true;
226 apIdBack2Here = edgeToBack.getTrgAPID();
227 apIdHere2Back = edgeToBack.getSrcAPID();
228 apIdHere2Frnt = edgeToFrnt.getSrcAPID();
229 apIdFrnt2Here = edgeToFrnt.getTrgAPID();
230 tpId = i-1;
231 tpIdRev = vertPathVAVB.size()-i;
232 }
233 else
234 {
235 if (insideOut)
236 {
237 apIdBack2Here = edgeToBack.getSrcAPID();
238 apIdHere2Back = edgeToBack.getTrgAPID();
239 apIdHere2Frnt = edgeToFrnt.getSrcAPID();
240 apIdFrnt2Here = edgeToFrnt.getTrgAPID();
241 }
242 else
243 {
244 apIdBack2Here = edgeToBack.getTrgAPID();
245 apIdHere2Back = edgeToBack.getSrcAPID();
246 apIdHere2Frnt = edgeToFrnt.getTrgAPID();
247 apIdFrnt2Here = edgeToFrnt.getSrcAPID();
248 }
249 }
250
251 String[] ids = vertHere.getPathIDs(vertHere.getAP(apIdHere2Back),
252 vertHere.getAP(apIdHere2Frnt));
253 chainID = chainID + ids[0];
254 revChainID = ids[1] + revChainID;
255
256 // We must work with clones of the actual vertices/edges
257 Vertex cloneVertBack = vertBack.clone();
258 Vertex cloneVertHere = vertHere.clone();
259 Vertex cloneVertFrnt = vertFrnt.clone();
260
261 // Collect vertices and make edges to build a graph from A to B
262 if (i == 1) {
263 gVertices.add(cloneVertBack);
264 } else if (i > 1)
265 {
266 // Need to collect the reference to the vertex defined in the
267 // previous cycle.
268 cloneVertBack = gVertices.get(gVertices.size()-1);
269 }
270 gVertices.add(cloneVertHere);
271 gEdges.add(new Edge(cloneVertBack.getAP(apIdBack2Here),
272 cloneVertHere.getAP(apIdHere2Back),
273 edgeToBack.getBondType()));
274 if (i == vertPathVAVB.size()-2)
275 {
276 gVertices.add(cloneVertFrnt);
277 gEdges.add(new Edge(cloneVertHere.getAP(apIdHere2Frnt),
278 cloneVertFrnt.getAP(apIdFrnt2Here),
279 edgeToFrnt.getBondType()));
280 }
281 }
282
283 // Build the DENOPTIMGraph with edges directed from VA to VB
284 this.graph = new DGraph(gVertices,gEdges);
285
286 // prepare alternative chain IDs
287 String[] pA = chainID.split("_");
288 String[] pB = revChainID.split("_");
289 allPossibleChainIDs.add(chainID + "%" + tpId);
290 allPossibleChainIDs.add(revChainID + "%" + tpIdRev);
291 for (int i=1; i<pA.length; i++)
292 {
293 String altrnA = "";
294 String altrnB = "";
295 for (int j=0; j<pA.length; j++)
296 {
297 if ((i+j) < pA.length)
298 {
299 altrnA = altrnA + pA[i+j] + "_";
300 altrnB = altrnB + pB[i+j] + "_";
301 } else {
302 altrnA = altrnA + pA[i+j-pA.length] + "_";
303 altrnB = altrnB + pB[i+j-pA.length] + "_";
304 }
305 }
306 allPossibleChainIDs.add(altrnA + "%" + tpId);
307 allPossibleChainIDs.add(altrnB + "%" + tpIdRev);
308 }
309 chainID = chainID + "%" + tpId;
310 revChainID = revChainID + "%" + tpIdRev;
311 }
312
313//------------------------------------------------------------------------------
314
328 public static DGraph findPath(Vertex from, Vertex to) {
329 DGraph g = new DGraph();
330 try {
331 if (from == to) {
332 return g;
333 }
334
335 Iterator<AttachmentPoint> path = findPath(from, to,
336 new HashSet<>()).iterator();
337
338 if (!path.hasNext()) {
339 return g;
340 }
341
342 AttachmentPoint srcAP = path.next().clone();
343 Vertex srcVertex = srcAP.getOwner().clone();
344 srcAP.setOwner(srcVertex);
345
346 g.addVertex(srcVertex);
347
348 AttachmentPoint trgAP = path.next().clone();
349 Vertex trgVertex = trgAP.getOwner().clone();
350 trgAP.setOwner(trgVertex);
351
352 g.appendVertexOnAP(srcAP, trgAP);
353
354 while (path.hasNext()) {
355 srcAP = path.next().clone();
356 srcVertex = srcAP.getOwner().clone();
357 srcAP.setOwner(srcVertex);
358
359 trgAP = path.next().clone();
360 trgVertex = trgAP.getOwner().clone();
361 trgAP.setOwner(trgVertex);
362
363 g.appendVertexOnAP(srcAP, trgAP);
364 }
365 } catch (DENOPTIMException e) {
366 e.printStackTrace();
367 }
368 return g;
369 }
370
371//------------------------------------------------------------------------------
372
382 private static Iterable<AttachmentPoint> findPath(
383 Vertex from, Vertex to, Set<Long> visited) {
384
385 long fromId = from.getVertexId();
386 if (visited.contains(fromId)) {
387 return new ArrayList<>();
388 }
389 visited.add(fromId);
390
391 for (AttachmentPoint fromAP : from.getAttachmentPoints()) {
392 Edge e = fromAP.getEdgeUser();
393 AttachmentPoint adjAP = e.getSrcVertex() == fromId ?
394 e.getTrgAP() : e.getSrcAP();
395 Vertex adj = adjAP.getOwner();
396
397 if (adj == to) {
398 return Arrays.asList(fromAP, adjAP);
399 }
400
401 Iterable<AttachmentPoint> path = findPath(adj, to, visited);
402 // Non-empty if there exists a path
403 if (path.iterator().hasNext()) {
404 List<AttachmentPoint> extendedPath =
405 new ArrayList<AttachmentPoint>(Arrays.asList(
406 fromAP, adjAP));
407 path.iterator().forEachRemaining(extendedPath::add);
408 return extendedPath;
409 }
410 }
411 // Dead end
412 return Collections.emptyList();
413 }
414
415//------------------------------------------------------------------------------
416
427 public void makeMolecularRepresentation(IAtomContainer mol, boolean make3D,
428 Logger logger, Randomizer randomizer) throws DENOPTIMException
429 {
430 // Build molecular representation
431 ThreeDimTreeBuilder tb = new ThreeDimTreeBuilder(logger, randomizer);
433 Map<IAtom,ArrayList<AttachmentPoint>> apsPerAtom =
435 Map<IBond,ArrayList<AttachmentPoint>> apsPerBond =
437
438 if (debug)
439 {
440 String f = "/tmp/pathSubGraph.sdf";
441 System.out.println("Find SDF representation of path in: " + f);
442 try {
444 DenoptimIO.writeSDFFile(f,mol,true);
445 } catch (Throwable t) {
446 throw new Error("Could not save debug file '" + f + "'.");
447 }
448 }
449
450 // Get shortest atom path between the two ends of the chain
452
453 // Identify which atoms in mol represent the RCA in the current chain.
454 // Since we are looking for the verteces of the RCA atoms
455 // there is only one atom per each of the two vertexID required
456
457 IAtom e0 = null;
458 IAtom e1 = null;
459 for (IAtom atm : mol.atoms())
460 {
461 long vrtId = (Long) atm.getProperty(
463 if (vrtId == vertPathVAVB.get(0).getVertexId())
464 e0 = atm;
465
466 if (vrtId == vertPathVAVB.get(vertPathVAVB.size()-1).getVertexId())
467 e1 = atm;
468
469 if (e0 != null && e1 != null)
470 break;
471 }
472 List<IAtom> ends = new ArrayList<IAtom>();
473 ends.add(e0);
474 ends.add(e1);
475
476 // Get path in mol that corresponds to the shortest path in iacPathVAVB
477 // This is done to get the bond properties from mol that is a
478 // fully defined molecule.
479 // Note that multiple paths with length equal to the shortest length
480 // are possible if there are rings within fragments (vertices),
481 // but in such case the alternative paths involve only non-rotatable.
482 // Therefore, the actual identity of the bond doesn't matter in
483 // this particular context.
484 List<IAtom> pathInFullMol = new ArrayList<IAtom>();
485
486 IAtom currentAtm = null;
487 long prevAtmInPathVID = -1;
488 long currAtmInPathVID = -1;
489 long nextAtmInPathVID = -1;
490 List<IAtom> candidates = new ArrayList<IAtom>();
491 for (int i=1; i<(atomsPathVAVB.size()); i++)
492 {
493 //We have already found the atoms corresponding to the extremes
494 if (i==1)
495 {
496 currentAtm = ends.get(0);
497 pathInFullMol.add(currentAtm);
498 candidates.addAll(mol.getConnectedAtomsList(currentAtm));
499 } else if (i==(atomsPathVAVB.size()-1))
500 {
501 pathInFullMol.add(ends.get(1));
502 break;
503 }
504
505 // Now, standard behaviour for all other non-extreme cases
506 prevAtmInPathVID = getVertexIdInPath(atomsPathVAVB.get(i-1));
507 currAtmInPathVID = getVertexIdInPath(atomsPathVAVB.get(i));
508 nextAtmInPathVID = getVertexIdInPath(atomsPathVAVB.get(i+1));
509
510 if (prevAtmInPathVID != currAtmInPathVID)
511 {
512 for (IAtom c : candidates)
513 {
514 if (getVertexIdInPath(c) == currAtmInPathVID)
515 {
516 currentAtm = c;
517 pathInFullMol.add(currentAtm);
518 candidates.clear();
519
520 for (IAtom c2 : mol.getConnectedAtomsList(c))
521 {
522 if (!pathInFullMol.contains(c2))
523 candidates.add(c2);
524 }
525 break;
526 }
527 }
528 continue;
529 } else {
530 //NB: currentAtm remains the same
531 List<IAtom> newCandidates = new ArrayList<IAtom>();
532 for (IAtom nbr : candidates)
533 {
534 boolean foundNextLevel = false;
535 for (IAtom nbrNbr : mol.getConnectedAtomsList(nbr))
536 {
537 if (pathInFullMol.contains(nbrNbr)
538 || candidates.contains(nbrNbr))
539 continue;
540
541 long vid = getVertexIdInPath(nbrNbr);
542 if (vid == nextAtmInPathVID
543 && currAtmInPathVID!=nextAtmInPathVID)
544 {
545 ShortestPaths sp = new ShortestPaths(mol,
546 currentAtm);
547 List<IAtom> itnraVertPath = new ArrayList<IAtom>(
548 Arrays.asList(sp.atomsTo(nbr)));
549
550 // currentAtm was already added: skip it
551 for (int j=1; j<itnraVertPath.size(); j++)
552 pathInFullMol.add(itnraVertPath.get(j));
553
554 currentAtm = nbr;
555 newCandidates.clear();
556 newCandidates.add(nbrNbr);
557 foundNextLevel = true;
558 break;
559 } else {
560 if (vid == currAtmInPathVID)
561 {
562 newCandidates.add(nbrNbr);
563 }
564 }
565 }
566 if (foundNextLevel)
567 break;
568 }
569 candidates.clear();
570 candidates.addAll(newCandidates);
571 continue;
572 }
573 }
574 if (pathInFullMol.size() != atomsPathVAVB.size())
575 {
576 throw new IllegalStateException("Paths have different size! "
577 + "Unable to "
578 + "proceed in the evaluation of ring closability. "
579 + "Please report this to the author.");
580 }
581
582 // Identify the path of bonds between head and tail
583 // This is taken from the fully defined mol to inherit rotatability
584 // and allow identification of bonds used in multiple rings-closing
585 // chains.
586 bondsPathVAVB = new ArrayList<IBond>();
587 for (int i=0; i < pathInFullMol.size()-1; i++)
588 {
589 IBond bnd = mol.getBond(pathInFullMol.get(i),
590 pathInFullMol.get(i+1));
591 bondsPathVAVB.add(bnd);
592 }
593
594 // Define points used to calculate dihedral angle of each bond
595 // excluding the first and last
596 dihedralRefPts = new ArrayList<ArrayList<Point3d>>();
597 String keyPropVrtID = DENOPTIMConstants.ATMPROPVERTEXID;
598 for (int it=3; it<atomsPathVAVB.size(); it++)
599 {
600 ArrayList<Point3d> fourPoints = new ArrayList<Point3d>();
601 Point3d p0;
602 Point3d p1;
603 Point3d p2;
604 Point3d p3;
605 IAtom a0 = atomsPathVAVB.get(it-3);
606 IAtom a1 = atomsPathVAVB.get(it-2);
607 IAtom a2 = atomsPathVAVB.get(it-1);
608 IAtom a3 = atomsPathVAVB.get(it);
609 long vIdA0 = a0.getProperty(keyPropVrtID);
610 long vIdA1 = a1.getProperty(keyPropVrtID);
611 long vIdA2 = a2.getProperty(keyPropVrtID);
612 long vIdA3 = a3.getProperty(keyPropVrtID);
613 IBond bndA1A2 = iacPathVAVB.getBond(a1,a2);
614
615 // trivial for points 1 and 2
616 p0 = a0.getPoint3d(); // only initialization
617 p1 = a1.getPoint3d();
618 p2 = a2.getPoint3d();
619 p3 = a3.getPoint3d(); // only initialization
620
621 // chose point 0
622 if (vIdA0 != vIdA1)
623 {
624 // use the point identified by the ap on atom a1 that
625 // has the lowest index in the list of aps on a1,
626 // but is not the AP used to bind a1 and a2
627 for (AttachmentPoint ap : apsPerAtom.get(a1))
628 {
629 if (apsPerBond.keySet().contains(bndA1A2))
630 {
631 if (apsPerBond.get(bndA1A2).contains(ap))
632 {
633 continue;
634 }
635 }
636 p0 = new Point3d(ap.getDirectionVector());
637 break;
638 }
639 }
640 else
641 {
642 // Choose the atom connected to a1 that has the lowest index
643 // in the IAtomContainer and is not a2
644 List<IAtom> nbrsOfA1 = iacPathVAVB.getConnectedAtomsList(a1);
645 int lowIDs = 10000000;
646 for (IAtom nbrOfA1 : nbrsOfA1)
647 {
648 if (nbrOfA1 == a2)
649 {
650 continue;
651 }
652 int atmID = iacPathVAVB.indexOf(nbrOfA1);
653 if (atmID < lowIDs)
654 {
655 lowIDs = atmID;
656 }
657 }
658 p0 = new Point3d(iacPathVAVB.getAtom(lowIDs).getPoint3d());
659 }
660
661 // choose point 3 (as done for point 0)
662 if (vIdA2 != vIdA3)
663 {
664 // use the point identified by the ap on atom a2 that
665 // has the lowest index in the list of aps on a2,
666 // but is not the AP used to bind a1 and a1
667 for (AttachmentPoint ap : apsPerAtom.get(a2))
668 {
669 if (apsPerBond.keySet().contains(bndA1A2))
670 {
671 if (apsPerBond.get(bndA1A2).contains(ap))
672 {
673 continue;
674 }
675 }
676 p3 = new Point3d(ap.getDirectionVector());
677 break;
678 }
679 }
680 else
681 {
682 // Choose the atom connected to a2 that has the lowest index
683 // in the IAtomContainer and is not a1.
684 List<IAtom> nbrsOfA2 = iacPathVAVB.getConnectedAtomsList(a2);
685 int lowIDs = 10000000;
686 for (IAtom nbrOfA2 : nbrsOfA2)
687 {
688 if (nbrOfA2 == a1)
689 {
690 continue;
691 }
692 int atmID = iacPathVAVB.indexOf(nbrOfA2);
693 if (atmID < lowIDs)
694 {
695 lowIDs = atmID;
696 }
697 }
698 p3 = new Point3d(iacPathVAVB.getAtom(lowIDs).getPoint3d());
699 }
700
701 fourPoints.add(p0);
702 fourPoints.add(p1);
703 fourPoints.add(p2);
704 fourPoints.add(p3);
705
706 dihedralRefPts.add(fourPoints);
707 }
708
709 if (debug)
710 {
711 System.out.println("Points for dihedral angle definition: ");
712 for (ArrayList<Point3d> fp : dihedralRefPts)
713 {
714 for (Point3d p : fp)
715 {
716 System.out.println(" "+p);
717 }
718 System.out.println(" ");
719 }
720 }
721
722 // set flag
723 hasMolRepr = true;
724 }
725
726//-----------------------------------------------------------------------------
727
735 public static List<IAtom> findAtomPath(IAtomContainer iac)
736 {
737 IAtom head = iac.getAtom(0);
738 IAtom tail = iac.getAtom(iac.getAtomCount()-1);
739 ShortestPaths sp = new ShortestPaths(iac, head);
740 List<IAtom> path = new ArrayList<IAtom>(Arrays.asList(
741 sp.atomsTo(tail)));
742 return path;
743 }
744
745//-----------------------------------------------------------------------------
746
747 private long getVertexIdInPath(IAtom a)
748 {
749 return a.getProperty(DENOPTIMConstants.ATMPROPVERTEXID, Long.class)
750 .longValue();
751 }
752
753//-----------------------------------------------------------------------------
754
759 public String getChainID()
760 {
761 return chainID;
762 }
763
764//-----------------------------------------------------------------------------
765
771 public List<String> getAllAlternativeChainIDs()
772 {
773 return allPossibleChainIDs;
774 }
775
776//-----------------------------------------------------------------------------
777
783 {
784 return vA;
785 }
786
787//-----------------------------------------------------------------------------
788
794 {
795 return vB;
796 }
797
798//-----------------------------------------------------------------------------
799
804 public int getPathLength()
805 {
806 return edgesPathVAVB.size();
807 }
808//-----------------------------------------------------------------------------
809
814 public List<Vertex> getVertecesPath()
815 {
816 return vertPathVAVB;
817 }
818
819//-----------------------------------------------------------------------------
820
825 public List<Edge> getEdgesPath()
826 {
827 return edgesPathVAVB;
828 }
829
830//-----------------------------------------------------------------------------
831
837 {
838 return hasMolRepr;
839 }
840
841//-----------------------------------------------------------------------------
842
846 public IAtomContainer getMolecularRepresentation()
847 {
848 return iacPathVAVB;
849 }
850
851//-----------------------------------------------------------------------------
852
857 public List<IAtom> getAtomPath()
858 {
859 return atomsPathVAVB;
860 }
861
862//-----------------------------------------------------------------------------
863
869 public String getAtomRefStr()
870 {
871 return atmNumStr;
872 }
873
874//-----------------------------------------------------------------------------
875
882 public List<IBond> getBondPath()
883 {
884 return bondsPathVAVB;
885 }
886
887//-----------------------------------------------------------------------------
888
895 public ArrayList<ArrayList<Point3d>> getDihedralRefPoints()
896 {
897 return dihedralRefPts;
898 }
899
900//-----------------------------------------------------------------------------
901
907 {
908 return rcc;
909 }
910
911//-----------------------------------------------------------------------------
912
918 {
919 this.rcc = rcc;
920 }
921
922//-----------------------------------------------------------------------------
923
928 @Override
929 public String toString()
930 {
931 StringBuilder sb = new StringBuilder();
932 boolean first = true;
933 for (Vertex v : vertPathVAVB)
934 {
935 if (!first)
936 {
937 sb.append("-");
938 }
939 sb.append(v.getVertexId());
940 first = false;
941 }
942 return sb.toString();
943 }
944
945 public DGraph getGraph() {
946 return graph;
947 }
948
949//-----------------------------------------------------------------------------
950
951}
General set of constants used in DENOPTIM.
static final Object MOLPROPAPxBOND
Key for IAtomContainer property containing the map of AttachmentPoints per atom.
static final String ATMPROPVERTEXID
String tag of Atom property used to store the unique ID of the Vertex corresponding to the molecular ...
static final Object MOLPROPAPxATOM
Key for IAtomContainer property containing the map of AttachmentPoints per vertex ID.
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....
void setOwner(Vertex owner)
Sets the reference to the vertex that owns this attachment point.
AttachmentPoint clone()
Returns a deep clone of this attachment point.
Container for the list of vertices and the edges that connect them.
Definition: DGraph.java:102
void addVertex(Vertex vertex)
Appends a vertex to this graph without creating any edge.
Definition: DGraph.java:1097
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,...
Definition: DGraph.java:5776
void getParentTree(Vertex vertex, List< Vertex > parentTree)
Traverse the graph until it identifies the source of the directed path reachable from the given verte...
Definition: DGraph.java:3149
This class represents the edge between two vertices.
Definition: Edge.java:38
AttachmentPoint getTrgAP()
Definition: Edge.java:115
long getSrcVertex()
Definition: Edge.java:122
AttachmentPoint getSrcAP()
Definition: Edge.java:94
BondType getBondType()
Definition: Edge.java:164
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
Definition: Vertex.java:61
abstract Vertex clone()
Returns a deep-copy of this vertex.
String[] getPathIDs(AttachmentPoint apA, AttachmentPoint apB)
Produces a pair of strings that identify the "path" between two given attachment points.
Definition: Vertex.java:1315
abstract List< AttachmentPoint > getAttachmentPoints()
AttachmentPoint getAP(int i)
Get attachment point i on this vertex.
Definition: Vertex.java:920
This object represents a path in a DGraph.
RingClosingConformations rcc
The list of closable conformations, if any is found.
boolean hasMolRepr
The flag defining whether this object has already a molecular representation or not.
String getAtomRefStr()
Returns the string with atom symbols and number for an easy identification of the path in a molecular...
static Iterable< AttachmentPoint > findPath(Vertex from, Vertex to, Set< Long > visited)
Returns a sequence of APs that is the path from vertex from to vertex to.
List< IBond > getBondPath()
Returns the list of bonds in the path between the head and the tail.
RingClosingConformations getRCC()
Returns the ring closing conformations.
String atmNumStr
The string of atoms involved (atom numbers from full molecule list)
int getPathLength()
Returns the length of the list of edges involved in this path.
void makeMolecularRepresentation(IAtomContainer mol, boolean make3D, Logger logger, Randomizer randomizer)
Creates the molecular representation, list of atoms and bonds involved in the path between the head a...
List< Vertex > getVertecesPath()
Returns the list of verteces involved.
Vertex vA
The vertex representing the first RCA: head of the path.
IAtomContainer getMolecularRepresentation()
Returns the molecular representation.
String chainID
The string identifier of this path.
String getChainID()
Returns the string representation of the path.
Vertex vB
The vertex representing the second RCA: the tail of the path.
PathSubGraph(Vertex vA, Vertex vB, DGraph molGraph)
Constructs a new PathSubGraph specifying the first and last vertex of the path.
List< IBond > bondsPathVAVB
The list of bonds in the shortest path.
IAtomContainer iacPathVAVB
The molecular representation of the fragment in the path.
List< IAtom > getAtomPath()
Returns the list of atoms in the path between the head and the tail.
boolean hasMolecularRepresentation()
Returns true if the molecular representation has been set.
List< Edge > edgesPathVAVB
The list of edges of the original graph and involved in the path.
Vertex getHeadVertex()
Returns the vertex representing the head of the chain.
List< IAtom > atomsPathVAVB
The list of atoms in the shortest path.
ArrayList< ArrayList< Point3d > > dihedralRefPts
Per each bond the pair of point used to define the torsion.
static List< IAtom > findAtomPath(IAtomContainer iac)
Finds the shortest path of atoms between the first and last atom in the given atom container.
ArrayList< ArrayList< Point3d > > getDihedralRefPoints()
Returns the list of point to be used to define the torsion of a bond uniquely (independently on the s...
Vertex getTailVertex()
Returns the vertex representing the tail of the chain.
List< Vertex > vertPathVAVB
The list of vertices of the original graph and involved in the path.
static DGraph findPath(Vertex from, Vertex to)
Returns a path as a DENOPTIMGraph from the first argument to the second one.
List< Edge > getEdgesPath()
Returns the list of edges involved.
ArrayList< String > allPossibleChainIDs
void setRCC(RingClosingConformations rcc)
Set the ring closing conformations to this object.
DGraph graph
The graph representation of this path.
Vertex turningPointVert
The turning point in the graph: after this point the direction of edges becomes opposite than before.
List< String > getAllAlternativeChainIDs()
Returns all the possible IDs for this chain.
Serializable object to store/get a list of conformations that allow to close a ring from an open chai...
Utility methods for input/output.
static void writeSDFFile(String fileName, IAtomContainer mol)
Writes IAtomContainer to SDF file.
Tool to build build three-dimensional (3D) tree-like molecular structures from DGraph.
IAtomContainer convertGraphTo3DAtomContainer(DGraph graph)
Created a three-dimensional molecular representation from a given DGraph.
Tool to generate random numbers and random decisions.
Definition: Randomizer.java:35