From: <mar...@us...> - 2009-08-18 16:26:34
|
Revision: 14741 http://cdk.svn.sourceforge.net/cdk/?rev=14741&view=rev Author: mark_rynbeek Date: 2009-08-18 16:26:26 +0000 (Tue, 18 Aug 2009) Log Message: ----------- allow reading of mdlv3000 format properly Modified Paths: -------------- jchempaint/trunk/src/main/org/openscience/jchempaint/application/JChemPaint.java Modified: jchempaint/trunk/src/main/org/openscience/jchempaint/application/JChemPaint.java =================================================================== --- jchempaint/trunk/src/main/org/openscience/jchempaint/application/JChemPaint.java 2009-08-18 15:30:08 UTC (rev 14740) +++ jchempaint/trunk/src/main/org/openscience/jchempaint/application/JChemPaint.java 2009-08-18 16:26:26 UTC (rev 14741) @@ -368,7 +368,7 @@ String error = null; ChemModel chemModel = null; IChemFile chemFile = null; - if (cor.accepts(IChemFile.class)) { + if (cor.accepts(IChemFile.class) && chemModel==null) { // try to read a ChemFile try { chemFile = (IChemFile) cor.read((IChemObject) new ChemFile()); @@ -383,7 +383,7 @@ if (error != null) { throw new CDKException(error); } - if (cor.accepts(ChemModel.class)) { + if (cor.accepts(ChemModel.class) && chemModel==null) { // try to read a ChemModel try { @@ -397,8 +397,8 @@ } } - // necessary for Smiles reading..? - if (cor.accepts(MoleculeSet.class)) { + // Smiles reading + if (cor.accepts(MoleculeSet.class) && chemModel==null) { // try to read a Molecule set try { IMoleculeSet som = (MoleculeSet) cor.read(new MoleculeSet()); @@ -413,6 +413,26 @@ } } + // MDLV3000 reading + if (cor.accepts(Molecule.class) && chemModel==null) { + // try to read a Molecule + IMolecule mol = (Molecule) cor.read(new Molecule()); + if(mol!=null ) + try{ + IMoleculeSet newSet = new MoleculeSet(); + newSet.addMolecule(mol); + chemModel = new ChemModel(); + chemModel.setMoleculeSet(newSet); + if (chemModel == null) { + error = "The object chemModel was empty unexpectedly!"; + } + } catch (Exception exception) { + error = "Error while reading file: " + exception.getMessage(); + exception.printStackTrace(); + } + } + + if (error != null) { throw new CDKException(error); } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |