Skip to content

Commit

Permalink
Updated to CDK 2.7.1
Browse files Browse the repository at this point in the history
  • Loading branch information
egonw committed Jan 11, 2022
1 parent 978a08c commit 664d694
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 39 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,6 @@
import org.openscience.cdk.tools.manipulator.ChemFileManipulator;
import org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator;

import com.google.common.collect.Lists;

import io.github.egonw.bacting.IBactingManager;
import net.bioclipse.cdk.domain.CDKMolecule;
import net.bioclipse.cdk.domain.ICDKMolecule;
Expand Down Expand Up @@ -455,8 +453,7 @@ public Set<IAtom> getAtomsWithUndefinedStereo(IMolecule molecule) throws Bioclip
public Set<IAtom> getAtomsWithDefinedStereo(IMolecule molecule) throws BioclipseException {
Set<IAtom> stereoAtoms = new HashSet<IAtom>();
IAtomContainer container = asCDKMolecule(molecule).getAtomContainer();
List<IStereoElement> stereoInfo = Lists.newArrayList(container.stereoElements());
for (IStereoElement elem : stereoInfo) {
for (IStereoElement elem : container.stereoElements()) {
IChemObject focus = elem.getFocus();
if (focus instanceof IAtom) {
stereoAtoms.add((IAtom)focus);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,16 +22,15 @@
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.interfaces.IBond;

import io.github.dan2097.jnainchi.InchiCheckStatus;
import io.github.dan2097.jnainchi.InchiFlag;
import io.github.dan2097.jnainchi.InchiKeyCheckStatus;
import io.github.dan2097.jnainchi.InchiStatus;
import io.github.dan2097.jnainchi.JnaInchi;
import io.github.egonw.bacting.IBactingManager;
import net.bioclipse.core.business.BioclipseException;
import net.bioclipse.core.domain.IMolecule;
import net.bioclipse.inchi.InChI;
import net.sf.jniinchi.INCHI_KEY_STATUS;
import net.sf.jniinchi.INCHI_OPTION;
import net.sf.jniinchi.INCHI_RET;
import net.sf.jniinchi.INCHI_STATUS;
import net.sf.jniinchi.JniInchiException;
import net.sf.jniinchi.JniInchiWrapper;

/**
* Bioclipse manager that provides functionality to create and
Expand Down Expand Up @@ -80,7 +79,7 @@ public String load() {

public List<String> options() {
List<String> options = new ArrayList<String>();
for (INCHI_OPTION option : INCHI_OPTION.values()) {
for (InchiFlag option : InchiFlag.values()) {
options.add("" + option);
}
return options;
Expand Down Expand Up @@ -109,9 +108,8 @@ public InChI generate(IMolecule molecule, String options) throws Exception {
for (IBond bond : clone.bonds())
bond.setFlag(CDKConstants.ISAROMATIC, false);
InChIGenerator gen = factory.getInChIGenerator(clone, options);
INCHI_RET status = gen.getReturnStatus();
if (status == INCHI_RET.OKAY ||
status == INCHI_RET.WARNING) {
InchiStatus status = gen.getStatus();
if (status == InchiStatus.SUCCESS) {
InChI inchi = new InChI();
inchi.setValue(gen.getInchi());
inchi.setKey(gen.getInchiKey());
Expand Down Expand Up @@ -151,9 +149,8 @@ public InChI generate(IMolecule molecule) throws Exception {
for (IBond bond : clone.bonds())
bond.setFlag(CDKConstants.ISAROMATIC, false);
InChIGenerator gen = factory.getInChIGenerator(clone);
INCHI_RET status = gen.getReturnStatus();
if (status == INCHI_RET.OKAY ||
status == INCHI_RET.WARNING) {
InchiStatus status = gen.getStatus();
if (status == InchiStatus.SUCCESS) {
InChI inchi = new InChI();
inchi.setValue(gen.getInchi());
inchi.setKey(gen.getInchiKey());
Expand Down Expand Up @@ -188,13 +185,8 @@ public boolean isLoaded() {
* @throws BioclipseException
*/
public boolean checkKey(String inchikey) throws BioclipseException {
INCHI_KEY_STATUS status;
try {
status = JniInchiWrapper.checkInchiKey(inchikey);
} catch (JniInchiException exception) {
throw new BioclipseException("Error while validating the inchi: " + exception.getMessage(), exception);
}
if (status == INCHI_KEY_STATUS.VALID_STANDARD || status == INCHI_KEY_STATUS.VALID_NON_STANDARD)
InchiKeyCheckStatus status = JnaInchi.checkInchiKey(inchikey);
if (status == InchiKeyCheckStatus.VALID_STANDARD || status == InchiKeyCheckStatus.VALID_NON_STANDARD)
return true;
// everything else is false
return false;
Expand All @@ -208,13 +200,8 @@ public boolean checkKey(String inchikey) throws BioclipseException {
* @throws BioclipseException
*/
public boolean check(String inchi) throws BioclipseException {
INCHI_STATUS status;
try {
status = JniInchiWrapper.checkInchi(inchi, false);
} catch (JniInchiException exception) {
throw new BioclipseException("Error while validating the inchi: " + exception.getMessage(), exception);
}
if (status == INCHI_STATUS.VALID_STANDARD || status == INCHI_STATUS.VALID_NON_STANDARD)
InchiCheckStatus status = JnaInchi.checkInchi(inchi, false);
if (status == InchiCheckStatus.VALID_STANDARD || status == InchiCheckStatus.VALID_NON_STANDARD)
return true;
// everything else is false
return false;
Expand All @@ -228,13 +215,8 @@ public boolean check(String inchi) throws BioclipseException {
* @throws BioclipseException
*/
public boolean checkStrict(String inchi) throws BioclipseException {
INCHI_STATUS status;
try {
status = JniInchiWrapper.checkInchi(inchi, true);
} catch (JniInchiException exception) {
throw new BioclipseException("Error while validating the inchi: " + exception.getMessage(), exception);
}
if (status == INCHI_STATUS.VALID_STANDARD || status == INCHI_STATUS.VALID_NON_STANDARD)
InchiCheckStatus status = JnaInchi.checkInchi(inchi, true);
if (status == InchiCheckStatus.VALID_STANDARD || status == InchiCheckStatus.VALID_NON_STANDARD)
return true;
// everything else is false
return false;
Expand Down
2 changes: 1 addition & 1 deletion pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@
</scm>

<properties>
<cdk.version>2.6</cdk.version>
<cdk.version>2.7.1</cdk.version>
<bioclipse.version>2.8.0.12-SNAPSHOT</bioclipse.version>
<junit5.excludeGroups>pubchem,chemspider</junit5.excludeGroups>
</properties>
Expand Down

0 comments on commit 664d694

Please sign in to comment.