Skip to content

Commit

Permalink
Revert "Just count the number of oxygens directly from the containers"
Browse files Browse the repository at this point in the history
This reverts commit bddda96.
  • Loading branch information
johnmay committed Jun 24, 2015
1 parent 6e21795 commit 8b36b5e
Showing 1 changed file with 19 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,9 @@
package org.openscience.cdk.qsar.descriptors.substance;

import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.interfaces.IAtom;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IChemObjectBuilder;
import org.openscience.cdk.interfaces.IIsotope;
import org.openscience.cdk.interfaces.IMolecularFormula;
import org.openscience.cdk.interfaces.ISubstance;
import org.openscience.cdk.qsar.DescriptorSpecification;
import org.openscience.cdk.qsar.DescriptorValue;
Expand Down Expand Up @@ -74,18 +74,24 @@ public void setParameters(Object[] parameters) throws CDKException {
public DescriptorValue calculate(ISubstance substance) {
if (substance == null) return newNaNDescriptor();

int count = 0;
for (IAtomContainer container : substance.atomContainers()) {
for (IAtom atom : container.atoms()) {
if ("O".equals(atom.getSymbol()) || 8 == atom.getAtomicNumber())
count++;
}
}
IMolecularFormula molFormula = SubstanceManipulator.getChemicalComposition(substance);
if (molFormula == null) return newNaNDescriptor();

return new DescriptorValue(
getSpecification(), getParameterNames(), getParameters(),
new IntegerResult(count), getDescriptorNames()
);
int count = 0;
for (IIsotope isotope : molFormula.isotopes()) {
if ("O".equals(isotope.getSymbol())) {
count = molFormula.getIsotopeCount(isotope);
return new DescriptorValue(
getSpecification(),
getParameterNames(),
getParameters(),
new IntegerResult(count),
getDescriptorNames()
);
}
}

return newNaNDescriptor();
}

/**
Expand Down

0 comments on commit 8b36b5e

Please sign in to comment.