Nina Jeliazkova
-
2014-02-03
- assigned_to: ntk
Hello,
I get this error:
Exception in thread "main" java.lang.NullPointerException
at org.knime.cisrg.hyperstructures.smarts.SmartsParser.isAtomForStereoDoubleBond(SmartsParser.java:1814)
at org.knime.cisrg.hyperstructures.smarts.SmartsParser.setDoubleBondsStereoInfo(SmartsParser.java:1777)
at org.knime.cisrg.hyperstructures.smarts.SmartsParser.parse(SmartsParser.java:176)
at org.knime.cisrg.hyperstructures.smarts.SmartsParser.parse(SmartsParser.java:117)
at test.AMBITSMARTSStereoBug.main(AMBITSMARTSStereoBug.java:74)
When using this sample code
package test;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import org.knime.cisrg.hyperstructures.smarts.SmartsHelper;
import org.knime.cisrg.hyperstructures.smarts.SmartsParser;
import org.openscience.cdk.DefaultChemObjectBuilder;
import org.openscience.cdk.aromaticity.Aromaticity;
import org.openscience.cdk.aromaticity.ElectronDonation;
import org.openscience.cdk.exception.CDKException;
import org.openscience.cdk.graph.Cycles;
import org.openscience.cdk.interfaces.IAtomContainer;
import org.openscience.cdk.io.iterator.IteratingSMILESReader;
import org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer;
import org.openscience.cdk.smiles.SmilesGenerator;
import org.openscience.cdk.tools.manipulator.AtomContainerManipulator;
public class AMBITSMARTSStereoBug {
public static void main( String[] argv ) {
File inputFile = new File( "/usr/users/people/edmund/Documents/PhD/workspace/cisrg/data/input/ergosterol_analogues.smi" );
ArrayList<IAtomContainer> queries = new ArrayList<IAtomContainer>(5);
IteratingSMILESReader isr = null;
try {
isr = new IteratingSMILESReader( new FileInputStream(inputFile), DefaultChemObjectBuilder.getInstance() );
} catch (FileNotFoundException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
while( isr.hasNext() ) {
try {
IAtomContainer molecule = isr.next();
try {
AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(molecule);
//CDKHueckelAromaticityDetector.detectAromaticity(molecule);
// aromaticity.apply(molecule);
} catch (CDKException e) {
//logger.debug(e.toString());
throw new CDKException(e.toString(), e);
}
queries.add( molecule );
} catch( Exception e2 ) {
e2.printStackTrace();
}
}
try {
isr.close();
} catch (IOException e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
SmartsParser smartsParser = new SmartsParser( );
SmilesGenerator sGenerator = new SmilesGenerator().isomeric().aromatic();
try {
for( IAtomContainer mol : queries ) {
String refSMILES = sGenerator.create(mol);
System.out.println( refSMILES );
IQueryAtomContainer ref = smartsParser.parse( refSMILES );
}
} catch (CDKException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
}
}
with this SMILES file
CC(C)[C@@H](C)\C=C\[C@@H](C)[C@H]1C[C@H](O)C2=C3C=CC4=CC(=O)CC[C@]4(C)C3CC[C@]12C CHEMBL2021472
CC(C)CCC[C@@H](C)[C@H]1CC(=O)C2=C3CC[C@H]4C[C@@H](O)CC[C@]4(C)[C@H]3CC[C@]12C CHEMBL2104586
CC(=O)[C@H]1CCC2C3CC[C@H]4C[C@H](O)CC[C@]4(C)C3=CC[C@]12C CHEMBL289862
CC[C@H](CC[C@@H](C)C1CC[C@H]2[C@@H]3CC=C4C[C@@H](O)CC[C@]4(C)[C@H]3CC[C@]12C)C(C)C CHEMBL1875388
C[C@H](CCC=C(C)C)[C@@H]1CC[C@]2(C)C3=CC[C@H]4C(C)(C)[C@@H](O)CC[C@]4(C)C3=CC[C@@]12C CHEMBL517452
The offending method's code that I have is here:
boolean isAtomForStereoDoubleBond(IAtom atom)
{
//Following elements could participate in a stereo double bond: C, N, P, Si
if (atom.getSymbol().equals("C"))
return true;
if (atom.getSymbol().equals("N"))
return true;
if (atom.getSymbol().equals("P"))
return true;
if (atom.getSymbol().equals("Si"))
return true;
return false;
}
So I guess there's an atom which is missing a Symbol. I haven't figured out where in the SmartsParser code this actually happens, but I'm sure you can :-)
Two things I should note:
Thank you in advance,
Ed.