21import static org.junit.jupiter.api.Assertions.assertEquals;
22import static org.junit.jupiter.api.Assertions.assertFalse;
23import static org.junit.jupiter.api.Assertions.assertNotNull;
24import static org.junit.jupiter.api.Assertions.assertTrue;
27import java.util.ArrayList;
28import java.util.Arrays;
29import java.util.HashMap;
30import java.util.HashSet;
31import java.util.Iterator;
35import java.util.logging.Logger;
36import java.util.stream.Collectors;
38import javax.vecmath.Point3d;
40import org.junit.jupiter.api.Test;
41import org.junit.jupiter.api.io.TempDir;
42import org.openscience.cdk.Atom;
43import org.openscience.cdk.interfaces.IAtom;
44import org.openscience.cdk.interfaces.IAtomContainer;
45import org.openscience.cdk.interfaces.IBond;
46import org.openscience.cdk.interfaces.IChemObjectBuilder;
47import org.openscience.cdk.layout.StructureDiagramGenerator;
48import org.openscience.cdk.silent.Bond;
49import org.openscience.cdk.silent.SilentChemObjectBuilder;
50import org.openscience.cdk.smiles.SmilesParser;
52import denoptim.constants.DENOPTIMConstants;
53import denoptim.exception.DENOPTIMException;
54import denoptim.fragmenter.ScaffoldingPolicy;
55import denoptim.fragspace.FragmentSpace;
56import denoptim.fragspace.FragmentSpaceParameters;
57import denoptim.ga.EAUtils.CandidateSource;
58import denoptim.graph.APClass;
59import denoptim.graph.AttachmentPoint;
60import denoptim.graph.Candidate;
61import denoptim.graph.DGraph;
62import denoptim.graph.DGraphTest;
63import denoptim.graph.Edge.BondType;
64import denoptim.graph.EmptyVertex;
65import denoptim.graph.Fragment;
66import denoptim.graph.GraphPattern;
67import denoptim.graph.RelatedAPPair;
68import denoptim.graph.SymmetricVertexes;
69import denoptim.graph.Template;
70import denoptim.graph.Template.ContractLevel;
71import denoptim.graph.Vertex;
72import denoptim.graph.Vertex.BBType;
73import denoptim.graph.rings.RingClosureParameters;
74import denoptim.io.DenoptimIO;
75import denoptim.logging.Monitor;
76import denoptim.programs.denovo.GAParameters;
77import denoptim.programs.fragmenter.CuttingRule;
78import denoptim.utils.MoleculeUtils;
79import denoptim.utils.Randomizer;
91 private static String
a=
"A",
b=
"B",
c=
"C";
93 private static final String
SEP = System.getProperty(
"file.separator");
94 private static final String
NL = System.getProperty(
"line.separator");
99 private IChemObjectBuilder
builder = SilentChemObjectBuilder.getInstance();
112 HashMap<APClass,ArrayList<APClass>> cpMap =
113 new HashMap<APClass,ArrayList<APClass>>();
114 ArrayList<APClass> lstA =
new ArrayList<APClass>();
116 cpMap.put(
APCA, lstA);
117 ArrayList<APClass> lstB =
new ArrayList<APClass>();
120 cpMap.put(
APCB, lstB);
121 ArrayList<APClass> lstC =
new ArrayList<APClass>();
124 cpMap.put(
APCC, lstC);
138 HashMap<APClass,APClass> capMap =
new HashMap<APClass,APClass>();
139 HashSet<APClass> forbEnds =
new HashSet<APClass>();
143 new ArrayList<Vertex>(),
144 new ArrayList<Vertex>(),
145 new ArrayList<Vertex>(),
146 cpMap, capMap, forbEnds, cpMap);
171 for (
int i=1; i<6; i++)
186 graphForTemplate.
addRing(rcv1, rcv2);
189 template.setInnerGraph(graphForTemplate);
208 assertTrue(
false,
"faild construction of graph");
218 boolean foundChange =
false;
221 if (v.getBuildingBlockId() != 0)
224 assertTrue(foundChange,
"The initial inner graph has changed.");
254 ArrayList<Candidate> eligibleParents =
new ArrayList<Candidate>();
255 eligibleParents.add(c1);
256 eligibleParents.add(c2);
263 population, mnt, gaParams);
265 assertTrue(offspring==
null,
"Redundat xover is not done");
292 ArrayList<Candidate> eligibleParents =
new ArrayList<Candidate>();
293 eligibleParents.add(cA);
294 eligibleParents.add(cE);
299 population, mnt,
new int[]{0,1}, 3, 0, gaparams);
302 population, mnt,
new int[]{0,1}, 3, 1, gaparams);
310 ArrayList<Vertex> childTree =
new ArrayList<Vertex>();
312 if (childTree.size()>maxLength)
314 maxLength = childTree.size();
317 assertEquals(3,maxLength);
325 ArrayList<Vertex> childTree =
new ArrayList<Vertex>();
327 if (childTree.size()>maxLength)
329 maxLength = childTree.size();
332 assertEquals(7,maxLength);
367 ArrayList<Candidate> eligibleParents =
new ArrayList<Candidate>();
368 eligibleParents.add(cA);
369 eligibleParents.add(cB);
374 population, mnt,
new int[]{0,1}, 8, 0, gaparams);
377 population, mnt,
new int[]{0,1}, 8, 1, gaparams);
383 DGraph expected0 = expectedPair[0];
384 DGraph expected1 = expectedPair[1];
390 assertTrue(expected0.
sameAs(g0xo,
new StringBuilder()));
391 assertTrue(expected1.
sameAs(g1xo,
new StringBuilder()));
426 ArrayList<Candidate> eligibleParents =
new ArrayList<Candidate>();
427 eligibleParents.add(cA);
428 eligibleParents.add(cB);
433 population, mnt,
new int[]{0,1}, 17, 0, gaparams);
436 population, mnt,
new int[]{0,1}, 17, 1, gaparams);
442 DGraph expected0 = expectedPair[0];
443 DGraph expected1 = expectedPair[1];
449 assertTrue(expected0.
sameAs(g0xo,
new StringBuilder()));
450 assertTrue(expected1.
sameAs(g1xo,
new StringBuilder()));
473 String propName =
"uniquefier";
477 v.setUniquefyingProperty(propName);
478 v.setProperty(propName, i);
486 ArrayList<Candidate> eligibleParents =
new ArrayList<Candidate>();
487 eligibleParents.add(cA);
488 eligibleParents.add(cB);
491 boolean embeddedGraphHasBeenAlteredA =
false;
492 boolean embeddedGraphHasBeenAlteredB =
false;
493 for (
int ixo=0; ixo<11; ixo++)
500 population, mnt,
new int[]{0,1}, ixo, 0, gaparams);
502 population, mnt,
new int[]{0,1}, ixo, 1, gaparams);
503 }
catch (IndexOutOfBoundsException e)
505 if (e.getMessage().contains(
"Index 10 out of bounds"))
544 embeddedGraphHasBeenAlteredA =
true;
549 embeddedGraphHasBeenAlteredB =
true;
558 assertTrue(embeddedGraphHasBeenAlteredA);
559 assertTrue(embeddedGraphHasBeenAlteredB);
567 int ix = 0, im=0, ic=0, tot=1000;
568 double wx = 2, wm = 0.6, wc=0.05;
569 double wtot = wx + wm + wc;
571 for (
int i=0; i<tot; i++)
587 assertTrue(
false,
"Unexpected generation mode "+mode);
591 double x = ((double)ix) / tot;
592 double m = ((double)im) / tot;
593 double c = ((double)ic) / tot;
597 assertTrue(Math.abs(x-(wx/wtot)) < thld,
"#Xover cases are off!");
598 assertTrue(Math.abs(m-(wm/wtot)) < thld,
"#Mutation cases are off!");
599 assertTrue(Math.abs(
c-(wc/wtot)) < thld,
"#Built cases are off!");
609 long otherSeed = 987654321;
610 double wx = 2, wm = 0.6, wc=0.05;
613 List<CandidateSource> resultsA =
new ArrayList<CandidateSource>();
614 for (
int i=0; i<tot; i++)
620 List<CandidateSource> resultsB =
new ArrayList<CandidateSource>();
621 for (
int i=0; i<tot; i++)
627 List<CandidateSource> resultsC =
new ArrayList<CandidateSource>();
628 for (
int i=0; i<tot; i++)
633 boolean different =
false;
634 for (
int i=0; i<tot; i++)
636 if (resultsA.get(i) != resultsB.get(i))
642 assertTrue(different);
644 for (
int i=0; i<tot; i++)
646 assertEquals(resultsA.get(i),resultsC.get(i),
647 "Inconsistent sequence of random decisions");
662 assertTrue(Math.abs(1.0 - p)<t,
663 "Scheme 3 should return always 1.0 but was "+p);
667 assertTrue(Math.abs(1.0 - p)<t,
"Scheme 0 on ap3: 1.0 != "+p);
669 assertTrue(Math.abs(1.0 - p)<t,
"Scheme 1 on ap3: 1.0 != "+p);
671 assertTrue(Math.abs(1.0 - p)<t,
"Scheme 2 on ap3: 1.0 != "+p);
675 assertTrue(Math.abs(0.5 - p)<t,
"Scheme 2 on ap2");
721 for (
int i=0; i<5; i++)
724 assertEquals(expected, chosen,
"Index of the only choosable vertex");
733 double[] weights =
new double[] {0,0,0,0,1};
737 weights =
new double[] {1,0,0,0,1};
741 weights =
new double[] {1,1,1,1,1};
760 assertTrue(
tempDir.isDirectory(),
"Should be a directory ");
761 String structureFile =
tempDir.getAbsolutePath() +
SEP +
"mol.sdf";
764 +
" OpenBabel03302310043D" +
NL
766 +
" 33 35 0 0 0 0 0 0 0 0999 V2000" +
NL
767 +
" -1.5455 1.4965 3.4529 O 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
768 +
" -1.1783 1.0876 2.3182 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
769 +
" -1.8597 -0.0221 1.6796 N 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
770 +
" -3.0535 -0.6083 2.2978 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
771 +
" 0.0153 1.7383 1.6547 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
772 +
" -0.1038 1.5947 0.1342 C 0 0 1 0 0 0 0 0 0 0 0 0" +
NL
773 +
" 0.9646 2.2439 -0.5585 O 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
774 +
" 2.0315 1.3700 -0.8940 C 0 0 2 0 0 0 0 0 0 0 0 0" +
NL
775 +
" 3.0842 2.1330 -1.6910 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
776 +
" 3.5659 3.1894 -0.9391 F 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
777 +
" 4.1344 1.2898 -2.0067 F 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
778 +
" 2.5295 2.6237 -2.8597 F 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
779 +
" 1.5529 0.2692 -1.6691 O 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
780 +
" 0.4699 -0.4528 -1.1881 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
781 +
" -0.3192 0.1414 -0.2151 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
782 +
" -1.2683 -0.6053 0.4932 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
783 +
" -1.5222 -1.9320 0.0906 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
784 +
" -0.8092 -2.5038 -0.9766 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
785 +
" -1.1169 -3.8201 -1.3518 O 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
786 +
" -0.4725 -4.5263 -2.4070 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
787 +
" 0.2040 -1.7556 -1.6127 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
788 +
" -3.7666 -0.9444 1.5155 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
789 +
" -3.5865 0.1389 2.9228 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
790 +
" -2.7606 -1.4709 2.9321 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
791 +
" 0.9449 1.2474 2.0144 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
792 +
" 0.0550 2.8163 1.9227 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
793 +
" -1.0337 2.1265 -0.1667 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
794 +
" 2.5075 0.9860 0.0372 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
795 +
" -2.2462 -2.5403 0.6157 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
796 +
" -0.6162 -3.9902 -3.3689 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
797 +
" -0.9204 -5.5374 -2.4930 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
798 +
" 0.6107 -4.6349 -2.1878 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
799 +
" 0.8117 -2.1861 -2.3969 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
800 +
" 1 2 2 0 0 0 0" +
NL
801 +
" 2 3 1 0 0 0 0" +
NL
802 +
" 2 5 1 0 0 0 0" +
NL
803 +
" 3 4 1 0 0 0 0" +
NL
804 +
" 4 22 1 0 0 0 0" +
NL
805 +
" 4 23 1 0 0 0 0" +
NL
806 +
" 4 24 1 0 0 0 0" +
NL
807 +
" 5 6 1 0 0 0 0" +
NL
808 +
" 5 25 1 0 0 0 0" +
NL
809 +
" 5 26 1 0 0 0 0" +
NL
810 +
" 6 7 1 0 0 0 0" +
NL
811 +
" 6 27 1 6 0 0 0" +
NL
812 +
" 7 8 1 0 0 0 0" +
NL
813 +
" 8 9 1 0 0 0 0" +
NL
814 +
" 8 13 1 0 0 0 0" +
NL
815 +
" 8 28 1 1 0 0 0" +
NL
816 +
" 9 10 1 0 0 0 0" +
NL
817 +
" 9 11 1 0 0 0 0" +
NL
818 +
" 9 12 1 0 0 0 0" +
NL
819 +
" 13 14 1 0 0 0 0" +
NL
820 +
" 14 15 2 0 0 0 0" +
NL
821 +
" 15 16 1 0 0 0 0" +
NL
822 +
" 15 6 1 0 0 0 0" +
NL
823 +
" 16 17 2 0 0 0 0" +
NL
824 +
" 16 3 1 0 0 0 0" +
NL
825 +
" 17 18 1 0 0 0 0" +
NL
826 +
" 17 29 1 0 0 0 0" +
NL
827 +
" 18 19 1 0 0 0 0" +
NL
828 +
" 18 21 2 0 0 0 0" +
NL
829 +
" 19 20 1 0 0 0 0" +
NL
830 +
" 20 30 1 0 0 0 0" +
NL
831 +
" 20 31 1 0 0 0 0" +
NL
832 +
" 20 32 1 0 0 0 0" +
NL
833 +
" 21 14 1 0 0 0 0" +
NL
834 +
" 21 33 1 0 0 0 0" +
NL
840 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
841 cuttingRules.add(
new CuttingRule(
"cC",
"[c]",
"[C]",
"~", 0,
842 new ArrayList<String>()));
843 cuttingRules.add(
new CuttingRule(
"cN",
"[c]",
"[#7]",
"~", 1,
844 new ArrayList<String>()));
845 cuttingRules.add(
new CuttingRule(
"cO",
"[c]",
"[#8]",
"~", 2,
846 new ArrayList<String>()));
847 cuttingRules.add(
new CuttingRule(
"OC",
"[O]",
"[C]",
"-", 3,
848 new ArrayList<String>()));
849 cuttingRules.add(
new CuttingRule(
"CF",
"[C]",
"[F]",
"-", 4,
850 new ArrayList<String>()));
851 cuttingRules.add(
new CuttingRule(
"NC",
"[N]",
"[C]",
"-", 5,
852 new ArrayList<String>()));
875 .collect(Collectors.toList());
876 assertEquals(1, templates.size());
889 SmilesParser p =
new SmilesParser(
builder);
890 IAtomContainer mol = p.parseSmiles(
"c1ccccc1OCN(CC)(C)[Ru](N)(N)C#O");
894 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
895 cuttingRules.add(
new CuttingRule(
"C-O",
"[#6]",
"[#8]",
"-", 2,
896 new ArrayList<String>()));
897 cuttingRules.add(
new CuttingRule(
"N-C",
"[#7]",
"[#6]",
"-", 5,
898 new ArrayList<String>()));
899 cuttingRules.add(
new CuttingRule(
"Ru-Any",
"[Ru]",
"[$([*])]",
"~", 5,
900 new ArrayList<String>()));
912 .collect(Collectors.toList());
913 assertEquals(1, scaffolds.size());
914 Vertex scaffold = scaffolds.get(0);
916 assertEquals(6, iacScaffold.getAtomCount());
922 cuttingRules, settings.
getLogger(), policy);
930 .collect(Collectors.toList());
931 assertEquals(1, scaffolds.size());
932 scaffold = scaffolds.get(0);
934 assertEquals(1, iacScaffold.getAtomCount());
935 assertEquals(
"Ru", iacScaffold.getAtom(0).getSymbol());
943 SmilesParser p =
new SmilesParser(
builder);
944 IAtomContainer mol = p.parseSmiles(
945 "Oc1cc(O)cc(O)c1CN(CC)(CC)[Ru](N)(Nc1c(F)cc(F)cc1(Cl))C#O");
949 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
950 cuttingRules.add(
new CuttingRule(
"C-F",
"[#6]",
"[#9]",
"-", 1,
951 new ArrayList<String>()));
952 cuttingRules.add(
new CuttingRule(
"C-O",
"[#6]",
"[#8]",
"-", 2,
953 new ArrayList<String>()));
954 cuttingRules.add(
new CuttingRule(
"N-C",
"[#7]",
"[#6]",
"-", 5,
955 new ArrayList<String>()));
956 cuttingRules.add(
new CuttingRule(
"Ru-Any",
"[Ru]",
"[$([*])]",
"~", 5,
957 new ArrayList<String>()));
967 boolean foundO =
false;
968 boolean foundF =
false;
970 while (iter.hasNext())
973 String el = ss.get(0).getIAtomContainer().getAtom(0).getSymbol();
976 else if (
"F".equals(el))
986 cuttingRules, settings.
getLogger(), policy);
995 while (iter.hasNext())
998 String el = ss.get(0).getIAtomContainer().getAtom(0).getSymbol();
1001 else if (
"F".equals(el))
1012 cuttingRules, settings.
getLogger(), policy);
1021 while (iter.hasNext())
1024 String el = ss.get(0).getIAtomContainer().getAtom(0).getSymbol();
1027 else if (
"F".equals(el))
1031 assertFalse(foundF);
1040 SmilesParser p =
new SmilesParser(
builder);
1041 IAtomContainer mol = p.parseSmiles(
"C#C-C#C-C#N");
1044 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
1045 sdg.generateCoordinates(mol);
1049 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
1050 cuttingRules.add(
new CuttingRule(
"C-C",
"[#6]",
"[#6]",
"-", 2,
1051 new ArrayList<String>()));
1052 cuttingRules.add(
new CuttingRule(
"C-X",
"[#6]",
"[#9,#17,#35,#53]",
"~",
1053 3,
new ArrayList<String>()));
1066 for (IAtom
a : v.getIAtomContainer().atoms())
1074 assertEquals(4, duAtmCount);
1077 IAtomContainer molNonLinear = p.parseSmiles(
"C(Cl)(F)Br");
1078 sdg.generateCoordinates(molNonLinear);
1090 for (IAtom
a : v.getIAtomContainer().atoms())
1098 assertEquals(0, duAtmCount);
1112 for (IAtom
a : v.getIAtomContainer().atoms())
1120 assertEquals(0, duAtmCount);
1136 SmilesParser p =
new SmilesParser(
builder);
1137 IAtomContainer mol = p.parseSmiles(
1138 "P123C(OC[SiH2]O1)(OC[SiH2]O2)OC[SiH2]O3");
1141 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
1142 cuttingRules.add(
new CuttingRule(
"PC-O",
"[$(CP)]",
"[O]",
"-", -1,
1143 new ArrayList<String>()));
1144 cuttingRules.add(
new CuttingRule(
"C-O",
"[C]",
"[O]",
"-", 0,
1145 new ArrayList<String>()));
1146 cuttingRules.add(
new CuttingRule(
"C-Si",
"[C]",
"[Si]",
"-", 1,
1147 new ArrayList<String>()));
1148 cuttingRules.add(
new CuttingRule(
"Si-O",
"[Si]",
"[O]",
"-", 2,
1149 new ArrayList<String>()));
1150 cuttingRules.add(
new CuttingRule(
"P-C",
"[P]",
"[C]",
"-", 3,
1151 new ArrayList<String>()));
1152 cuttingRules.add(
new CuttingRule(
"P-O",
"[P]",
"[O]",
"-", 4,
1153 new ArrayList<String>()));
1156 scaffoldOnP.label =
"P";
1162 List<List<Integer>> expected =
new ArrayList<List<Integer>>();
1163 expected.add(Arrays.asList(3, 9, 15));
1164 expected.add(Arrays.asList(5, 11, 17));
1165 expected.add(Arrays.asList(7, 13, 19));
1166 expected.add(Arrays.asList(4, 10, 16));
1167 expected.add(Arrays.asList(2, 8, 14));
1168 expected.add(Arrays.asList(6, 12, 18));
1169 for (List<Integer> vrtxIDs : expected)
1173 assertFalse(sv0.isEmpty());
1174 for (
int i=1; i<vrtxIDs.size(); i++)
1178 assertTrue(sv0 == svI);
1182 IAtomContainer mol2 = p.parseSmiles(
1183 "C1C(C(C(F)(F)(F))(C(F)(F)(F)))OCCC1((N(C([H])([H])C3=C"
1184 +
"(C(=C(C(=C3[H])[H])[F])[F]))(C([H])([H])C3=C(C(=C(C"
1185 +
"(=C3[H])[H])[F])[F]))))");
1187 cuttingRules =
new ArrayList<CuttingRule>();
1188 cuttingRules.add(
new CuttingRule(
"C-C",
"[#6]",
"[#6]",
"-!@", -1,
1189 new ArrayList<String>()));
1190 cuttingRules.add(
new CuttingRule(
"C-X",
"[#6]",
"[#9]",
"-", 0,
1191 new ArrayList<String>()));
1192 cuttingRules.add(
new CuttingRule(
"C-N",
"[#6]",
"[N]",
"-", 1,
1193 new ArrayList<String>()));
1202 expected =
new ArrayList<List<Integer>>();
1203 expected.add(Arrays.asList(11, 15));
1204 expected.add(Arrays.asList(2, 6));
1205 expected.add(Arrays.asList(3, 4, 5, 7, 8, 9));
1206 expected.add(Arrays.asList(13, 14, 17, 18));
1207 expected.add(Arrays.asList(12, 16));
1208 for (List<Integer> vrtxIDs : expected)
1212 assertFalse(sv0.isEmpty());
1213 for (
int i=1; i<vrtxIDs.size(); i++)
1217 assertTrue(sv0 == svI);
1230 SmilesParser p =
new SmilesParser(
builder);
1231 IAtomContainer mol = p.parseSmiles(
"Cc1cnc(Cl)cc1O");
1235 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
1236 sdg.generateCoordinates(mol);
1240 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
1241 cuttingRules.add(
new CuttingRule(
"sAr",
"[c]",
"[*]",
"-", 2,
1242 new ArrayList<String>()));
1243 cuttingRules.add(
new CuttingRule(
"Ox",
"[O]",
"[*]",
"-", 3,
1244 new ArrayList<String>()));
1250 capH.
addAtom(
new Atom(
"H",
new Point3d()));
1251 capH.
addAP(0, hyd1,
new Point3d(1.0,0,0));
1253 ArrayList<Vertex> cappingGroups =
new ArrayList<Vertex>();
1254 cappingGroups.add(capH);
1256 HashMap<APClass, APClass> capMap =
new HashMap<APClass, APClass>();
1257 capMap.put(sAr0, hyd1);
1258 capMap.put(ox0, hyd1);
1262 new ArrayList<Vertex>(),
1263 new ArrayList<Vertex>(),
1265 new HashMap<
APClass,ArrayList<APClass>>(),
1267 new HashSet<APClass>(),
1268 new HashMap<
APClass,ArrayList<APClass>>());
1309 Logger logger = Logger.getLogger(
"DummyLogger");
1313 HashMap<APClass,APClass> capMap =
new HashMap<APClass,APClass>();
1314 capMap.put(apcA,hyd);
1315 capMap.put(apcB,hyd);
1316 capMap.put(apcC,hyd);
1317 capMap.put(apcD,hyd);
1318 capMap.put(apcE,hyd);
1319 capMap.put(apcF,hyd);
1320 capMap.put(apcG,hyd);
1321 capMap.put(apcNotFusable,hyd);
1323 ArrayList<Vertex> cappingGroups =
new ArrayList<Vertex>();
1325 capH.
addAtom(
new Atom(
"H",
new Point3d()));
1326 capH.
addAP(0,
new Point3d(1.0, 0, 0), hyd);
1327 cappingGroups.add(capH);
1330 HashMap<APClass,ArrayList<APClass>> rcCMap =
1331 new HashMap<APClass,ArrayList<APClass>>();
1332 rcCMap.put(apcA,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1333 rcCMap.put(apcB,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1334 rcCMap.put(apcC,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1335 rcCMap.put(apcD,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1336 rcCMap.put(apcE,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1337 rcCMap.put(apcF,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1338 rcCMap.put(apcG,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1343 new ArrayList<Vertex>(),
1344 new ArrayList<Vertex>(),
1346 new HashMap<
APClass,ArrayList<APClass>>(),
1347 capMap,
new HashSet<APClass>(),
1356 SmilesParser parser =
new SmilesParser(
builder);
1357 IAtomContainer mol = parser.parseSmiles(
"c1ccccc1");
1359 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
1360 sdg.generateCoordinates(mol);
1370 graph, fragSpace, rcParams,
false, logger, rng);
1372 assertEquals(1, combinations.size());
1373 assertEquals(1, combinations.get(0).size());
1374 assertEquals(2, combinations.get(0).get(0).apA.getIndexInOwner());
1375 assertEquals(3, combinations.get(0).get(0).apB.getIndexInOwner());
1382 parser =
new SmilesParser(
builder);
1383 mol = parser.parseSmiles(
"c1ccccc1");
1385 sdg.generateCoordinates(mol);
1387 for (
int i= 0; i<6; i++)
1395 graph, fragSpace, rcParams,
false, logger, rng);
1397 assertEquals(6, combinations.size());
1398 Set<AttachmentPoint> involvedAPs =
new HashSet<AttachmentPoint>();
1399 for (List<RelatedAPPair> comb : combinations)
1401 assertEquals(1, comb.size());
1407 involvedAPs.add(pair.
apA);
1408 involvedAPs.add(pair.
apB);
1410 assertEquals(6, involvedAPs.size());
1422 assertEquals(2, combinations.size());
1423 involvedAPs =
new HashSet<AttachmentPoint>();
1424 for (List<RelatedAPPair> comb : combinations)
1426 assertEquals(3, comb.size());
1427 involvedAPs =
new HashSet<AttachmentPoint>();
1430 involvedAPs.add(pair.apA);
1431 involvedAPs.add(pair.apB);
1434 assertEquals(6, involvedAPs.size());
1452 mol = parser.parseSmiles(
"c1ccccc1c1ccccc1");
1454 sdg.generateCoordinates(mol);
1470 assertEquals(6, combinations.size());
1471 int[] apUsageCounts =
new int[8];
1472 for (List<RelatedAPPair> comb : combinations)
1474 assertEquals(1, comb.size());
1477 apUsageCounts[pair.apA.getIndexInOwner()] =
1478 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1479 apUsageCounts[pair.apB.getIndexInOwner()] =
1480 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1483 assertEquals(1, apUsageCounts[0]);
1484 assertEquals(2, apUsageCounts[1]);
1485 assertEquals(2, apUsageCounts[2]);
1486 assertEquals(2, apUsageCounts[3]);
1487 assertEquals(1, apUsageCounts[4]);
1488 assertEquals(1, apUsageCounts[5]);
1489 assertEquals(2, apUsageCounts[6]);
1490 assertEquals(1, apUsageCounts[7]);
1508 assertEquals(5, combinations.size());
1509 apUsageCounts =
new int[8];
1510 int[] sizesCount =
new int[4];
1511 for (List<RelatedAPPair> comb : combinations)
1513 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1516 apUsageCounts[pair.apA.getIndexInOwner()] =
1517 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1518 apUsageCounts[pair.apB.getIndexInOwner()] =
1519 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1522 assertEquals(2, apUsageCounts[0]);
1523 assertEquals(3, apUsageCounts[1]);
1524 assertEquals(2, apUsageCounts[2]);
1525 assertEquals(3, apUsageCounts[3]);
1526 assertEquals(2, apUsageCounts[4]);
1527 assertEquals(1, apUsageCounts[5]);
1528 assertEquals(2, apUsageCounts[6]);
1529 assertEquals(1, apUsageCounts[7]);
1530 assertEquals(0, sizesCount[0]);
1531 assertEquals(2, sizesCount[1]);
1532 assertEquals(3, sizesCount[2]);
1533 assertEquals(0, sizesCount[3]);
1549 mol = parser.parseSmiles(
"c1ccccc1Oc1ccccc1");
1551 sdg.generateCoordinates(mol);
1568 assertEquals(7, combinations.size());
1569 apUsageCounts =
new int[11];
1570 sizesCount =
new int[4];
1571 for (List<RelatedAPPair> comb : combinations)
1573 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1576 apUsageCounts[pair.apA.getIndexInOwner()] =
1577 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1578 apUsageCounts[pair.apB.getIndexInOwner()] =
1579 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1582 assertEquals(2, apUsageCounts[0]);
1583 assertEquals(3, apUsageCounts[1]);
1584 assertEquals(2, apUsageCounts[2]);
1585 assertEquals(3, apUsageCounts[3]);
1586 assertEquals(2, apUsageCounts[4]);
1587 assertEquals(1, apUsageCounts[5]);
1588 assertEquals(2, apUsageCounts[6]);
1589 assertEquals(2, apUsageCounts[7]);
1590 assertEquals(2, apUsageCounts[8]);
1591 assertEquals(1, apUsageCounts[9]);
1592 assertEquals(0, apUsageCounts[10]);
1593 assertEquals(0, sizesCount[0]);
1594 assertEquals(4, sizesCount[1]);
1595 assertEquals(3, sizesCount[2]);
1596 assertEquals(0, sizesCount[3]);
1613 mol = parser.parseSmiles(
"c1ccccc1c1ccccc1");
1615 sdg.generateCoordinates(mol);
1632 assertEquals(12, combinations.size());
1633 apUsageCounts =
new int[10];
1634 sizesCount =
new int[4];
1635 for (List<RelatedAPPair> comb : combinations)
1637 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1640 apUsageCounts[pair.apA.getIndexInOwner()] =
1641 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1642 apUsageCounts[pair.apB.getIndexInOwner()] =
1643 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1646 assertEquals(3, apUsageCounts[0]);
1647 assertEquals(2, apUsageCounts[1]);
1648 assertEquals(2, apUsageCounts[2]);
1649 assertEquals(2, apUsageCounts[3]);
1650 assertEquals(3, apUsageCounts[4]);
1651 assertEquals(3, apUsageCounts[5]);
1652 assertEquals(2, apUsageCounts[6]);
1653 assertEquals(2, apUsageCounts[7]);
1654 assertEquals(2, apUsageCounts[8]);
1655 assertEquals(3, apUsageCounts[9]);
1656 assertEquals(0, sizesCount[0]);
1657 assertEquals(12, sizesCount[1]);
1658 assertEquals(0, sizesCount[2]);
1659 assertEquals(0, sizesCount[3]);
1667 graph, fragSpace, rcParams,
true, logger, rng);
1669 assertEquals(8, combinations.size());
1670 apUsageCounts =
new int[10];
1671 sizesCount =
new int[4];
1672 for (List<RelatedAPPair> comb : combinations)
1674 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1677 apUsageCounts[pair.apA.getIndexInOwner()] =
1678 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1679 apUsageCounts[pair.apB.getIndexInOwner()] =
1680 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1683 assertEquals(4, apUsageCounts[0]);
1684 assertEquals(3, apUsageCounts[1]);
1685 assertEquals(2, apUsageCounts[2]);
1686 assertEquals(3, apUsageCounts[3]);
1687 assertEquals(4, apUsageCounts[4]);
1688 assertEquals(4, apUsageCounts[5]);
1689 assertEquals(3, apUsageCounts[6]);
1690 assertEquals(2, apUsageCounts[7]);
1691 assertEquals(3, apUsageCounts[8]);
1692 assertEquals(4, apUsageCounts[9]);
1693 assertEquals(0, sizesCount[0]);
1694 assertEquals(0, sizesCount[1]);
1695 assertEquals(8, sizesCount[2]);
1696 assertEquals(0, sizesCount[3]);
1723 mol = parser.parseSmiles(
"o1cccc1c1cc2c(cc1)c[n+]3c(c2)Nc(c3)[Ru]c1ccc(cc1)c1ccc(cc1)[Ru]c1ccc(N1)c1cnN(c1)");
1725 sdg.generateCoordinates(mol);
1755 graph, fragSpace, rcParams,
false, logger, rng);
1757 assertEquals(17, combinations.size());
1758 apUsageCounts =
new int[18];
1759 sizesCount =
new int[4];
1760 Map<String,Integer> countTypes =
new HashMap<String,Integer>();
1761 for (List<RelatedAPPair> comb : combinations)
1763 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1766 apUsageCounts[pair.apA.getIndexInOwner()] =
1767 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1768 apUsageCounts[pair.apB.getIndexInOwner()] =
1769 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1770 if (countTypes.containsKey(pair.propID))
1771 countTypes.put(pair.propID, countTypes.get(pair.propID)+1);
1773 countTypes.put(pair.propID, 1);
1776 assertEquals(1, apUsageCounts[0]);
1777 assertEquals(2, apUsageCounts[1]);
1778 assertEquals(3, apUsageCounts[2]);
1779 assertEquals(2, apUsageCounts[3]);
1780 assertEquals(2, apUsageCounts[4]);
1781 assertEquals(2, apUsageCounts[5]);
1782 assertEquals(2, apUsageCounts[6]);
1783 assertEquals(2, apUsageCounts[7]);
1784 assertEquals(1, apUsageCounts[8]);
1785 assertEquals(1, apUsageCounts[9]);
1786 assertEquals(2, apUsageCounts[10]);
1787 assertEquals(2, apUsageCounts[11]);
1788 assertEquals(2, apUsageCounts[12]);
1789 assertEquals(2, apUsageCounts[13]);
1790 assertEquals(2, apUsageCounts[14]);
1791 assertEquals(2, apUsageCounts[15]);
1792 assertEquals(2, apUsageCounts[16]);
1793 assertEquals(2, apUsageCounts[17]);
1794 assertEquals(0, sizesCount[0]);
1795 assertEquals(17, sizesCount[1]);
1796 assertEquals(0, sizesCount[2]);
1797 assertEquals(0, sizesCount[3]);
1798 assertEquals(3, countTypes.get(
"2el2atm"));
1799 assertEquals(2, countTypes.get(
"3el3atm_6+5"));
1800 assertEquals(2, countTypes.get(
"3el3atm_6+6"));
1801 assertEquals(4, countTypes.get(
"4el4atm_6+6"));
1802 assertEquals(2, countTypes.get(
"4el4atm_6+5"));
1803 assertEquals(4, countTypes.get(
"4el4atm_5+5"));
1819 parser =
new SmilesParser(
builder);
1820 IAtomContainer molF0 = parser.parseSmiles(
"c1ccccc1");
1822 sdg.generateCoordinates(molF0);
1830 IAtomContainer molF1 = parser.parseSmiles(
"C=CC=C");
1832 sdg.generateCoordinates(molF1);
1842 IAtomContainer molF2 = parser.parseSmiles(
"N");
1844 sdg.generateCoordinates(molF2);
1851 IAtomContainer molF3 = parser.parseSmiles(
"C=CC=C");
1853 sdg.generateCoordinates(molF3);
1874 graphManyFrags.
addRing(rcvOnF1a, rcvOnF2);
1875 graphManyFrags.
addRing(rcvOnF1b, rcvOnF3);
1878 graphManyFrags, fragSpace, rcParams,
false, logger, rng);
1880 assertEquals(4, combinations.size());
1882 Map<Long,Integer> vertexUsageCounts =
new HashMap<Long,Integer>();
1883 for (List<RelatedAPPair> comb : combinations)
1887 long vIdA = pair.apA.getOwner().getVertexId();
1888 if (vertexUsageCounts.containsKey(vIdA))
1890 vertexUsageCounts.put(vIdA, vertexUsageCounts.get(vIdA)+1);
1892 vertexUsageCounts.put(vIdA,1);
1894 long vIdB = pair.apB.getOwner().getVertexId();
1895 if (vertexUsageCounts.containsKey(vIdB))
1897 vertexUsageCounts.put(vIdB, vertexUsageCounts.get(vIdB)+1);
1899 vertexUsageCounts.put(vIdB,1);
1903 assertTrue(vertexUsageCounts.containsKey(fragF0.
getVertexId()));
1905 assertEquals(4, vertexUsageCounts.get(fragF0.
getVertexId()));
1906 assertTrue(vertexUsageCounts.containsKey(fragF1.
getVertexId()));
1907 assertEquals(1, vertexUsageCounts.get(fragF1.
getVertexId()));
1908 assertTrue(vertexUsageCounts.containsKey(fragF2.
getVertexId()));
1909 assertEquals(2, vertexUsageCounts.get(fragF2.
getVertexId()));
1910 assertTrue(vertexUsageCounts.containsKey(fragF3.
getVertexId()));
1911 assertEquals(1, vertexUsageCounts.get(fragF3.
getVertexId()));
1944 mol = parser.parseSmiles(
"S1CCOCC1C1NCC(CC1)C1C=NC(C1)C1CC2C(N1)CC(CC2)"
1945 +
"(C1CC(C1)C1CC(C1)C1CCCC1)"
1946 +
"C1C(C1)C1C(C1)C1CCCC1C1C(C1)C1CCC1");
1948 sdg.generateCoordinates(mol);
1975 graph, fragSpace, rcParams,
false, logger, rng);
1977 assertEquals(27, combinations.size());
1978 apUsageCounts =
new int[20];
1979 countTypes =
new HashMap<String,Integer>();
1980 for (List<RelatedAPPair> comb : combinations)
1984 apUsageCounts[pair.apA.getIndexInOwner()] =
1985 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1986 apUsageCounts[pair.apB.getIndexInOwner()] =
1987 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1988 if (countTypes.containsKey(pair.propID))
1989 countTypes.put(pair.propID, countTypes.get(pair.propID)+1);
1991 countTypes.put(pair.propID, 1);
1995 assertEquals(3, apUsageCounts[0]);
1996 assertEquals(3, apUsageCounts[1]);
1997 assertEquals(6, apUsageCounts[2]);
1998 assertEquals(3, apUsageCounts[3]);
1999 assertEquals(3, apUsageCounts[4]);
2000 assertEquals(3, apUsageCounts[5]);
2001 assertEquals(3, apUsageCounts[6]);
2002 assertEquals(3, apUsageCounts[7]);
2003 assertEquals(3, apUsageCounts[8]);
2004 assertEquals(4, apUsageCounts[9]);
2005 assertEquals(3, apUsageCounts[10]);
2006 assertEquals(3, apUsageCounts[11]);
2007 assertEquals(3, apUsageCounts[12]);
2008 assertEquals(2, apUsageCounts[13]);
2009 assertEquals(1, apUsageCounts[14]);
2010 assertEquals(3, apUsageCounts[15]);
2011 assertEquals(2, apUsageCounts[16]);
2012 assertEquals(1, apUsageCounts[17]);
2013 assertEquals(1, apUsageCounts[18]);
2014 assertEquals(1, apUsageCounts[19]);
2015 assertEquals(2, countTypes.get(
"aliph2atm"));
2016 assertEquals(4, countTypes.get(
"aliph3atm"));
2017 assertEquals(6, countTypes.get(
"aliph4atm_6+6"));
2018 assertEquals(4, countTypes.get(
"aliph4atm_6+5"));
2019 assertEquals(2, countTypes.get(
"aliph4atm_6+4"));
2020 assertEquals(2, countTypes.get(
"aliph4atm_6+3"));
2021 assertEquals(2, countTypes.get(
"aliph4atm_5+5"));
2022 assertEquals(1, countTypes.get(
"aliph4atm_5+4"));
2023 assertEquals(1, countTypes.get(
"aliph4atm_5+3"));
2024 assertEquals(1, countTypes.get(
"aliph4atm_4+4"));
2025 assertEquals(1, countTypes.get(
"aliph4atm_4+3"));
2026 assertEquals(1, countTypes.get(
"aliph4atm_3+3"));
2027 assertFalse(countTypes.containsKey(
"2el2atm"));
2028 assertFalse(countTypes.containsKey(
"3el3atm_6+5"));
2029 assertFalse(countTypes.containsKey(
"4el4atm_6+6"));
2030 assertFalse(countTypes.containsKey(
"4el4atm_6+5"));
2031 assertFalse(countTypes.containsKey(
"4el4atm_5+5"));
2039 mol = parser.parseSmiles(
"C1CCCCCCCCC1");
2041 sdg.generateCoordinates(mol);
2068 graph, fragSpace, rcParams,
true, logger, rng);
2071 assertEquals(136, combinations.size());
2074 assertEquals(6, combinations.get(0).size());
2097 mol = parser.parseSmiles(
"c1c2c(ccc1)ccc3c2c(c1cc3)cNc1");
2099 sdg.generateCoordinates(mol);
2112 graph, fragSpace, rcParams,
false, logger, rng);
2114 assertEquals(2, combinations.size());
2115 apUsageCounts =
new int[6];
2116 sizesCount =
new int[3];
2117 countTypes =
new HashMap<String,Integer>();
2118 for (List<RelatedAPPair> comb : combinations)
2120 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
2123 apUsageCounts[pair.apA.getIndexInOwner()] =
2124 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
2125 apUsageCounts[pair.apB.getIndexInOwner()] =
2126 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
2127 if (countTypes.containsKey(pair.propID))
2128 countTypes.put(pair.propID, countTypes.get(pair.propID)+1);
2130 countTypes.put(pair.propID, 1);
2133 assertEquals(1, apUsageCounts[0]);
2134 assertEquals(1, apUsageCounts[1]);
2135 assertEquals(1, apUsageCounts[2]);
2136 assertEquals(0, apUsageCounts[3]);
2137 assertEquals(1, apUsageCounts[4]);
2138 assertEquals(0, apUsageCounts[5]);
2139 assertEquals(0, sizesCount[0]);
2140 assertEquals(2, sizesCount[1]);
2141 assertEquals(0, sizesCount[2]);
2142 assertEquals(1, countTypes.get(
"3el3atm_6+6"));
2143 assertEquals(1, countTypes.get(
"5el5atm_6+6+6"));
2166 mol = parser.parseSmiles(
"c1c2c(ccc1)ccc3c2c(c1N3)cccc1");
2168 sdg.generateCoordinates(mol);
2181 graph, fragSpace, rcParams,
false, logger, rng);
2183 assertEquals(1, combinations.size());
2184 assertEquals(1, combinations.get(0).size());
2186 assertEquals(
"3el3atm_6+6", combinations.get(0).get(0).propID);
2209 mol = parser.parseSmiles(
"c1c(cccc1)c1cccc2c1cNc2");
2211 sdg.generateCoordinates(mol);
2222 graph, fragSpace, rcParams,
false, logger, rng);
2224 assertEquals(1, combinations.size());
2225 assertEquals(1, combinations.get(0).size());
2227 assertEquals(
"5el5atm_6-6*", combinations.get(0).get(0).propID);
2250 mol = parser.parseSmiles(
"c1c2c(ccc1)cccc2c1cNcc1");
2252 sdg.generateCoordinates(mol);
2267 graph, fragSpace, rcParams,
false, logger, rng);
2269 assertEquals(2, combinations.size());
2270 boolean found4el =
false;
2271 boolean found5el =
false;
2272 for (List<RelatedAPPair> comb : combinations)
2274 assertEquals(1, combinations.get(0).size());
2276 if (
"4el4atm_6+5".equals(pair.
propID))
2278 if (
"5el5atm_66-*".equals(pair.
propID))
2281 assertTrue(found4el);
2282 assertTrue(found5el);
2296 Logger logger = Logger.getLogger(
"DummyLogger");
2300 HashMap<APClass,APClass> capMap =
new HashMap<APClass,APClass>();
2301 capMap.put(apcSymImposed, hyd);
2302 capMap.put(apcFree, hyd);
2304 ArrayList<Vertex> cappingGroups =
new ArrayList<Vertex>();
2306 capH.
addAtom(
new Atom(
"H",
new Point3d()));
2307 capH.
addAP(0,
new Point3d(1.0, 0, 0), hyd);
2308 cappingGroups.add(capH);
2311 HashMap<APClass,ArrayList<APClass>> rcCMap =
2312 new HashMap<APClass,ArrayList<APClass>>();
2313 rcCMap.put(apcSymImposed,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
2318 new ArrayList<Vertex>(),
2319 new ArrayList<Vertex>(),
2321 new HashMap<
APClass,ArrayList<APClass>>(),
2322 capMap,
new HashSet<APClass>(),
2335 SmilesParser parser =
new SmilesParser(
builder);
2336 IAtomContainer mol = parser.parseSmiles(
"c1ccccc1");
2338 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
2339 sdg.generateCoordinates(mol);
2351 graph, fragSpace, rcParams,
false, logger, rng);
2354 assertEquals(2, combinations.size());
2358 HashMap<APClass, Double> symmetryConstraints =
2359 new HashMap<APClass, Double>();
2360 symmetryConstraints.put(apcSymImposed, 1.0);
2364 graph, fragSpace, rcParams,
false, logger, rng);
2367 assertEquals(1, combinations.size());
2368 assertEquals(2, combinations.get(0).size());
2375 boolean done =
false;
2387 throw new IllegalStateException(
"No H found that could be changed "
2396 ArrayList<Vertex> libFrags =
new ArrayList<Vertex>();
2403 IAtom a4elA_0 =
new Atom(
"C",
new Point3d());
2404 IAtom a4elA_1 =
new Atom(
"C",
new Point3d());
2405 IAtom a4elA_2 =
new Atom(
"C",
new Point3d());
2406 IAtom a4elA_3 =
new Atom(
"C",
new Point3d());
2411 bridge4elA.
addBond(
new Bond(a4elA_0, a4elA_1, IBond.Order.DOUBLE));
2412 bridge4elA.
addBond(
new Bond(a4elA_1, a4elA_2, IBond.Order.SINGLE));
2413 bridge4elA.
addBond(
new Bond(a4elA_2, a4elA_3, IBond.Order.DOUBLE));
2414 bridge4elA.
addAP(0,
new Point3d(), APC4EL);
2415 bridge4elA.
addAP(3,
new Point3d(), APC4EL);
2416 bridge4elA.
addAP(0,
new Point3d(), apcA);
2417 bridge4elA.
addAP(1,
new Point3d(), apcA);
2418 bridge4elA.
addAP(2,
new Point3d(), apcA);
2419 bridge4elA.
addAP(3,
new Point3d(), apcA);
2420 libFrags.add(bridge4elA);
2423 IAtom a4elB_0 =
new Atom(
"Si",
new Point3d());
2424 IAtom a4elB_1 =
new Atom(
"Si",
new Point3d());
2425 IAtom a4elB_2 =
new Atom(
"Si",
new Point3d());
2426 IAtom a4elB_3 =
new Atom(
"Si",
new Point3d());
2431 bridge4elB.
addBond(
new Bond(a4elB_0, a4elB_1, IBond.Order.DOUBLE));
2432 bridge4elB.
addBond(
new Bond(a4elB_1, a4elB_2, IBond.Order.SINGLE));
2433 bridge4elB.
addBond(
new Bond(a4elB_2, a4elB_3, IBond.Order.DOUBLE));
2434 bridge4elB.
addAP(0,
new Point3d(), APC4EL);
2435 bridge4elB.
addAP(3,
new Point3d(), APC4EL);
2436 libFrags.add(bridge4elB);
2439 IAtom a2elA_0 =
new Atom(
"O",
new Point3d());
2441 bridge2elA.
addAP(0,
new Point3d(), APC2EL);
2442 bridge2elA.
addAP(0,
new Point3d(), APC2EL);
2443 libFrags.add(bridge2elA);
2446 IAtom a2elB_0 =
new Atom(
"C",
new Point3d());
2447 IAtom a2elB_1 =
new Atom(
"C",
new Point3d());
2450 bridge2elB.
addBond(
new Bond(a2elB_0, a2elB_1, IBond.Order.DOUBLE));
2451 bridge2elB.
addAP(0,
new Point3d(), APC2EL);
2452 bridge2elB.
addAP(1,
new Point3d(), APC2EL);
2453 bridge2elB.
addAP(0,
new Point3d(), apcA);
2454 bridge2elB.
addAP(1,
new Point3d(), apcA);
2455 libFrags.add(bridge2elB);
2458 HashMap<APClass,ArrayList<APClass>> cpMap =
2459 new HashMap<APClass,ArrayList<APClass>>();
2460 cpMap.put(apcA,
new ArrayList<APClass>());
2464 new ArrayList<Vertex>(),
2466 new ArrayList<Vertex>(),
2468 new HashMap<APClass,APClass>(),
2469 new HashSet<APClass>(),
2470 new HashMap<
APClass,ArrayList<APClass>>());
2475 assertEquals(0, lst.size());
2479 assertEquals(0, lst.size());
2483 assertEquals(2, lst.size());
2486 assertEquals(1, lst.size());
2489 assertEquals(1, lst.size());
2497 ArrayList<Vertex> libFrags =
new ArrayList<Vertex>();
2504 SmilesParser parser =
new SmilesParser(
builder);
2505 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
2507 IAtomContainer mol = parser.parseSmiles(
"CC");
2509 sdg.generateCoordinates(mol);
2518 IAtomContainer mol1 = parser.parseSmiles(
"CCC");
2520 sdg.generateCoordinates(mol1);
2525 libFrags.add(frag1);
2527 IAtomContainer mol2 = parser.parseSmiles(
"CCCC");
2529 sdg.generateCoordinates(mol2);
2534 libFrags.add(frag2);
2536 IAtomContainer mol3 = parser.parseSmiles(
"CCCCC");
2538 sdg.generateCoordinates(mol3);
2544 libFrags.add(frag3);
2547 HashMap<APClass,ArrayList<APClass>> cpMap =
2548 new HashMap<APClass,ArrayList<APClass>>();
2549 cpMap.put(apcB,
new ArrayList<APClass>(Arrays.asList(apcA)));
2550 cpMap.put(apcC,
new ArrayList<APClass>(Arrays.asList(apcD)));
2554 new ArrayList<Vertex>(),
2556 new ArrayList<Vertex>(),
2558 new HashMap<APClass,APClass>(),
2559 new HashSet<APClass>(),
2560 new HashMap<
APClass,ArrayList<APClass>>());
2565 assertEquals(4, lst.size());
2569 assertEquals(8, lst.size());
2573 assertEquals(1, lst.size());
General set of constants used in DENOPTIM.
static final String DUMMYATMSYMBOL
Symbol of dummy atom.
Class defining a space of building blocks.
void appendVertexToLibrary(Vertex v, Vertex.BBType bbt, ArrayList< Vertex > library)
Takes a vertex and add it to a given library.
void setAPclassBasedApproach(boolean useAPC)
Set the fragment space to behave according to APClass-based approach.
static Vertex getPolarizedRCV(boolean polarity)
Returns a newly-built vertex that can play the role of a ring-closing vertex even when working with 3...
void setSymmConstraints(HashMap< APClass, Double > map)
ArrayList< Vertex > getScaffoldLibrary()
ArrayList< Vertex > getFragmentLibrary()
Parameters defining the fragment space.
Helper methods for the genetic algorithm.
static CandidateSource pickNewCandidateGenerationMode(double xoverWeight, double mutWeight, double newWeight, Randomizer randomizer)
Takes a decision on which CandidateSource method to use for generating a new Candidate.
static int chooseNumberOfSitesToMutate(double[] multiSiteMutationProb, double hit)
Takes a decision on how many sites to mutate on a candidate.
static Candidate buildCandidateByXOver(List< Candidate > eligibleParents, Population population, Monitor mnt, GAParameters settings)
Generates a new offspring by performing a crossover operation.
static DGraph makeGraphFromFragmentationOfMol(IAtomContainer mol, List< CuttingRule > cuttingRules, Logger logger, ScaffoldingPolicy scaffoldingPolicy)
Converts a molecule into a DGraph by fragmentation and re-assembling of the fragments.
static List< Vertex > getUsableAliphaticBridges(APClass apcA, APClass apcB, int[] allowedLengths, FragmentSpace fragSpace)
Finds all vertexes that can be used as aliphatic bridge.
static double getCrowdingProbability(AttachmentPoint ap, GAParameters settings)
Calculated the probability of using and attachment point rooted on an atom that is holding other atta...
static List< List< RelatedAPPair > > searchRingFusionSites(DGraph graph, GAParameters gaParams)
static DGraph buildGraph(GAParameters settings)
Graph construction starts with selecting a random core/scaffold.
static List< Vertex > getUsableAromaticBridges(String elInIncomingFrag, int[] allowedLengths, FragmentSpace fragSpace)
Finds all vertexes that can be used as aromatic bridge, i.e., can be used to create an aromatic ring ...
static Vertex selectNonScaffoldNonCapVertex(DGraph g, Randomizer randomizer)
Chose randomly a vertex that is neither scaffold or capping group.
void testMakeGraphFromFragmentationOfMol()
void testCandidateGenerationMethodReproducibility()
FragmentSpaceParameters prepare()
void testGetUsableAromaticBridges()
void testSearchForApPairsSuitableToRingFusion()
static void replaceHatomWithAP(Fragment frag, int srcId, APClass apc)
void testBuildByXOver_SubGraph()
void testCrowdingProbability()
void testFusionSiteDetection_ImposeSymmetry()
void testSelectNonScaffoldNonCapVertex()
void testMakeGraphFromFragmentationOfMol_symmetry()
Test the detection of "some" symmetry.
void testCandidateGenerationMethod()
void testMakeGraphFromFragmentationOfMol_linearities()
void testMakeGraphFromFragmentationOfMol_Symmetry()
IChemObjectBuilder builder
Private builder of atom containers.
void testAvoidRedundantXOver()
void testChooseNumberOfSitesToMutate()
void testBuildGraphFromTemplateScaffold()
void testMakeGraphFromFragmentationOfMol_cappingGroups()
void testMakeGraphFromFragmentationOfMol_ScaffoldingPolicy()
void testGetUsableAliphaticBridges()
void testBuildByXOver_Embedded_Free()
NB: the graphs from methods getPairOfTestGraphsB() and getPairOfTestGraphsBxo() and getPairOfTestGr...
void testBuildByXOver_Embedded_FixedStructure()
void testBuildByXOver_Embedded_FreeBackwards()
NB: the graphs from methods getPairOfTestGraphsB() and getPairOfTestGraphsBxo() and getPairOfTestGr...
A collection of candidates.
static GAParameters prepare()
static DGraph[] getPairOfTestGraphsBxoxo()
Builds a pair of graphs that contain templates with ContractLevel#FREE contract.
static DGraph makeGraphE()
Produced a graph like this:
static DGraph[] getPairOfTestGraphsB()
Builds a pair of graphs that contain templates with ContractLevel#FREE contract.
static DGraph[] getPairOfTestGraphsBxo()
Builds a pair of graphs that contain templates with ContractLevel#FREE contract.
static DGraph makeGraphA()
Produced a graph like this:
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....
A candidate is the combination of a denoptim graph with molecular representation and may include also...
void setFitness(double fitness)
Container for the list of vertices and the edges that connect them.
Vertex getVertexWithId(long vid)
Searches for a vertex with the given identifier.
int getSymmetricSetCount()
Returns the number of symmetric sets of vertices.
ArrayList< AttachmentPoint > getAttachmentPoints()
Returns the list of all attachment points contained in this graph.
boolean isIsomorphicTo(DGraph other)
Checks if this graph is "DENOPTIM-isomorphic" to the other one given.
void addVertex(Vertex vertex)
Appends a vertex to this graph without creating any edge.
DGraph embedPatternsInTemplates(GraphPattern pattern, FragmentSpace fragSpace)
Searches for the given pattern type and generated a new graph where each set of (clones of) vertexes ...
void getChildrenTree(Vertex vertex, List< Vertex > children)
Gets all the children of the current vertex recursively.
Iterator< SymmetricVertexes > getSymSetsIterator()
Get an iterator for the sets of symmetrically related vertices.
Vertex getVertexAtPosition(int pos)
Returns the vertex that is in the given position of the list of vertices belonging to this graph.
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()
DGraph clone()
Returns almost "deep-copy" of this graph.
void removeCappingGroups(List< Vertex > lstVerts)
Remove capping groups that belong to this graph and are in the given list.
boolean sameAs(DGraph other, StringBuilder reason)
Compare this and another graph ignoring the vertex IDs.
SymmetricVertexes getSymSetForVertex(Vertex v)
Returns the set of vertexes symmetric to the given one.
boolean isIsostructuralTo(DGraph other)
Checks if this graph is "DENOPTIM-isostructural" to the other one given.
Unit test for DENOPTIMGraph.
static DGraph makeTestGraphA()
Build a graph meant to be used in unit tests.
An empty vertex has the behaviors of a vertex, but has no molecular structure.
void addAP()
Adds an attachment point with no APClass or other attribute.
Class representing a continuously connected portion of chemical object holding attachment points.
List< IAtom > getConnectedAtomsList(IAtom atom)
void addAP(int atomPositionNumber)
Adds an attachment point with a dummy APClass.
List< AttachmentPoint > getAttachmentPoints()
IAtom getAtom(int number)
void removeAtom(IAtom atom)
A collection of Vertexs that are related by a relation that we call "symmetry", even though this clas...
ContractLevel getContractLevel()
Returns the contract level of this template, i.e., to what extent the content of this template can be...
List< Vertex > getMutationSites(List< MutationType > ignoredTypes)
A list of mutation sites from within this vertex.
void setContractLevel(ContractLevel contract)
Imposes the given contract to this template.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
void setVertexId(long vertexId2)
Vertex.BBType getBuildingBlockType()
void setAsRCV(boolean isRCV)
void setBuildingBlockId(int buildingBlockId)
void setBuildingBlockType(Vertex.BBType buildingBlockType)
abstract IAtomContainer getIAtomContainer()
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.
Parameters and setting related to handling ring closures.
Utility methods for input/output.
static ArrayList< IAtomContainer > readSDFFile(String fileName)
Reads a file containing multiple molecules (multiple SD format))
static void writeData(String fileName, String data, boolean append)
Write text-like data file.
A collection of counters user to count actions taken by the evolutionary algorithm.
void setParameters(RunTimeParameters otherParams)
Logger getLogger()
Get the name of the program specific logger.
Parameters for genetic algorithm.
A cutting rule with three SMARTS queries (atom 1, bond, atom2) and options.
Utilities for molecule conversion.
static String getSymbolOrLabel(IAtom atm)
Gets either the elemental symbol (for standard atoms) of the label (for pseudo-atoms).
static void explicitHydrogens(IAtomContainer mol)
Converts all the implicit hydrogens to explicit.
static Point3d getPoint3d(IAtom atm)
Return the 3D coordinates, if present.
Tool to generate random numbers and random decisions.
Defines how to define the scaffold vertex of a graph.
A chosen method for generation of new Candidates.
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.
FIXED
Inner graphs are effectively equivalent to the Fragment class, as no change in the inner structure is...
FIXED_STRUCT
Inner graph keep the same structure, but the identify of vertices can change.
The type of building block.