|
From: John S. <jo...@jo...> - 2014-10-02 12:26:38
|
Hi -
I am encountering a Null Pointer exception on a specific molecule within an SDF when calling MolecularFormulaManipulator.getTotalMassNumber. Similar stack calling getTotalExactMass. Note that I can extract the formula and other things, so it is not likely a parsing error. since getMajorIsotope can return null (note that it logs a warning in this scenario) it seems like mass calculation needs to take this into account - presumably if it is not a major isotope (i.e. null) it can just skip that element. If you agree let me know and I will generate a patch that handles this for the methods that call getMajorIsotope.
Here are the details:
java.lang.NullPointerException
at org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator.getTotalMassNumber(MolecularFormulaManipulator.java:691)
java.lang.NullPointerException
at org.openscience.cdk.tools.manipulator.MolecularFormulaManipulator.getTotalExactMass(MolecularFormulaManipulator.java:648)
Here is a code snippet that will reproduce the first stack:
IteratingSDFReader reader = new IteratingSDFReader(stream, DefaultChemObjectBuilder.getInstance(), true);
while (reader.hasNext()) {
IAtomContainer container = reader.next();
IMolecularFormula moleculeFormula = MolecularFormulaManipulator.getMolecularFormula(container);
String formula = MolecularFormulaManipulator.getString(moleculeFormula);
double weight = MolecularFormulaManipulator.getTotalMassNumber(moleculeFormula);
}
and it fails when parsing this sdf:
csChFnd80/03051211042D
29 32 0 0 0 0 0 0 0 0999 V2000
3.6373 2.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.6373 0.7000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.8497 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
6.0622 0.7000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
6.0622 2.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
4.8497 2.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.2746 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.4870 0.7000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.4870 2.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.2746 2.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.4249 2.8000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.2124 2.1000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
1.2124 0.7000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.4249 0.0000 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.8397 3.7900 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.2041 5.0374 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.8213 4.8184 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
3.6023 3.4356 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
7.2378 3.7167 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
8.0003 4.8908 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.3647 6.1382 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
5.9666 6.2115 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
2.8314 5.8083 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
0.0000 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
9.6995 0.0000 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
8.3546 7.1282 0.0000 C 0 0 0 0 0 0 0 0 0 0 0 0
7.9923 8.4804 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
9.7069 6.7658 0.0000 O 0 0 0 0 0 0 0 0 0 0 0 0
25.0040 1.4934 0.0000 R 0 0 0 0 0 0 0 0 0 0 0 0
1 2 2 0 0 0 0
6 1 1 0 0 0 0
1 11 1 0 0 0 0
2 3 1 0 0 0 0
14 2 1 0 0 0 0
3 4 1 0 0 0 0
4 5 2 0 0 0 0
4 7 1 0 0 0 0
5 6 1 0 0 0 0
10 5 1 0 0 0 0
6 15 1 0 0 0 0
18 6 1 0 0 0 0
7 8 2 0 0 0 0
8 9 1 0 0 0 0
8 25 1 0 0 0 0
9 10 2 0 0 0 0
11 12 2 0 0 0 0
12 13 1 0 0 0 0
13 14 2 0 0 0 0
13 24 1 0 0 0 0
15 16 2 0 0 0 0
15 19 1 0 0 0 0
16 17 1 0 0 0 0
22 16 1 0 0 0 0
17 18 1 0 0 0 0
17 23 2 0 0 0 0
19 20 2 0 0 0 0
20 21 1 0 0 0 0
21 22 2 0 0 0 0
21 26 1 0 0 0 0
26 27 2 0 0 0 0
26 28 1 0 0 0 0
M END
$$$$
|