1package denoptim.programs.fragmenter;
3import java.util.HashMap;
6import java.util.logging.Level;
7import java.util.logging.Logger;
9import org.openscience.cdk.interfaces.IAtom;
10import org.openscience.cdk.interfaces.IAtomContainer;
11import org.openscience.cdk.isomorphism.Mappings;
13import denoptim.constants.DENOPTIMConstants;
14import denoptim.exception.DENOPTIMException;
15import denoptim.graph.APClass;
16import denoptim.utils.ManySMARTSQuery;
17import denoptim.utils.MoleculeUtils;
93 throw new IllegalArgumentException(
"ruleName cannot be '"
96 throw new IllegalArgumentException(
"SMARTS for atom cannot be '"
99 throw new IllegalArgumentException(
"SMARTS for atom cannot be '"
102 throw new IllegalArgumentException(
"SMARTS for bond cannot be '"
244 if (
opts.contains(
"HAPTO"))
285 if (s.contains(
"!@"))
287 s = s.substring(0,s.indexOf(
"!@"));
291 else if (s.equals(
"="))
293 else if (s.equals(
"#"))
361 for (
int i=0; i<this.
getOptions().size(); i++)
382 IAtomContainer mol = atmS.getContainer();
383 int idxSInMol = mol.indexOf(atmS);
384 int idxTInMol = mol.indexOf(atmT);
386 boolean hasHapto =
false;
387 boolean checkRings =
false;
389 boolean checkOMRings =
false;
390 int minSzOMRing = -1;
391 for (String opt :
opts)
393 if (opt.startsWith(
"HAPTO"))
396 if (opt.startsWith(
"RING>"))
399 minSzRing = Integer.parseInt(opt.replace(
"RING>",
"").trim());
401 }
else if (opt.startsWith(
"OMRING"))
404 minSzOMRing = Integer.parseInt(opt.replace(
"OMRING>",
"").trim());
414 Map<String,String> allSmarts =
new HashMap<String,String>();
415 StringBuilder smartsBuilder =
new StringBuilder();
418 smartsBuilder.append(
"1");
422 smartsBuilder.append(
"~");
424 for (
int i=3; i<Math.max(minSzRing, minSzOMRing)+1; i++)
426 smartsBuilder.append(
"[*]~");
427 allSmarts.put(
"ring"+i, smartsBuilder.toString()+
"1");
436 logger.log(Level.WARNING,
"Problem matching SMARTS for OM/RING "
437 +
"options. Ignoring bond for which we cannot check if "
438 +
"we satisfy OM/RING options. " + msq.
getMessage());
443 for (
int ringSize=3; ringSize<Math.max(minSzRing, minSzOMRing)+1; ringSize++)
445 String smartsName =
"ring"+ringSize;
453 for (
int[] atmsInOneRing : atomsInAllRings)
455 if (atmsInOneRing[0]==idxSInMol && atmsInOneRing[1]==idxTInMol)
457 boolean isOMRing =
false;
458 for (
int j=0; j<atmsInOneRing.length; j++)
460 IAtom atmInRing = mol.getAtom(atmsInOneRing[j]);
464 atmInRing.getSymbol()))
470 if (!isOMRing && checkRings && ringSize<=minSzRing)
473 logger.log(Level.FINEST,
"Bond between " + idxSInMol
474 +
" and " + idxTInMol +
" matches SMARTS of "
475 +
"cutting rule '" +
this.ruleName
476 +
"', but does not satisfy "
477 +
"RING>" + minSzRing +
" as it is part of "
478 +
"a " + ringSize +
"-member organic-only ring.");
481 if (isOMRing && checkOMRings && ringSize<=minSzOMRing)
483 logger.log(Level.FINEST,
"Bond between " + idxSInMol
484 +
" and " + idxTInMol +
" matches SMARTS of "
485 +
"cutting rule '" +
this.ruleName
486 +
"', but does not satisfy "
487 +
"OMRING>" + minSzOMRing +
" as it is part of "
488 +
"a " + ringSize +
"-member ring including a "
General set of constants used in DENOPTIM.
static ArrayList< String > ALL_METALS
Elemental symbols of all metal elements, including alkaly, transition metals, actinides,...
static final String SEPARATORAPPROPSCL
Separator between APClass and APSubClass and coordinates.
static APClass make(String ruleAndSubclass)
Creates an APClass if it does not exist already, or returns the reference to the existing instance.
A cutting rule with three SMARTS queries (atom 1, bond, atom2) and options.
APClass getAPClass0()
Get the AP class with sub class 0.
APClass apc1
Second APClass derived from this rule.
String getName()
Returns the name of the cutting rule.
String smartsAtm1
SMARTS query matching the second atom.
String smartsBnd
SMARTS query matching the bond between first and second atom.
Boolean satisfiesOptions(MatchedBond matchedBond, Logger logger)
Checks if a given bond satisfies the additional options of this rule beyond the matching of the SMART...
int getBondOrder()
Tries to identify the bond order of the matched bond by searching for the corresponding,...
APClass getComplementaryAPClass(APClass apc)
Get complementary class.
String getSMARTSAtom1()
Get the SMARTS query of the second atom (SubClass 1)
List< String > getOptions()
Returns the list of options.
String smartsAtm0
SMARTS query matching the first atom.
CuttingRule(String ruleName, String smartsAtm0, String smartsAtm1, String smartsBnd, int priority, List< String > opts)
Constructor for a cutting rule.
APClass getAPClass1()
Get the AP class with sub class 1.
String getSMARTSAtom0()
Get the SMARTS query of the first atom (SubClass 0)
String toString()
Returns the string representing this rule.
String ruleName
Rule name.
String getWholeSMARTSRule()
Returns the SMARTS query of the whole rule.
int priority
Priority index of this rule.
String getSMARTSBnd()
Get the SMARTS query of the bond.
List< String > opts
Additional Options.
APClass apc0
First APClass derived from this rule.
IAtom getAtmSubClass1()
Returns the atom matching subclass '1'.
IAtom getAtmSubClass0()
Returns the atom matching subclass '0'.
Container of lists of atoms matching a list of SMARTS.
Mappings getMatchesOfSMARTS(String ref)
int getNumMatchesOfQuery(String query)
Utilities for molecule conversion.
static boolean isElement(IAtom atom)
Check element symbol corresponds to real element of Periodic Table.