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);
351 gaparams.maxXoverEndPointsCombinations = 100;
352 gaparams.maxXoverEndPointsPermutations = 100;
353 gaparams.maxAPMappingCombinations = 100;
354 gaparams.maxCompatibleVrtxPairs = 100;
371 ArrayList<Candidate> eligibleParents =
new ArrayList<Candidate>();
372 eligibleParents.add(cA);
373 eligibleParents.add(cB);
378 population, mnt,
new int[]{0,1}, 8, 0, gaparams);
381 population, mnt,
new int[]{0,1}, 8, 1, gaparams);
387 DGraph expected0 = expectedPair[0];
388 DGraph expected1 = expectedPair[1];
394 assertTrue(expected0.
sameAs(g0xo,
new StringBuilder()));
395 assertTrue(expected1.
sameAs(g1xo,
new StringBuilder()));
430 ArrayList<Candidate> eligibleParents =
new ArrayList<Candidate>();
431 eligibleParents.add(cA);
432 eligibleParents.add(cB);
437 population, mnt,
new int[]{0,1}, 17, 0, gaparams);
440 population, mnt,
new int[]{0,1}, 17, 1, gaparams);
446 DGraph expected0 = expectedPair[0];
447 DGraph expected1 = expectedPair[1];
453 assertTrue(expected0.
sameAs(g0xo,
new StringBuilder()));
454 assertTrue(expected1.
sameAs(g1xo,
new StringBuilder()));
463 gaparams.maxXoverEndPointsCombinations = 100;
464 gaparams.maxXoverEndPointsPermutations = 100;
465 gaparams.maxAPMappingCombinations = 100;
466 gaparams.maxCompatibleVrtxPairs = 100;
481 String propName =
"uniquefier";
485 v.setUniquefyingProperty(propName);
486 v.setProperty(propName, i);
494 ArrayList<Candidate> eligibleParents =
new ArrayList<Candidate>();
495 eligibleParents.add(cA);
496 eligibleParents.add(cB);
499 boolean embeddedGraphHasBeenAlteredA =
false;
500 boolean embeddedGraphHasBeenAlteredB =
false;
501 for (
int ixo=0; ixo<11; ixo++)
508 population, mnt,
new int[]{0,1}, ixo, 0, gaparams);
510 population, mnt,
new int[]{0,1}, ixo, 1, gaparams);
511 }
catch (IndexOutOfBoundsException e)
513 if (e.getMessage().contains(
"Index 10 out of bounds"))
552 embeddedGraphHasBeenAlteredA =
true;
557 embeddedGraphHasBeenAlteredB =
true;
566 assertTrue(embeddedGraphHasBeenAlteredA);
567 assertTrue(embeddedGraphHasBeenAlteredB);
575 int ix = 0, im=0, ic=0, tot=1000;
576 double wx = 2, wm = 0.6, wc=0.05;
577 double wtot = wx + wm + wc;
579 for (
int i=0; i<tot; i++)
595 assertTrue(
false,
"Unexpected generation mode "+mode);
599 double x = ((double)ix) / tot;
600 double m = ((double)im) / tot;
601 double c = ((double)ic) / tot;
605 assertTrue(Math.abs(x-(wx/wtot)) < thld,
"#Xover cases are off!");
606 assertTrue(Math.abs(m-(wm/wtot)) < thld,
"#Mutation cases are off!");
607 assertTrue(Math.abs(
c-(wc/wtot)) < thld,
"#Built cases are off!");
617 long otherSeed = 987654321;
618 double wx = 2, wm = 0.6, wc=0.05;
621 List<CandidateSource> resultsA =
new ArrayList<CandidateSource>();
622 for (
int i=0; i<tot; i++)
628 List<CandidateSource> resultsB =
new ArrayList<CandidateSource>();
629 for (
int i=0; i<tot; i++)
635 List<CandidateSource> resultsC =
new ArrayList<CandidateSource>();
636 for (
int i=0; i<tot; i++)
641 boolean different =
false;
642 for (
int i=0; i<tot; i++)
644 if (resultsA.get(i) != resultsB.get(i))
650 assertTrue(different);
652 for (
int i=0; i<tot; i++)
654 assertEquals(resultsA.get(i),resultsC.get(i),
655 "Inconsistent sequence of random decisions");
670 assertTrue(Math.abs(1.0 - p)<t,
671 "Scheme 3 should return always 1.0 but was "+p);
675 assertTrue(Math.abs(1.0 - p)<t,
"Scheme 0 on ap3: 1.0 != "+p);
677 assertTrue(Math.abs(1.0 - p)<t,
"Scheme 1 on ap3: 1.0 != "+p);
679 assertTrue(Math.abs(1.0 - p)<t,
"Scheme 2 on ap3: 1.0 != "+p);
683 assertTrue(Math.abs(0.5 - p)<t,
"Scheme 2 on ap2");
729 for (
int i=0; i<5; i++)
732 assertEquals(expected, chosen,
"Index of the only choosable vertex");
741 double[] weights =
new double[] {0,0,0,0,1};
745 weights =
new double[] {1,0,0,0,1};
749 weights =
new double[] {1,1,1,1,1};
768 assertTrue(
tempDir.isDirectory(),
"Should be a directory ");
769 String structureFile =
tempDir.getAbsolutePath() +
SEP +
"mol.sdf";
772 +
" OpenBabel03302310043D" +
NL
774 +
" 33 35 0 0 0 0 0 0 0 0999 V2000" +
NL
775 +
" -1.5455 1.4965 3.4529 O 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
776 +
" -1.1783 1.0876 2.3182 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
777 +
" -1.8597 -0.0221 1.6796 N 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
778 +
" -3.0535 -0.6083 2.2978 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
779 +
" 0.0153 1.7383 1.6547 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
780 +
" -0.1038 1.5947 0.1342 C 0 0 1 0 0 0 0 0 0 0 0 0" +
NL
781 +
" 0.9646 2.2439 -0.5585 O 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
782 +
" 2.0315 1.3700 -0.8940 C 0 0 2 0 0 0 0 0 0 0 0 0" +
NL
783 +
" 3.0842 2.1330 -1.6910 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
784 +
" 3.5659 3.1894 -0.9391 F 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
785 +
" 4.1344 1.2898 -2.0067 F 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
786 +
" 2.5295 2.6237 -2.8597 F 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
787 +
" 1.5529 0.2692 -1.6691 O 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
788 +
" 0.4699 -0.4528 -1.1881 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
789 +
" -0.3192 0.1414 -0.2151 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
790 +
" -1.2683 -0.6053 0.4932 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
791 +
" -1.5222 -1.9320 0.0906 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
792 +
" -0.8092 -2.5038 -0.9766 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
793 +
" -1.1169 -3.8201 -1.3518 O 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
794 +
" -0.4725 -4.5263 -2.4070 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
795 +
" 0.2040 -1.7556 -1.6127 C 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
796 +
" -3.7666 -0.9444 1.5155 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
797 +
" -3.5865 0.1389 2.9228 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
798 +
" -2.7606 -1.4709 2.9321 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
799 +
" 0.9449 1.2474 2.0144 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
800 +
" 0.0550 2.8163 1.9227 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
801 +
" -1.0337 2.1265 -0.1667 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
802 +
" 2.5075 0.9860 0.0372 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
803 +
" -2.2462 -2.5403 0.6157 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
804 +
" -0.6162 -3.9902 -3.3689 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
805 +
" -0.9204 -5.5374 -2.4930 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
806 +
" 0.6107 -4.6349 -2.1878 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
807 +
" 0.8117 -2.1861 -2.3969 H 0 0 0 0 0 0 0 0 0 0 0 0" +
NL
808 +
" 1 2 2 0 0 0 0" +
NL
809 +
" 2 3 1 0 0 0 0" +
NL
810 +
" 2 5 1 0 0 0 0" +
NL
811 +
" 3 4 1 0 0 0 0" +
NL
812 +
" 4 22 1 0 0 0 0" +
NL
813 +
" 4 23 1 0 0 0 0" +
NL
814 +
" 4 24 1 0 0 0 0" +
NL
815 +
" 5 6 1 0 0 0 0" +
NL
816 +
" 5 25 1 0 0 0 0" +
NL
817 +
" 5 26 1 0 0 0 0" +
NL
818 +
" 6 7 1 0 0 0 0" +
NL
819 +
" 6 27 1 6 0 0 0" +
NL
820 +
" 7 8 1 0 0 0 0" +
NL
821 +
" 8 9 1 0 0 0 0" +
NL
822 +
" 8 13 1 0 0 0 0" +
NL
823 +
" 8 28 1 1 0 0 0" +
NL
824 +
" 9 10 1 0 0 0 0" +
NL
825 +
" 9 11 1 0 0 0 0" +
NL
826 +
" 9 12 1 0 0 0 0" +
NL
827 +
" 13 14 1 0 0 0 0" +
NL
828 +
" 14 15 2 0 0 0 0" +
NL
829 +
" 15 16 1 0 0 0 0" +
NL
830 +
" 15 6 1 0 0 0 0" +
NL
831 +
" 16 17 2 0 0 0 0" +
NL
832 +
" 16 3 1 0 0 0 0" +
NL
833 +
" 17 18 1 0 0 0 0" +
NL
834 +
" 17 29 1 0 0 0 0" +
NL
835 +
" 18 19 1 0 0 0 0" +
NL
836 +
" 18 21 2 0 0 0 0" +
NL
837 +
" 19 20 1 0 0 0 0" +
NL
838 +
" 20 30 1 0 0 0 0" +
NL
839 +
" 20 31 1 0 0 0 0" +
NL
840 +
" 20 32 1 0 0 0 0" +
NL
841 +
" 21 14 1 0 0 0 0" +
NL
842 +
" 21 33 1 0 0 0 0" +
NL
848 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
849 cuttingRules.add(
new CuttingRule(
"cC",
"[c]",
"[C]",
"~", 0,
850 new ArrayList<String>()));
851 cuttingRules.add(
new CuttingRule(
"cN",
"[c]",
"[#7]",
"~", 1,
852 new ArrayList<String>()));
853 cuttingRules.add(
new CuttingRule(
"cO",
"[c]",
"[#8]",
"~", 2,
854 new ArrayList<String>()));
855 cuttingRules.add(
new CuttingRule(
"OC",
"[O]",
"[C]",
"-", 3,
856 new ArrayList<String>()));
857 cuttingRules.add(
new CuttingRule(
"CF",
"[C]",
"[F]",
"-", 4,
858 new ArrayList<String>()));
859 cuttingRules.add(
new CuttingRule(
"NC",
"[N]",
"[C]",
"-", 5,
860 new ArrayList<String>()));
883 .collect(Collectors.toList());
884 assertEquals(1, templates.size());
897 SmilesParser p =
new SmilesParser(
builder);
898 IAtomContainer mol = p.parseSmiles(
"c1ccccc1OCN(CC)(C)[Ru](N)(N)C#O");
902 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
903 cuttingRules.add(
new CuttingRule(
"C-O",
"[#6]",
"[#8]",
"-", 2,
904 new ArrayList<String>()));
905 cuttingRules.add(
new CuttingRule(
"N-C",
"[#7]",
"[#6]",
"-", 5,
906 new ArrayList<String>()));
907 cuttingRules.add(
new CuttingRule(
"Ru-Any",
"[Ru]",
"[$([*])]",
"~", 5,
908 new ArrayList<String>()));
920 .collect(Collectors.toList());
921 assertEquals(1, scaffolds.size());
922 Vertex scaffold = scaffolds.get(0);
924 assertEquals(6, iacScaffold.getAtomCount());
930 cuttingRules, settings.
getLogger(), policy);
938 .collect(Collectors.toList());
939 assertEquals(1, scaffolds.size());
940 scaffold = scaffolds.get(0);
942 assertEquals(1, iacScaffold.getAtomCount());
943 assertEquals(
"Ru", iacScaffold.getAtom(0).getSymbol());
951 SmilesParser p =
new SmilesParser(
builder);
952 IAtomContainer mol = p.parseSmiles(
953 "Oc1cc(O)cc(O)c1CN(CC)(CC)[Ru](N)(Nc1c(F)cc(F)cc1(Cl))C#O");
957 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
958 cuttingRules.add(
new CuttingRule(
"C-F",
"[#6]",
"[#9]",
"-", 1,
959 new ArrayList<String>()));
960 cuttingRules.add(
new CuttingRule(
"C-O",
"[#6]",
"[#8]",
"-", 2,
961 new ArrayList<String>()));
962 cuttingRules.add(
new CuttingRule(
"N-C",
"[#7]",
"[#6]",
"-", 5,
963 new ArrayList<String>()));
964 cuttingRules.add(
new CuttingRule(
"Ru-Any",
"[Ru]",
"[$([*])]",
"~", 5,
965 new ArrayList<String>()));
975 boolean foundO =
false;
976 boolean foundF =
false;
978 while (iter.hasNext())
981 String el = ss.get(0).getIAtomContainer().getAtom(0).getSymbol();
984 else if (
"F".equals(el))
994 cuttingRules, settings.
getLogger(), policy);
1003 while (iter.hasNext())
1006 String el = ss.get(0).getIAtomContainer().getAtom(0).getSymbol();
1009 else if (
"F".equals(el))
1020 cuttingRules, settings.
getLogger(), policy);
1029 while (iter.hasNext())
1032 String el = ss.get(0).getIAtomContainer().getAtom(0).getSymbol();
1035 else if (
"F".equals(el))
1039 assertFalse(foundF);
1048 SmilesParser p =
new SmilesParser(
builder);
1049 IAtomContainer mol = p.parseSmiles(
"C#C-C#C-C#N");
1052 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
1053 sdg.generateCoordinates(mol);
1057 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
1058 cuttingRules.add(
new CuttingRule(
"C-C",
"[#6]",
"[#6]",
"-", 2,
1059 new ArrayList<String>()));
1060 cuttingRules.add(
new CuttingRule(
"C-X",
"[#6]",
"[#9,#17,#35,#53]",
"~",
1061 3,
new ArrayList<String>()));
1074 for (IAtom
a : v.getIAtomContainer().atoms())
1082 assertEquals(4, duAtmCount);
1085 IAtomContainer molNonLinear = p.parseSmiles(
"C(Cl)(F)Br");
1086 sdg.generateCoordinates(molNonLinear);
1098 for (IAtom
a : v.getIAtomContainer().atoms())
1106 assertEquals(0, duAtmCount);
1120 for (IAtom
a : v.getIAtomContainer().atoms())
1128 assertEquals(0, duAtmCount);
1144 SmilesParser p =
new SmilesParser(
builder);
1145 IAtomContainer mol = p.parseSmiles(
1146 "P123C(OC[SiH2]O1)(OC[SiH2]O2)OC[SiH2]O3");
1149 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
1150 cuttingRules.add(
new CuttingRule(
"PC-O",
"[$(CP)]",
"[O]",
"-", -1,
1151 new ArrayList<String>()));
1152 cuttingRules.add(
new CuttingRule(
"C-O",
"[C]",
"[O]",
"-", 0,
1153 new ArrayList<String>()));
1154 cuttingRules.add(
new CuttingRule(
"C-Si",
"[C]",
"[Si]",
"-", 1,
1155 new ArrayList<String>()));
1156 cuttingRules.add(
new CuttingRule(
"Si-O",
"[Si]",
"[O]",
"-", 2,
1157 new ArrayList<String>()));
1158 cuttingRules.add(
new CuttingRule(
"P-C",
"[P]",
"[C]",
"-", 3,
1159 new ArrayList<String>()));
1160 cuttingRules.add(
new CuttingRule(
"P-O",
"[P]",
"[O]",
"-", 4,
1161 new ArrayList<String>()));
1164 scaffoldOnP.label =
"P";
1170 List<List<Integer>> expected =
new ArrayList<List<Integer>>();
1171 expected.add(Arrays.asList(3, 9, 15));
1172 expected.add(Arrays.asList(5, 11, 17));
1173 expected.add(Arrays.asList(7, 13, 19));
1174 expected.add(Arrays.asList(4, 10, 16));
1175 expected.add(Arrays.asList(2, 8, 14));
1176 expected.add(Arrays.asList(6, 12, 18));
1177 for (List<Integer> vrtxIDs : expected)
1181 assertFalse(sv0.isEmpty());
1182 for (
int i=1; i<vrtxIDs.size(); i++)
1186 assertTrue(sv0 == svI);
1190 IAtomContainer mol2 = p.parseSmiles(
1191 "C1C(C(C(F)(F)(F))(C(F)(F)(F)))OCCC1((N(C([H])([H])C3=C"
1192 +
"(C(=C(C(=C3[H])[H])[F])[F]))(C([H])([H])C3=C(C(=C(C"
1193 +
"(=C3[H])[H])[F])[F]))))");
1195 cuttingRules =
new ArrayList<CuttingRule>();
1196 cuttingRules.add(
new CuttingRule(
"C-C",
"[#6]",
"[#6]",
"-!@", -1,
1197 new ArrayList<String>()));
1198 cuttingRules.add(
new CuttingRule(
"C-X",
"[#6]",
"[#9]",
"-", 0,
1199 new ArrayList<String>()));
1200 cuttingRules.add(
new CuttingRule(
"C-N",
"[#6]",
"[N]",
"-", 1,
1201 new ArrayList<String>()));
1210 expected =
new ArrayList<List<Integer>>();
1211 expected.add(Arrays.asList(11, 15));
1212 expected.add(Arrays.asList(2, 6));
1213 expected.add(Arrays.asList(3, 4, 5, 7, 8, 9));
1214 expected.add(Arrays.asList(13, 14, 17, 18));
1215 expected.add(Arrays.asList(12, 16));
1216 for (List<Integer> vrtxIDs : expected)
1220 assertFalse(sv0.isEmpty());
1221 for (
int i=1; i<vrtxIDs.size(); i++)
1225 assertTrue(sv0 == svI);
1238 SmilesParser p =
new SmilesParser(
builder);
1239 IAtomContainer mol = p.parseSmiles(
"Cc1cnc(Cl)cc1O");
1243 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
1244 sdg.generateCoordinates(mol);
1248 List<CuttingRule> cuttingRules =
new ArrayList<CuttingRule>();
1249 cuttingRules.add(
new CuttingRule(
"sAr",
"[c]",
"[*]",
"-", 2,
1250 new ArrayList<String>()));
1251 cuttingRules.add(
new CuttingRule(
"Ox",
"[O]",
"[*]",
"-", 3,
1252 new ArrayList<String>()));
1258 capH.
addAtom(
new Atom(
"H",
new Point3d()));
1259 capH.
addAP(0, hyd1,
new Point3d(1.0,0,0));
1261 ArrayList<Vertex> cappingGroups =
new ArrayList<Vertex>();
1262 cappingGroups.add(capH);
1264 HashMap<APClass, APClass> capMap =
new HashMap<APClass, APClass>();
1265 capMap.put(sAr0, hyd1);
1266 capMap.put(ox0, hyd1);
1270 new ArrayList<Vertex>(),
1271 new ArrayList<Vertex>(),
1273 new HashMap<
APClass,ArrayList<APClass>>(),
1275 new HashSet<APClass>(),
1276 new HashMap<
APClass,ArrayList<APClass>>());
1317 Logger logger = Logger.getLogger(
"DummyLogger");
1321 HashMap<APClass,APClass> capMap =
new HashMap<APClass,APClass>();
1322 capMap.put(apcA,hyd);
1323 capMap.put(apcB,hyd);
1324 capMap.put(apcC,hyd);
1325 capMap.put(apcD,hyd);
1326 capMap.put(apcE,hyd);
1327 capMap.put(apcF,hyd);
1328 capMap.put(apcG,hyd);
1329 capMap.put(apcNotFusable,hyd);
1331 ArrayList<Vertex> cappingGroups =
new ArrayList<Vertex>();
1333 capH.
addAtom(
new Atom(
"H",
new Point3d()));
1334 capH.
addAP(0,
new Point3d(1.0, 0, 0), hyd);
1335 cappingGroups.add(capH);
1338 HashMap<APClass,ArrayList<APClass>> rcCMap =
1339 new HashMap<APClass,ArrayList<APClass>>();
1340 rcCMap.put(apcA,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1341 rcCMap.put(apcB,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1342 rcCMap.put(apcC,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1343 rcCMap.put(apcD,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1344 rcCMap.put(apcE,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1345 rcCMap.put(apcF,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1346 rcCMap.put(apcG,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
1351 new ArrayList<Vertex>(),
1352 new ArrayList<Vertex>(),
1354 new HashMap<
APClass,ArrayList<APClass>>(),
1355 capMap,
new HashSet<APClass>(),
1364 SmilesParser parser =
new SmilesParser(
builder);
1365 IAtomContainer mol = parser.parseSmiles(
"c1ccccc1");
1367 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
1368 sdg.generateCoordinates(mol);
1378 graph, fragSpace, rcParams,
false, logger, rng);
1380 assertEquals(1, combinations.size());
1381 assertEquals(1, combinations.get(0).size());
1382 assertEquals(2, combinations.get(0).get(0).apA.getIndexInOwner());
1383 assertEquals(3, combinations.get(0).get(0).apB.getIndexInOwner());
1390 parser =
new SmilesParser(
builder);
1391 mol = parser.parseSmiles(
"c1ccccc1");
1393 sdg.generateCoordinates(mol);
1395 for (
int i= 0; i<6; i++)
1403 graph, fragSpace, rcParams,
false, logger, rng);
1405 assertEquals(6, combinations.size());
1406 Set<AttachmentPoint> involvedAPs =
new HashSet<AttachmentPoint>();
1407 for (List<RelatedAPPair> comb : combinations)
1409 assertEquals(1, comb.size());
1415 involvedAPs.add(pair.
apA);
1416 involvedAPs.add(pair.
apB);
1418 assertEquals(6, involvedAPs.size());
1430 assertEquals(2, combinations.size());
1431 involvedAPs =
new HashSet<AttachmentPoint>();
1432 for (List<RelatedAPPair> comb : combinations)
1434 assertEquals(3, comb.size());
1435 involvedAPs =
new HashSet<AttachmentPoint>();
1438 involvedAPs.add(pair.apA);
1439 involvedAPs.add(pair.apB);
1442 assertEquals(6, involvedAPs.size());
1460 mol = parser.parseSmiles(
"c1ccccc1c1ccccc1");
1462 sdg.generateCoordinates(mol);
1478 assertEquals(6, combinations.size());
1479 int[] apUsageCounts =
new int[8];
1480 for (List<RelatedAPPair> comb : combinations)
1482 assertEquals(1, comb.size());
1485 apUsageCounts[pair.apA.getIndexInOwner()] =
1486 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1487 apUsageCounts[pair.apB.getIndexInOwner()] =
1488 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1491 assertEquals(1, apUsageCounts[0]);
1492 assertEquals(2, apUsageCounts[1]);
1493 assertEquals(2, apUsageCounts[2]);
1494 assertEquals(2, apUsageCounts[3]);
1495 assertEquals(1, apUsageCounts[4]);
1496 assertEquals(1, apUsageCounts[5]);
1497 assertEquals(2, apUsageCounts[6]);
1498 assertEquals(1, apUsageCounts[7]);
1516 assertEquals(5, combinations.size());
1517 apUsageCounts =
new int[8];
1518 int[] sizesCount =
new int[4];
1519 for (List<RelatedAPPair> comb : combinations)
1521 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1524 apUsageCounts[pair.apA.getIndexInOwner()] =
1525 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1526 apUsageCounts[pair.apB.getIndexInOwner()] =
1527 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1530 assertEquals(2, apUsageCounts[0]);
1531 assertEquals(3, apUsageCounts[1]);
1532 assertEquals(2, apUsageCounts[2]);
1533 assertEquals(3, apUsageCounts[3]);
1534 assertEquals(2, apUsageCounts[4]);
1535 assertEquals(1, apUsageCounts[5]);
1536 assertEquals(2, apUsageCounts[6]);
1537 assertEquals(1, apUsageCounts[7]);
1538 assertEquals(0, sizesCount[0]);
1539 assertEquals(2, sizesCount[1]);
1540 assertEquals(3, sizesCount[2]);
1541 assertEquals(0, sizesCount[3]);
1557 mol = parser.parseSmiles(
"c1ccccc1Oc1ccccc1");
1559 sdg.generateCoordinates(mol);
1576 assertEquals(7, combinations.size());
1577 apUsageCounts =
new int[11];
1578 sizesCount =
new int[4];
1579 for (List<RelatedAPPair> comb : combinations)
1581 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1584 apUsageCounts[pair.apA.getIndexInOwner()] =
1585 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1586 apUsageCounts[pair.apB.getIndexInOwner()] =
1587 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1590 assertEquals(2, apUsageCounts[0]);
1591 assertEquals(3, apUsageCounts[1]);
1592 assertEquals(2, apUsageCounts[2]);
1593 assertEquals(3, apUsageCounts[3]);
1594 assertEquals(2, apUsageCounts[4]);
1595 assertEquals(1, apUsageCounts[5]);
1596 assertEquals(2, apUsageCounts[6]);
1597 assertEquals(2, apUsageCounts[7]);
1598 assertEquals(2, apUsageCounts[8]);
1599 assertEquals(1, apUsageCounts[9]);
1600 assertEquals(0, apUsageCounts[10]);
1601 assertEquals(0, sizesCount[0]);
1602 assertEquals(4, sizesCount[1]);
1603 assertEquals(3, sizesCount[2]);
1604 assertEquals(0, sizesCount[3]);
1621 mol = parser.parseSmiles(
"c1ccccc1c1ccccc1");
1623 sdg.generateCoordinates(mol);
1640 assertEquals(12, combinations.size());
1641 apUsageCounts =
new int[10];
1642 sizesCount =
new int[4];
1643 for (List<RelatedAPPair> comb : combinations)
1645 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1648 apUsageCounts[pair.apA.getIndexInOwner()] =
1649 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1650 apUsageCounts[pair.apB.getIndexInOwner()] =
1651 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1654 assertEquals(3, apUsageCounts[0]);
1655 assertEquals(2, apUsageCounts[1]);
1656 assertEquals(2, apUsageCounts[2]);
1657 assertEquals(2, apUsageCounts[3]);
1658 assertEquals(3, apUsageCounts[4]);
1659 assertEquals(3, apUsageCounts[5]);
1660 assertEquals(2, apUsageCounts[6]);
1661 assertEquals(2, apUsageCounts[7]);
1662 assertEquals(2, apUsageCounts[8]);
1663 assertEquals(3, apUsageCounts[9]);
1664 assertEquals(0, sizesCount[0]);
1665 assertEquals(12, sizesCount[1]);
1666 assertEquals(0, sizesCount[2]);
1667 assertEquals(0, sizesCount[3]);
1675 graph, fragSpace, rcParams,
true, logger, rng);
1677 assertEquals(8, combinations.size());
1678 apUsageCounts =
new int[10];
1679 sizesCount =
new int[4];
1680 for (List<RelatedAPPair> comb : combinations)
1682 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1685 apUsageCounts[pair.apA.getIndexInOwner()] =
1686 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1687 apUsageCounts[pair.apB.getIndexInOwner()] =
1688 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1691 assertEquals(4, apUsageCounts[0]);
1692 assertEquals(3, apUsageCounts[1]);
1693 assertEquals(2, apUsageCounts[2]);
1694 assertEquals(3, apUsageCounts[3]);
1695 assertEquals(4, apUsageCounts[4]);
1696 assertEquals(4, apUsageCounts[5]);
1697 assertEquals(3, apUsageCounts[6]);
1698 assertEquals(2, apUsageCounts[7]);
1699 assertEquals(3, apUsageCounts[8]);
1700 assertEquals(4, apUsageCounts[9]);
1701 assertEquals(0, sizesCount[0]);
1702 assertEquals(0, sizesCount[1]);
1703 assertEquals(8, sizesCount[2]);
1704 assertEquals(0, sizesCount[3]);
1731 mol = parser.parseSmiles(
"o1cccc1c1cc2c(cc1)c[n+]3c(c2)Nc(c3)[Ru]c1ccc(cc1)c1ccc(cc1)[Ru]c1ccc(N1)c1cnN(c1)");
1733 sdg.generateCoordinates(mol);
1763 graph, fragSpace, rcParams,
false, logger, rng);
1765 assertEquals(17, combinations.size());
1766 apUsageCounts =
new int[18];
1767 sizesCount =
new int[4];
1768 Map<String,Integer> countTypes =
new HashMap<String,Integer>();
1769 for (List<RelatedAPPair> comb : combinations)
1771 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
1774 apUsageCounts[pair.apA.getIndexInOwner()] =
1775 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1776 apUsageCounts[pair.apB.getIndexInOwner()] =
1777 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1778 if (countTypes.containsKey(pair.propID))
1779 countTypes.put(pair.propID, countTypes.get(pair.propID)+1);
1781 countTypes.put(pair.propID, 1);
1784 assertEquals(1, apUsageCounts[0]);
1785 assertEquals(2, apUsageCounts[1]);
1786 assertEquals(3, apUsageCounts[2]);
1787 assertEquals(2, apUsageCounts[3]);
1788 assertEquals(2, apUsageCounts[4]);
1789 assertEquals(2, apUsageCounts[5]);
1790 assertEquals(2, apUsageCounts[6]);
1791 assertEquals(2, apUsageCounts[7]);
1792 assertEquals(1, apUsageCounts[8]);
1793 assertEquals(1, apUsageCounts[9]);
1794 assertEquals(2, apUsageCounts[10]);
1795 assertEquals(2, apUsageCounts[11]);
1796 assertEquals(2, apUsageCounts[12]);
1797 assertEquals(2, apUsageCounts[13]);
1798 assertEquals(2, apUsageCounts[14]);
1799 assertEquals(2, apUsageCounts[15]);
1800 assertEquals(2, apUsageCounts[16]);
1801 assertEquals(2, apUsageCounts[17]);
1802 assertEquals(0, sizesCount[0]);
1803 assertEquals(17, sizesCount[1]);
1804 assertEquals(0, sizesCount[2]);
1805 assertEquals(0, sizesCount[3]);
1806 assertEquals(3, countTypes.get(
"2el2atm"));
1807 assertEquals(2, countTypes.get(
"3el3atm_6+5"));
1808 assertEquals(2, countTypes.get(
"3el3atm_6+6"));
1809 assertEquals(4, countTypes.get(
"4el4atm_6+6"));
1810 assertEquals(2, countTypes.get(
"4el4atm_6+5"));
1811 assertEquals(4, countTypes.get(
"4el4atm_5+5"));
1827 parser =
new SmilesParser(
builder);
1828 IAtomContainer molF0 = parser.parseSmiles(
"c1ccccc1");
1830 sdg.generateCoordinates(molF0);
1838 IAtomContainer molF1 = parser.parseSmiles(
"C=CC=C");
1840 sdg.generateCoordinates(molF1);
1850 IAtomContainer molF2 = parser.parseSmiles(
"N");
1852 sdg.generateCoordinates(molF2);
1859 IAtomContainer molF3 = parser.parseSmiles(
"C=CC=C");
1861 sdg.generateCoordinates(molF3);
1882 graphManyFrags.
addRing(rcvOnF1a, rcvOnF2);
1883 graphManyFrags.
addRing(rcvOnF1b, rcvOnF3);
1886 graphManyFrags, fragSpace, rcParams,
false, logger, rng);
1888 assertEquals(4, combinations.size());
1890 Map<Long,Integer> vertexUsageCounts =
new HashMap<Long,Integer>();
1891 for (List<RelatedAPPair> comb : combinations)
1895 long vIdA = pair.apA.getOwner().getVertexId();
1896 if (vertexUsageCounts.containsKey(vIdA))
1898 vertexUsageCounts.put(vIdA, vertexUsageCounts.get(vIdA)+1);
1900 vertexUsageCounts.put(vIdA,1);
1902 long vIdB = pair.apB.getOwner().getVertexId();
1903 if (vertexUsageCounts.containsKey(vIdB))
1905 vertexUsageCounts.put(vIdB, vertexUsageCounts.get(vIdB)+1);
1907 vertexUsageCounts.put(vIdB,1);
1911 assertTrue(vertexUsageCounts.containsKey(fragF0.
getVertexId()));
1913 assertEquals(4, vertexUsageCounts.get(fragF0.
getVertexId()));
1914 assertTrue(vertexUsageCounts.containsKey(fragF1.
getVertexId()));
1915 assertEquals(1, vertexUsageCounts.get(fragF1.
getVertexId()));
1916 assertTrue(vertexUsageCounts.containsKey(fragF2.
getVertexId()));
1917 assertEquals(2, vertexUsageCounts.get(fragF2.
getVertexId()));
1918 assertTrue(vertexUsageCounts.containsKey(fragF3.
getVertexId()));
1919 assertEquals(1, vertexUsageCounts.get(fragF3.
getVertexId()));
1952 mol = parser.parseSmiles(
"S1CCOCC1C1NCC(CC1)C1C=NC(C1)C1CC2C(N1)CC(CC2)"
1953 +
"(C1CC(C1)C1CC(C1)C1CCCC1)"
1954 +
"C1C(C1)C1C(C1)C1CCCC1C1C(C1)C1CCC1");
1956 sdg.generateCoordinates(mol);
1983 graph, fragSpace, rcParams,
false, logger, rng);
1985 assertEquals(27, combinations.size());
1986 apUsageCounts =
new int[20];
1987 countTypes =
new HashMap<String,Integer>();
1988 for (List<RelatedAPPair> comb : combinations)
1992 apUsageCounts[pair.apA.getIndexInOwner()] =
1993 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
1994 apUsageCounts[pair.apB.getIndexInOwner()] =
1995 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
1996 if (countTypes.containsKey(pair.propID))
1997 countTypes.put(pair.propID, countTypes.get(pair.propID)+1);
1999 countTypes.put(pair.propID, 1);
2003 assertEquals(3, apUsageCounts[0]);
2004 assertEquals(3, apUsageCounts[1]);
2005 assertEquals(6, apUsageCounts[2]);
2006 assertEquals(3, apUsageCounts[3]);
2007 assertEquals(3, apUsageCounts[4]);
2008 assertEquals(3, apUsageCounts[5]);
2009 assertEquals(3, apUsageCounts[6]);
2010 assertEquals(3, apUsageCounts[7]);
2011 assertEquals(3, apUsageCounts[8]);
2012 assertEquals(4, apUsageCounts[9]);
2013 assertEquals(3, apUsageCounts[10]);
2014 assertEquals(3, apUsageCounts[11]);
2015 assertEquals(3, apUsageCounts[12]);
2016 assertEquals(2, apUsageCounts[13]);
2017 assertEquals(1, apUsageCounts[14]);
2018 assertEquals(3, apUsageCounts[15]);
2019 assertEquals(2, apUsageCounts[16]);
2020 assertEquals(1, apUsageCounts[17]);
2021 assertEquals(1, apUsageCounts[18]);
2022 assertEquals(1, apUsageCounts[19]);
2023 assertEquals(2, countTypes.get(
"aliph2atm"));
2024 assertEquals(4, countTypes.get(
"aliph3atm"));
2025 assertEquals(6, countTypes.get(
"aliph4atm_6+6"));
2026 assertEquals(4, countTypes.get(
"aliph4atm_6+5"));
2027 assertEquals(2, countTypes.get(
"aliph4atm_6+4"));
2028 assertEquals(2, countTypes.get(
"aliph4atm_6+3"));
2029 assertEquals(2, countTypes.get(
"aliph4atm_5+5"));
2030 assertEquals(1, countTypes.get(
"aliph4atm_5+4"));
2031 assertEquals(1, countTypes.get(
"aliph4atm_5+3"));
2032 assertEquals(1, countTypes.get(
"aliph4atm_4+4"));
2033 assertEquals(1, countTypes.get(
"aliph4atm_4+3"));
2034 assertEquals(1, countTypes.get(
"aliph4atm_3+3"));
2035 assertFalse(countTypes.containsKey(
"2el2atm"));
2036 assertFalse(countTypes.containsKey(
"3el3atm_6+5"));
2037 assertFalse(countTypes.containsKey(
"4el4atm_6+6"));
2038 assertFalse(countTypes.containsKey(
"4el4atm_6+5"));
2039 assertFalse(countTypes.containsKey(
"4el4atm_5+5"));
2047 mol = parser.parseSmiles(
"C1CCCCCCCCC1");
2049 sdg.generateCoordinates(mol);
2076 graph, fragSpace, rcParams,
true, logger, rng);
2079 assertEquals(136, combinations.size());
2082 assertEquals(6, combinations.get(0).size());
2105 mol = parser.parseSmiles(
"c1c2c(ccc1)ccc3c2c(c1cc3)cNc1");
2107 sdg.generateCoordinates(mol);
2120 graph, fragSpace, rcParams,
false, logger, rng);
2122 assertEquals(2, combinations.size());
2123 apUsageCounts =
new int[6];
2124 sizesCount =
new int[3];
2125 countTypes =
new HashMap<String,Integer>();
2126 for (List<RelatedAPPair> comb : combinations)
2128 sizesCount[comb.size()] = sizesCount[comb.size()] +1;
2131 apUsageCounts[pair.apA.getIndexInOwner()] =
2132 apUsageCounts[pair.apA.getIndexInOwner()] + 1;
2133 apUsageCounts[pair.apB.getIndexInOwner()] =
2134 apUsageCounts[pair.apB.getIndexInOwner()] + 1;
2135 if (countTypes.containsKey(pair.propID))
2136 countTypes.put(pair.propID, countTypes.get(pair.propID)+1);
2138 countTypes.put(pair.propID, 1);
2141 assertEquals(1, apUsageCounts[0]);
2142 assertEquals(1, apUsageCounts[1]);
2143 assertEquals(1, apUsageCounts[2]);
2144 assertEquals(0, apUsageCounts[3]);
2145 assertEquals(1, apUsageCounts[4]);
2146 assertEquals(0, apUsageCounts[5]);
2147 assertEquals(0, sizesCount[0]);
2148 assertEquals(2, sizesCount[1]);
2149 assertEquals(0, sizesCount[2]);
2150 assertEquals(1, countTypes.get(
"3el3atm_6+6"));
2151 assertEquals(1, countTypes.get(
"5el5atm_6+6+6"));
2174 mol = parser.parseSmiles(
"c1c2c(ccc1)ccc3c2c(c1N3)cccc1");
2176 sdg.generateCoordinates(mol);
2189 graph, fragSpace, rcParams,
false, logger, rng);
2191 assertEquals(1, combinations.size());
2192 assertEquals(1, combinations.get(0).size());
2194 assertEquals(
"3el3atm_6+6", combinations.get(0).get(0).propID);
2217 mol = parser.parseSmiles(
"c1c(cccc1)c1cccc2c1cNc2");
2219 sdg.generateCoordinates(mol);
2230 graph, fragSpace, rcParams,
false, logger, rng);
2232 assertEquals(1, combinations.size());
2233 assertEquals(1, combinations.get(0).size());
2235 assertEquals(
"5el5atm_6-6*", combinations.get(0).get(0).propID);
2258 mol = parser.parseSmiles(
"c1c2c(ccc1)cccc2c1cNcc1");
2260 sdg.generateCoordinates(mol);
2275 graph, fragSpace, rcParams,
false, logger, rng);
2277 assertEquals(2, combinations.size());
2278 boolean found4el =
false;
2279 boolean found5el =
false;
2280 for (List<RelatedAPPair> comb : combinations)
2282 assertEquals(1, combinations.get(0).size());
2284 if (
"4el4atm_6+5".equals(pair.
propID))
2286 if (
"5el5atm_66-*".equals(pair.
propID))
2289 assertTrue(found4el);
2290 assertTrue(found5el);
2304 Logger logger = Logger.getLogger(
"DummyLogger");
2308 HashMap<APClass,APClass> capMap =
new HashMap<APClass,APClass>();
2309 capMap.put(apcSymImposed, hyd);
2310 capMap.put(apcFree, hyd);
2312 ArrayList<Vertex> cappingGroups =
new ArrayList<Vertex>();
2314 capH.
addAtom(
new Atom(
"H",
new Point3d()));
2315 capH.
addAP(0,
new Point3d(1.0, 0, 0), hyd);
2316 cappingGroups.add(capH);
2319 HashMap<APClass,ArrayList<APClass>> rcCMap =
2320 new HashMap<APClass,ArrayList<APClass>>();
2321 rcCMap.put(apcSymImposed,
new ArrayList<APClass>(Arrays.asList(apcFusedBridge)));
2326 new ArrayList<Vertex>(),
2327 new ArrayList<Vertex>(),
2329 new HashMap<
APClass,ArrayList<APClass>>(),
2330 capMap,
new HashSet<APClass>(),
2343 SmilesParser parser =
new SmilesParser(
builder);
2344 IAtomContainer mol = parser.parseSmiles(
"c1ccccc1");
2346 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
2347 sdg.generateCoordinates(mol);
2359 graph, fragSpace, rcParams,
false, logger, rng);
2362 assertEquals(2, combinations.size());
2366 HashMap<APClass, Double> symmetryConstraints =
2367 new HashMap<APClass, Double>();
2368 symmetryConstraints.put(apcSymImposed, 1.0);
2372 graph, fragSpace, rcParams,
false, logger, rng);
2375 assertEquals(1, combinations.size());
2376 assertEquals(2, combinations.get(0).size());
2383 boolean done =
false;
2395 throw new IllegalStateException(
"No H found that could be changed "
2404 ArrayList<Vertex> libFrags =
new ArrayList<Vertex>();
2411 IAtom a4elA_0 =
new Atom(
"C",
new Point3d());
2412 IAtom a4elA_1 =
new Atom(
"C",
new Point3d());
2413 IAtom a4elA_2 =
new Atom(
"C",
new Point3d());
2414 IAtom a4elA_3 =
new Atom(
"C",
new Point3d());
2419 bridge4elA.
addBond(
new Bond(a4elA_0, a4elA_1, IBond.Order.DOUBLE));
2420 bridge4elA.
addBond(
new Bond(a4elA_1, a4elA_2, IBond.Order.SINGLE));
2421 bridge4elA.
addBond(
new Bond(a4elA_2, a4elA_3, IBond.Order.DOUBLE));
2422 bridge4elA.
addAP(0,
new Point3d(), APC4EL);
2423 bridge4elA.
addAP(3,
new Point3d(), APC4EL);
2424 bridge4elA.
addAP(0,
new Point3d(), apcA);
2425 bridge4elA.
addAP(1,
new Point3d(), apcA);
2426 bridge4elA.
addAP(2,
new Point3d(), apcA);
2427 bridge4elA.
addAP(3,
new Point3d(), apcA);
2428 libFrags.add(bridge4elA);
2431 IAtom a4elB_0 =
new Atom(
"Si",
new Point3d());
2432 IAtom a4elB_1 =
new Atom(
"Si",
new Point3d());
2433 IAtom a4elB_2 =
new Atom(
"Si",
new Point3d());
2434 IAtom a4elB_3 =
new Atom(
"Si",
new Point3d());
2439 bridge4elB.
addBond(
new Bond(a4elB_0, a4elB_1, IBond.Order.DOUBLE));
2440 bridge4elB.
addBond(
new Bond(a4elB_1, a4elB_2, IBond.Order.SINGLE));
2441 bridge4elB.
addBond(
new Bond(a4elB_2, a4elB_3, IBond.Order.DOUBLE));
2442 bridge4elB.
addAP(0,
new Point3d(), APC4EL);
2443 bridge4elB.
addAP(3,
new Point3d(), APC4EL);
2444 libFrags.add(bridge4elB);
2447 IAtom a2elA_0 =
new Atom(
"O",
new Point3d());
2449 bridge2elA.
addAP(0,
new Point3d(), APC2EL);
2450 bridge2elA.
addAP(0,
new Point3d(), APC2EL);
2451 libFrags.add(bridge2elA);
2454 IAtom a2elB_0 =
new Atom(
"C",
new Point3d());
2455 IAtom a2elB_1 =
new Atom(
"C",
new Point3d());
2458 bridge2elB.
addBond(
new Bond(a2elB_0, a2elB_1, IBond.Order.DOUBLE));
2459 bridge2elB.
addAP(0,
new Point3d(), APC2EL);
2460 bridge2elB.
addAP(1,
new Point3d(), APC2EL);
2461 bridge2elB.
addAP(0,
new Point3d(), apcA);
2462 bridge2elB.
addAP(1,
new Point3d(), apcA);
2463 libFrags.add(bridge2elB);
2466 HashMap<APClass,ArrayList<APClass>> cpMap =
2467 new HashMap<APClass,ArrayList<APClass>>();
2468 cpMap.put(apcA,
new ArrayList<APClass>());
2472 new ArrayList<Vertex>(),
2474 new ArrayList<Vertex>(),
2476 new HashMap<APClass,APClass>(),
2477 new HashSet<APClass>(),
2478 new HashMap<
APClass,ArrayList<APClass>>());
2483 assertEquals(0, lst.size());
2487 assertEquals(0, lst.size());
2491 assertEquals(2, lst.size());
2494 assertEquals(1, lst.size());
2497 assertEquals(1, lst.size());
2505 ArrayList<Vertex> libFrags =
new ArrayList<Vertex>();
2512 SmilesParser parser =
new SmilesParser(
builder);
2513 StructureDiagramGenerator sdg =
new StructureDiagramGenerator();
2515 IAtomContainer mol = parser.parseSmiles(
"CC");
2517 sdg.generateCoordinates(mol);
2526 IAtomContainer mol1 = parser.parseSmiles(
"CCC");
2528 sdg.generateCoordinates(mol1);
2533 libFrags.add(frag1);
2535 IAtomContainer mol2 = parser.parseSmiles(
"CCCC");
2537 sdg.generateCoordinates(mol2);
2542 libFrags.add(frag2);
2544 IAtomContainer mol3 = parser.parseSmiles(
"CCCCC");
2546 sdg.generateCoordinates(mol3);
2552 libFrags.add(frag3);
2555 HashMap<APClass,ArrayList<APClass>> cpMap =
2556 new HashMap<APClass,ArrayList<APClass>>();
2557 cpMap.put(apcB,
new ArrayList<APClass>(Arrays.asList(apcA)));
2558 cpMap.put(apcC,
new ArrayList<APClass>(Arrays.asList(apcD)));
2562 new ArrayList<Vertex>(),
2564 new ArrayList<Vertex>(),
2566 new HashMap<APClass,APClass>(),
2567 new HashSet<APClass>(),
2568 new HashMap<
APClass,ArrayList<APClass>>());
2573 assertEquals(4, lst.size());
2577 assertEquals(8, lst.size());
2581 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()
Returns the list of vertexes without entering Templates.
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.
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.