Package org.openscience.cdk.io

Examples of org.openscience.cdk.io.CMLReader


   * @return The CDK molecule.
   * @throws Exception
   */
  public static IMolecule cmlToMolecule(Element cmlMol) throws Exception {
    ByteArrayInputStream bais = new ByteArrayInputStream(cmlMol.toXML().getBytes());
    IChemFile cf = (IChemFile) new CMLReader(bais).read(new ChemFile());
    IMolecule mol = cf.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0);
    configureMolecule(mol);
    return mol;
  }
View Full Code Here


    configureMolecule(mol);
    return mol;
  }
 
  static IMolecule cmlToMolecule(InputStream is) throws Exception {
    IChemFile cf = (IChemFile) new CMLReader(is).read(new ChemFile());
    IMolecule mol = cf.getChemSequence(0).getChemModel(0).getMoleculeSet().getMolecule(0);
    configureMolecule(mol);
    return mol;   
  }
View Full Code Here

            if (format instanceof RGroupQueryFormat ) {
                  cor = new RGroupQueryReader();
              cor.setReader(input);
            }
            else if (format instanceof CMLFormat ) {
              cor = new CMLReader(urlString);
              cor.setReader(url.openStream());
            }
            else if (format instanceof MDLV2000Format ) {
                  cor = new MDLV2000Reader(getReader(url));
              cor.setReader(input);
            }
            // SMILES format is never guessed :(
            //else if (format instanceof SMILESFormat ) {
            //  cor = new SMILESReader(getReader(url));
            //  cor.setReader(input);
            //}
            //InChI format is never guessed :(
            //else if (format instanceof INChIPlainTextFormat ) {
            //  cor = new INChIPlainTextReader(getReader(url));
            //   cor.setReader(input);
            //}
          }
        } catch (Exception exc) {
            exc.printStackTrace();
        }

       
        if (cor == null) {
            // try to determine from user's guess
          type = ext;
            if (type.equals(JCPFileFilter.cml)|| type.equals(JCPFileFilter.xml)) {
                cor = new CMLReader(urlString);

            } else if (type.equals(JCPFileFilter.sdf)) {
                cor = new MDLV2000Reader(getReader(url));
            } else if (type.equals(JCPFileFilter.mol)) {
                cor = new MDLV2000Reader(getReader(url));
View Full Code Here

                }
            }

            // if looks like CML - InputStream required. Reader throws error.
            if(content!=null && content.indexOf("cml")>-1) {
                reader = new CMLReader(new ByteArrayInputStream(content.getBytes()));
            }

            IAtomContainer toPaste = null;
            boolean rgrpQuery=false;
            if (reader != null) {
View Full Code Here

TOP

Related Classes of org.openscience.cdk.io.CMLReader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.