Permalink
Browse files

Made QueryChemObject require a IChemObject builder when being constru…

…cted. This has a knock on effect that all the SMARTs atoms require the builder also. Although there are a lot of changes there's little front end API changes - the SMARTSQueryTool and PubChemFingerprinter now require a builder but other methods (e.g. descriptors and QueryAtomContainerCreator) could make use of the builder from other IChemObjects.
  • Loading branch information...
johnmay committed Oct 26, 2012
1 parent f093134 commit fd311519b89092120167bdbcea294f8064ff016d
Showing with 503 additions and 341 deletions.
  1. +1 −1 src/main/org/openscience/cdk/fingerprint/EStateFingerprinter.java
  2. +1 −1 src/main/org/openscience/cdk/fingerprint/MACCSFingerprinter.java
  3. +6 −3 src/main/org/openscience/cdk/fingerprint/PubchemFingerprinter.java
  4. +1 −1 src/main/org/openscience/cdk/fingerprint/SubstructureFingerprinter.java
  5. +2 −2 src/main/org/openscience/cdk/io/MDLV2000Reader.java
  6. +5 −0 src/main/org/openscience/cdk/isomorphism/matchers/CTFileQueryBond.java
  7. +4 −1 src/main/org/openscience/cdk/isomorphism/matchers/InverseSymbolSetQueryAtom.java
  8. +5 −3 src/main/org/openscience/cdk/isomorphism/matchers/OrderQueryBond.java
  9. +5 −3 src/main/org/openscience/cdk/isomorphism/matchers/OrderQueryBondOrderOnly.java
  10. +6 −2 src/main/org/openscience/cdk/isomorphism/matchers/QueryAtom.java
  11. +9 −4 src/main/org/openscience/cdk/isomorphism/matchers/QueryAtomContainer.java
  12. +36 −24 src/main/org/openscience/cdk/isomorphism/matchers/QueryAtomContainerCreator.java
  13. +13 −9 src/main/org/openscience/cdk/isomorphism/matchers/QueryBond.java
  14. +5 −7 src/main/org/openscience/cdk/isomorphism/matchers/QueryChemObject.java
  15. +4 −0 src/main/org/openscience/cdk/isomorphism/matchers/RGroupQuery.java
  16. +5 −2 src/main/org/openscience/cdk/isomorphism/matchers/SymbolAndChargeQueryAtom.java
  17. +5 −2 src/main/org/openscience/cdk/isomorphism/matchers/SymbolChargeIDQueryAtom.java
  18. +5 −2 src/main/org/openscience/cdk/isomorphism/matchers/SymbolQueryAtom.java
  19. +4 −1 src/main/org/openscience/cdk/isomorphism/matchers/SymbolSetQueryAtom.java
  20. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AliphaticAtom.java
  21. +3 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AliphaticSymbolAtom.java
  22. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AnyAtom.java
  23. +5 −4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AnyOrderQueryBond.java
  24. +4 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AromaticAtom.java
  25. +5 −4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AromaticOrSingleQueryBond.java
  26. +5 −4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AromaticQueryBond.java
  27. +3 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AromaticSymbolAtom.java
  28. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AtomicNumberAtom.java
  29. +3 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/ChiralityAtom.java
  30. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/ConnectionCountAtom.java
  31. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/DegreeAtom.java
  32. +5 −4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/ExplicitConnectionAtom.java
  33. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/FormalChargeAtom.java
  34. +4 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/HybridizationNumberAtom.java
  35. +3 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/HydrogenAtom.java
  36. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/ImplicitHCountAtom.java
  37. +6 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/LogicalOperatorAtom.java
  38. +5 −0 src/main/org/openscience/cdk/isomorphism/matchers/smarts/LogicalOperatorBond.java
  39. +5 −3 src/main/org/openscience/cdk/isomorphism/matchers/smarts/MassAtom.java
  40. +3 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/NonCHHeavyAtom.java
  41. +3 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/OrderQueryBond.java
  42. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/PeriodicGroupNumberAtom.java
  43. +1 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/RecursiveSmartsAtom.java
  44. +5 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/RingAtom.java
  45. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/RingBond.java
  46. +6 −0 src/main/org/openscience/cdk/isomorphism/matchers/smarts/RingIdentifierAtom.java
  47. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/RingMembershipAtom.java
  48. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/SMARTSAtom.java
  49. +6 −3 src/main/org/openscience/cdk/isomorphism/matchers/smarts/SMARTSBond.java
  50. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/SmallestRingAtom.java
  51. +5 −0 src/main/org/openscience/cdk/isomorphism/matchers/smarts/StereoBond.java
  52. +5 −3 src/main/org/openscience/cdk/isomorphism/matchers/smarts/TotalConnectionAtom.java
  53. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/TotalHCountAtom.java
  54. +4 −2 src/main/org/openscience/cdk/isomorphism/matchers/smarts/TotalRingConnectionAtom.java
  55. +3 −1 src/main/org/openscience/cdk/isomorphism/matchers/smarts/TotalValencyAtom.java
  56. +1 −1 src/main/org/openscience/cdk/pharmacophore/PharmacophoreMatcher.java
  57. +4 −1 src/main/org/openscience/cdk/pharmacophore/PharmacophoreQuery.java
  58. +3 −2 src/main/org/openscience/cdk/qsar/descriptors/molecular/AcidicGroupCountDescriptor.java
  59. +3 −2 src/main/org/openscience/cdk/qsar/descriptors/molecular/BasicGroupCountDescriptor.java
  60. +1 −1 src/main/org/openscience/cdk/qsar/descriptors/molecular/KierHallSmartsDescriptor.java
  61. +9 −9 src/main/org/openscience/cdk/qsar/descriptors/molecular/XLogPDescriptor.java
  62. +7 −2 src/main/org/openscience/cdk/smiles/smarts/SMARTSQueryTool.java
  63. +1 −1 src/main/org/openscience/cdk/smiles/smarts/parser/ASTLowAndExpression.java
  64. +3 −2 src/main/org/openscience/cdk/smiles/smarts/parser/SMARTSParser.jjt
  65. +77 −76 src/main/org/openscience/cdk/smiles/smarts/parser/visitor/SmartsQueryVisitor.java
  66. +10 −10 src/test/org/openscience/cdk/fingerprint/PubchemFingerprinterTest.java
  67. +2 −1 src/test/org/openscience/cdk/io/ChemObjectIOTest.java
  68. +8 −7 src/test/org/openscience/cdk/io/RGroupQueryReaderTest.java
  69. +1 −1 src/test/org/openscience/cdk/io/RGroupQueryWriterTest.java
  70. +32 −22 src/test/org/openscience/cdk/isomorphism/SMARTSTest.java
  71. +14 −14 src/test/org/openscience/cdk/isomorphism/UniversalIsomorphismTesterTest.java
  72. +2 −1 src/test/org/openscience/cdk/isomorphism/matchers/SymbolSetQueryAtomTest.java
  73. +4 −0 src/test/org/openscience/cdk/modeling/builder3d/TemplateHandler3DTest.java
  74. +2 −1 src/test/org/openscience/cdk/qsar/descriptors/molecular/AcidicGroupCountDescriptorTest.java
  75. +2 −1 src/test/org/openscience/cdk/qsar/descriptors/molecular/BasicGroupCountDescriptorTest.java
  76. +8 −8 src/test/org/openscience/cdk/smiles/smarts/SMARTSQueryToolTest.java
  77. +13 −12 src/test/org/openscience/cdk/smiles/smarts/parser/ParserTest.java
  78. +2 −2 src/test/org/openscience/cdk/smiles/smarts/parser/RecursiveTest.java
  79. +28 −28 src/test/org/openscience/cdk/smiles/smarts/parser/SMARTSSearchTest.java
  80. +2 −1 src/test/org/openscience/cdk/smiles/smarts/parser/visitor/SmartsQueryVisitorTest.java
  81. +6 −6 src/test/org/openscience/cdk/smsd/algorithm/rgraph/CDKMCSTest.java
@@ -76,7 +76,7 @@ public IBitFingerprint getBitFingerprint(IAtomContainer atomContainer)
int bitsetLength = PATTERNS.length;
BitSet fingerPrint = new BitSet(bitsetLength);
- SMARTSQueryTool sqt = new SMARTSQueryTool("C");
+ SMARTSQueryTool sqt = new SMARTSQueryTool("C", atomContainer.getBuilder());
for (int i = 0; i < PATTERNS.length; i++) {
sqt.setSmarts(PATTERNS[i]);
boolean status = sqt.matches(atomContainer);
@@ -97,7 +97,7 @@ public IBitFingerprint getBitFingerprint(IAtomContainer atomContainer)
int bitsetLength = keys.length;
BitSet fingerPrint = new BitSet(bitsetLength);
- SMARTSQueryTool sqt = new SMARTSQueryTool("C");
+ SMARTSQueryTool sqt = new SMARTSQueryTool("C", atomContainer.getBuilder());
for (int i = 0; i < keys.length; i++) {
String smarts = keys[i].getSmarts();
if (smarts.equals("?")) continue;
@@ -31,6 +31,7 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IRingSet;
import org.openscience.cdk.ringsearch.SSSRFinder;
import org.openscience.cdk.smiles.smarts.SMARTSQueryTool;
@@ -94,8 +95,8 @@
private byte[] m_bits;
private SMARTSQueryTool sqt;
- public PubchemFingerprinter() {
- sqt = new SMARTSQueryTool("C");
+ public PubchemFingerprinter(IChemObjectBuilder builder) {
+ sqt = new SMARTSQueryTool("C", builder);
m_bits = new byte[(FP_SIZE + 7) >> 3];
}
@@ -368,7 +369,9 @@ public static BitSet decode(String enc) {
"Input is not a proper PubChem base64 encoded fingerprint");
}
- PubchemFingerprinter pc = new PubchemFingerprinter();
+ // note the IChemObjectBuilder is passed as null because the SMARTSQueryTool
+ // isn't needed when decoding
+ PubchemFingerprinter pc = new PubchemFingerprinter(null);
for (int i = 0; i < pc.m_bits.length; ++i) {
pc.m_bits[i] = fp[i + 4];
}
@@ -409,7 +409,7 @@ public IBitFingerprint getBitFingerprint(IAtomContainer atomContainer)
int bitsetLength = smarts.length;
BitSet fingerPrint = new BitSet(bitsetLength);
- SMARTSQueryTool sqt = new SMARTSQueryTool("C");
+ SMARTSQueryTool sqt = new SMARTSQueryTool("C", atomContainer.getBuilder());
for (int i = 0; i < smarts.length; i++) {
String pattern = smarts[i];
@@ -721,7 +721,7 @@ private IAtomContainer readAtomContainer(IAtomContainer molecule) throws CDKExce
}
else {
queryBondCount++;
- newBond = new CTFileQueryBond();
+ newBond = new CTFileQueryBond(molecule.getBuilder());
IAtom[] bondAtoms = {a1,a2};
newBond.setAtoms(bondAtoms);
newBond.setOrder(null);
@@ -741,7 +741,7 @@ private IAtomContainer readAtomContainer(IAtomContainer molecule) throws CDKExce
if(queryBondCount==0)
outputContainer = molecule;
else {
- outputContainer = new QueryAtomContainer();
+ outputContainer = new QueryAtomContainer(molecule.getBuilder());
}
outputContainer.setProperty(CDKConstants.TITLE, title);
@@ -24,6 +24,8 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObject;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* Captures query bond types defined in the CTFile.
@@ -51,6 +53,9 @@
ANY
}
+ public CTFileQueryBond(IChemObjectBuilder builder){
+ super(builder);
+ }
/**
* The type of this bond.
*/
@@ -23,6 +23,7 @@
import java.util.Set;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* A QueryAtom that matches all symbols but those in this container. You may
@@ -45,7 +46,9 @@
/**
* Constructor for the InverseSymbolSetQueryAtom object
*/
- public InverseSymbolSetQueryAtom() { }
+ public InverseSymbolSetQueryAtom(IChemObjectBuilder builder) {
+ super(builder);
+ }
public void setOperator(String str){}
/**
@@ -26,6 +26,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* @cdk.module isomorphism
@@ -35,11 +36,12 @@
private static final long serialVersionUID = 2292654937621883661L;
- public OrderQueryBond() {
+ public OrderQueryBond(IChemObjectBuilder builder) {
+ super(builder);
}
- public OrderQueryBond(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order) {
- super(atom1, atom2, order);
+ public OrderQueryBond(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order, IChemObjectBuilder builder) {
+ super(atom1, atom2, order, builder);
}
public boolean matches(IBond bond) {
@@ -25,6 +25,7 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* <code>IQueryBond</code> that matches IBond object only based on bond order, and
@@ -37,11 +38,12 @@
private static final long serialVersionUID = 2292654937621883661L;
- public OrderQueryBondOrderOnly() {
+ public OrderQueryBondOrderOnly(IChemObjectBuilder builder) {
+ super(builder);
}
- public OrderQueryBondOrderOnly(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order) {
- super(atom1, atom2, order);
+ public OrderQueryBondOrderOnly(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order, IChemObjectBuilder builder) {
+ super(atom1, atom2, order, builder);
}
public boolean matches(IBond bond) {
@@ -25,6 +25,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtomType;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* @cdk.module isomorphism
@@ -127,11 +128,14 @@
/** The atomic number for this element giving their position in the periodic table. */
protected Integer atomicNumber = (Integer) CDKConstants.UNSET;
- public QueryAtom(String symbol) {
+ public QueryAtom(String symbol, IChemObjectBuilder builder) {
+ this(builder);
this.symbol = symbol;
}
- public QueryAtom() {}
+ public QueryAtom(IChemObjectBuilder builder) {
+ super(builder);
+ }
/**
* Sets the partial charge of this atom.
@@ -26,6 +26,7 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IBond.Order;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IChemObjectChangeEvent;
import org.openscience.cdk.interfaces.IElectronContainer;
import org.openscience.cdk.interfaces.ILonePair;
@@ -117,8 +118,9 @@ public String toString() {
/**
* Constructs an empty AtomContainer.
*/
- public QueryAtomContainer() {
- this(10, 10, 0, 0);
+ public QueryAtomContainer(IChemObjectBuilder builder) {
+ this(10, 10, 0, 0,
+ builder);
}
@@ -129,8 +131,9 @@ public QueryAtomContainer() {
*
* @param container An AtomContainer to copy the atoms and electronContainers from
*/
- public QueryAtomContainer(IAtomContainer container)
+ public QueryAtomContainer(IAtomContainer container, IChemObjectBuilder builder)
{
+ super(builder);
this.atomCount = container.getAtomCount();
this.bondCount = container.getBondCount();
this.lonePairCount = container.getLonePairCount();
@@ -172,8 +175,10 @@ public QueryAtomContainer(IAtomContainer container)
*@param seCount Number of single electrons to be in this container
*
*/
- public QueryAtomContainer(int atomCount, int bondCount, int lpCount, int seCount)
+ public QueryAtomContainer(int atomCount, int bondCount, int lpCount, int seCount,
+ IChemObjectBuilder builder)
{
+ super(builder);
this.atomCount = 0;
this.bondCount = 0;
this.lonePairCount = 0;
Oops, something went wrong.

0 comments on commit fd31151

Please sign in to comment.