$darkmode
DENOPTIM
FragmenterParameters.java
Go to the documentation of this file.
1/*
2 * DENOPTIM
3 * Copyright (C) 2019 Marco Foscato <marco.foscato@uib.no>
4 *
5 * This program is free software: you can redistribute it and/or modify
6 * it under the terms of the GNU Affero General Public License as published
7 * by the Free Software Foundation, either version 3 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU Affero General Public License for more details.
14 *
15 * You should have received a copy of the GNU Affero General Public License
16 * along with this program. If not, see <http://www.gnu.org/licenses/>.
17 */
18
19package denoptim.programs.fragmenter;
20
21import java.io.File;
22import java.lang.reflect.Field;
23import java.text.SimpleDateFormat;
24import java.util.ArrayList;
25import java.util.Date;
26import java.util.HashMap;
27import java.util.HashSet;
28import java.util.LinkedHashMap;
29import java.util.List;
30import java.util.Map;
31import java.util.Set;
32import java.util.concurrent.atomic.AtomicInteger;
33import java.util.logging.Level;
34
35import denoptim.constants.DENOPTIMConstants;
36import denoptim.exception.DENOPTIMException;
37import denoptim.files.FileFormat;
38import denoptim.files.FileUtils;
39import denoptim.fragmenter.FragmentClusterer;
40import denoptim.fragmenter.ScaffoldingPolicy;
41import denoptim.graph.DGraph;
42import denoptim.graph.Template.ContractLevel;
43import denoptim.graph.Vertex;
44import denoptim.graph.Vertex.BBType;
45import denoptim.io.DenoptimIO;
46import denoptim.logging.StaticLogger;
47import denoptim.programs.RunTimeParameters;
48import denoptim.utils.FormulaUtils;
49
50
58{
63 private String structuresFile;
64
69 private String formulaeFile;
70
75 private LinkedHashMap<String, String> formulae;
76
80 private String cutRulesFile;
81
85 List<CuttingRule> cuttingRules;
86
90 private int numParallelTasks = 1;
91
97 private boolean checkFormula = false;
98
105 private boolean acceptUnsetToSingeBOApprox = false;
106
110 private boolean addExplicitH = false;
111
115 private boolean preFilter = false;
116
122 private Set<String> preFilterSMARTS = new HashSet<String>();
123
127 private boolean doFragmentation = false;
128
136 private boolean doFiltering = false;
137
141 private boolean doFragExtractionFromGraphs = false;
142
146 private boolean doRejectWeirdIsotopes = true;
147
151 private Set<String> rejectedElements = new HashSet<String>();
152
158 private Map<String,Double> formulaCriteriaLessThan =
159 new HashMap<String,Double>();
160
166 private Set<Map<String,Double>> formulaCriteriaMoreThan =
167 new HashSet<Map<String,Double>>();
168
172 private Set<String> rejectedAPClasses = new HashSet<String>();
173
178 private Set<String[]> rejectedAPClassCombinations = new HashSet<String[]>();
179
184 private int maxFragHeavyAtomCount = -1;
185
190 private int minFragHeavyAtomCount = -1;
191
195 private Map<String, String> fragRejectionSMARTS = new HashMap<String, String>();
196
201 private Map<String, String> fragRetentionSMARTS = new HashMap<String, String>();
202
207 private boolean doAddDuOnLinearity = true;
208
213 private double linearAngleLimit = 170.0;
214
218 private String ignorableFragmentsFile = "";
219
223 private ArrayList<Vertex> ignorableFragments = new ArrayList<Vertex>();
224
229 private String targetFragmentsFile = "";
230
235 private ArrayList<Vertex> targetFragments = new ArrayList<Vertex>();
236
263 // NB: javadoc reproduced also in the getter method. See below
264 private boolean doManageIsomorphicFamilies = false;
265
272 private int isomorphicSampleSize = 1;
273
277 public static final int MAXISOMORPHICSAMPLESIZE = 50;
278
282 private int mwSlotSize = 10;
283
288 private Map<String,File> mwSlotToAllFragsFile = new HashMap<String,File>();
289
294 private Map<String,File> mwSlotToUnqFragsFile = new HashMap<String,File>();
295
301 private Map<String,Integer> isomorphsCount = new HashMap<String,Integer>();
302
303 //TODO: We could use something like the SizeControlledSet used in the EA to
304 // collect unique identifiers.
305
309 private AtomicInteger unqIsomorphicFamilyId = new AtomicInteger(0);
310
316 public final Object MANAGEMWSLOTSSLOCK = new Object();
317
323 private boolean doExtactRepresentativeConformer = false;
324
331 private int sizeUnimodalPop = 20;
332
338 private double maxNoiseUnimodalPop = 0.2;
339
349
355
359 private boolean saveClustersOfConformerToFile = false;
360
364 private boolean isStandaloneFragmentClustering = false;
365
369 private boolean workingIn3D = true;
370
377
382 protected boolean embedRingsInTemplate = false;
383
389
394 private String fragmentationTmplFile = "";
395
400 private List<DGraph> fragmentationTmpls = new ArrayList<DGraph>();
401
402//------------------------------------------------------------------------------
403
408 {
410 }
411
412//------------------------------------------------------------------------------
413
417 public int getNumTasks()
418 {
419 return numParallelTasks;
420 }
421
422//------------------------------------------------------------------------------
423
429 {
430 this.numParallelTasks = numParallelTasks;
431 }
432
433//------------------------------------------------------------------------------
434
438 public String getStructuresFile()
439 {
440 return structuresFile;
441 }
442
443//------------------------------------------------------------------------------
444
450 {
451 this.structuresFile = structuresFile;
452 }
453
454//------------------------------------------------------------------------------
455
461 public void setFormulaeFile(String formulaeFile)
462 {
463 this.formulaeFile = formulaeFile;
464 }
465
466//------------------------------------------------------------------------------
467
472 public String getFormulaeFile()
473 {
474 return formulaeFile;
475 }
476
477//------------------------------------------------------------------------------
478
482 public List<CuttingRule> getCuttingRules()
483 {
484 return cuttingRules;
485 }
486
487//------------------------------------------------------------------------------
488
492 public void setCuttingRules(List<CuttingRule> cuttingRules)
493 {
494 this.cuttingRules = cuttingRules;
495 }
496
497//------------------------------------------------------------------------------
498
502 public void setCuttingRulesFilePathname(String pathname)
503 {
504 this.cutRulesFile = pathname;
505 }
506
507//------------------------------------------------------------------------------
508
513 {
514 return cutRulesFile;
515 }
516
517//------------------------------------------------------------------------------
518
522 public LinkedHashMap<String, String> getFormulae()
523 {
524 return formulae;
525 }
526
527//------------------------------------------------------------------------------
528
535 public boolean doCheckFormula()
536 {
537 return checkFormula;
538 }
539
540//------------------------------------------------------------------------------
541
547 public void setCheckFormula(boolean checkFormula)
548 {
549 this.checkFormula = checkFormula;
550 }
551
552
553//------------------------------------------------------------------------------
554
558 public boolean doPreFilter()
559 {
560 return preFilter;
561 }
562
563//------------------------------------------------------------------------------
564
569 public Set<String> getPreFiltrationSMARTS()
570 {
571 return preFilterSMARTS;
572 }
573
574//------------------------------------------------------------------------------
575
579 public boolean doFragmentation()
580 {
581 return doFragmentation;
582 }
583
584//------------------------------------------------------------------------------
585
590 {
592 }
593
594//------------------------------------------------------------------------------
595
600 public boolean doRejectWeirdIsotopes()
601 {
603 }
604
605//------------------------------------------------------------------------------
606
611 public boolean doAddDuOnLinearity()
612 {
613 return doAddDuOnLinearity;
614 }
615
616//------------------------------------------------------------------------------
617
621 public Set<String> getRejectedElements()
622 {
623 return rejectedElements;
624 }
625
626//------------------------------------------------------------------------------
627
632 public Map<String, Double> getRejectedFormulaLessThan()
633 {
635 }
636
637//------------------------------------------------------------------------------
638
643 public Set<Map<String, Double>> getRejectedFormulaMoreThan()
644 {
646 }
647
648//------------------------------------------------------------------------------
649
653 public Set<String> getRejectedAPClasses()
654 {
655 return rejectedAPClasses;
656 }
657
658//------------------------------------------------------------------------------
659
663 public Set<String[]> getRejectedAPClassCombinations()
664 {
666 }
667
668//------------------------------------------------------------------------------
669
674 {
676 }
677
678//------------------------------------------------------------------------------
679
684 {
686 }
687
688//------------------------------------------------------------------------------
689
693 public Map<String, String> getFragRejectionSMARTS()
694 {
695 return fragRejectionSMARTS;
696 }
697
698//------------------------------------------------------------------------------
699
703 public Map<String, String> getFragRetentionSMARTS()
704 {
705 return fragRetentionSMARTS;
706 }
707
708//------------------------------------------------------------------------------
709
711 {
712 this.doRejectWeirdIsotopes = doRejectWeirdIsotopes;
713 }
714
715//------------------------------------------------------------------------------
716
717 public void setRejectedElements(Set<String> rejectedElements)
718 {
719 this.rejectedElements = rejectedElements;
720 }
721
722//------------------------------------------------------------------------------
723
725 Map<String, Double> formulaMax)
726 {
727 this.formulaCriteriaLessThan = formulaMax;
728 }
729
730//------------------------------------------------------------------------------
731
733 Set<Map<String, Double>> formulaCriteriaMoreThan)
734 {
735 this.formulaCriteriaMoreThan = formulaCriteriaMoreThan;
736 }
737
738//------------------------------------------------------------------------------
739
741 {
742 this.rejectedAPClasses = rejectedAPClasses;
743 }
744
745//------------------------------------------------------------------------------
746
748 Set<String[]> rejectedAPClassCombinations)
749 {
750 this.rejectedAPClassCombinations = rejectedAPClassCombinations;
751 }
752
753//------------------------------------------------------------------------------
754
756 {
757 this.maxFragHeavyAtomCount = maxFragHeavyAtomCount;
758 }
759
760//------------------------------------------------------------------------------
761
763 {
764 this.minFragHeavyAtomCount = minFragHeavyAtomCount;
765 }
766
767//------------------------------------------------------------------------------
768
769 public void setFragRejectionSMARTS(Map<String, String> fragRejectionSMARTS)
770 {
771 this.fragRejectionSMARTS = fragRejectionSMARTS;
772 }
773
774//------------------------------------------------------------------------------
775
776 public void setFragRetentionSMARTS(Map<String, String> fragRetentionSMARTS)
777 {
778 this.fragRetentionSMARTS = fragRetentionSMARTS;
779 }
780
781//------------------------------------------------------------------------------
782
786 public ArrayList<Vertex> getIgnorableFragments()
787 {
788 return ignorableFragments;
789 }
790
791//------------------------------------------------------------------------------
792
797 public ArrayList<Vertex> getTargetFragments()
798 {
799 return targetFragments;
800 }
801
802//------------------------------------------------------------------------------
803
833 {
835 }
836
837//------------------------------------------------------------------------------
838
840 {
842 }
843
844//------------------------------------------------------------------------------
845
847 {
848 this.isomorphicSampleSize = isomorphicSampleSize;
849 }
850
851//------------------------------------------------------------------------------
852
853 public int getMWSlotSize()
854 {
855 return mwSlotSize;
856 }
857
858//------------------------------------------------------------------------------
859
860 public void setMWSlotSize(int mwSlotSize)
861 {
862 this.mwSlotSize = mwSlotSize;
863 }
864
865//------------------------------------------------------------------------------
866
867 public Map<String, File> getMWSlotToAllFragsFile()
868 {
870 }
871
872//------------------------------------------------------------------------------
873
874 public void setMWSlotToAllFragsFile(Map<String, File> mwSlotToAllFragsFile)
875 {
876 this.mwSlotToAllFragsFile = mwSlotToAllFragsFile;
877 }
878
879//------------------------------------------------------------------------------
880
881 public Map<String, File> getMWSlotToUnqFragsFile()
882 {
884 }
885
886//------------------------------------------------------------------------------
887
896 public File getMWSlotFileNameUnqFrags(String mwSlotId)
897 {
898 return new File(getWorkDirectory() + DenoptimIO.FS
902 }
903
904//------------------------------------------------------------------------------
905
913 public File getMWSlotFileNameAllFrags(String mwSlotId)
914 {
915 return new File(getWorkDirectory() + DenoptimIO.FS
919 }
920
921//------------------------------------------------------------------------------
922
926 public Map<String,Integer> getIsomorphsCount()
927 {
928 return isomorphsCount;
929 }
930
931//------------------------------------------------------------------------------
932
937 public String newIsomorphicFamilyID()
938 {
939 return "IsomorphicFamily_" + unqIsomorphicFamilyId.getAndIncrement();
940 }
941
942//------------------------------------------------------------------------------
943
949 public boolean doFiltering()
950 {
951 return doFiltering;
952 }
953
954//------------------------------------------------------------------------------
955
959 public boolean addExplicitH()
960 {
961 return addExplicitH;
962 }
963
964//------------------------------------------------------------------------------
965
970 public void setAddExplicitH(boolean addExplicitH)
971 {
972 this.addExplicitH = addExplicitH;
973 }
974
975//------------------------------------------------------------------------------
976
981 public boolean acceptUnsetToSingeBO()
982 {
984 }
985
986//-----------------------------------------------------------------------------
987
993 {
994 this.embedRingsInTemplate = embedRingsInTemplate;
995 }
996
997//-----------------------------------------------------------------------------
998
1003 public boolean embedRingsInTemplate()
1004 {
1005 return embedRingsInTemplate;
1006 }
1007
1008//------------------------------------------------------------------------------
1009
1016 {
1017 this.embeddedRingsContract = embeddedRingsContract;
1018 }
1019
1020//------------------------------------------------------------------------------
1021
1027 {
1028 return embeddedRingsContract;
1029 }
1030
1031//------------------------------------------------------------------------------
1032
1038 {
1039 this.scaffoldingPolicy = sp;
1040 }
1041
1042//------------------------------------------------------------------------------
1043
1049 {
1050 return scaffoldingPolicy;
1051 }
1052
1053//------------------------------------------------------------------------------
1054
1059 public List<DGraph> getFragmentationTmpls()
1060 {
1061 return fragmentationTmpls;
1062 }
1063
1064//------------------------------------------------------------------------------
1065
1072 public void interpretKeyword(String key, String value)
1073 throws DENOPTIMException
1074 {
1075 String msg = "";
1076 switch (key.toUpperCase())
1077 {
1078 case "WORKDIR=":
1079 workDir = value;
1080 break;
1081
1082 case "STRUCTURESFILE=":
1083 structuresFile = value;
1084 break;
1085
1086 case "FORMULATXTFILE=":
1087 checkFormula = true;
1088 formulaeFile = value;
1089 break;
1090
1091 case "PREFILTERSMARTS=":
1092 preFilter = true;
1093 preFilterSMARTS.add(value);
1094 break;
1095
1096 case "CUTTINGRULESFILE=":
1097 doFragmentation = true;
1098 cutRulesFile = value;
1099 break;
1100
1101 case "EXTRACTFROMGRAPHS=":
1102 structuresFile = value;
1104 break;
1105
1106 case "ADDEXPLICITHYDROGEN":
1107 addExplicitH = true;
1108 break;
1109
1110 case "UNSETTOSINGLEBO":
1112 break;
1113
1114 case "IGNORABLEFRAGMENTS=":
1115 ignorableFragmentsFile = value;
1116 doFiltering = true;
1117 break;
1118
1119 case "TARGETFRAGMENTS=":
1120 targetFragmentsFile = value;
1121 doFiltering = true;
1122 break;
1123
1124 case "ISOMORPHICSAMPLESIZE=":
1125 try {
1126 isomorphicSampleSize = Integer.parseInt(value);
1127 } catch (Throwable t)
1128 {
1129 msg = "Unable to parse value of " + key + ": '" + value + "'";
1130 throw new DENOPTIMException(msg);
1131 }
1134 break;
1135
1136 case "REMOVEDUPLICATES":
1138 break;
1139
1140 case "MWSLOTSIZE=":
1141 try {
1142 mwSlotSize = Integer.parseInt(value);
1143 } catch (Throwable t)
1144 {
1145 msg = "Unable to parse value of " + key + ": '" + value + "'";
1146 throw new DENOPTIMException(msg);
1147 }
1148 break;
1149
1150 case "REJECTMINORISOTOPES":
1151 doRejectWeirdIsotopes = true;
1152 doFiltering = true;
1153 break;
1154
1155 case "REJECTELEMENT=":
1156 rejectedElements.add(value);
1157 doFiltering = true;
1158 break;
1159
1160 case "REJFORMULALESSTHAN=":
1161 if (formulaCriteriaLessThan.size()>0)
1162 {
1163 msg = "Attempt to specify more than one criterion for "
1164 + "rejecting fragments based on a lower-limit "
1165 + "molecular formula. ";
1166 throw new DENOPTIMException(msg);
1167 }
1168 Map<String,Double> elSymbolsCount = null;
1169 try {
1170 elSymbolsCount = FormulaUtils.parseFormula(value);
1171 } catch (Throwable t)
1172 {
1173 msg = "Unable to parse value of " + key + ": '" + value + "'";
1174 throw new DENOPTIMException(msg);
1175 }
1176 formulaCriteriaLessThan = elSymbolsCount;
1177 doFiltering = true;
1178 break;
1179
1180 case "REJFORMULAMORETHAN=":
1181 Map<String,Double> elSymbolsCount2= null;
1182 try {
1183 elSymbolsCount2 = FormulaUtils.parseFormula(value);
1184 } catch (Throwable t)
1185 {
1186 msg = "Unable to parse value of " + key + ": '" + value + "'";
1187 throw new DENOPTIMException(msg);
1188 }
1189 formulaCriteriaMoreThan.add(elSymbolsCount2);
1190 doFiltering = true;
1191 break;
1192
1193 case "REJECTAPCLASS=":
1194 rejectedAPClasses.add(value);
1195 doFiltering = true;
1196 break;
1197
1198 case "REJECTAPCLASSCOMBINATION=":
1199 String[] lst = value.split("\\s+");
1201 doFiltering = true;
1202 break;
1203
1204 case "MAXFRAGSIZE=":
1205 try {
1206 maxFragHeavyAtomCount = Integer.parseInt(value);
1207 } catch (Throwable t)
1208 {
1209 msg = "Unable to parse value of " + key + ": '" + value + "'";
1210 throw new DENOPTIMException(msg);
1211 }
1212 doFiltering = true;
1213 break;
1214
1215 case "MINFRAGSIZE=":
1216 try {
1217 minFragHeavyAtomCount = Integer.parseInt(value);
1218 } catch (Throwable t)
1219 {
1220 msg = "Unable to parse value of " + key + ": '" + value + "'";
1221 throw new DENOPTIMException(msg);
1222 }
1223 doFiltering = true;
1224 break;
1225
1226 case "REJECTSMARTS=":
1227 fragRejectionSMARTS.put(value, value);
1228 doFiltering = true;
1229 break;
1230
1231 case "RETAINSMARTS=":
1232 fragRetentionSMARTS.put(value, value);
1233 doFiltering = true;
1234 break;
1235
1236 case "CLUSTERIZEANDCOLLECT=":
1239 switch (value.trim().toUpperCase())
1240 {
1241 case "CENTROIDS":
1243 break;
1244
1245 case "MOSTCENTRAL":
1247 break;
1248
1249 default:
1250 throw new DENOPTIMException("Unable to parse value of "
1251 + key + ": '" + value + "'");
1252 }
1253 break;
1254
1255 case "SAVECLUSTERS":
1258 break;
1259
1260 case "SIZEUNIMODALPOPULATION=":
1261 sizeUnimodalPop = Integer.parseInt(value);
1262 break;
1263
1264 case "MAXNOISEUNIMODALPOPULATION=":
1265 maxNoiseUnimodalPop = Double.parseDouble(value);
1266 break;
1267
1268 case "SDWEIGHTUNIMODALPOPULATION=":
1269 factorForSDOnStatsOfUnimodalPop = Double.parseDouble(value);
1270 break;
1271
1272 case "SCAFFOLDINGPOLICY=":
1273 String[] words = value.split("\\s+");
1274 try {
1276 words[0].toUpperCase());
1278 {
1279 if (words.length<2)
1280 {
1281 throw new DENOPTIMException("Expected elemental "
1282 + "symbol after '"
1283 + ScaffoldingPolicy.ELEMENT+ "', but none "
1284 + "found");
1285 }
1286 scaffoldingPolicy.label = words[1];
1287 }
1288 } catch (Throwable t)
1289 {
1290 msg = "Unable to parse value of " + key + ": '" + value + "'";
1291 throw new DENOPTIMException(msg, t);
1292 }
1293 break;
1294
1295 case "EMBEDRINGSINTEMPLATES=":
1296 {
1298 break;
1299 }
1300
1301 case "RINGEMBEDDINGCONTRACT=":
1302 {
1303 if (value.length() > 0)
1304 {
1305 embeddedRingsContract = ContractLevel.valueOf(value);
1306 }
1307 break;
1308 }
1309
1310 case "FRAGMENTATIONTEMPLATE=":
1311 {
1312 doFragmentation = true;
1313 fragmentationTmplFile = value;
1314 break;
1315 }
1316
1317/*
1318 case "=":
1319 = value;
1320 doFiltering = true;
1321 break;
1322 */
1323
1324 case "PARALLELTASKS=":
1325 try
1326 {
1327 numParallelTasks = Integer.parseInt(value);
1328 }
1329 catch (Throwable t)
1330 {
1331 msg = "Unable to understand value " + key + "'" + value + "'";
1332 throw new DENOPTIMException(msg);
1333 }
1334 break;
1335
1336 case "VERBOSITY=":
1337 try
1338 {
1339 verbosity = Integer.parseInt(value);
1340 }
1341 catch (Throwable t)
1342 {
1343 msg = "Unable to understand value " + key + "'" + value + "'";
1344 throw new DENOPTIMException(msg);
1345 }
1346 break;
1347
1348 default:
1349 msg = "Keyword " + key + " is not a known Fragmenter-"
1350 + "related keyword. Check input files.";
1351 throw new DENOPTIMException(msg);
1352 }
1353 }
1354
1355//------------------------------------------------------------------------------
1356
1363 {
1364 if (!workDir.equals(System.getProperty("user.dir")))
1365 {
1367 }
1368 ensureIsPositive("numParallelTasks", numParallelTasks, "PARALLELTASKS");
1369 ensureIsPositive("isomorphicSampleSize", isomorphicSampleSize,
1370 "ISOMORPHICSAMPLESIZE");
1371 ensureIsPositive("mwSlotSize", mwSlotSize, "MWSLOTSIZE");
1378
1380 }
1381
1382//------------------------------------------------------------------------------
1383
1390 {
1391 if (isMaster)
1393
1394 cuttingRules = new ArrayList<CuttingRule>();
1395 if (cutRulesFile!=null && !cutRulesFile.isBlank())
1396 {
1398 }
1399 if (formulaeFile!=null && !formulaeFile.isBlank())
1400 {
1402 }
1404
1405 if (ignorableFragmentsFile!=null && !ignorableFragmentsFile.isBlank())
1406 {
1407 try
1408 {
1411 } catch (Throwable e)
1412 {
1413 throw new DENOPTIMException("Problems reading file '"
1414 + ignorableFragmentsFile + "'", e);
1415 }
1416 }
1417
1418 if (targetFragmentsFile!=null && !targetFragmentsFile.isBlank())
1419 {
1420 try
1421 {
1424 } catch (Throwable e)
1425 {
1426 throw new DENOPTIMException("Problems reading file '"
1427 + targetFragmentsFile + "'", e);
1428 }
1429 }
1430
1431 if (fragmentationTmplFile!=null && !fragmentationTmplFile.isBlank())
1432 {
1433 try
1434 {
1436 new File(fragmentationTmplFile));
1437 } catch (Throwable e)
1438 {
1439 throw new DENOPTIMException("Problems reading file '"
1440 + fragmentationTmplFile + "'", e);
1441 }
1442 }
1443
1445 {
1447 }
1448
1449 if (isMaster)
1450 {
1451 StaticLogger.appLogger.log(Level.INFO, "Program log file: "
1453 + "Output files associated with the current run are "
1454 + "located in " + workDir);
1455 }
1456 }
1457
1458//------------------------------------------------------------------------------
1459
1461 {
1462 String curDir = workDir;
1463 String fileSep = System.getProperty("file.separator");
1464 boolean success = false;
1465 while (!success)
1466 {
1467 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddkkmmss");
1468 String str = "FRG" + sdf.format(new Date());
1469 workDir = curDir + fileSep + str;
1471 }
1473 logFile = workDir + ".log";
1474 }
1475
1476//------------------------------------------------------------------------------
1477
1484 public String getPrintedList()
1485 {
1486 StringBuilder sb = new StringBuilder(1024);
1487 sb.append(" " + paramTypeName() + " ").append(NL);
1488 for (Field f : this.getClass().getDeclaredFields())
1489 {
1490 try
1491 {
1492 sb.append(f.getName()).append(" = ").append(
1493 f.get(this)).append(NL);
1494 }
1495 catch (Throwable t)
1496 {
1497 sb.append("ERROR! Unable to print " + paramTypeName()
1498 + " parameters. Cause: " + t);
1499 break;
1500 }
1501 }
1502 for (RunTimeParameters otherCollector : otherParameters.values())
1503 {
1504 sb.append(otherCollector.getPrintedList());
1505 }
1506 return sb.toString();
1507 }
1508
1509//------------------------------------------------------------------------------
1510
1515 public double getLinearAngleLimit()
1516 {
1517 return linearAngleLimit;
1518 }
1519
1520//------------------------------------------------------------------------------
1521
1528 {
1529 this.linearAngleLimit = linearAngleLimit;
1530 }
1531
1532//------------------------------------------------------------------------------
1533
1539 {
1541 }
1542
1543//------------------------------------------------------------------------------
1544
1551 {
1552 return sizeUnimodalPop;
1553 }
1554
1555//------------------------------------------------------------------------------
1556
1563 {
1564 this.sizeUnimodalPop = sizeUnimodalPop;
1565 }
1566
1567//------------------------------------------------------------------------------
1568
1576 {
1577 return maxNoiseUnimodalPop;
1578 }
1579
1580//------------------------------------------------------------------------------
1581
1589 {
1590 this.maxNoiseUnimodalPop = maxNoiseUnimodalPop;
1591 }
1592
1593//------------------------------------------------------------------------------
1594
1602 {
1604 }
1605
1606
1607//------------------------------------------------------------------------------
1608
1617 {
1618 this.factorForSDOnStatsOfUnimodalPop = factorForSDOnStatsOfUnimodalPop;
1619 }
1620
1621//------------------------------------------------------------------------------
1622
1630 {
1632 }
1633
1634//------------------------------------------------------------------------------
1635
1645 {
1646 this.useCentroidsAsRepresentativeConformer =
1648 }
1649
1650//------------------------------------------------------------------------------
1651
1658 {
1660 }
1661
1662//------------------------------------------------------------------------------
1663
1672 {
1673 this.saveClustersOfConformerToFile = saveClustersOfConformerToFile;
1674 }
1675
1676//------------------------------------------------------------------------------
1677
1683 {
1685 }
1686
1687//------------------------------------------------------------------------------
1688
1693 public boolean isWorkingIn3D()
1694 {
1695 return workingIn3D;
1696 }
1697
1698//------------------------------------------------------------------------------
1699
1704 public void setWorkingIn3D(boolean workingIn3D)
1705 {
1706 this.workingIn3D = workingIn3D;
1707 }
1708
1709//------------------------------------------------------------------------------
1710
1715 public void setFragmentationTmpls(List<DGraph> fragmentationTmpls) {
1716 this.fragmentationTmpls = fragmentationTmpls;
1717 }
1718
1719//------------------------------------------------------------------------------
1720
1721}
General set of constants used in DENOPTIM.
static final String MWSLOTFRAGSUNQFILENANEEND
Final part of filename used to collect unique fragments in a certain molecular weight slot.
static final String EOL
new line character
static final FileFormat TMPFRAGFILEFORMAT
Format for intermediate files used during fragmentation.
static final String MWSLOTFRAGSFILENAMEROOT
Initial part of filename used to collect fragments belonging to a certain molecular weight slot.
static final String MWSLOTFRAGSALLFILENANEEND
Final part of filename used to collect all samples fragments in a certain molecular weight slot inclu...
static boolean createDirectory(String fileName)
Creates a directory.
Definition: FileUtils.java:231
static void addToRecentFiles(String fileName, FileFormat ff)
Appends an entry to the list of recent files.
Definition: FileUtils.java:67
Utility methods for input/output.
static LinkedHashMap< String, String > readCSDFormulae(File file)
Read molecular formula from TXT data representation produced by Cambridge Structural Database tools (...
static void readCuttingRules(BufferedReader reader, List< CuttingRule > cutRules, String source)
Read cutting rules from a stream.
static ArrayList< DGraph > readDENOPTIMGraphsFromFile(File inFile)
Reads a list of DGraphs from file.
static ArrayList< Vertex > readVertexes(File file, Vertex.BBType bbt)
Reads Vertexes from any file that can contain such items.
static final String FS
File separator from system.
Logger class for DENOPTIM.
static final Logger appLogger
Collection of parameters controlling the behavior of the software.
Map< ParametersType, RunTimeParameters > otherParameters
Collection of other parameters by type.
boolean isMaster
Flag signaling this is the master collection of parameters.
String getWorkDirectory()
Gets the pathname to the working directory.
static boolean readYesNoTrueFalse(String s)
Reads a string searching for any common way to say either yes/true (including shorthand t/y) or no/fa...
void ensureFileExists(String pathname)
Ensures a pathname does lead to an existing file or triggers an error.
String paramTypeName()
Returns a string defining the type the parameters collected here.
void ensureIsPositive(String paramName, int value, String paramKey)
Ensures that a parameter is a positive number (x>=0) or triggers an error.
void checkOtherParameters()
Checks any of the parameter collections contained in this instance.
final String NL
New line character.
void processOtherParameters()
Processes any of the parameter collections contained in this instance.
int verbosity
Verbosity level for logger.
void ensureFileExistsIfSet(String pathname)
Ensures a pathname is not empty nor null and that it does lead to an existing file or triggers an err...
Parameters controlling execution of the fragmenter.
String structuresFile
Pathname to the file containing the structures of the molecules to fragment or the fragments to proce...
void setEmbeddedRingsContract(ContractLevel embeddedRingsContract)
void setFragRejectionSMARTS(Map< String, String > fragRejectionSMARTS)
void setRejectedAPClassCombinations(Set< String[]> rejectedAPClassCombinations)
void setSaveClustersOfConformerToFile(boolean saveClustersOfConformerToFile)
Sets the flag requesting to print clusters of fragments to file upon extraction of the most represent...
void setCuttingRules(List< CuttingRule > cuttingRules)
Assigns the cutting rules loaded from the input.
void setStructuresFile(String structuresFile)
Sets the pathname of the file containing input structures.
void setSizeUnimodalPop(int sizeUnimodalPop)
Sets the size of the population of normally distributed noise-distorted population used to define the...
void setFragmentationTmpls(List< DGraph > fragmentationTmpls)
Sets the list of graph templates for fragmentation.
double factorForSDOnStatsOfUnimodalPop
Factor used to multiply the standard deviation when adding it to the mean of the RMSD for a unimodal ...
void setCheckFormula(boolean checkFormula)
Sets the value of the flag controlling the execution of elemental analysis on the structures.
Set< String > preFilterSMARTS
SMARTS identifying substructures that lead to rejection of a structure before fragmentation.
Map< String, File > mwSlotToUnqFragsFile
Mapping of the molecular weight slot identifier to the file collecting unique fragments belonging to ...
void setFactorForSDOnStatsOfUnimodalPop(double factorForSDOnStatsOfUnimodalPop)
Sets the weight of the standard deviation when calculating the RMSD threshold from the statistics of ...
String cutRulesFile
Pathname to the file containing the cutting rules.
String formulaeFile
Pathname to the file containing the formulae of the molecules to fragment.
ContractLevel embeddedRingsContract
Type of constrain defined for any template generated upon conversion of molecules into DGraph.
void setRejectedFormulaMoreThan(Set< Map< String, Double > > formulaCriteriaMoreThan)
boolean doRejectWeirdIsotopes
Flag requesting to reject fragments with minor isotopes.
void checkParameters()
Evaluate consistency of input parameters.
void interpretKeyword(String key, String value)
Processes a keyword/value pair and assign the related parameters.
void setFragRetentionSMARTS(Map< String, String > fragRetentionSMARTS)
final Object MANAGEMWSLOTSSLOCK
Synchronization lock for manipulating a) the collections (i.e., MW slots) of fragments produced by mu...
boolean doAddDuOnLinearity
Flag requesting to add dummy atoms on linearities.
double linearAngleLimit
Upper limit for an angle before it is treated as "flat" ("linear") angle, i.e., close enough to 180 D...
int minFragHeavyAtomCount
Lower limit for number of non-H atoms in fragments.
void setAddExplicitH(boolean addExplicitH)
Give true to add explicit H atoms on all atoms.
boolean doFiltering
Flag requesting to do post-fragmentation processing of fragments, i.e., application of all filtration...
void setUseCentroidsAsRepresentativeConformer(boolean useCentroidsAsRepresentativeConformer)
void setRejectedFormulaLessThan(Map< String, Double > formulaMax)
Set< Map< String, Double > > formulaCriteriaMoreThan
Upper limits of formula-based criteria for fragment rejection.
String fragmentationTmplFile
Pathname to file containing a graph to be used as template for fragmentation.
boolean doFragmentation
Fag requesting the fragmentation of the structures.
void setNumTasks(int numParallelTasks)
Sets the number of parallel tasks to run.
AtomicInteger unqIsomorphicFamilyId
Unique identifier of a family of isomorphic versions of a fragment,.
void setLinearAngleLimit(double linearAngleLimit)
Sets the upper limit for an angle before it is treated as "flat" angle, i.e., close enough to 180 DEG...
List< CuttingRule > cuttingRules
List of cutting rules sorted by priority.
String getPrintedList()
Returns the list of parameters in a string with newline characters as delimiters.
File getMWSlotFileNameAllFrags(String mwSlotId)
Builds the pathname of the file meant to hold all isomorphic fragments from a given MW slot.
Set< String > rejectedAPClasses
The initial part of APClasses that lead to rejection of a fragment.
boolean doExtactRepresentativeConformer
Flag signaling the request to analyze each isomorphic family to extract the most representative fragm...
ArrayList< Vertex > targetFragments
List of fragment that will be retained, i.e., any isomorphic fragment of any of these will be kept,...
boolean acceptUnsetToSingeBOApprox
Flag requesting to force-accepting the approximation that converts all unset bond orders to single bo...
boolean workingIn3D
Flag activating operations depending on 3D structure.
Map< String, File > mwSlotToAllFragsFile
Mapping of the molecular weight slot identifier to the file collecting all collected fragments belong...
boolean doFragExtractionFromGraphs
Flag requesting to extract fragments from graphs.
void setMaxNoiseUnimodalPop(double maxNoiseUnimodalPop)
Sets the maximum noise of the population of normally distributed noise-distorted population used to d...
Set< String > rejectedElements
Symbols of elements that lead to rejection of a fragment.
boolean saveClustersOfConformerToFile
Flag requesting to print clusters of fragments to file.
int mwSlotSize
Molecular weight slot width for collecting fragments.
void setRejectWeirdIsotopes(boolean doRejectWeirdIsotopes)
String newIsomorphicFamilyID()
Produced a new unique identifier for a family of isomorphic fragments.
double maxNoiseUnimodalPop
Maximum amount of absolute noise used to generate normally distributed noise-distorted population of ...
boolean checkFormula
Flag requesting the execution of elemental analysis and comparison of the content of the structure fi...
Map< String, String > fragRejectionSMARTS
SMARTS leading to rejection of a fragment.
void setFormulaeFile(String formulaeFile)
Sets the pathname of the file containing molecular formula with a format respecting Cambridge Structu...
File getMWSlotFileNameUnqFrags(String mwSlotId)
Builds the pathname of the file meant to hold unique fragments from within a given MW slot,...
boolean useCentroidsAsRepresentativeConformer
Flag requesting to same cluster centroids rather than the actual fragments that are closest to the ce...
void setCuttingRulesFilePathname(String pathname)
Assigns the pathname to the cutting rules file.
boolean addExplicitH
Flag requesting to add explicit H atoms.
void setEmbedRingsInTemplate(boolean embedRingsInTemplate)
int maxFragHeavyAtomCount
Upper limit for number of non-H atoms in fragments.
int numParallelTasks
Number of parallel tasks to run.
Map< String, Double > formulaCriteriaLessThan
Lower limits of formula-based criteria for fragment rejection.
Map< String, String > fragRetentionSMARTS
SMARTS leading to retention of a fragment.
int sizeUnimodalPop
Size of on-the-fly generated, normally distributed noise-distorted population of geometries used to d...
void setRejectedAPClasses(Set< String > rejectedAPClasses)
boolean isStandaloneFragmentClustering
Flag requesting to run fragment clusterer in stand-alone fashion.
ScaffoldingPolicy scaffoldingPolicy
The policy for defining the scaffold vertex in a graph that does not have such a BBType.
String ignorableFragmentsFile
Pathname to file with fragments that can be ignored.
boolean preFilter
Fag requesting the pre-fragmentation filtering of the structures.
ArrayList< Vertex > ignorableFragments
List of fragment that can be rejected.
void setRejectedElements(Set< String > rejectedElements)
void processParameters()
Processes all parameters and initialize related objects.
List< DGraph > fragmentationTmpls
List of graphs to be used as templates for fragmentation.
LinkedHashMap< String, String > formulae
Molecular formula read-in from CSD file.
boolean embedRingsInTemplate
Flag that enables the embedding of rings in templates upon conversion of molecules into DGraph.
int isomorphicSampleSize
Size of the sample of isomorphic fragments to collect.
Map< String, Integer > isomorphsCount
Counts of isomorphic versions of each known fragment generated in a fragmentation process.
void setMWSlotToAllFragsFile(Map< String, File > mwSlotToAllFragsFile)
static final int MAXISOMORPHICSAMPLESIZE
Maximum isomorphic sample size.
void setWorkingIn3D(boolean workingIn3D)
Sets boolean variable workingIn3D.
String targetFragmentsFile
Pathname to file with fragments that will be retained, i.e., any isomorphic fragment of any of these ...
Set< String[]> rejectedAPClassCombinations
Combination of strings matching the beginning of APClass names that lead to rejection of a fragment.
Utilities for manipulating molecular formulas.
static Map< String, Double > parseFormula(String formula)
Reads a molecular formula written as "H2 O" or "C6 H12 O6".
File formats identified by DENOPTIM.
Definition: FileFormat.java:32
Defines how to define the scaffold vertex of a graph.
Enum specifying to what extent the template's inner graph can be changed.
Definition: Template.java:104
FREE
Inner graphs are free to change within the confines of the required AttachmentPoints.
Definition: Template.java:109
The type of building block.
Definition: Vertex.java:86
FRG_PARAMS
Parameters controlling the fragmenter.