1package denoptim.fragmenter;
4import java.io.FileInputStream;
5import java.io.IOException;
6import java.util.ArrayList;
7import java.util.HashMap;
8import java.util.HashSet;
12import java.util.logging.Level;
13import java.util.logging.Logger;
15import javax.vecmath.Point3d;
17import org.openscience.cdk.Bond;
18import org.openscience.cdk.DefaultChemObjectBuilder;
19import org.openscience.cdk.PseudoAtom;
20import org.openscience.cdk.config.Isotopes;
21import org.openscience.cdk.exception.CDKException;
22import org.openscience.cdk.interfaces.IAtom;
23import org.openscience.cdk.interfaces.IAtomContainer;
24import org.openscience.cdk.interfaces.IBond;
25import org.openscience.cdk.interfaces.IIsotope;
26import org.openscience.cdk.io.iterator.IteratingSDFReader;
27import org.openscience.cdk.isomorphism.Mappings;
28import org.openscience.cdk.isomorphism.Pattern;
29import org.openscience.cdk.silent.SilentChemObjectBuilder;
30import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
32import denoptim.constants.DENOPTIMConstants;
33import denoptim.exception.DENOPTIMException;
34import denoptim.files.FileFormat;
35import denoptim.files.UndetectedFileFormatException;
36import denoptim.graph.APClass;
37import denoptim.graph.AttachmentPoint;
38import denoptim.graph.DGraph;
39import denoptim.graph.Edge;
40import denoptim.graph.Fragment;
41import denoptim.graph.Template;
42import denoptim.graph.Vertex;
43import denoptim.graph.Vertex.BBType;
44import denoptim.graph.rings.RingClosingAttractor;
45import denoptim.io.DenoptimIO;
46import denoptim.io.IteratingAtomContainerReader;
47import denoptim.molecularmodeling.ThreeDimTreeBuilder;
48import denoptim.programs.RunTimeParameters.ParametersType;
49import denoptim.programs.fragmenter.CuttingRule;
50import denoptim.programs.fragmenter.FragmenterParameters;
51import denoptim.programs.fragmenter.MatchedBond;
52import denoptim.utils.DummyAtomHandler;
53import denoptim.utils.FormulaUtils;
54import denoptim.utils.ManySMARTSQuery;
55import denoptim.utils.MoleculeUtils;
56import denoptim.utils.Randomizer;
78 File output, Logger logger)
81 FileInputStream fis =
new FileInputStream(input);
82 IteratingSDFReader reader =
new IteratingSDFReader(fis,
83 DefaultChemObjectBuilder.getInstance());
86 int maxBufferSize = 2000;
87 ArrayList<IAtomContainer> buffer =
new ArrayList<IAtomContainer>(500);
89 while (reader.hasNext())
94 logger.log(Level.FINE,
"Checking elemental analysis of "
95 +
"structure " + index);
97 IAtomContainer mol = reader.next();
101 +
"' not found in molecule " + index +
" in file "
102 + input +
". Cannot compare formula with elemental"
115 logger.log(Level.INFO,
"Inconsistency between elemental "
116 +
"analysis of structure and molecular formula."
117 +
" Rejecting structure " + index +
": "
123 if (buffer.size() >= maxBufferSize)
134 if (buffer.size() < maxBufferSize)
169 }
catch (CDKException e)
171 if (e.getMessage().contains(
"Cannot assign Kekulé structure"))
175 settings.
getLogger().log(Level.WARNING,
"Some bond order "
176 +
"are unset and attempt to kekulize the "
177 +
"system has failed "
178 +
"for structure " + index +
". "
179 +
"This hampers use of SMARTS queries, which "
181 +
"not work as expected. Structure " + index
182 +
" will be rejected. "
183 +
"You can avoid rejection by using "
186 +
"UNSETTOSINGLEBO, but you'll "
187 +
"still be using a peculiar connectivity "
189 +
"many bonds are artificially marked as "
191 +
"avoid use of 'UNSET' bond order. "
192 +
"Further details on the problem: "
196 settings.
getLogger().log(Level.WARNING,
"Failed "
198 +
"for structure " + index
199 +
" but UNSETTOSINGLEBO "
200 +
"keyword used. Forcing use of single bonds to "
201 +
"replace bonds with unset order.");
202 for (IBond bnd : mol.bonds())
204 if (bnd.getOrder().equals(IBond.Order.UNSET))
206 bnd.setOrder(IBond.Order.SINGLE);
229 File output, Logger logger)
232 FileInputStream fis =
new FileInputStream(input);
233 IteratingSDFReader reader =
new IteratingSDFReader(fis,
234 DefaultChemObjectBuilder.getInstance());
237 Map<String, String> smartsMap =
new HashMap<String, String>();
238 for (String s : smarts)
241 smartsMap.put(
"prefilter-"+i, s);
245 int maxBufferSize = 2000;
246 ArrayList<IAtomContainer> buffer =
new ArrayList<IAtomContainer>(500);
248 while (reader.hasNext())
253 logger.log(Level.FINE,
"Prefiltering structure " + index);
255 IAtomContainer mol = reader.next();
260 String msg =
"WARNING! Problems while searching for "
261 +
"specific atoms/bonds using SMARTS: "
267 if (allMatches.size()==0)
272 for (String s : allMatches.keySet())
273 hits = hits + DenoptimIO.NL + smartsMap.get(s);
276 logger.log(Level.INFO,
"Found match for " + hits
277 +
"Rejecting structure " + index +
": "
283 if (buffer.size() >= maxBufferSize)
293 if (buffer.size() < maxBufferSize)
324 List<Vertex> fragments = graph.getVertexList();
327 List<Vertex> keptFragments =
new ArrayList<Vertex>();
329 for (
Vertex frag : fragments)
334 keptFragments, logger);
338 logger.log(Level.FINE,
"Fragments surviving post-"
339 +
"processing: " + keptFragments.size());
342 if (keptFragments.size()>0)
344 totalProd += keptFragments.size();
346 keptFragments,
true);
374 File output, Logger logger)
throws CDKException, IOException,
389 logger.log(Level.FINE,
"Fragmenting structure " + index);
391 IAtomContainer mol = iterator.
next();
392 String molName =
"noname-mol" + index;
393 if (mol.getTitle()!=
null && !mol.getTitle().isBlank())
394 molName = mol.getTitle();
397 List<Vertex> fragments =
new ArrayList<Vertex>();
398 if (settings.getFragmentationTmpls().size()>0)
400 fragments =
fragmentation(mol, settings.getFragmentationTmpls(),
401 settings.getRandomizer(), logger);
408 logger.log(Level.FINE,
"Fragmentation produced "
409 + fragments.size() +
" fragments.");
411 totalProd += fragments.size();
414 List<Vertex> keptFragments =
new ArrayList<Vertex>();
416 for (
Vertex frag : fragments)
419 String fragIdStr =
"From_" + molName +
"_" + fragCounter;
420 frag.setProperty(
"cdk:Title", fragIdStr);
423 keptFragments, logger);
427 logger.log(Level.FINE,
"Fragments surviving post-"
428 +
"processing: " + keptFragments.size());
430 totalKept += keptFragments.size();
431 if (!settings.doManageIsomorphicFamilies() && totalKept>0)
446 logger.log(Level.WARNING,
"No fragment produced. Cutting rules "
447 +
"were ineffective on the given structures.");
450 }
else if (totalKept==0)
454 logger.log(Level.WARNING,
"No fragment kept out of " + totalProd
455 +
" produced fragments. Filtering criteria might be "
456 +
"too restrictive.");
478 Set<IAtom> boundaryAtoms =
new HashSet<>();
479 Map<IAtom, Long> atomToVertexId =
new HashMap<>();
482 for (IAtom atom : templateMol.atoms())
490 Long vid = Long.parseLong(vidProp.toString());
491 atomToVertexId.put(atom, vid);
494 List<IAtom> neighbors = templateMol.getConnectedAtomsList(atom);
495 for (IAtom neighbor : neighbors)
498 if (nbrVidProp !=
null)
500 Long nbrVid = Long.parseLong(nbrVidProp.toString());
501 if (!vid.equals(nbrVid))
503 boundaryAtoms.add(atom);
504 boundaryAtoms.add(neighbor);
512 if (boundaryAtoms.isEmpty())
518 Set<IAtom> atomsToKeep =
new HashSet<>(boundaryAtoms);
521 List<IAtom> boundaryList =
new ArrayList<>(boundaryAtoms);
522 for (
int i = 0; i < boundaryList.size(); i++)
524 for (
int j = i + 1; j < boundaryList.size(); j++)
526 IAtom start = boundaryList.get(i);
527 IAtom end = boundaryList.get(j);
533 atomsToKeep.addAll(path);
539 IAtomContainer reduced = SilentChemObjectBuilder.getInstance().newAtomContainer();
540 Map<IAtom, IAtom> originalToReduced =
new HashMap<>();
543 for (IAtom originalAtom : atomsToKeep)
545 IAtom reducedAtom = originalAtom.getBuilder().newInstance(IAtom.class, originalAtom);
546 reduced.addAtom(reducedAtom);
547 originalToReduced.put(originalAtom, reducedAtom);
550 int originalIndex = templateMol.indexOf(originalAtom);
551 reducedAtom.setProperty(
"DENOPTIM_ORIGINAL_ATOM_INDEX", originalIndex);
554 for (Object key : originalAtom.getProperties().keySet())
556 if (!key.equals(
"DENOPTIM_ORIGINAL_ATOM_INDEX"))
558 reducedAtom.setProperty(key, originalAtom.getProperty(key));
564 for (IBond bond : templateMol.bonds())
566 IAtom atom1 = bond.getAtom(0);
567 IAtom atom2 = bond.getAtom(1);
569 if (atomsToKeep.contains(atom1) && atomsToKeep.contains(atom2))
571 IBond newBond = bond.getBuilder().newInstance(IBond.class,
572 originalToReduced.get(atom1), originalToReduced.get(atom2), bond.getOrder());
573 reduced.addBond(newBond);
592 List<DGraph> templates,
Randomizer randomizer, Logger logger)
595 List<Vertex> fragments =
new ArrayList<Vertex>();
597 for (
DGraph template : templates)
607 List<Map<IAtom,IAtom>> atomMappings;
610 if (reducedTemplateMol == templateMol)
619 reducedTemplateMol, mol, logger);
622 atomMappings =
new ArrayList<>();
623 for (Map<IAtom,IAtom> reducedMapping : reducedAtomMappings)
625 Map<IAtom,IAtom> fullMapping =
new HashMap<>();
626 for (Map.Entry<IAtom,IAtom> entry : reducedMapping.entrySet())
628 IAtom reducedAtom = entry.getKey();
629 IAtom molAtom = entry.getValue();
632 Object indexObj = reducedAtom.getProperty(
"DENOPTIM_ORIGINAL_ATOM_INDEX");
633 if (indexObj !=
null)
635 int originalIndex = ((Number) indexObj).intValue();
636 IAtom originalAtom = templateMol.getAtom(originalIndex);
637 if (originalAtom !=
null)
639 fullMapping.put(originalAtom, molAtom);
643 if (!fullMapping.isEmpty())
645 atomMappings.add(fullMapping);
655 for (Map<IAtom,IAtom> atomMapping : atomMappings)
659 masterFrag, masterFragIAC, mol, atomMapping);
660 }
catch (Throwable e) {
662 logger.log(Level.WARNING,
"Error while exploring the template graph: " + e.getMessage());
668 List<Vertex> locfragments =
new ArrayList<Vertex>();
669 Set<Integer> doneAlready =
new HashSet<Integer>();
672 if (doneAlready.contains(idx))
678 atmsToKeep.stream().forEach(atm -> doneAlready.add(iac.indexOf(atm)));
680 Set<IAtom> atmsToRemove =
new HashSet<IAtom>();
681 for (IAtom atm : cloneOfMaster.
atoms())
683 if (!atmsToKeep.contains(atm))
685 atmsToRemove.add(atm);
690 locfragments.add(cloneOfMaster);
693 if (locfragments.size() > bestMatch)
695 bestMatch = locfragments.size();
696 fragments = locfragments;
709 Fragment masterFrag, IAtomContainer masterFragIAC, IAtomContainer mol,
710 Map<IAtom,IAtom> graphToMolMapping)
715 IAtom graphAtmSrc = graphIAC.getAtom(edge.getSrcAP().getAtomPositionNumberInMol());
716 IAtom graphAtmTrg = graphIAC.getAtom(edge.getTrgAP().getAtomPositionNumberInMol());
718 IAtom masterFragAtmSrc = masterFragIAC.getAtom(mol.indexOf(graphToMolMapping.get(graphAtmSrc)));
719 IAtom masterFragAtmTrg = masterFragIAC.getAtom(mol.indexOf(graphToMolMapping.get(graphAtmTrg)));
721 IBond bnd = masterFragIAC.getBond(masterFragAtmSrc, masterFragAtmTrg);
724 masterFragIAC.removeBond(bnd);
728 edge.getSrcAP().getAPClass(),
731 edge.getTrgAP().getAPClass(),
762 Map<String, List<MatchedBond>> matchingbonds =
769 String ruleName = rule.getName();
772 if (!matchingbonds.keySet().contains(ruleName))
777 IAtom atmA = tb.getAtmSubClass0();
778 IAtom atmB = tb.getAtmSubClass1();
781 if (!fragsMol.getConnectedAtomsList(atmA).contains(atmB))
792 IAtom centralAtm = atmA;
796 ArrayList<IAtom> candidatesForHapto =
new ArrayList<IAtom>();
797 for (
MatchedBond tbForHapto : matchingbonds.get(ruleName))
800 if (tbForHapto.getAtmSubClass0() == centralAtm)
801 candidatesForHapto.add(tbForHapto.getAtmSubClass1());
806 Set<IAtom> atmsInHapto =
new HashSet<IAtom>();
807 atmsInHapto.add(tb.getAtmSubClass1());
809 centralAtm, candidatesForHapto, fragsMol);
810 if (atmsInHapto.size() == 1)
812 logger.log(Level.WARNING,
"Unable to find more than one "
813 +
"bond involved in high-hapticity ligand! "
819 boolean isSystemIntact =
true;
820 for (IAtom ligAtm : atmsInHapto)
822 List<IAtom> nbrsOfLigAtm =
823 fragsMol.getConnectedAtomsList(ligAtm);
824 if (!nbrsOfLigAtm.contains(centralAtm))
826 isSystemIntact =
false;
838 Point3d dummyP3d =
new Point3d();
839 for (IAtom ligAtm : atmsInHapto)
842 dummyP3d.x = dummyP3d.x + ligP3d.x;
843 dummyP3d.y = dummyP3d.y + ligP3d.y;
844 dummyP3d.z = dummyP3d.z + ligP3d.z;
847 dummyP3d.x = dummyP3d.x / (double) atmsInHapto.size();
848 dummyP3d.y = dummyP3d.y / (double) atmsInHapto.size();
849 dummyP3d.z = dummyP3d.z / (double) atmsInHapto.size();
853 IAtom dummyAtm =
null;
854 for (IAtom oldDu : fragsMol.atoms())
859 Point3d oldDuP3d = oldDu.getPoint3d();
860 if (oldDuP3d.distance(dummyP3d) < 0.002)
871 dummyAtm.setPoint3d(dummyP3d);
872 fragsMol.addAtom(dummyAtm);
878 IBond.Order border = IBond.Order.valueOf(
"SINGLE");
880 for (IAtom ligAtm : atmsInHapto)
882 List<IAtom> nbrsOfDu = fragsMol.getConnectedAtomsList(
884 if (!nbrsOfDu.contains(ligAtm))
887 Bond bnd =
new Bond(dummyAtm,ligAtm,border);
888 fragsMol.addBond(bnd);
891 IBond oldBnd = fragsMol.getBond(centralAtm,ligAtm);
892 fragsMol.removeBond(oldBnd);
909 IBond bnd = fragsMol.getBond(atmA,atmB);
910 fragsMol.removeBond(bnd);
927 List<Vertex> fragments =
new ArrayList<Vertex>();
928 Set<Integer> doneAlready =
new HashSet<Integer>();
931 if (doneAlready.contains(idx))
937 atmsToKeep.stream().forEach(atm -> doneAlready.add(iac.indexOf(atm)));
939 Set<IAtom> atmsToRemove =
new HashSet<IAtom>();
940 for (IAtom atm : cloneOfMaster.
atoms())
942 if (!atmsToKeep.contains(atm))
944 atmsToRemove.add(atm);
949 fragments.add(cloneOfMaster);
970 ArrayList<IAtom> candidates, IAtomContainer mol)
972 Set<IAtom> atmsInHapto =
new HashSet<IAtom>();
973 atmsInHapto.add(seed);
974 ArrayList<IAtom> toVisitAtoms =
new ArrayList<IAtom>();
975 toVisitAtoms.add(seed);
976 ArrayList<IAtom> visitedAtoms =
new ArrayList<IAtom>();
977 while (toVisitAtoms.size()>0)
979 ArrayList<IAtom> toVisitLater =
new ArrayList<IAtom>();
980 for (IAtom atomInFocus : toVisitAtoms)
982 if (visitedAtoms.contains(atomInFocus)
983 || atomInFocus==centralAtom)
986 visitedAtoms.add(atomInFocus);
988 if (candidates.contains(atomInFocus))
990 atmsInHapto.add(atomInFocus);
991 toVisitLater.addAll(mol.getConnectedAtomsList(atomInFocus));
994 toVisitAtoms.clear();
995 toVisitAtoms.addAll(toVisitLater);
1011 Set<IAtom> atmsReachableFromSeed =
new HashSet<IAtom>();
1012 ArrayList<IAtom> toVisitAtoms =
new ArrayList<IAtom>();
1013 toVisitAtoms.add(seed);
1014 ArrayList<IAtom> visitedAtoms =
new ArrayList<IAtom>();
1015 while (toVisitAtoms.size()>0)
1017 ArrayList<IAtom> toVisitLater =
new ArrayList<IAtom>();
1018 for (IAtom atomInFocus : toVisitAtoms)
1020 if (visitedAtoms.contains(atomInFocus))
1023 visitedAtoms.add(atomInFocus);
1025 atmsReachableFromSeed.add(atomInFocus);
1026 toVisitLater.addAll(mol.getConnectedAtomsList(atomInFocus));
1028 toVisitAtoms.clear();
1029 toVisitAtoms.addAll(toVisitLater);
1031 return atmsReachableFromSeed;
1045 IAtomContainer mol, List<CuttingRule> rules, Logger logger)
1048 Map<String,String> smarts =
new HashMap<String,String>();
1051 smarts.put(rule.getName(),rule.getWholeSMARTSRule());
1055 Map<String, List<MatchedBond>> bondsMatchingRules =
1056 new HashMap<String, List<MatchedBond>>();
1060 if (msq.hasProblems())
1064 logger.log(Level.WARNING,
"Problem matching SMARTS: "
1065 + msq.getMessage());
1067 return bondsMatchingRules;
1072 String ruleName = rule.getName();
1074 if (msq.getNumMatchesOfQuery(ruleName) == 0)
1080 Mappings purgedPairs = msq.getMatchesOfSMARTS(ruleName);
1083 ArrayList<MatchedBond> bondsMatched =
new ArrayList<MatchedBond>();
1084 for (
int[] pair : purgedPairs)
1088 throw new Error(
"Cutting rule: " + ruleName
1089 +
" has identified " + pair.length +
" atoms "
1090 +
"instead of 2. Modify rule to make it find a "
1091 +
"pair of atoms.");
1094 mol.getAtom(pair[1]), rule);
1098 bondsMatched.add(tb);
1101 if (!bondsMatched.isEmpty())
1102 bondsMatchingRules.put(ruleName, bondsMatched);
1105 return bondsMatchingRules;
1120 FileInputStream fis =
new FileInputStream(input);
1121 IteratingSDFReader reader =
new IteratingSDFReader(fis,
1122 DefaultChemObjectBuilder.getInstance());
1125 int maxBufferSize = 2000;
1126 ArrayList<Vertex> buffer =
new ArrayList<Vertex>(500);
1128 while (reader.hasNext())
1133 logger.log(Level.FINE,
"Processing fragment " + index);
1140 if (buffer.size() >= maxBufferSize)
1150 if (buffer.size() < maxBufferSize)
1179 List<Vertex> collector, Logger logger)
1190 if (settings.getIgnorableFragments().size() > 0)
1192 if (settings.getIgnorableFragments().stream()
1193 .anyMatch(ignorable -> ((
Fragment)frag)
1194 .isIsomorphicTo(ignorable)))
1198 logger.log(Level.FINE,
"Fragment " + fragCounter
1199 +
" is ignorable.");
1206 if (settings.getTargetFragments().size() > 0)
1208 if (!settings.getTargetFragments().stream()
1209 .anyMatch(ignorable -> ((
Fragment)frag)
1210 .isIsomorphicTo(ignorable)))
1214 logger.log(Level.FINE,
"Fragment " + fragCounter
1215 +
" doesn't match any target: rejected.");
1223 && settings.doAddDuOnLinearity())
1226 settings.getLinearAngleLimit());
1233 if (settings.doManageIsomorphicFamilies())
1235 synchronized (settings.MANAGEMWSLOTSSLOCK)
1238 settings.getMWSlotSize());
1240 File mwFileUnq = settings.getMWSlotFileNameUnqFrags(
1242 File mwFileAll = settings.getMWSlotFileNameAllFrags(
1246 Vertex unqVersion =
null;
1247 if (mwFileUnq.exists())
1249 ArrayList<Vertex> knownFrags =
1251 unqVersion = knownFrags.stream()
1252 .filter(knownFrag ->
1253 ((
Fragment)frag).isIsomorphicTo(knownFrag))
1257 if (unqVersion!=
null)
1266 int sampleSize = settings.getIsomorphsCount()
1268 if (sampleSize < settings.getIsomorphicSampleSize())
1274 settings.getIsomorphsCount().put(isoFamID,
1278 collector.add(frag);
1299 String isoFamID = settings.newIsomorphicFamilyID();
1303 settings.getIsomorphsCount().put(isoFamID, 1);
1308 collector.add(frag);
1313 collector.add(frag);
1351 for (IAtom atm : frag.
atoms())
1362 logger.log(Level.FINE,
"Removing fragment contains non-element '"
1372 Point3d ap3d = ap.getDirectionVector();
1375 for (IAtom atm : frag.
atoms())
1378 double dist = ap3d.distance(atm3d);
1381 logger.log(Level.FINE,
"Removing fragment with AP"
1393 for (IAtom atm : frag.
atoms())
1398 if (atm.getMassNumber() ==
null)
1402 int a = atm.getMassNumber();
1404 IIsotope major = Isotopes.getInstance().getMajorIsotope(symb);
1405 if (a != major.getMassNumber())
1407 logger.log(Level.FINE,
"Removing fragment containing "
1408 +
"isotope "+symb+a+
".");
1411 }
catch (Throwable t) {
1412 logger.log(Level.WARNING,
"Not able to perform Isotope"
1424 for (IAtom atm : frag.
atoms())
1429 logger.log(Level.FINE,
"Removing fragment containing '"
1442 for (Map<String,Double> criterion :
1445 for (String el : criterion.keySet())
1447 if (eaMol.containsKey(el))
1450 if (eaMol.get(el) - criterion.get(el) > 0.5)
1452 logger.log(Level.FINE,
"Removing fragment that "
1453 +
"contains too much '" + el +
"' "
1454 +
"as requested by formula"
1455 +
"-based (more-than) settings (" + el
1456 + eaMol.get(el) +
" > " + criterion +
").");
1464 for (String el : criterion.keySet())
1466 if (!eaMol.containsKey(el))
1468 logger.log(Level.FINE,
"Removing fragment that does not "
1469 +
"contain '" + el +
"' as requested by formula"
1470 +
"-based (less-than) settings.");
1474 if (eaMol.get(el) - criterion.get(el) < -0.5)
1476 logger.log(Level.FINE,
"Removing fragment that "
1477 +
"contains too little '" + el +
"' "
1478 +
"as requested by formula"
1479 +
"-based settings (" + el
1480 + eaMol.get(el) +
" < " + criterion +
").");
1494 if (apc.toString().startsWith(s))
1496 logger.log(Level.FINE,
"Removing fragment with APClass "
1506 loopOverCombinations:
1509 for (
int ip=0; ip<conditions.length; ip++)
1511 String condition = conditions[ip];
1512 boolean found =
false;
1515 if (apc.toString().startsWith(condition))
1522 continue loopOverCombinations;
1528 String allCondsAsString =
"";
1529 for (
int i=0; i<conditions.length; i++)
1530 allCondsAsString = allCondsAsString +
" " + conditions[i];
1532 logger.log(Level.FINE,
"Removing fragment with combination of "
1533 +
"APClasses matching '" + allCondsAsString +
"'.");
1541 int totHeavyAtm = 0;
1542 for (IAtom atm : frag.
atoms())
1547 if ((!symb.equals(
"H")) && (!symb.equals(
1555 logger.log(Level.FINE,
"Removing fragment with too many atoms ("
1556 + totHeavyAtm +
" < "
1564 logger.log(Level.FINE,
"Removing fragment with too few atoms ("
1565 + totHeavyAtm +
" < "
1578 logger.log(Level.WARNING,
"Problems evaluating SMARTS-based "
1579 +
"rejection criteria. " + msq.
getMessage());
1586 logger.log(Level.FINE,
"Removing fragment that matches "
1587 +
"SMARTS-based rejection criteria '" + criterion
1600 logger.log(Level.WARNING,
"Problems evaluating SMARTS-based "
1601 +
"rejection criteria. " + msq.
getMessage());
1604 boolean matchesAny =
false;
1615 logger.log(Level.FINE,
"Removing fragment that does not "
1616 +
"match any SMARTS-based retention criteria.");
1636 if (a.getImplicitHydrogenCount()==
null)
1637 a.setImplicitHydrogenCount(0);
1640 int slotNum = (int) (mw / (Double.valueOf(slotSize)));
1641 return slotNum*slotSize +
"-" + (slotNum+1)*slotSize;
1649 IAtomContainer mol = SilentChemObjectBuilder.getInstance()
1650 .newAtomContainer();
1651 Point3d apv = ap.getDirectionVector();
1655 Double.valueOf(apv.x),
1656 Double.valueOf(apv.y),
1657 Double.valueOf(apv.z))));
1663 ap.getOwner().getIAtomContainer().getAtom(
1664 ap.getAtomPositionNumber()));
1665 rcv.
addAP(0, rcvApClass,
new Point3d(
1666 Double.valueOf(aps.x),
1667 Double.valueOf(aps.y),
1668 Double.valueOf(aps.z)));
General set of constants used in DENOPTIM.
static final Object FORMULASTR
Property name used to store molecular formula as string in an atom container.
static final String ATMPROPVERTEXID
String tag of Atom property used to store the unique ID of the Vertex corresponding to the molecular ...
static final String DUMMYATMSYMBOL
Symbol of dummy atom.
static final Object ISOMORPHICFAMILYID
Property used to store the identifier of the family of isomorphic fragments that owns a fragment.
An attachment point (AP) is a possibility to attach a Vertex onto the vertex holding the AP (i....
Container for the list of vertices and the edges that connect them.
List< Vertex > getVertexList()
List< Edge > getEdgeList()
This class represents the edge between two vertices.
Class representing a continuously connected portion of chemical object holding attachment points.
void addAP(int atomPositionNumber)
Adds an attachment point with a dummy APClass.
AttachmentPoint addAPOnAtom(IAtom srcAtm, APClass apc, Point3d vector)
Add an attachment point to the specifies atom.
List< AttachmentPoint > getAttachmentPoints()
Fragment clone()
Returns a deep copy of this fragments.
Iterable< IAtom > atoms()
IAtomContainer getIAtomContainer()
void removeAtoms(Collection< IAtom > atoms)
Removes a list of atoms and updates the list of attachment points.
A vertex is a data structure that has an identity and holds a list of AttachmentPoints.
ArrayList< APClass > getAllAPClasses()
Returns the list of all APClasses present on this vertex.
void setAsRCV(boolean isRCV)
Object getProperty(Object property)
abstract IAtomContainer getIAtomContainer()
void setProperty(Object key, Object property)
The RingClosingAttractor represent the available valence/connection that allows to close a ring.
static final HashMap< APClass, String > RCALABELPERAPCLASS
Conventional labels for attractor pseudoatom.
Utility methods for input/output.
static File writeVertexesToFile(File file, FileFormat format, List< Vertex > vertexes)
Writes vertexes to file.
static void writeSDFFile(String fileName, IAtomContainer mol)
Writes IAtomContainer to SDF file.
static File writeVertexToFile(File file, FileFormat format, Vertex vertex, boolean append)
Writes vertexes to file.
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.
An iterator that take IAtomContainers from a file, possibly using an available iterating reader,...
void close()
Close the memory-efficient iterator if any is open.
Tool to build build three-dimensional (3D) tree-like molecular structures from DGraph.
IAtomContainer convertGraphTo3DAtomContainer(DGraph graph)
Created a three-dimensional molecular representation from a given DGraph.
Logger getLogger()
Get the name of the program specific logger.
A cutting rule with three SMARTS queries (atom 1, bond, atom2) and options.
Parameters controlling execution of the fragmenter.
boolean doRejectWeirdIsotopes
Flag requesting to reject fragments with minor isotopes.
Map< String, Double > getRejectedFormulaLessThan()
int getMinFragHeavyAtomCount()
Set< String > getRejectedElements()
Map< String, String > getFragRetentionSMARTS()
int getMaxFragHeavyAtomCount()
Set< Map< String, Double > > getRejectedFormulaMoreThan()
Map< String, String > getFragRejectionSMARTS()
Set< String[]> getRejectedAPClassCombinations()
boolean addExplicitH
Flag requesting to add explicit H atoms.
Set< String > getRejectedAPClasses()
boolean acceptUnsetToSingeBO()
Boolean satisfiesRuleOptions
Flag indicating that we have checked the additional option from the cutting rule (otherwise this flag...
Toll to add/remove dummy atoms from linearities or multi-hapto sites.
static void addDummiesOnLinearities(Fragment frag, double angLim)
Append dummy atoms on otherwise linear arrangements of atoms.
Container of lists of atoms matching a list of SMARTS.
Map< String, Mappings > getAllMatches()
int getNumMatchesOfQuery(String query)
Utilities for molecule conversion.
static void setZeroImplicitHydrogensToAllAtoms(IAtomContainer iac)
Sets zero implicit hydrogen count to all atoms.
static int getDimensions(IAtomContainer mol)
Determines the dimensionality of the given chemical object.
static String getSymbolOrLabel(IAtom atm)
Gets either the elemental symbol (for standard atoms) of the label (for pseudo-atoms).
static List< Map< IAtom, IAtom > > findUniqueAtomMappings(IAtomContainer substructure, IAtomContainer mol, Logger logger)
Finds the maximum common substructure (MCS) between two molecules.
static void ensureNoUnsetBondOrders(IAtomContainer iac)
Sets bond order = single to all otherwise unset bonds.
static void explicitHydrogens(IAtomContainer mol)
Converts all the implicit hydrogens to explicit.
static List< IAtom > findShortestPath(IAtomContainer mol, IAtom start, IAtom end, Map< IAtom, Long > atomToVertexId)
Finds the shortest path between two atoms in a molecule using BFS.
static Point3d getPoint3d(IAtom atm)
Return the 3D coordinates, if present.
static boolean isElement(IAtom atom)
Check element symbol corresponds to real element of Periodic Table.
Tool to generate random numbers and random decisions.
The type of building block.
Identifier of the type of parameters.
FRG_PARAMS
Parameters controlling the fragmenter.