File tree Expand file tree Collapse file tree 3 files changed +42
-1
lines changed
main/java/org/openscience/cdk/io
java/org/openscience/cdk/io
resources/org/openscience/cdk/io Expand file tree Collapse file tree 3 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -417,6 +417,7 @@ public void readBondBlock(IAtomContainer readData) throws CDKException {
417417 String orderString = tokenizer .nextToken ();
418418 int order = Integer .parseInt (orderString );
419419 if (order >= 4 ) {
420+ bond .setOrder (IBond .Order .UNSET );
420421 logger .warn ("Query order types are not supported (yet). File a bug if you need it" );
421422 } else {
422423 bond .setOrder (BondManipulator .createBondOrder ((double ) order ));
Original file line number Diff line number Diff line change 3131import org .openscience .cdk .exception .CDKException ;
3232import org .openscience .cdk .interfaces .IAtom ;
3333import org .openscience .cdk .interfaces .IAtomContainer ;
34- import org .openscience .cdk .io . iterator . IteratingSDFReader ;
34+ import org .openscience .cdk .interfaces . IBond ;
3535import org .openscience .cdk .sgroup .Sgroup ;
3636import org .openscience .cdk .sgroup .SgroupType ;
3737import org .openscience .cdk .silent .AtomContainer ;
@@ -154,4 +154,20 @@ public void testPseudoAtomLabels() throws Exception {
154154 assertThat (mol .getAtomCount (), CoreMatchers .is (31 ));
155155 }
156156 }
157+
158+ /**
159+ * @cdk.bug https://github.com/cdk/cdk/issues/664
160+ *
161+ * MDLV3000Reader does not yet support queries. Parsed query bonds (order >= 4) should be set to IBond.Order.UNSET
162+ * to avoid NPE in valence calculation.
163+ */
164+ @ Test public void reading_query_bond_should_not_npe () throws Exception {
165+ try (MDLV3000Reader reader = new MDLV3000Reader (getClass ().getResourceAsStream ("v3000Query.mol" ))) {
166+ IAtomContainer container = reader .read (SilentChemObjectBuilder .getInstance ().newAtomContainer ());
167+ for (IBond bond : container .bonds ()) {
168+ assertNotNull (bond .getOrder ());
169+ }
170+ assertThat (container .getBond (4 ).getOrder (), is (IBond .Order .UNSET ));
171+ }
172+ }
157173}
Original file line number Diff line number Diff line change 1+
2+
3+
4+ 0 0 0 0 0 999 V3000
5+ M V30 BEGIN CTAB
6+ M V30 COUNTS 6 6 0 0 0
7+ M V30 BEGIN ATOM
8+ M V30 1 C -4.5418 1.0401 0 0
9+ M V30 2 C -5.8753 0.2701 0 0
10+ M V30 3 C -5.8753 -1.2701 0 0
11+ M V30 4 C -4.5418 -2.0401 0 0
12+ M V30 5 C -3.208 -1.2701 0 0
13+ M V30 6 C -3.208 0.2701 0 0
14+ M V30 END ATOM
15+ M V30 BEGIN BOND
16+ M V30 1 2 1 2
17+ M V30 2 1 2 3
18+ M V30 3 2 3 4
19+ M V30 4 1 4 5
20+ M V30 5 4 5 6
21+ M V30 6 1 6 1
22+ M V30 END BOND
23+ M V30 END CTAB
24+ M END
You can’t perform that action at this time.
0 commit comments