Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
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...
commit fd311519b89092120167bdbcea294f8064ff016d 1 parent f093134
@johnmay authored
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
View
2  src/main/org/openscience/cdk/fingerprint/EStateFingerprinter.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);
View
2  src/main/org/openscience/cdk/fingerprint/MACCSFingerprinter.java
@@ -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;
View
9 src/main/org/openscience/cdk/fingerprint/PubchemFingerprinter.java
@@ -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];
}
View
2  src/main/org/openscience/cdk/fingerprint/SubstructureFingerprinter.java
@@ -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];
View
4 src/main/org/openscience/cdk/io/MDLV2000Reader.java
@@ -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);
View
5 src/main/org/openscience/cdk/isomorphism/matchers/CTFileQueryBond.java
@@ -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.
*/
View
5 src/main/org/openscience/cdk/isomorphism/matchers/InverseSymbolSetQueryAtom.java
@@ -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){}
/**
View
8 src/main/org/openscience/cdk/isomorphism/matchers/OrderQueryBond.java
@@ -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) {
View
8 src/main/org/openscience/cdk/isomorphism/matchers/OrderQueryBondOrderOnly.java
@@ -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) {
View
8 src/main/org/openscience/cdk/isomorphism/matchers/QueryAtom.java
@@ -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.
View
13 src/main/org/openscience/cdk/isomorphism/matchers/QueryAtomContainer.java
@@ -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;
View
60 src/main/org/openscience/cdk/isomorphism/matchers/QueryAtomContainerCreator.java
@@ -45,7 +45,7 @@
*@return The new QueryAtomContainer created from container.
*/
public static QueryAtomContainer createBasicQueryContainer(IAtomContainer container) {
- QueryAtomContainer queryContainer = new QueryAtomContainer();
+ QueryAtomContainer queryContainer = new QueryAtomContainer(container.getBuilder());
for (int i = 0; i < container.getAtomCount(); i++) {
queryContainer.addAtom(new SymbolQueryAtom(container.getAtom(i)));
}
@@ -57,11 +57,13 @@ public static QueryAtomContainer createBasicQueryContainer(IAtomContainer contai
if (bond.getFlag(CDKConstants.ISAROMATIC)) {
queryContainer.addBond(new AromaticQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- IBond.Order.SINGLE));
+ IBond.Order.SINGLE,
+ container.getBuilder()));
} else {
queryContainer.addBond(new OrderQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- bond.getOrder()));
+ bond.getOrder(),
+ container.getBuilder()));
}
}
return queryContainer;
@@ -75,7 +77,7 @@ public static QueryAtomContainer createBasicQueryContainer(IAtomContainer contai
* @return The new QueryAtomContainer created from container.
*/
public static QueryAtomContainer createSymbolAndBondOrderQueryContainer(IAtomContainer container) {
- QueryAtomContainer queryContainer = new QueryAtomContainer();
+ QueryAtomContainer queryContainer = new QueryAtomContainer(container.getBuilder());
for (int i = 0; i < container.getAtomCount(); i++) {
queryContainer.addAtom(new SymbolQueryAtom(container.getAtom(i)));
}
@@ -88,7 +90,8 @@ public static QueryAtomContainer createSymbolAndBondOrderQueryContainer(IAtomCon
new OrderQueryBondOrderOnly(
(IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- bond.getOrder()
+ bond.getOrder(),
+ container.getBuilder()
)
);
}
@@ -103,7 +106,7 @@ public static QueryAtomContainer createSymbolAndBondOrderQueryContainer(IAtomCon
*@return The new QueryAtomContainer created from container.
*/
public static QueryAtomContainer createSymbolAndChargeQueryContainer(IAtomContainer container) {
- QueryAtomContainer queryContainer = new QueryAtomContainer();
+ QueryAtomContainer queryContainer = new QueryAtomContainer(container.getBuilder());
for (int i = 0; i < container.getAtomCount(); i++) {
queryContainer.addAtom(new SymbolAndChargeQueryAtom(container.getAtom(i)));
}
@@ -115,18 +118,20 @@ public static QueryAtomContainer createSymbolAndChargeQueryContainer(IAtomContai
if (bond.getFlag(CDKConstants.ISAROMATIC)) {
queryContainer.addBond(new AromaticQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- IBond.Order.SINGLE));
+ IBond.Order.SINGLE,
+ container.getBuilder()));
} else {
queryContainer.addBond(new OrderQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- bond.getOrder()));
+ bond.getOrder(),
+ container.getBuilder()));
}
}
return queryContainer;
}
public static QueryAtomContainer createSymbolChargeIDQueryContainer(IAtomContainer container) {
- QueryAtomContainer queryContainer = new QueryAtomContainer();
+ QueryAtomContainer queryContainer = new QueryAtomContainer(container.getBuilder());
for (int i = 0; i < container.getAtomCount(); i++) {
queryContainer.addAtom(new SymbolChargeIDQueryAtom(container.getAtom(i)));
}
@@ -138,11 +143,13 @@ public static QueryAtomContainer createSymbolChargeIDQueryContainer(IAtomContain
if (bond.getFlag(CDKConstants.ISAROMATIC)) {
queryContainer.addBond(new AromaticQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- IBond.Order.SINGLE));
+ IBond.Order.SINGLE,
+ container.getBuilder()));
} else {
queryContainer.addBond(new OrderQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- bond.getOrder()));
+ bond.getOrder(),
+ container.getBuilder()));
}
}
return queryContainer;
@@ -157,13 +164,13 @@ public static QueryAtomContainer createSymbolChargeIDQueryContainer(IAtomContain
*@return The new QueryAtomContainer created from container
*/
public static QueryAtomContainer createAnyAtomContainer(IAtomContainer container, boolean aromaticity) {
- QueryAtomContainer queryContainer = new QueryAtomContainer();
+ QueryAtomContainer queryContainer = new QueryAtomContainer(container.getBuilder());
for (int i = 0; i < container.getAtomCount(); i++) {
if (aromaticity && container.getAtom(i).getFlag(CDKConstants.ISAROMATIC)) {
- queryContainer.addAtom(new AromaticAtom());
+ queryContainer.addAtom(new AromaticAtom(container.getBuilder()));
} else {
- queryContainer.addAtom(new AnyAtom());
+ queryContainer.addAtom(new AnyAtom(container.getBuilder()));
}
}
@@ -175,11 +182,13 @@ public static QueryAtomContainer createAnyAtomContainer(IAtomContainer container
if (aromaticity && bond.getFlag(CDKConstants.ISAROMATIC)) {
queryContainer.addBond(new AromaticQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- IBond.Order.SINGLE));
+ IBond.Order.SINGLE,
+ container.getBuilder()));
} else {
queryContainer.addBond(new OrderQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- bond.getOrder()));
+ bond.getOrder(),
+ container.getBuilder()));
}
}
return queryContainer;
@@ -196,13 +205,13 @@ public static QueryAtomContainer createAnyAtomContainer(IAtomContainer container
* @return The new QueryAtomContainer
*/
public static QueryAtomContainer createAnyAtomAnyBondContainer(IAtomContainer container, boolean aromaticity) {
- QueryAtomContainer queryContainer = new QueryAtomContainer();
+ QueryAtomContainer queryContainer = new QueryAtomContainer(container.getBuilder());
for (int i = 0; i < container.getAtomCount(); i++) {
if (aromaticity && container.getAtom(i).getFlag(CDKConstants.ISAROMATIC)) {
- queryContainer.addAtom(new AromaticAtom());
+ queryContainer.addAtom(new AromaticAtom(container.getBuilder()));
} else {
- queryContainer.addAtom(new AnyAtom());
+ queryContainer.addAtom(new AnyAtom(container.getBuilder()));
}
}
@@ -213,7 +222,8 @@ public static QueryAtomContainer createAnyAtomAnyBondContainer(IAtomContainer co
int index2 = container.getAtomNumber(bond.getAtom(1));
queryContainer.addBond(new AnyOrderQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- bond.getOrder()));
+ bond.getOrder(),
+ container.getBuilder()));
}
return queryContainer;
}
@@ -227,10 +237,10 @@ public static QueryAtomContainer createAnyAtomAnyBondContainer(IAtomContainer co
*@return The new QueryAtomContainer created from container.
*/
public static QueryAtomContainer createAnyAtomForPseudoAtomQueryContainer(IAtomContainer container) {
- QueryAtomContainer queryContainer = new QueryAtomContainer();
+ QueryAtomContainer queryContainer = new QueryAtomContainer(container.getBuilder());
for (int i = 0; i < container.getAtomCount(); i++) {
if (container.getAtom(i) instanceof IPseudoAtom) {
- queryContainer.addAtom(new AnyAtom());
+ queryContainer.addAtom(new AnyAtom(container.getBuilder()));
}
else {
queryContainer.addAtom(new SymbolQueryAtom(container.getAtom(i)));
@@ -245,11 +255,13 @@ public static QueryAtomContainer createAnyAtomForPseudoAtomQueryContainer(IAtomC
if (bond.getFlag(CDKConstants.ISAROMATIC)) {
queryContainer.addBond(new AromaticQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- IBond.Order.SINGLE));
+ IBond.Order.SINGLE,
+ container.getBuilder()));
} else {
queryContainer.addBond(new OrderQueryBond((IQueryAtom) queryContainer.getAtom(index1),
(IQueryAtom) queryContainer.getAtom(index2),
- bond.getOrder()));
+ bond.getOrder(),
+ container.getBuilder()));
}
}
return queryContainer;
View
22 src/main/org/openscience/cdk/isomorphism/matchers/QueryBond.java
@@ -30,6 +30,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
@@ -65,8 +66,8 @@
/**
* Constructs an empty query bond.
*/
- public QueryBond() {
- this(null, null, null, IQueryBond.Stereo.NONE);
+ public QueryBond(IChemObjectBuilder builder) {
+ this(null, null, null, IQueryBond.Stereo.NONE, builder);
atomCount = 0;
}
@@ -77,8 +78,8 @@ public QueryBond() {
* @param atom1 the first Atom in the query bond
* @param atom2 the second Atom in the query bond
*/
- public QueryBond(IAtom atom1, IAtom atom2) {
- this(atom1, atom2, IQueryBond.Order.SINGLE, IQueryBond.Stereo.NONE);
+ public QueryBond(IAtom atom1, IAtom atom2, IChemObjectBuilder builder) {
+ this(atom1, atom2, IQueryBond.Order.SINGLE, IQueryBond.Stereo.NONE, builder);
}
@@ -89,8 +90,8 @@ public QueryBond(IAtom atom1, IAtom atom2) {
* @param atom2 the second Atom in the query bond
* @param order the query bond order
*/
- public QueryBond(IAtom atom1, IAtom atom2, Order order) {
- this(atom1, atom2, order, IQueryBond.Stereo.NONE);
+ public QueryBond(IAtom atom1, IAtom atom2, Order order, IChemObjectBuilder builder) {
+ this(atom1, atom2, order, IQueryBond.Stereo.NONE, builder);
}
/**
@@ -98,7 +99,8 @@ public QueryBond(IAtom atom1, IAtom atom2, Order order) {
*
* @param atoms An array of IAtom containing the atoms constituting the query bond
*/
- public QueryBond(IAtom[] atoms) {
+ public QueryBond(IAtom[] atoms, IChemObjectBuilder builder) {
+ super(builder);
this.atoms = new IAtom[atoms.length];
System.arraycopy(atoms, 0, this.atoms, 0, atoms.length);
atomCount = this.atoms.length;
@@ -110,7 +112,8 @@ public QueryBond(IAtom[] atoms) {
* @param atoms An array of IAtom containing the atoms constituting the query bond
* @param order The order of the query bond
*/
- public QueryBond(IAtom[] atoms, Order order) {
+ public QueryBond(IAtom[] atoms, Order order, IChemObjectBuilder builder) {
+ super(builder);
this.atoms = new IAtom[atoms.length];
System.arraycopy(atoms, 0, this.atoms, 0, atoms.length);
atomCount = this.atoms.length;
@@ -127,7 +130,8 @@ public QueryBond(IAtom[] atoms, Order order) {
* @param order the query bond order
* @param stereo a descriptor the stereochemical orientation of this query bond
*/
- public QueryBond(IAtom atom1, IAtom atom2, Order order, IQueryBond.Stereo stereo) {
+ public QueryBond(IAtom atom1, IAtom atom2, Order order, IQueryBond.Stereo stereo, IChemObjectBuilder builder) {
+ super(builder);
atoms = new IAtom[2];
atoms[0] = atom1;
atoms[1] = atom2;
View
12 src/main/org/openscience/cdk/isomorphism/matchers/QueryChemObject.java
@@ -64,10 +64,13 @@
*/
private short flags; // flags are currently stored as a single short value MAX_FLAG_INDEX < 16
- public QueryChemObject() {
+ private final IChemObjectBuilder builder;
+
+ public QueryChemObject(IChemObjectBuilder builder) {
chemObjectListeners = null;
properties = null;
identifier = null;
+ this.builder = builder;
}
/**
@@ -274,7 +277,6 @@ public void setID(String identifier)
/**
* @inheritDoc
*/
- @Override
public void setFlag(int mask, boolean value)
{
// set/unset a bit in the flags value
@@ -288,7 +290,6 @@ public void setFlag(int mask, boolean value)
/**
* @inheritDoc
*/
- @Override
public boolean getFlag(int mask)
{
return (flags & mask) != 0;
@@ -316,7 +317,6 @@ public void setProperties(Map<Object,Object> properties)
/**
* @inheritDoc
*/
- @Override
public void setFlags(boolean[] flagsNew){
for(int i = 0; i < flagsNew.length ; i++)
setFlag(CDKConstants.FLAG_MASKS[i], flagsNew[i]);
@@ -325,7 +325,6 @@ public void setFlags(boolean[] flagsNew){
/**
* @inheritDoc
*/
- @Override
public boolean[] getFlags(){
// could use a list a invoke .toArray() on the return
boolean[] flagArray = new boolean[CDKConstants.MAX_FLAG_INDEX + 1];
@@ -340,7 +339,6 @@ public void setFlags(boolean[] flagsNew){
/**
* @inheritDoc
*/
- @Override
public Short getFlagValue(){
return flags;
}
@@ -354,7 +352,7 @@ public boolean getNotification() {
}
public IChemObjectBuilder getBuilder() {
- throw new IllegalAccessError();
+ return builder;
}
public boolean matches(IAtom atom) {
View
4 src/main/org/openscience/cdk/isomorphism/matchers/RGroupQuery.java
@@ -40,6 +40,7 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;
import org.openscience.cdk.interfaces.IChemObject;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IPseudoAtom;
import org.openscience.cdk.tools.ILoggingTool;
import org.openscience.cdk.tools.LoggingToolFactory;
@@ -95,6 +96,9 @@
*/
private Map<IAtom, Map<Integer, IBond>> rootAttachmentPoints;
+ public RGroupQuery(IChemObjectBuilder builder){
+ super(builder);
+ }
/**
* Returns all R# type atoms (pseudo atoms) found in the root structure
View
7 src/main/org/openscience/cdk/isomorphism/matchers/SymbolAndChargeQueryAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* @cdk.module isomorphism
@@ -33,10 +34,12 @@
private static final long serialVersionUID = 3328313175614956150L;
- public SymbolAndChargeQueryAtom() {}
+ public SymbolAndChargeQueryAtom(IChemObjectBuilder builder) {
+ super(builder);
+ }
public SymbolAndChargeQueryAtom(IAtom atom) {
- super(atom.getSymbol());
+ super(atom.getSymbol(), atom.getBuilder());
setFormalCharge(atom.getFormalCharge());
}
public void setOperator(String str){}
View
7 src/main/org/openscience/cdk/isomorphism/matchers/SymbolChargeIDQueryAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* @cdk.module isomorphism
@@ -33,10 +34,12 @@
private static final long serialVersionUID = 3328313175614956150L;
- public SymbolChargeIDQueryAtom() {}
+ public SymbolChargeIDQueryAtom(IChemObjectBuilder builder) {
+ super(builder);
+ }
public SymbolChargeIDQueryAtom(IAtom atom) {
- super(atom.getSymbol());
+ super(atom.getSymbol(), atom.getBuilder());
setFormalCharge(atom.getFormalCharge());
setID(atom.getID());
}
View
7 src/main/org/openscience/cdk/isomorphism/matchers/SymbolQueryAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* @cdk.module isomorphism
@@ -34,10 +35,12 @@
private static final long serialVersionUID = -5774610415273279451L;
private String ID;
private int HCount=0;
- public SymbolQueryAtom() {}
+ public SymbolQueryAtom(IChemObjectBuilder builder) {
+ super(builder);
+ }
public SymbolQueryAtom(IAtom atom) {
- super(atom.getSymbol());
+ super(atom.getSymbol(), atom.getBuilder());
}
public void setHCount(int m_HCount){
HCount = m_HCount;
View
5 src/main/org/openscience/cdk/isomorphism/matchers/SymbolSetQueryAtom.java
@@ -28,6 +28,7 @@
import java.util.Set;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* A QueryAtom that matches all symbols in this container. You may add symbols
@@ -50,7 +51,9 @@
/**
* Constructor for the SymbolSetQueryAtom object
*/
- public SymbolSetQueryAtom() { }
+ public SymbolSetQueryAtom(IChemObjectBuilder builder) {
+ super(builder);
+ }
public void setOperator(String str){}
/**
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AliphaticAtom.java
@@ -25,6 +25,7 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.CDKConstants;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher any non-aromatic atom. This assumes that aromaticity in the
@@ -42,7 +43,8 @@
* Creates a new instance
*
*/
- public AliphaticAtom() {
+ public AliphaticAtom(IChemObjectBuilder builder) {
+ super(builder);
setFlag(CDKConstants.ISALIPHATIC, true);
}
View
5 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AliphaticSymbolAtom.java
@@ -21,6 +21,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This smarts atom matches aliphatic atom with element symbol specified
@@ -37,8 +38,8 @@
*
* @param symbol the atom symbol
*/
- public AliphaticSymbolAtom(String symbol) {
- super();
+ public AliphaticSymbolAtom(String symbol, IChemObjectBuilder builder) {
+ super(builder);
setFlag(CDKConstants.ISAROMATIC, false);
setSymbol(symbol);
}
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AnyAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher any Atom.
@@ -39,7 +40,8 @@
/**
* Creates a new instance
*/
- public AnyAtom() {
+ public AnyAtom(IChemObjectBuilder builder) {
+ super(builder);
}
/* (non-Javadoc)
View
9 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AnyOrderQueryBond.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
/**
@@ -37,8 +38,8 @@
private static final long serialVersionUID = -826100570208878645L;
- public AnyOrderQueryBond() {
- super();
+ public AnyOrderQueryBond(IChemObjectBuilder builder) {
+ super(builder);
}
/**
@@ -47,8 +48,8 @@ public AnyOrderQueryBond() {
* @param atom1
* @param atom2
*/
- public AnyOrderQueryBond(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order) {
- super(atom1, atom2, order);
+ public AnyOrderQueryBond(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order, IChemObjectBuilder builder) {
+ super(atom1, atom2, order, builder);
}
/* (non-Javadoc)
View
6 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AromaticAtom.java
@@ -25,8 +25,9 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.CDKConstants;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
-/**
+ /**
* This matcher any aromatic atom. This assumes that aromaticity in the molecule
* has been perceived.
*
@@ -41,7 +42,8 @@
* Creates a new instance
*
*/
- public AromaticAtom() {
+ public AromaticAtom(IChemObjectBuilder builder) {
+ super(builder);
setFlag(CDKConstants.ISAROMATIC, true);
}
View
9 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AromaticOrSingleQueryBond.java
@@ -25,6 +25,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
/**
@@ -42,8 +43,8 @@
* Creates a new instance
*
*/
- public AromaticOrSingleQueryBond() {
- super();
+ public AromaticOrSingleQueryBond(IChemObjectBuilder builder) {
+ super(builder);
setFlag(CDKConstants.ISAROMATIC, true);
}
@@ -51,8 +52,8 @@ public AromaticOrSingleQueryBond() {
* Creates a new instance
*
*/
- public AromaticOrSingleQueryBond(IQueryAtom atom1, IQueryAtom atom2, Order order) {
- super(atom1, atom2, order);
+ public AromaticOrSingleQueryBond(IQueryAtom atom1, IQueryAtom atom2, Order order, IChemObjectBuilder builder) {
+ super(atom1, atom2, order, builder);
setFlag(CDKConstants.ISAROMATIC, true);
}
View
9 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AromaticQueryBond.java
@@ -25,6 +25,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
/**
@@ -42,8 +43,8 @@
* Creates a new instance
*
*/
- public AromaticQueryBond() {
- super();
+ public AromaticQueryBond(IChemObjectBuilder builder) {
+ super(builder);
setFlag(CDKConstants.ISAROMATIC, true);
}
@@ -51,8 +52,8 @@ public AromaticQueryBond() {
* Creates a new instance
*
*/
- public AromaticQueryBond(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order) {
- super(atom1, atom2, order);
+ public AromaticQueryBond(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order, IChemObjectBuilder builder) {
+ super(atom1, atom2, order, builder);
setFlag(CDKConstants.ISAROMATIC, true);
}
View
5 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AromaticSymbolAtom.java
@@ -21,6 +21,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This class matches aromatic atom with element symbol specified.
@@ -32,8 +33,8 @@
public class AromaticSymbolAtom extends SMARTSAtom {
private static final long serialVersionUID = -2887357588636946195L;
- public AromaticSymbolAtom(String symbol) {
- super();
+ public AromaticSymbolAtom(String symbol, IChemObjectBuilder builder) {
+ super(builder);
setFlag(CDKConstants.ISAROMATIC, true);
setSymbol(symbol);
}
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/AtomicNumberAtom.java
@@ -30,6 +30,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.tools.periodictable.PeriodicTable;
/**
@@ -47,7 +48,8 @@
*
* @param atomicNumber
*/
- public AtomicNumberAtom(int atomicNumber) {
+ public AtomicNumberAtom(int atomicNumber, IChemObjectBuilder builder) {
+ super(builder);
this.setAtomicNumber(atomicNumber);
}
View
5 src/main/org/openscience/cdk/isomorphism/matchers/smarts/ChiralityAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matches an atom with chirality property. It is not implemented yet.
@@ -77,8 +78,8 @@ public void setClockwise(boolean clockwise) {
* Creates a new instance
*
*/
- public ChiralityAtom() {
- super();
+ public ChiralityAtom(IChemObjectBuilder builder) {
+ super(builder);
}
public boolean matches(IAtom atom) {
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/ConnectionCountAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher checks the total valency of the Atom.
@@ -44,7 +45,8 @@
*
* @param count
*/
- public ConnectionCountAtom(int count) {
+ public ConnectionCountAtom(int count, IChemObjectBuilder builder) {
+ super(builder);
this.setProperty(CC_PROP, count);
}
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/DegreeAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher checks the number of connections of the checked Atom
@@ -37,7 +38,8 @@
private static final long serialVersionUID = 2623272739045200480L;
- public DegreeAtom(int charge) {
+ public DegreeAtom(int charge, IChemObjectBuilder builder) {
+ super(builder);
setFormalCharge(charge);
}
View
9 src/main/org/openscience/cdk/isomorphism/matchers/smarts/ExplicitConnectionAtom.java
@@ -21,6 +21,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This smarts atom matches any atom with a certain number of explicit
@@ -41,15 +42,15 @@
/**
* Creates a new instance.
*/
- public ExplicitConnectionAtom() {
- super();
+ public ExplicitConnectionAtom(IChemObjectBuilder builder) {
+ super(builder);
}
/**
* Creates a new instance.
*/
- public ExplicitConnectionAtom(int connection) {
- super();
+ public ExplicitConnectionAtom(int connection, IChemObjectBuilder builder) {
+ super(builder);
this.numOfConnection = connection;
}
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/FormalChargeAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher checks the formal charge of the Atom.
@@ -41,7 +42,8 @@
*
* @param charge
*/
- public FormalChargeAtom(int charge) {
+ public FormalChargeAtom(int charge, IChemObjectBuilder builder) {
+ super(builder);
this.formalCharge = charge;
}
View
6 src/main/org/openscience/cdk/isomorphism/matchers/smarts/HybridizationNumberAtom.java
@@ -31,12 +31,13 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomType;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher checks the hybridization state of an atom.
*
* @cdk.module smarts
- * @cdk.githash
+ * @cdk.githash
* @cdk.keyword SMARTS
*/
@@ -48,7 +49,8 @@
*
* @param hybridizationNumber the hybridiation
*/
- public HybridizationNumberAtom(int hybridizationNumber) {
+ public HybridizationNumberAtom(int hybridizationNumber, IChemObjectBuilder builder) {
+ super(builder);
switch (hybridizationNumber) {
case 1:
hybridization = IAtomType.Hybridization.SP1;
View
5 src/main/org/openscience/cdk/isomorphism/matchers/smarts/HydrogenAtom.java
@@ -22,6 +22,7 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import java.util.List;
@@ -42,8 +43,8 @@
* Creates a new instance.
*
*/
- public HydrogenAtom() {
- super();
+ public HydrogenAtom(IChemObjectBuilder builder) {
+ super(builder);
}
/* (non-Javadoc)
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/ImplicitHCountAtom.java
@@ -25,6 +25,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher checks the number of implicit hydrogens of the Atom.
@@ -42,7 +43,8 @@
*
* @param hCount
*/
- public ImplicitHCountAtom(int hCount) {
+ public ImplicitHCountAtom(int hCount, IChemObjectBuilder builder) {
+ super(builder);
this.setImplicitHydrogenCount(hCount);
}
View
7 src/main/org/openscience/cdk/isomorphism/matchers/smarts/LogicalOperatorAtom.java
@@ -20,13 +20,14 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
/**
* This class matches a logical operator that connects two query atoms
*
* @cdk.module smarts
- * @cdk.githash
+ * @cdk.githash
* @cdk.keyword SMARTS
*/
public class LogicalOperatorAtom extends SMARTSAtom {
@@ -47,6 +48,10 @@
*/
private IQueryAtom right;
+ public LogicalOperatorAtom(IChemObjectBuilder builder){
+ super(builder);
+ }
+
public IQueryAtom getLeft() {
return left;
}
View
5 src/main/org/openscience/cdk/isomorphism/matchers/smarts/LogicalOperatorBond.java
@@ -21,6 +21,7 @@
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.isomorphism.matchers.IQueryBond;
/**
@@ -48,6 +49,10 @@
*/
private IQueryBond right;
+ public LogicalOperatorBond(IChemObjectBuilder builder){
+ super(builder);
+ }
+
public IQueryBond getLeft() {
return left;
}
View
8 src/main/org/openscience/cdk/isomorphism/matchers/smarts/MassAtom.java
@@ -29,13 +29,14 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This class matches an atom based on the atomic mass.
*
* @cdk.module smarts
- * @cdk.githash
- * @cdk.keyword SMARTS
+ * @cdk.githash
+ * @cdk.keyword SMARTS
*/
public class MassAtom extends SMARTSAtom{
/**
@@ -43,7 +44,8 @@
*
* @param mass
*/
- public MassAtom(int mass) {
+ public MassAtom(int mass, IChemObjectBuilder builder) {
+ super(builder);
this.setMassNumber(mass);
}
View
5 src/main/org/openscience/cdk/isomorphism/matchers/smarts/NonCHHeavyAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher any heavy atom that is not C or H.
@@ -40,8 +41,8 @@
* Creates a new instance
*
*/
- public NonCHHeavyAtom() {
-
+ public NonCHHeavyAtom(IChemObjectBuilder builder) {
+ super(builder);
}
/* (non-Javadoc)
View
5 src/main/org/openscience/cdk/isomorphism/matchers/smarts/OrderQueryBond.java
@@ -25,6 +25,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matches a bond with a certain bond order.
@@ -45,8 +46,8 @@
*
* @param order the order of bond
*/
- public OrderQueryBond(IBond.Order order) {
- super();
+ public OrderQueryBond(IBond.Order order, IChemObjectBuilder builder) {
+ super(builder);
this.setOrder(order);
}
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/PeriodicGroupNumberAtom.java
@@ -30,6 +30,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.tools.periodictable.PeriodicTable;
/**
@@ -48,7 +49,8 @@
*
* @param groupNumber the periodic group number
*/
- public PeriodicGroupNumberAtom(int groupNumber) {
+ public PeriodicGroupNumberAtom(int groupNumber, IChemObjectBuilder builder) {
+ super(builder);
this.groupNumber = groupNumber;
}
View
2  src/main/org/openscience/cdk/isomorphism/matchers/smarts/RecursiveSmartsAtom.java
@@ -73,7 +73,7 @@
* @param query
*/
public RecursiveSmartsAtom(IQueryAtomContainer query) {
- super();
+ super(query.getBuilder());
this.recursiveQuery = query;
}
View
7 src/main/org/openscience/cdk/isomorphism/matchers/smarts/RingAtom.java
@@ -32,13 +32,15 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
+
import java.util.ArrayList;
/**
* This matches an atom in a specific size ring.
*
* @cdk.module smarts
- * @cdk.githash
+ * @cdk.githash
* @cdk.keyword SMARTS
*/
public class RingAtom extends SMARTSAtom {
@@ -52,7 +54,8 @@
*
* @param ringSize
*/
- public RingAtom(int ringSize) {
+ public RingAtom(int ringSize, IChemObjectBuilder builder) {
+ super(builder);
this.ringSize = ringSize;
}
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/RingBond.java
@@ -21,6 +21,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This smarts bond matches any bond that is in a ring.
@@ -36,7 +37,8 @@
* Creates a new instance
*
*/
- public RingBond() {
+ public RingBond(IChemObjectBuilder builder) {
+ super(builder);
this.setFlag(CDKConstants.ISINRING, true);
}
View
6 src/main/org/openscience/cdk/isomorphism/matchers/smarts/RingIdentifierAtom.java
@@ -20,6 +20,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
import org.openscience.cdk.isomorphism.matchers.IQueryBond;
@@ -35,6 +36,11 @@
private static final long serialVersionUID = -6812146026923460637L;
private IQueryAtom atom;
private IQueryBond ringBond;
+
+ public RingIdentifierAtom(IChemObjectBuilder builder){
+ super(builder);
+ }
+
/* (non-Javadoc)
* @see org.openscience.cdk.isomorphism.matchers.smarts.SMARTSAtom#matches(org.openscience.cdk.interfaces.IAtom)
*/
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/RingMembershipAtom.java
@@ -21,6 +21,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IRingSet;
/**
@@ -37,7 +38,8 @@
*/
private int numSSSR;
- public RingMembershipAtom(int num) {
+ public RingMembershipAtom(int num, IChemObjectBuilder builder) {
+ super(builder);
this.numSSSR = num;
}
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/SMARTSAtom.java
@@ -19,6 +19,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
import org.openscience.cdk.isomorphism.matchers.QueryAtom;
@@ -32,7 +33,8 @@
public abstract class SMARTSAtom extends QueryAtom implements
IQueryAtom {
- public SMARTSAtom() {
+ public SMARTSAtom(IChemObjectBuilder builder) {
+ super(builder);
}
public boolean matches(IAtom atom) {
View
9 src/main/org/openscience/cdk/isomorphism/matchers/smarts/SMARTSBond.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
import org.openscience.cdk.isomorphism.matchers.IQueryBond;
import org.openscience.cdk.isomorphism.matchers.QueryBond;
@@ -39,10 +40,12 @@
private static final long serialVersionUID = 6164978147730140061L;
- public SMARTSBond() {}
+ public SMARTSBond(IChemObjectBuilder builder) {
+ super(builder);
+ }
- public SMARTSBond(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order) {
- super(atom1, atom2, order);
+ public SMARTSBond(IQueryAtom atom1, IQueryAtom atom2, IBond.Order order, IChemObjectBuilder builder) {
+ super(atom1, atom2, order, builder);
}
public boolean matches(IBond bond) {
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/SmallestRingAtom.java
@@ -24,6 +24,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This smarts atom matches any atom with the smallest SSSR size being a
@@ -40,7 +41,8 @@
*/
private int smallestRingSize;
- public SmallestRingAtom(int size) {
+ public SmallestRingAtom(int size, IChemObjectBuilder builder) {
+ super(builder);
this.smallestRingSize = size;
}
View
5 src/main/org/openscience/cdk/isomorphism/matchers/smarts/StereoBond.java
@@ -20,6 +20,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This query bond matches bonds with specific stereo type. It is not
@@ -33,6 +34,10 @@
private static final long serialVersionUID = 3529688197057645996L;
+ public StereoBond(IChemObjectBuilder builder){
+ super(builder);
+ }
+
public boolean matches(IBond bond) {
if (this.getOrder() != bond.getOrder()) {
// bond orders not match
View
8 src/main/org/openscience/cdk/isomorphism/matchers/smarts/TotalConnectionAtom.java
@@ -32,13 +32,14 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matches an atom using total number of connections.
*
* @cdk.module smarts
- * @cdk.githash
- * @cdk.keyword SMARTS
+ * @cdk.githash
+ * @cdk.keyword SMARTS
*/
public class TotalConnectionAtom extends SMARTSAtom {
private static final long serialVersionUID = 2714616726873309671L;
@@ -46,7 +47,8 @@
/**
* Creates a new instance.
*/
- public TotalConnectionAtom(int count) {
+ public TotalConnectionAtom(int count, IChemObjectBuilder builder) {
+ super(builder);
this.setProperty(CDKConstants.TOTAL_CONNECTIONS, count);
}
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/TotalHCountAtom.java
@@ -25,6 +25,7 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher checks the formal charge of the Atom. This cannot be matched
@@ -38,7 +39,8 @@
private static final long serialVersionUID = -3532280322660394553L;
- public TotalHCountAtom(int hCount) {
+ public TotalHCountAtom(int hCount, IChemObjectBuilder builder) {
+ super(builder);
setProperty(CDKConstants.TOTAL_H_COUNT, hCount);
}
View
6 src/main/org/openscience/cdk/isomorphism/matchers/smarts/TotalRingConnectionAtom.java
@@ -31,13 +31,14 @@
import org.openscience.cdk.CDKConstants;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher checks the number of ring connections of the checked Atom with
* other Atom's. This cannot be matched with a unpreprocessed Atom!
*
* @cdk.module smarts
- * @cdk.githash
+ * @cdk.githash
* @cdk.keyword SMARTS
*/
@@ -47,7 +48,8 @@
*
* @param ringConn number of ring connections
*/
- public TotalRingConnectionAtom(int ringConn) {
+ public TotalRingConnectionAtom(int ringConn, IChemObjectBuilder builder) {
+ super(builder);
this.setProperty(CDKConstants.RING_CONNECTIONS, ringConn);
}
View
4 src/main/org/openscience/cdk/isomorphism/matchers/smarts/TotalValencyAtom.java
@@ -24,6 +24,7 @@
package org.openscience.cdk.isomorphism.matchers.smarts;
import org.openscience.cdk.interfaces.IAtom;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
/**
* This matcher checks the total valency of the Atom.
@@ -37,7 +38,8 @@
private static final long serialVersionUID = -8067867220731999668L;
- public TotalValencyAtom(int valency) {
+ public TotalValencyAtom(int valency, IChemObjectBuilder builder) {
+ super(builder);
setValency(valency);
}
View
2  src/main/org/openscience/cdk/pharmacophore/PharmacophoreMatcher.java
@@ -379,7 +379,7 @@ public void setPharmacophoreQuery(PharmacophoreQuery query) {
private IAtomContainer getPharmacophoreMolecule(IAtomContainer atomContainer) throws CDKException {
- SMARTSQueryTool sqt = new SMARTSQueryTool("C");
+ SMARTSQueryTool sqt = new SMARTSQueryTool("C", atomContainer.getBuilder());
IAtomContainer pharmacophoreMolecule = DefaultChemObjectBuilder.getInstance().newInstance(IAtomContainer.class);
// lets loop over each pcore query atom
View
5 src/main/org/openscience/cdk/pharmacophore/PharmacophoreQuery.java
@@ -23,10 +23,12 @@
*/
package org.openscience.cdk.pharmacophore;
+import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.annotations.TestClass;
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IBond;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.isomorphism.matchers.QueryAtomContainer;
import java.util.ArrayList;
@@ -50,7 +52,8 @@
private List<Object> exclusionVolumes;
public PharmacophoreQuery() {
- super();
+ // builder should be injected but this is difficult as this class is create in static methods
+ super(DefaultChemObjectBuilder.getInstance());
exclusionVolumes = new ArrayList<Object>();
}
View
5 src/main/org/openscience/cdk/qsar/descriptors/molecular/AcidicGroupCountDescriptor.java
@@ -26,6 +26,7 @@
import org.openscience.cdk.aromaticity.CDKHueckelAromaticityDetector;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.qsar.DescriptorSpecification;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.IMolecularDescriptor;
@@ -65,9 +66,9 @@
* Creates a new {@link AcidicGroupCountDescriptor}.
*/
@TestMethod("testConstructor")
- public AcidicGroupCountDescriptor() throws CDKException {
+ public AcidicGroupCountDescriptor(IChemObjectBuilder builder) throws CDKException {
for (String smarts : SMARTS_STRINGS) {
- tools.add(new SMARTSQueryTool(smarts));
+ tools.add(new SMARTSQueryTool(smarts, builder));
}
this.checkAromaticity = true;
}
View
5 src/main/org/openscience/cdk/qsar/descriptors/molecular/BasicGroupCountDescriptor.java
@@ -25,6 +25,7 @@
import org.openscience.cdk.annotations.TestMethod;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtomContainer;
+import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.qsar.DescriptorSpecification;
import org.openscience.cdk.qsar.DescriptorValue;
import org.openscience.cdk.qsar.IMolecularDescriptor;
@@ -62,9 +63,9 @@
* Creates a new {@link BasicGroupCountDescriptor}.
*/
@TestMethod("testConstructor")
- public BasicGroupCountDescriptor() throws CDKException {
+ public BasicGroupCountDescriptor(IChemObjectBuilder builder) throws CDKException {
for (String smarts : SMARTS_STRINGS) {
- tools.add(new SMARTSQueryTool(smarts));
+ tools.add(new SMARTSQueryTool(smarts, builder));
}
}
View
2  src/main/org/openscience/cdk/qsar/descriptors/molecular/KierHallSmartsDescriptor.java
@@ -405,7 +405,7 @@ public DescriptorValue calculate(IAtomContainer container) {
int[] counts = new int[smarts.length];
try {
- SMARTSQueryTool sqt = new SMARTSQueryTool("C");
+ SMARTSQueryTool sqt = new SMARTSQueryTool("C", container.getBuilder());
for (int i = 0; i < smarts.length; i++) {
sqt.setSmarts(smarts[i]);
boolean status = sqt.matches(atomContainer);
View
18 src/main/org/openscience/cdk/qsar/descriptors/molecular/XLogPDescriptor.java
@@ -879,7 +879,7 @@ else if (getAtomTypeXCount(ac, atomi) == 2) {
bondAtom1=bond.getAtom(1);
if ((bondAtom0.getSymbol().equals("C") && bondAtom1.getSymbol().equals("N")) || (bondAtom0.getSymbol().equals("N") && bondAtom1.getSymbol().equals("C"))&& bond.getOrder() == IBond.Order.SINGLE){
aminoAcid.removeBond(bondAtom0,bondAtom1);
- aminoAcid.addBond(new AnyOrderQueryBond((IQueryAtom)bondAtom0,(IQueryAtom)bondAtom1,IBond.Order.SINGLE));
+ aminoAcid.addBond(new AnyOrderQueryBond((IQueryAtom)bondAtom0,(IQueryAtom)bondAtom1,IBond.Order.SINGLE, atomContainer.getBuilder()));
break;
}
}
@@ -935,18 +935,18 @@ else if (getAtomTypeXCount(ac, atomi) == 2) {
// ortho oxygen pair
//AtomContainer orthopair = sp.parseSmiles("OCCO");
- QueryAtomContainer orthopair=new QueryAtomContainer();
- AromaticAtom atom1=new AromaticAtom();
+ QueryAtomContainer orthopair=new QueryAtomContainer(atomContainer.getBuilder());
+ AromaticAtom atom1=new AromaticAtom(atomContainer.getBuilder());
atom1.setSymbol("C");
- AromaticAtom atom2=new AromaticAtom();
+ AromaticAtom atom2=new AromaticAtom(atomContainer.getBuilder());
atom2.setSymbol("C");
- SymbolQueryAtom atom3=new SymbolQueryAtom();
+ SymbolQueryAtom atom3=new SymbolQueryAtom(atomContainer.getBuilder());
atom3.setSymbol("O");
- SymbolQueryAtom atom4=new SymbolQueryAtom();
+ SymbolQueryAtom atom4=new SymbolQueryAtom(atomContainer.getBuilder());
atom4.setSymbol("O");
- orthopair.addBond(new AromaticQueryBond(atom1,atom2,IBond.Order.SINGLE));
- orthopair.addBond(new OrderQueryBond(atom1,atom3,IBond.Order.SINGLE));
- orthopair.addBond(new OrderQueryBond(atom2,atom4,IBond.Order.SINGLE));
+ orthopair.addBond(new AromaticQueryBond(atom1,atom2,IBond.Order.SINGLE, atomContainer.getBuilder()));
+ orthopair.addBond(new OrderQueryBond(atom1,atom3,IBond.Order.SINGLE, atomContainer.getBuilder()));
+ orthopair.addBond(new OrderQueryBond(atom2,atom4,IBond.Order.SINGLE, atomContainer.getBuilder()));
try {
if (universalIsomorphismTester.isSubgraph(ac, orthopair)) {
View
9 src/main/org/openscience/cdk/smiles/smarts/SMARTSQueryTool.java
@@ -35,6 +35,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.isomorphism.UniversalIsomorphismTester;
import org.openscience.cdk.isomorphism.matchers.IQueryAtom;
@@ -117,6 +118,8 @@
private IAtomContainer atomContainer = null;
private QueryAtomContainer query = null;
+ private final IChemObjectBuilder builder;
+
private List<List<Integer>> matchingAtoms = null;
// a simplistic cache to store parsed SMARTS queries
@@ -132,7 +135,9 @@ public boolean removeEldestEntry(Map.Entry eldest) {
*
* @throws IllegalArgumentException if the SMARTS string can not be handled
*/
- public SMARTSQueryTool(String smarts) {
+ public SMARTSQueryTool(String smarts,
+ IChemObjectBuilder builder) {
+ this.builder = builder;
this.smarts = smarts;
try {
initializeQuery();
@@ -486,7 +491,7 @@ private void initializeQuery() throws CDKException {
matchingAtoms = null;
query = cache.get(smarts);
if (query == null) {
- query = SMARTSParser.parse(smarts);
+ query = SMARTSParser.parse(smarts, builder);
cache.put(smarts, query);
}
}
View
2