$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
405 private int maxBufferShellSize = 2;
406
407//------------------------------------------------------------------------------
408
413 {
415 }
416
417//------------------------------------------------------------------------------
418
422 public int getNumTasks()
423 {
424 return numParallelTasks;
425 }
426
427//------------------------------------------------------------------------------
428
434 {
435 this.numParallelTasks = numParallelTasks;
436 }
437
438//------------------------------------------------------------------------------
439
443 public String getStructuresFile()
444 {
445 return structuresFile;
446 }
447
448//------------------------------------------------------------------------------
449
455 {
456 this.structuresFile = structuresFile;
457 }
458
459//------------------------------------------------------------------------------
460
466 public void setFormulaeFile(String formulaeFile)
467 {
468 this.formulaeFile = formulaeFile;
469 }
470
471//------------------------------------------------------------------------------
472
477 public String getFormulaeFile()
478 {
479 return formulaeFile;
480 }
481
482//------------------------------------------------------------------------------
483
487 public List<CuttingRule> getCuttingRules()
488 {
489 return cuttingRules;
490 }
491
492//------------------------------------------------------------------------------
493
497 public void setCuttingRules(List<CuttingRule> cuttingRules)
498 {
499 this.cuttingRules = cuttingRules;
500 }
501
502//------------------------------------------------------------------------------
503
507 public void setCuttingRulesFilePathname(String pathname)
508 {
509 this.cutRulesFile = pathname;
510 }
511
512//------------------------------------------------------------------------------
513
518 {
519 return cutRulesFile;
520 }
521
522//------------------------------------------------------------------------------
523
527 public LinkedHashMap<String, String> getFormulae()
528 {
529 return formulae;
530 }
531
532//------------------------------------------------------------------------------
533
540 public boolean doCheckFormula()
541 {
542 return checkFormula;
543 }
544
545//------------------------------------------------------------------------------
546
552 public void setCheckFormula(boolean checkFormula)
553 {
554 this.checkFormula = checkFormula;
555 }
556
557
558//------------------------------------------------------------------------------
559
563 public boolean doPreFilter()
564 {
565 return preFilter;
566 }
567
568//------------------------------------------------------------------------------
569
574 public Set<String> getPreFiltrationSMARTS()
575 {
576 return preFilterSMARTS;
577 }
578
579//------------------------------------------------------------------------------
580
584 public boolean doFragmentation()
585 {
586 return doFragmentation;
587 }
588
589//------------------------------------------------------------------------------
590
595 {
597 }
598
599//------------------------------------------------------------------------------
600
605 public boolean doRejectWeirdIsotopes()
606 {
608 }
609
610//------------------------------------------------------------------------------
611
616 public boolean doAddDuOnLinearity()
617 {
618 return doAddDuOnLinearity;
619 }
620
621//------------------------------------------------------------------------------
622
626 public Set<String> getRejectedElements()
627 {
628 return rejectedElements;
629 }
630
631//------------------------------------------------------------------------------
632
637 public Map<String, Double> getRejectedFormulaLessThan()
638 {
640 }
641
642//------------------------------------------------------------------------------
643
648 public Set<Map<String, Double>> getRejectedFormulaMoreThan()
649 {
651 }
652
653//------------------------------------------------------------------------------
654
658 public Set<String> getRejectedAPClasses()
659 {
660 return rejectedAPClasses;
661 }
662
663//------------------------------------------------------------------------------
664
668 public Set<String[]> getRejectedAPClassCombinations()
669 {
671 }
672
673//------------------------------------------------------------------------------
674
679 {
681 }
682
683//------------------------------------------------------------------------------
684
689 {
691 }
692
693//------------------------------------------------------------------------------
694
698 public Map<String, String> getFragRejectionSMARTS()
699 {
700 return fragRejectionSMARTS;
701 }
702
703//------------------------------------------------------------------------------
704
708 public Map<String, String> getFragRetentionSMARTS()
709 {
710 return fragRetentionSMARTS;
711 }
712
713//------------------------------------------------------------------------------
714
716 {
717 this.doRejectWeirdIsotopes = doRejectWeirdIsotopes;
718 }
719
720//------------------------------------------------------------------------------
721
722 public void setRejectedElements(Set<String> rejectedElements)
723 {
724 this.rejectedElements = rejectedElements;
725 }
726
727//------------------------------------------------------------------------------
728
730 Map<String, Double> formulaMax)
731 {
732 this.formulaCriteriaLessThan = formulaMax;
733 }
734
735//------------------------------------------------------------------------------
736
738 Set<Map<String, Double>> formulaCriteriaMoreThan)
739 {
740 this.formulaCriteriaMoreThan = formulaCriteriaMoreThan;
741 }
742
743//------------------------------------------------------------------------------
744
746 {
747 this.rejectedAPClasses = rejectedAPClasses;
748 }
749
750//------------------------------------------------------------------------------
751
753 Set<String[]> rejectedAPClassCombinations)
754 {
755 this.rejectedAPClassCombinations = rejectedAPClassCombinations;
756 }
757
758//------------------------------------------------------------------------------
759
761 {
762 this.maxFragHeavyAtomCount = maxFragHeavyAtomCount;
763 }
764
765//------------------------------------------------------------------------------
766
768 {
769 this.minFragHeavyAtomCount = minFragHeavyAtomCount;
770 }
771
772//------------------------------------------------------------------------------
773
774 public void setFragRejectionSMARTS(Map<String, String> fragRejectionSMARTS)
775 {
776 this.fragRejectionSMARTS = fragRejectionSMARTS;
777 }
778
779//------------------------------------------------------------------------------
780
781 public void setFragRetentionSMARTS(Map<String, String> fragRetentionSMARTS)
782 {
783 this.fragRetentionSMARTS = fragRetentionSMARTS;
784 }
785
786//------------------------------------------------------------------------------
787
791 public ArrayList<Vertex> getIgnorableFragments()
792 {
793 return ignorableFragments;
794 }
795
796//------------------------------------------------------------------------------
797
802 public ArrayList<Vertex> getTargetFragments()
803 {
804 return targetFragments;
805 }
806
807//------------------------------------------------------------------------------
808
838 {
840 }
841
842//------------------------------------------------------------------------------
843
845 {
847 }
848
849//------------------------------------------------------------------------------
850
852 {
853 this.isomorphicSampleSize = isomorphicSampleSize;
854 }
855
856//------------------------------------------------------------------------------
857
858 public int getMWSlotSize()
859 {
860 return mwSlotSize;
861 }
862
863//------------------------------------------------------------------------------
864
865 public void setMWSlotSize(int mwSlotSize)
866 {
867 this.mwSlotSize = mwSlotSize;
868 }
869
870//------------------------------------------------------------------------------
871
872 public Map<String, File> getMWSlotToAllFragsFile()
873 {
875 }
876
877//------------------------------------------------------------------------------
878
879 public void setMWSlotToAllFragsFile(Map<String, File> mwSlotToAllFragsFile)
880 {
881 this.mwSlotToAllFragsFile = mwSlotToAllFragsFile;
882 }
883
884//------------------------------------------------------------------------------
885
886 public Map<String, File> getMWSlotToUnqFragsFile()
887 {
889 }
890
891//------------------------------------------------------------------------------
892
901 public File getMWSlotFileNameUnqFrags(String mwSlotId)
902 {
903 return new File(getWorkDirectory() + DenoptimIO.FS
907 }
908
909//------------------------------------------------------------------------------
910
918 public File getMWSlotFileNameAllFrags(String mwSlotId)
919 {
920 return new File(getWorkDirectory() + DenoptimIO.FS
924 }
925
926//------------------------------------------------------------------------------
927
931 public Map<String,Integer> getIsomorphsCount()
932 {
933 return isomorphsCount;
934 }
935
936//------------------------------------------------------------------------------
937
942 public String newIsomorphicFamilyID()
943 {
944 return "IsomorphicFamily_" + unqIsomorphicFamilyId.getAndIncrement();
945 }
946
947//------------------------------------------------------------------------------
948
954 public boolean doFiltering()
955 {
956 return doFiltering;
957 }
958
959//------------------------------------------------------------------------------
960
964 public boolean addExplicitH()
965 {
966 return addExplicitH;
967 }
968
969//------------------------------------------------------------------------------
970
975 public void setAddExplicitH(boolean addExplicitH)
976 {
977 this.addExplicitH = addExplicitH;
978 }
979
980//------------------------------------------------------------------------------
981
986 public boolean acceptUnsetToSingeBO()
987 {
989 }
990
991//-----------------------------------------------------------------------------
992
998 {
999 this.embedRingsInTemplate = embedRingsInTemplate;
1000 }
1001
1002//-----------------------------------------------------------------------------
1003
1008 public boolean embedRingsInTemplate()
1009 {
1010 return embedRingsInTemplate;
1011 }
1012
1013//------------------------------------------------------------------------------
1014
1021 {
1022 this.embeddedRingsContract = embeddedRingsContract;
1023 }
1024
1025//------------------------------------------------------------------------------
1026
1032 {
1033 return embeddedRingsContract;
1034 }
1035
1036//------------------------------------------------------------------------------
1037
1043 {
1044 this.scaffoldingPolicy = sp;
1045 }
1046
1047//------------------------------------------------------------------------------
1048
1054 {
1055 return scaffoldingPolicy;
1056 }
1057
1058//------------------------------------------------------------------------------
1059
1064 public List<DGraph> getFragmentationTmpls()
1065 {
1066 return fragmentationTmpls;
1067 }
1068
1069//------------------------------------------------------------------------------
1070
1077 {
1078 return maxBufferShellSize;
1079 }
1080
1081//------------------------------------------------------------------------------
1082
1089 public void interpretKeyword(String key, String value)
1090 throws DENOPTIMException
1091 {
1092 String msg = "";
1093 switch (key.toUpperCase())
1094 {
1095 case "WORKDIR=":
1096 workDir = value;
1097 break;
1098
1099 case "STRUCTURESFILE=":
1100 structuresFile = value;
1101 break;
1102
1103 case "FORMULATXTFILE=":
1104 checkFormula = true;
1105 formulaeFile = value;
1106 break;
1107
1108 case "PREFILTERSMARTS=":
1109 preFilter = true;
1110 preFilterSMARTS.add(value);
1111 break;
1112
1113 case "CUTTINGRULESFILE=":
1114 doFragmentation = true;
1115 cutRulesFile = value;
1116 break;
1117
1118 case "EXTRACTFROMGRAPHS=":
1119 structuresFile = value;
1121 break;
1122
1123 case "ADDEXPLICITHYDROGEN":
1124 addExplicitH = true;
1125 break;
1126
1127 case "UNSETTOSINGLEBO":
1129 break;
1130
1131 case "IGNORABLEFRAGMENTS=":
1132 ignorableFragmentsFile = value;
1133 doFiltering = true;
1134 break;
1135
1136 case "TARGETFRAGMENTS=":
1137 targetFragmentsFile = value;
1138 doFiltering = true;
1139 break;
1140
1141 case "ISOMORPHICSAMPLESIZE=":
1142 try {
1143 isomorphicSampleSize = Integer.parseInt(value);
1144 } catch (Throwable t)
1145 {
1146 msg = "Unable to parse value of " + key + ": '" + value + "'";
1147 throw new DENOPTIMException(msg);
1148 }
1151 break;
1152
1153 case "REMOVEDUPLICATES":
1155 break;
1156
1157 case "MWSLOTSIZE=":
1158 try {
1159 mwSlotSize = Integer.parseInt(value);
1160 } catch (Throwable t)
1161 {
1162 msg = "Unable to parse value of " + key + ": '" + value + "'";
1163 throw new DENOPTIMException(msg);
1164 }
1165 break;
1166
1167 case "REJECTMINORISOTOPES":
1168 doRejectWeirdIsotopes = true;
1169 doFiltering = true;
1170 break;
1171
1172 case "REJECTELEMENT=":
1173 rejectedElements.add(value);
1174 doFiltering = true;
1175 break;
1176
1177 case "REJFORMULALESSTHAN=":
1178 if (formulaCriteriaLessThan.size()>0)
1179 {
1180 msg = "Attempt to specify more than one criterion for "
1181 + "rejecting fragments based on a lower-limit "
1182 + "molecular formula. ";
1183 throw new DENOPTIMException(msg);
1184 }
1185 Map<String,Double> elSymbolsCount = null;
1186 try {
1187 elSymbolsCount = FormulaUtils.parseFormula(value);
1188 } catch (Throwable t)
1189 {
1190 msg = "Unable to parse value of " + key + ": '" + value + "'";
1191 throw new DENOPTIMException(msg);
1192 }
1193 formulaCriteriaLessThan = elSymbolsCount;
1194 doFiltering = true;
1195 break;
1196
1197 case "REJFORMULAMORETHAN=":
1198 Map<String,Double> elSymbolsCount2= null;
1199 try {
1200 elSymbolsCount2 = FormulaUtils.parseFormula(value);
1201 } catch (Throwable t)
1202 {
1203 msg = "Unable to parse value of " + key + ": '" + value + "'";
1204 throw new DENOPTIMException(msg);
1205 }
1206 formulaCriteriaMoreThan.add(elSymbolsCount2);
1207 doFiltering = true;
1208 break;
1209
1210 case "REJECTAPCLASS=":
1211 rejectedAPClasses.add(value);
1212 doFiltering = true;
1213 break;
1214
1215 case "REJECTAPCLASSCOMBINATION=":
1216 String[] lst = value.split("\\s+");
1218 doFiltering = true;
1219 break;
1220
1221 case "MAXFRAGSIZE=":
1222 try {
1223 maxFragHeavyAtomCount = Integer.parseInt(value);
1224 } catch (Throwable t)
1225 {
1226 msg = "Unable to parse value of " + key + ": '" + value + "'";
1227 throw new DENOPTIMException(msg);
1228 }
1229 doFiltering = true;
1230 break;
1231
1232 case "MINFRAGSIZE=":
1233 try {
1234 minFragHeavyAtomCount = Integer.parseInt(value);
1235 } catch (Throwable t)
1236 {
1237 msg = "Unable to parse value of " + key + ": '" + value + "'";
1238 throw new DENOPTIMException(msg);
1239 }
1240 doFiltering = true;
1241 break;
1242
1243 case "REJECTSMARTS=":
1244 fragRejectionSMARTS.put(value, value);
1245 doFiltering = true;
1246 break;
1247
1248 case "RETAINSMARTS=":
1249 fragRetentionSMARTS.put(value, value);
1250 doFiltering = true;
1251 break;
1252
1253 case "CLUSTERIZEANDCOLLECT=":
1256 switch (value.trim().toUpperCase())
1257 {
1258 case "CENTROIDS":
1260 break;
1261
1262 case "MOSTCENTRAL":
1264 break;
1265
1266 default:
1267 throw new DENOPTIMException("Unable to parse value of "
1268 + key + ": '" + value + "'");
1269 }
1270 break;
1271
1272 case "SAVECLUSTERS":
1275 break;
1276
1277 case "SIZEUNIMODALPOPULATION=":
1278 sizeUnimodalPop = Integer.parseInt(value);
1279 break;
1280
1281 case "MAXNOISEUNIMODALPOPULATION=":
1282 maxNoiseUnimodalPop = Double.parseDouble(value);
1283 break;
1284
1285 case "SDWEIGHTUNIMODALPOPULATION=":
1286 factorForSDOnStatsOfUnimodalPop = Double.parseDouble(value);
1287 break;
1288
1289 case "SCAFFOLDINGPOLICY=":
1290 String[] words = value.split("\\s+");
1291 try {
1293 words[0].toUpperCase());
1295 {
1296 if (words.length<2)
1297 {
1298 throw new DENOPTIMException("Expected elemental "
1299 + "symbol after '"
1300 + ScaffoldingPolicy.ELEMENT+ "', but none "
1301 + "found");
1302 }
1303 scaffoldingPolicy.label = words[1];
1304 }
1305 } catch (Throwable t)
1306 {
1307 msg = "Unable to parse value of " + key + ": '" + value + "'";
1308 throw new DENOPTIMException(msg, t);
1309 }
1310 break;
1311
1312 case "EMBEDRINGSINTEMPLATES=":
1313 {
1315 break;
1316 }
1317
1318 case "RINGEMBEDDINGCONTRACT=":
1319 {
1320 if (value.length() > 0)
1321 {
1322 embeddedRingsContract = ContractLevel.valueOf(value);
1323 }
1324 break;
1325 }
1326
1327 case "FRAGMENTATIONTEMPLATE=":
1328 {
1329 doFragmentation = true;
1330 fragmentationTmplFile = value;
1331 break;
1332 }
1333
1334 case "BONDSAROUNDTOPOCRITICATOM=":
1335 {
1336 maxBufferShellSize = Integer.parseInt(value);
1337 }
1338
1339/*
1340 case "=":
1341 = value;
1342 doFiltering = true;
1343 break;
1344 */
1345
1346 case "PARALLELTASKS=":
1347 try
1348 {
1349 numParallelTasks = Integer.parseInt(value);
1350 }
1351 catch (Throwable t)
1352 {
1353 msg = "Unable to understand value " + key + "'" + value + "'";
1354 throw new DENOPTIMException(msg);
1355 }
1356 break;
1357
1358 case "VERBOSITY=":
1359 try
1360 {
1361 verbosity = Integer.parseInt(value);
1362 }
1363 catch (Throwable t)
1364 {
1365 msg = "Unable to understand value " + key + "'" + value + "'";
1366 throw new DENOPTIMException(msg);
1367 }
1368 break;
1369
1370 default:
1371 msg = "Keyword " + key + " is not a known Fragmenter-"
1372 + "related keyword. Check input files.";
1373 throw new DENOPTIMException(msg);
1374 }
1375 }
1376
1377//------------------------------------------------------------------------------
1378
1385 {
1386 if (!workDir.equals(System.getProperty("user.dir")))
1387 {
1389 }
1390 ensureIsPositive("numParallelTasks", numParallelTasks, "PARALLELTASKS");
1391 ensureIsPositive("isomorphicSampleSize", isomorphicSampleSize,
1392 "ISOMORPHICSAMPLESIZE");
1393 ensureIsPositive("mwSlotSize", mwSlotSize, "MWSLOTSIZE");
1400
1402 }
1403
1404//------------------------------------------------------------------------------
1405
1412 {
1413 if (isMaster)
1415
1416 cuttingRules = new ArrayList<CuttingRule>();
1417 if (cutRulesFile!=null && !cutRulesFile.isBlank())
1418 {
1420 }
1421 if (formulaeFile!=null && !formulaeFile.isBlank())
1422 {
1424 }
1426
1427 if (ignorableFragmentsFile!=null && !ignorableFragmentsFile.isBlank())
1428 {
1429 try
1430 {
1433 } catch (Throwable e)
1434 {
1435 throw new DENOPTIMException("Problems reading file '"
1436 + ignorableFragmentsFile + "'", e);
1437 }
1438 }
1439
1440 if (targetFragmentsFile!=null && !targetFragmentsFile.isBlank())
1441 {
1442 try
1443 {
1446 } catch (Throwable e)
1447 {
1448 throw new DENOPTIMException("Problems reading file '"
1449 + targetFragmentsFile + "'", e);
1450 }
1451 }
1452
1453 if (fragmentationTmplFile!=null && !fragmentationTmplFile.isBlank())
1454 {
1455 try
1456 {
1458 new File(fragmentationTmplFile));
1459 } catch (Throwable e)
1460 {
1461 throw new DENOPTIMException("Problems reading file '"
1462 + fragmentationTmplFile + "'", e);
1463 }
1464 }
1465
1467 {
1469 }
1470
1471 if (isMaster)
1472 {
1473 StaticLogger.appLogger.log(Level.INFO, "Program log file: "
1475 + "Output files associated with the current run are "
1476 + "located in " + workDir);
1477 }
1478 }
1479
1480//------------------------------------------------------------------------------
1481
1483 {
1484 String curDir = workDir;
1485 String fileSep = System.getProperty("file.separator");
1486 boolean success = false;
1487 while (!success)
1488 {
1489 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddkkmmss");
1490 String str = "FRG" + sdf.format(new Date());
1491 workDir = curDir + fileSep + str;
1493 }
1495 logFile = workDir + ".log";
1496 }
1497
1498//------------------------------------------------------------------------------
1499
1506 public String getPrintedList()
1507 {
1508 StringBuilder sb = new StringBuilder(1024);
1509 sb.append(" " + paramTypeName() + " ").append(NL);
1510 for (Field f : this.getClass().getDeclaredFields())
1511 {
1512 try
1513 {
1514 sb.append(f.getName()).append(" = ").append(
1515 f.get(this)).append(NL);
1516 }
1517 catch (Throwable t)
1518 {
1519 sb.append("ERROR! Unable to print " + paramTypeName()
1520 + " parameters. Cause: " + t);
1521 break;
1522 }
1523 }
1524 for (RunTimeParameters otherCollector : otherParameters.values())
1525 {
1526 sb.append(otherCollector.getPrintedList());
1527 }
1528 return sb.toString();
1529 }
1530
1531//------------------------------------------------------------------------------
1532
1537 public double getLinearAngleLimit()
1538 {
1539 return linearAngleLimit;
1540 }
1541
1542//------------------------------------------------------------------------------
1543
1550 {
1551 this.linearAngleLimit = linearAngleLimit;
1552 }
1553
1554//------------------------------------------------------------------------------
1555
1561 {
1563 }
1564
1565//------------------------------------------------------------------------------
1566
1573 {
1574 return sizeUnimodalPop;
1575 }
1576
1577//------------------------------------------------------------------------------
1578
1585 {
1586 this.sizeUnimodalPop = sizeUnimodalPop;
1587 }
1588
1589//------------------------------------------------------------------------------
1590
1598 {
1599 return maxNoiseUnimodalPop;
1600 }
1601
1602//------------------------------------------------------------------------------
1603
1611 {
1612 this.maxNoiseUnimodalPop = maxNoiseUnimodalPop;
1613 }
1614
1615//------------------------------------------------------------------------------
1616
1624 {
1626 }
1627
1628
1629//------------------------------------------------------------------------------
1630
1639 {
1640 this.factorForSDOnStatsOfUnimodalPop = factorForSDOnStatsOfUnimodalPop;
1641 }
1642
1643//------------------------------------------------------------------------------
1644
1652 {
1654 }
1655
1656//------------------------------------------------------------------------------
1657
1667 {
1668 this.useCentroidsAsRepresentativeConformer =
1670 }
1671
1672//------------------------------------------------------------------------------
1673
1680 {
1682 }
1683
1684//------------------------------------------------------------------------------
1685
1694 {
1695 this.saveClustersOfConformerToFile = saveClustersOfConformerToFile;
1696 }
1697
1698//------------------------------------------------------------------------------
1699
1705 {
1707 }
1708
1709//------------------------------------------------------------------------------
1710
1715 public boolean isWorkingIn3D()
1716 {
1717 return workingIn3D;
1718 }
1719
1720//------------------------------------------------------------------------------
1721
1726 public void setWorkingIn3D(boolean workingIn3D)
1727 {
1728 this.workingIn3D = workingIn3D;
1729 }
1730
1731//------------------------------------------------------------------------------
1732
1737 public void setFragmentationTmpls(List<DGraph> fragmentationTmpls) {
1738 this.fragmentationTmpls = fragmentationTmpls;
1739 }
1740
1741//------------------------------------------------------------------------------
1742
1743}
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.
int maxBufferShellSize
Maximum number of buffer shells to consider for fragmentation.
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.