$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 doRejectWeirdIsotopes = true;
142
146 private Set<String> rejectedElements = new HashSet<String>();
147
153 private Map<String,Double> formulaCriteriaLessThan =
154 new HashMap<String,Double>();
155
161 private Set<Map<String,Double>> formulaCriteriaMoreThan =
162 new HashSet<Map<String,Double>>();
163
167 private Set<String> rejectedAPClasses = new HashSet<String>();
168
173 private Set<String[]> rejectedAPClassCombinations = new HashSet<String[]>();
174
179 private int maxFragHeavyAtomCount = -1;
180
185 private int minFragHeavyAtomCount = -1;
186
190 private Map<String, String> fragRejectionSMARTS = new HashMap<String, String>();
191
196 private Map<String, String> fragRetentionSMARTS = new HashMap<String, String>();
197
202 private boolean doAddDuOnLinearity = true;
203
208 private double linearAngleLimit = 170.0;
209
213 private String ignorableFragmentsFile = "";
214
218 private ArrayList<Vertex> ignorableFragments = new ArrayList<Vertex>();
219
224 private String targetFragmentsFile = "";
225
230 private ArrayList<Vertex> targetFragments = new ArrayList<Vertex>();
231
258 // NB: javadoc reproduced also in the getter method. See below
259 private boolean doManageIsomorphicFamilies = false;
260
267 private int isomorphicSampleSize = 1;
268
272 public static final int MAXISOMORPHICSAMPLESIZE = 50;
273
277 private int mwSlotSize = 10;
278
283 private Map<String,File> mwSlotToAllFragsFile = new HashMap<String,File>();
284
289 private Map<String,File> mwSlotToUnqFragsFile = new HashMap<String,File>();
290
296 private Map<String,Integer> isomorphsCount = new HashMap<String,Integer>();
297
298 //TODO: We could use something like the SizeControlledSet used in the EA to
299 // collect unique identifiers.
300
304 private AtomicInteger unqIsomorphicFamilyId = new AtomicInteger(0);
305
311 public final Object MANAGEMWSLOTSSLOCK = new Object();
312
318 private boolean doExtactRepresentativeConformer = false;
319
326 private int sizeUnimodalPop = 20;
327
333 private double maxNoiseUnimodalPop = 0.2;
334
344
350
354 private boolean saveClustersOfConformerToFile = false;
355
359 private boolean isStandaloneFragmentClustering = false;
360
364 private boolean workingIn3D = true;
365
372
377 protected boolean embedRingsInTemplate = false;
378
384
389 private String fragmentationTmplFile = "";
390
395 private List<DGraph> fragmentationTmpls = new ArrayList<DGraph>();
396
397//------------------------------------------------------------------------------
398
403 {
405 }
406
407//------------------------------------------------------------------------------
408
412 public int getNumTasks()
413 {
414 return numParallelTasks;
415 }
416
417//------------------------------------------------------------------------------
418
424 {
425 this.numParallelTasks = numParallelTasks;
426 }
427
428//------------------------------------------------------------------------------
429
433 public String getStructuresFile()
434 {
435 return structuresFile;
436 }
437
438//------------------------------------------------------------------------------
439
445 {
446 this.structuresFile = structuresFile;
447 }
448
449//------------------------------------------------------------------------------
450
456 public void setFormulaeFile(String formulaeFile)
457 {
458 this.formulaeFile = formulaeFile;
459 }
460
461//------------------------------------------------------------------------------
462
467 public String getFormulaeFile()
468 {
469 return formulaeFile;
470 }
471
472//------------------------------------------------------------------------------
473
477 public List<CuttingRule> getCuttingRules()
478 {
479 return cuttingRules;
480 }
481
482//------------------------------------------------------------------------------
483
487 public void setCuttingRules(List<CuttingRule> cuttingRules)
488 {
489 this.cuttingRules = cuttingRules;
490 }
491
492//------------------------------------------------------------------------------
493
497 public void setCuttingRulesFilePathname(String pathname)
498 {
499 this.cutRulesFile = pathname;
500 }
501
502//------------------------------------------------------------------------------
503
508 {
509 return cutRulesFile;
510 }
511
512//------------------------------------------------------------------------------
513
517 public LinkedHashMap<String, String> getFormulae()
518 {
519 return formulae;
520 }
521
522//------------------------------------------------------------------------------
523
530 public boolean doCheckFormula()
531 {
532 return checkFormula;
533 }
534
535//------------------------------------------------------------------------------
536
542 public void setCheckFormula(boolean checkFormula)
543 {
544 this.checkFormula = checkFormula;
545 }
546
547
548//------------------------------------------------------------------------------
549
553 public boolean doPreFilter()
554 {
555 return preFilter;
556 }
557
558//------------------------------------------------------------------------------
559
564 public Set<String> getPreFiltrationSMARTS()
565 {
566 return preFilterSMARTS;
567 }
568
569//------------------------------------------------------------------------------
570
574 public boolean doFragmentation()
575 {
576 return doFragmentation;
577 }
578
579//------------------------------------------------------------------------------
580
585 public boolean doRejectWeirdIsotopes()
586 {
588 }
589
590//------------------------------------------------------------------------------
591
596 public boolean doAddDuOnLinearity()
597 {
598 return doAddDuOnLinearity;
599 }
600
601//------------------------------------------------------------------------------
602
606 public Set<String> getRejectedElements()
607 {
608 return rejectedElements;
609 }
610
611//------------------------------------------------------------------------------
612
617 public Map<String, Double> getRejectedFormulaLessThan()
618 {
620 }
621
622//------------------------------------------------------------------------------
623
628 public Set<Map<String, Double>> getRejectedFormulaMoreThan()
629 {
631 }
632
633//------------------------------------------------------------------------------
634
638 public Set<String> getRejectedAPClasses()
639 {
640 return rejectedAPClasses;
641 }
642
643//------------------------------------------------------------------------------
644
648 public Set<String[]> getRejectedAPClassCombinations()
649 {
651 }
652
653//------------------------------------------------------------------------------
654
659 {
661 }
662
663//------------------------------------------------------------------------------
664
669 {
671 }
672
673//------------------------------------------------------------------------------
674
678 public Map<String, String> getFragRejectionSMARTS()
679 {
680 return fragRejectionSMARTS;
681 }
682
683//------------------------------------------------------------------------------
684
688 public Map<String, String> getFragRetentionSMARTS()
689 {
690 return fragRetentionSMARTS;
691 }
692
693//------------------------------------------------------------------------------
694
696 {
697 this.doRejectWeirdIsotopes = doRejectWeirdIsotopes;
698 }
699
700//------------------------------------------------------------------------------
701
702 public void setRejectedElements(Set<String> rejectedElements)
703 {
704 this.rejectedElements = rejectedElements;
705 }
706
707//------------------------------------------------------------------------------
708
710 Map<String, Double> formulaMax)
711 {
712 this.formulaCriteriaLessThan = formulaMax;
713 }
714
715//------------------------------------------------------------------------------
716
718 Set<Map<String, Double>> formulaCriteriaMoreThan)
719 {
720 this.formulaCriteriaMoreThan = formulaCriteriaMoreThan;
721 }
722
723//------------------------------------------------------------------------------
724
726 {
727 this.rejectedAPClasses = rejectedAPClasses;
728 }
729
730//------------------------------------------------------------------------------
731
733 Set<String[]> rejectedAPClassCombinations)
734 {
735 this.rejectedAPClassCombinations = rejectedAPClassCombinations;
736 }
737
738//------------------------------------------------------------------------------
739
741 {
742 this.maxFragHeavyAtomCount = maxFragHeavyAtomCount;
743 }
744
745//------------------------------------------------------------------------------
746
748 {
749 this.minFragHeavyAtomCount = minFragHeavyAtomCount;
750 }
751
752//------------------------------------------------------------------------------
753
754 public void setFragRejectionSMARTS(Map<String, String> fragRejectionSMARTS)
755 {
756 this.fragRejectionSMARTS = fragRejectionSMARTS;
757 }
758
759//------------------------------------------------------------------------------
760
761 public void setFragRetentionSMARTS(Map<String, String> fragRetentionSMARTS)
762 {
763 this.fragRetentionSMARTS = fragRetentionSMARTS;
764 }
765
766//------------------------------------------------------------------------------
767
771 public ArrayList<Vertex> getIgnorableFragments()
772 {
773 return ignorableFragments;
774 }
775
776//------------------------------------------------------------------------------
777
782 public ArrayList<Vertex> getTargetFragments()
783 {
784 return targetFragments;
785 }
786
787//------------------------------------------------------------------------------
788
818 {
820 }
821
822//------------------------------------------------------------------------------
823
825 {
827 }
828
829//------------------------------------------------------------------------------
830
832 {
833 this.isomorphicSampleSize = isomorphicSampleSize;
834 }
835
836//------------------------------------------------------------------------------
837
838 public int getMWSlotSize()
839 {
840 return mwSlotSize;
841 }
842
843//------------------------------------------------------------------------------
844
845 public void setMWSlotSize(int mwSlotSize)
846 {
847 this.mwSlotSize = mwSlotSize;
848 }
849
850//------------------------------------------------------------------------------
851
852 public Map<String, File> getMWSlotToAllFragsFile()
853 {
855 }
856
857//------------------------------------------------------------------------------
858
859 public void setMWSlotToAllFragsFile(Map<String, File> mwSlotToAllFragsFile)
860 {
861 this.mwSlotToAllFragsFile = mwSlotToAllFragsFile;
862 }
863
864//------------------------------------------------------------------------------
865
866 public Map<String, File> getMWSlotToUnqFragsFile()
867 {
869 }
870
871//------------------------------------------------------------------------------
872
881 public File getMWSlotFileNameUnqFrags(String mwSlotId)
882 {
883 return new File(getWorkDirectory() + DenoptimIO.FS
887 }
888
889//------------------------------------------------------------------------------
890
898 public File getMWSlotFileNameAllFrags(String mwSlotId)
899 {
900 return new File(getWorkDirectory() + DenoptimIO.FS
904 }
905
906//------------------------------------------------------------------------------
907
911 public Map<String,Integer> getIsomorphsCount()
912 {
913 return isomorphsCount;
914 }
915
916//------------------------------------------------------------------------------
917
922 public String newIsomorphicFamilyID()
923 {
924 return "IsomorphicFamily_" + unqIsomorphicFamilyId.getAndIncrement();
925 }
926
927//------------------------------------------------------------------------------
928
934 public boolean doFiltering()
935 {
936 return doFiltering;
937 }
938
939//------------------------------------------------------------------------------
940
944 public boolean addExplicitH()
945 {
946 return addExplicitH;
947 }
948
949//------------------------------------------------------------------------------
950
955 public void setAddExplicitH(boolean addExplicitH)
956 {
957 this.addExplicitH = addExplicitH;
958 }
959
960//------------------------------------------------------------------------------
961
966 public boolean acceptUnsetToSingeBO()
967 {
969 }
970
971//-----------------------------------------------------------------------------
972
978 {
979 this.embedRingsInTemplate = embedRingsInTemplate;
980 }
981
982//-----------------------------------------------------------------------------
983
988 public boolean embedRingsInTemplate()
989 {
991 }
992
993//------------------------------------------------------------------------------
994
1001 {
1002 this.embeddedRingsContract = embeddedRingsContract;
1003 }
1004
1005//------------------------------------------------------------------------------
1006
1012 {
1013 return embeddedRingsContract;
1014 }
1015
1016//------------------------------------------------------------------------------
1017
1023 {
1024 this.scaffoldingPolicy = sp;
1025 }
1026
1027//------------------------------------------------------------------------------
1028
1034 {
1035 return scaffoldingPolicy;
1036 }
1037
1038//------------------------------------------------------------------------------
1039
1044 public List<DGraph> getFragmentationTmpls()
1045 {
1046 return fragmentationTmpls;
1047 }
1048
1049//------------------------------------------------------------------------------
1050
1057 public void interpretKeyword(String key, String value)
1058 throws DENOPTIMException
1059 {
1060 String msg = "";
1061 switch (key.toUpperCase())
1062 {
1063 case "WORKDIR=":
1064 workDir = value;
1065 break;
1066
1067 case "STRUCTURESFILE=":
1068 structuresFile = value;
1069 break;
1070
1071 case "FORMULATXTFILE=":
1072 checkFormula = true;
1073 formulaeFile = value;
1074 break;
1075
1076 case "PREFILTERSMARTS=":
1077 preFilter = true;
1078 preFilterSMARTS.add(value);
1079 break;
1080
1081 case "CUTTINGRULESFILE=":
1082 doFragmentation = true;
1083 cutRulesFile = value;
1084 break;
1085
1086 case "ADDEXPLICITHYDROGEN":
1087 addExplicitH = true;
1088 break;
1089
1090 case "UNSETTOSINGLEBO":
1092 break;
1093
1094 case "IGNORABLEFRAGMENTS=":
1095 ignorableFragmentsFile = value;
1096 doFiltering = true;
1097 break;
1098
1099 case "TARGETFRAGMENTS=":
1100 targetFragmentsFile = value;
1101 doFiltering = true;
1102 break;
1103
1104 case "ISOMORPHICSAMPLESIZE=":
1105 try {
1106 isomorphicSampleSize = Integer.parseInt(value);
1107 } catch (Throwable t)
1108 {
1109 msg = "Unable to parse value of " + key + ": '" + value + "'";
1110 throw new DENOPTIMException(msg);
1111 }
1114 break;
1115
1116 case "REMOVEDUPLICATES":
1118 break;
1119
1120 case "MWSLOTSIZE=":
1121 try {
1122 mwSlotSize = Integer.parseInt(value);
1123 } catch (Throwable t)
1124 {
1125 msg = "Unable to parse value of " + key + ": '" + value + "'";
1126 throw new DENOPTIMException(msg);
1127 }
1128 break;
1129
1130 case "REJECTMINORISOTOPES":
1131 doRejectWeirdIsotopes = true;
1132 doFiltering = true;
1133 break;
1134
1135 case "REJECTELEMENT=":
1136 rejectedElements.add(value);
1137 doFiltering = true;
1138 break;
1139
1140 case "REJFORMULALESSTHAN=":
1141 if (formulaCriteriaLessThan.size()>0)
1142 {
1143 msg = "Attempt to specify more than one criterion for "
1144 + "rejecting fragments based on a lower-limit "
1145 + "molecular formula. ";
1146 throw new DENOPTIMException(msg);
1147 }
1148 Map<String,Double> elSymbolsCount = null;
1149 try {
1150 elSymbolsCount = FormulaUtils.parseFormula(value);
1151 } catch (Throwable t)
1152 {
1153 msg = "Unable to parse value of " + key + ": '" + value + "'";
1154 throw new DENOPTIMException(msg);
1155 }
1156 formulaCriteriaLessThan = elSymbolsCount;
1157 doFiltering = true;
1158 break;
1159
1160 case "REJFORMULAMORETHAN=":
1161 Map<String,Double> elSymbolsCount2= null;
1162 try {
1163 elSymbolsCount2 = FormulaUtils.parseFormula(value);
1164 } catch (Throwable t)
1165 {
1166 msg = "Unable to parse value of " + key + ": '" + value + "'";
1167 throw new DENOPTIMException(msg);
1168 }
1169 formulaCriteriaMoreThan.add(elSymbolsCount2);
1170 doFiltering = true;
1171 break;
1172
1173 case "REJECTAPCLASS=":
1174 rejectedAPClasses.add(value);
1175 doFiltering = true;
1176 break;
1177
1178 case "REJECTAPCLASSCOMBINATION=":
1179 String[] lst = value.split("\\s+");
1181 doFiltering = true;
1182 break;
1183
1184 case "MAXFRAGSIZE=":
1185 try {
1186 maxFragHeavyAtomCount = Integer.parseInt(value);
1187 } catch (Throwable t)
1188 {
1189 msg = "Unable to parse value of " + key + ": '" + value + "'";
1190 throw new DENOPTIMException(msg);
1191 }
1192 doFiltering = true;
1193 break;
1194
1195 case "MINFRAGSIZE=":
1196 try {
1197 minFragHeavyAtomCount = Integer.parseInt(value);
1198 } catch (Throwable t)
1199 {
1200 msg = "Unable to parse value of " + key + ": '" + value + "'";
1201 throw new DENOPTIMException(msg);
1202 }
1203 doFiltering = true;
1204 break;
1205
1206 case "REJECTSMARTS=":
1207 fragRejectionSMARTS.put(value, value);
1208 doFiltering = true;
1209 break;
1210
1211 case "RETAINSMARTS=":
1212 fragRetentionSMARTS.put(value, value);
1213 doFiltering = true;
1214 break;
1215
1216 case "CLUSTERIZEANDCOLLECT=":
1219 switch (value.trim().toUpperCase())
1220 {
1221 case "CENTROIDS":
1223 break;
1224
1225 case "MOSTCENTRAL":
1227 break;
1228
1229 default:
1230 throw new DENOPTIMException("Unable to parse value of "
1231 + key + ": '" + value + "'");
1232 }
1233 break;
1234
1235 case "SAVECLUSTERS":
1238 break;
1239
1240 case "SIZEUNIMODALPOPULATION=":
1241 sizeUnimodalPop = Integer.parseInt(value);
1242 break;
1243
1244 case "MAXNOISEUNIMODALPOPULATION=":
1245 maxNoiseUnimodalPop = Double.parseDouble(value);
1246 break;
1247
1248 case "SDWEIGHTUNIMODALPOPULATION=":
1249 factorForSDOnStatsOfUnimodalPop = Double.parseDouble(value);
1250 break;
1251
1252 case "SCAFFOLDINGPOLICY=":
1253 String[] words = value.split("\\s+");
1254 try {
1256 words[0].toUpperCase());
1258 {
1259 if (words.length<2)
1260 {
1261 throw new DENOPTIMException("Expected elemental "
1262 + "symbol after '"
1263 + ScaffoldingPolicy.ELEMENT+ "', but none "
1264 + "found");
1265 }
1266 scaffoldingPolicy.label = words[1];
1267 }
1268 } catch (Throwable t)
1269 {
1270 msg = "Unable to parse value of " + key + ": '" + value + "'";
1271 throw new DENOPTIMException(msg, t);
1272 }
1273 break;
1274
1275 case "EMBEDRINGSINTEMPLATES=":
1276 {
1278 break;
1279 }
1280
1281 case "RINGEMBEDDINGCONTRACT=":
1282 {
1283 if (value.length() > 0)
1284 {
1285 embeddedRingsContract = ContractLevel.valueOf(value);
1286 }
1287 break;
1288 }
1289
1290 case "FRAGMENTATIONTEMPLATE=":
1291 {
1292 doFragmentation = true;
1293 fragmentationTmplFile = value;
1294 break;
1295 }
1296
1297/*
1298 case "=":
1299 = value;
1300 doFiltering = true;
1301 break;
1302 */
1303
1304 case "PARALLELTASKS=":
1305 try
1306 {
1307 numParallelTasks = Integer.parseInt(value);
1308 }
1309 catch (Throwable t)
1310 {
1311 msg = "Unable to understand value " + key + "'" + value + "'";
1312 throw new DENOPTIMException(msg);
1313 }
1314 break;
1315
1316 case "VERBOSITY=":
1317 try
1318 {
1319 verbosity = Integer.parseInt(value);
1320 }
1321 catch (Throwable t)
1322 {
1323 msg = "Unable to understand value " + key + "'" + value + "'";
1324 throw new DENOPTIMException(msg);
1325 }
1326 break;
1327
1328 default:
1329 msg = "Keyword " + key + " is not a known Fragmenter-"
1330 + "related keyword. Check input files.";
1331 throw new DENOPTIMException(msg);
1332 }
1333 }
1334
1335//------------------------------------------------------------------------------
1336
1343 {
1344 if (!workDir.equals(System.getProperty("user.dir")))
1345 {
1347 }
1348 ensureIsPositive("numParallelTasks", numParallelTasks, "PARALLELTASKS");
1349 ensureIsPositive("isomorphicSampleSize", isomorphicSampleSize,
1350 "ISOMORPHICSAMPLESIZE");
1351 ensureIsPositive("mwSlotSize", mwSlotSize, "MWSLOTSIZE");
1358
1360 }
1361
1362//------------------------------------------------------------------------------
1363
1370 {
1371 if (isMaster)
1373
1374 cuttingRules = new ArrayList<CuttingRule>();
1375 if (cutRulesFile!=null && !cutRulesFile.isBlank())
1376 {
1378 }
1379 if (formulaeFile!=null && !formulaeFile.isBlank())
1380 {
1382 }
1384
1385 if (ignorableFragmentsFile!=null && !ignorableFragmentsFile.isBlank())
1386 {
1387 try
1388 {
1391 } catch (Throwable e)
1392 {
1393 throw new DENOPTIMException("Problems reading file '"
1394 + ignorableFragmentsFile + "'", e);
1395 }
1396 }
1397
1398 if (targetFragmentsFile!=null && !targetFragmentsFile.isBlank())
1399 {
1400 try
1401 {
1404 } catch (Throwable e)
1405 {
1406 throw new DENOPTIMException("Problems reading file '"
1407 + targetFragmentsFile + "'", e);
1408 }
1409 }
1410
1411 if (fragmentationTmplFile!=null && !fragmentationTmplFile.isBlank())
1412 {
1413 try
1414 {
1416 new File(fragmentationTmplFile));
1417 } catch (Throwable e)
1418 {
1419 throw new DENOPTIMException("Problems reading file '"
1420 + fragmentationTmplFile + "'", e);
1421 }
1422 }
1423
1425 {
1427 }
1428
1429 if (isMaster)
1430 {
1431 StaticLogger.appLogger.log(Level.INFO, "Program log file: "
1433 + "Output files associated with the current run are "
1434 + "located in " + workDir);
1435 }
1436 }
1437
1438//------------------------------------------------------------------------------
1439
1441 {
1442 String curDir = workDir;
1443 String fileSep = System.getProperty("file.separator");
1444 boolean success = false;
1445 while (!success)
1446 {
1447 SimpleDateFormat sdf = new SimpleDateFormat("yyyyMMddkkmmss");
1448 String str = "FRG" + sdf.format(new Date());
1449 workDir = curDir + fileSep + str;
1451 }
1453 logFile = workDir + ".log";
1454 }
1455
1456//------------------------------------------------------------------------------
1457
1464 public String getPrintedList()
1465 {
1466 StringBuilder sb = new StringBuilder(1024);
1467 sb.append(" " + paramTypeName() + " ").append(NL);
1468 for (Field f : this.getClass().getDeclaredFields())
1469 {
1470 try
1471 {
1472 sb.append(f.getName()).append(" = ").append(
1473 f.get(this)).append(NL);
1474 }
1475 catch (Throwable t)
1476 {
1477 sb.append("ERROR! Unable to print " + paramTypeName()
1478 + " parameters. Cause: " + t);
1479 break;
1480 }
1481 }
1482 for (RunTimeParameters otherCollector : otherParameters.values())
1483 {
1484 sb.append(otherCollector.getPrintedList());
1485 }
1486 return sb.toString();
1487 }
1488
1489//------------------------------------------------------------------------------
1490
1495 public double getLinearAngleLimit()
1496 {
1497 return linearAngleLimit;
1498 }
1499
1500//------------------------------------------------------------------------------
1501
1508 {
1509 this.linearAngleLimit = linearAngleLimit;
1510 }
1511
1512//------------------------------------------------------------------------------
1513
1519 {
1521 }
1522
1523//------------------------------------------------------------------------------
1524
1531 {
1532 return sizeUnimodalPop;
1533 }
1534
1535//------------------------------------------------------------------------------
1536
1543 {
1544 this.sizeUnimodalPop = sizeUnimodalPop;
1545 }
1546
1547//------------------------------------------------------------------------------
1548
1556 {
1557 return maxNoiseUnimodalPop;
1558 }
1559
1560//------------------------------------------------------------------------------
1561
1569 {
1570 this.maxNoiseUnimodalPop = maxNoiseUnimodalPop;
1571 }
1572
1573//------------------------------------------------------------------------------
1574
1582 {
1584 }
1585
1586
1587//------------------------------------------------------------------------------
1588
1597 {
1598 this.factorForSDOnStatsOfUnimodalPop = factorForSDOnStatsOfUnimodalPop;
1599 }
1600
1601//------------------------------------------------------------------------------
1602
1610 {
1612 }
1613
1614//------------------------------------------------------------------------------
1615
1625 {
1626 this.useCentroidsAsRepresentativeConformer =
1628 }
1629
1630//------------------------------------------------------------------------------
1631
1638 {
1640 }
1641
1642//------------------------------------------------------------------------------
1643
1652 {
1653 this.saveClustersOfConformerToFile = saveClustersOfConformerToFile;
1654 }
1655
1656//------------------------------------------------------------------------------
1657
1663 {
1665 }
1666
1667//------------------------------------------------------------------------------
1668
1673 public boolean isWorkingIn3D()
1674 {
1675 return workingIn3D;
1676 }
1677
1678//------------------------------------------------------------------------------
1679
1684 public void setWorkingIn3D(boolean workingIn3D)
1685 {
1686 this.workingIn3D = workingIn3D;
1687 }
1688
1689//------------------------------------------------------------------------------
1690
1695 public void setFragmentationTmpls(List<DGraph> fragmentationTmpls) {
1696 this.fragmentationTmpls = fragmentationTmpls;
1697 }
1698
1699//------------------------------------------------------------------------------
1700
1701}
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.
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...
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.