congrats Icon
New! Announcing Tabnine Chat Beta
Learn More
Tabnine Logo
CMLReader.read
Code IndexAdd Tabnine to your IDE (free)

How to use
read
method
in
org.openscience.cdk.io.CMLReader

Best Java code snippets using org.openscience.cdk.io.CMLReader.read (Showing top 20 results out of 315)

origin: asad/ReactionDecoder

protected IReaction parseCML(String input) throws FileNotFoundException, CDKException {
  File f = new File(input);
  if (!f.isFile()) {
    LOGGER.warn(WARNING, format("CML file not found! " + f.getName()));
    exit(1);
  }
  String[] split = f.getName().split(".cml");
  CMLReader cmlReader = new CMLReader(new FileInputStream(input));
  AtomContainer ac = cmlReader.read(new AtomContainer());
  IReaction r = new Reaction();
  r.addReactant(ac, 1.0);
  r.addProduct(ac, 1.0);
  r.setID(split[0]);
  return r;
}
origin: cdk/cdk

private IChemFile parseCMLString(String cmlString) throws Exception {
  IChemFile chemFile = null;
  CMLReader reader = new CMLReader(new ByteArrayInputStream(cmlString.getBytes()));
  chemFile = (IChemFile) reader.read(new org.openscience.cdk.ChemFile());
  return chemFile;
}
origin: cdk/cdk

private IChemFile parseCMLString(String cmlString) throws Exception {
  IChemFile chemFile = null;
  CMLReader reader = new CMLReader(new ByteArrayInputStream(cmlString.getBytes()));
  chemFile = (IChemFile) reader.read(new ChemFile());
  reader.close();
  return chemFile;
}
origin: cdk/cdk

private IChemFile parseCMLString(String cmlString) throws Exception {
  IChemFile chemFile = null;
  CMLReader reader = new CMLReader(new ByteArrayInputStream(cmlString.getBytes()));
  chemFile = (IChemFile) reader.read(new org.openscience.cdk.ChemFile());
  reader.close();
  return chemFile;
}
origin: cdk/cdk

private IChemFile parseCMLString(String cmlString) throws Exception {
  IChemFile chemFile = null;
  CMLReader reader = new CMLReader(new ByteArrayInputStream(cmlString.getBytes()));
  chemFile = (IChemFile) reader.read(new org.openscience.cdk.ChemFile());
  reader.close();
  return chemFile;
}
origin: cdk/cdk

@Test
public void testFile3() throws Exception {
  String filename = "data/cml/3.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile chemFile = (IChemFile) reader.read(new ChemFile());
  // test the resulting ChemFile content
  Assert.assertNotNull(chemFile);
  IAtomContainer mol = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
  String[] expectedTypes = {"C.sp2", "N.sp2", "C.sp2", "N.sp3", "C.sp2", "N.sp2", "O.sp3", "C.sp2", "C.sp2",
      "C.sp2"};
  assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
origin: cdk/cdk

@Test
public void testOla28() throws Exception {
  String filename = "data/cml/mol28.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile chemFile = (IChemFile) reader.read(new ChemFile());
  // test the resulting ChemFile content
  Assert.assertNotNull(chemFile);
  IAtomContainer mol = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
  String[] expectedTypes = {"C.sp2", "C.sp2", "C.sp2", "C.sp2", "F", "C.sp2", "C.sp2", "C.sp2", "O.sp2", "C.sp3",
      "C.sp3", "C.sp3", "N.plus", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp3", "C.sp2", "O.sp3", "C.sp2",
      "C.sp2", "C.sp2", "C.sp2", "C.sp2", "Cl"};
  assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
origin: cdk/cdk

public void visualBugPMR() throws Exception {
  String filename = "data/cml/SL0016a.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  ChemFile chemFile = (ChemFile) reader.read((ChemObject) new ChemFile());
  IChemSequence seq = chemFile.getChemSequence(0);
  IChemModel model = seq.getChemModel(0);
  IAtomContainer mol = model.getMoleculeSet().getAtomContainer(0);
  //MoleculeViewer2D.display(mol, true, false, JFrame.DO_NOTHING_ON_CLOSE,"");
}
origin: cdk/cdk

@Test
public void testOla28() throws Exception {
  String filename = "data/cml/mol28.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile file = reader.read(new ChemFile());
  reader.close();
  IAtomContainer mol = ChemFileManipulator.getAllAtomContainers(file).get(0);
  for (IAtom atom : mol.atoms()) {
    List<IAtom> neighbors = mol.getConnectedAtomsList(atom);
    if (neighbors.size() == 4) {
      Stereo stereo = StereoTool.getStereo(neighbors.get(0), neighbors.get(1), neighbors.get(2),
          neighbors.get(3));
      ITetrahedralChirality stereoCenter = new TetrahedralChirality(mol.getAtom(0),
          neighbors.toArray(new IAtom[]{}), stereo);
      CIP_CHIRALITY chirality = CIPTool.getCIPChirality(mol, stereoCenter);
    }
  }
}
origin: cdk/cdk

/**
 *  A unit test for JUnit
 *
 *@exception  Exception  Description of the Exception
 */
@Test
public void testResolveOverlap2() throws Exception {
  logger.debug("Test case with neither bond nor atom overlap");
  String filename = "data/cml/overlaptest2.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile chemFile = (IChemFile) reader.read(new ChemFile());
  IAtomContainer atomContainer = (IAtomContainer) ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
  //MoleculeViewer2D.display(new AtomContainer(atomContainer), false);
  double score = new OverlapResolver().getOverlapScore(atomContainer, new Vector(), new Vector());
  Assert.assertEquals(0.0, score, 0.0001);
  logger.debug("End of test case with neither bond nor atom overlap");
}
origin: cdk/cdk

/**
 * @cdk.bug 2114987
 */
@Test
public void testCMLTestCase() throws Exception {
  String filename = "data/cml/olaCmlAtomType.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile chemFile = new ChemFile();
  chemFile = (IChemFile) reader.read(chemFile);
  reader.close();
  IAtomContainer container = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
  for (IAtom atom : container.atoms()) {
    Assert.assertEquals(CDKConstants.UNSET, atom.getImplicitHydrogenCount());
  }
}
origin: cdk/cdk

/**
 *  A unit test for JUnit
 *
 *@exception  Exception  Description of the Exception
 */
@Test
public void testResolveOverlap3() throws Exception {
  logger.debug("Test case with bond overlap");
  String filename = "data/cml/overlaptest3.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile chemFile = (IChemFile) reader.read(new ChemFile());
  IAtomContainer atomContainer = (IAtomContainer) ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
  //MoleculeViewer2D.display(new AtomContainer(atomContainer), false);
  double score = new OverlapResolver().getBondOverlapScore(atomContainer, new Vector());
  Assert.assertTrue(score > 0);
  logger.debug("End of test case with bond overlap");
}
origin: cdk/cdk

/**
 * @cdk.bug 1930029
 */
@Test
public void testAtomProperties() throws Exception {
  String filename = "data/cml/custompropertiestest.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  ChemFile chemFile = (ChemFile) reader.read((ChemFile) new ChemFile());
  reader.close();
  Assert.assertNotNull(chemFile);
  IAtomContainer container = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
  for (int i = 0; i < container.getAtomCount(); i++) {
    Assert.assertEquals(2, container.getAtom(i).getProperties().size());
  }
}
origin: cdk/cdk

/**
 *  A unit test for JUnit
 *
 *@exception  Exception  Description of the Exception
 */
@Test
public void testResolveOverlap4() throws Exception {
  double overlapScore = 0;
  logger.debug("Test case with atom clash");
  String filename = "data/cml/overlaptest.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile chemFile = (IChemFile) reader.read(new ChemFile());
  IAtomContainer atomContainer = (IAtomContainer) ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
  //MoleculeViewer2D.display(new AtomContainer(atomContainer), false);
  OverlapResolver or = new OverlapResolver();
  overlapScore = or.resolveOverlap(atomContainer, null);
  //MoleculeViewer2D.display(new AtomContainer(atomContainer), false);
  Assert.assertEquals(0.0, overlapScore, 0.0001);
  logger.debug("End of test case with atom clash");
}
origin: cdk/cdk

  /**
   */
  @Test
  public void testReactionProperties() throws Exception {
    String filename = "data/cml/reaction.2.cml";
    InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
    CMLReader reader = new CMLReader(ins);
    IChemFile chemFile = new ChemFile();
    chemFile = (IChemFile) reader.read(chemFile);
    reader.close();
    IReaction reaction = chemFile.getChemSequence(0).getChemModel(0).getReactionSet().getReaction(0);

    Assert.assertEquals("3", (String) reaction.getProperty("Ka"));
  }
}
origin: cdk/cdk

  @Test
  public void testMixedNamespaces() throws Exception {
    InputStream in = getClass().getResourceAsStream("US06358966-20020319-C00001-enr.cml");
    CMLReader reader = new CMLReader(in);
    try {
      IChemFile cfile = reader.read(DefaultChemObjectBuilder.getInstance().newInstance(IChemFile.class));
      Assert.assertEquals(34, ChemFileManipulator.getAtomCount(cfile));
      Assert.assertEquals(39, ChemFileManipulator.getBondCount(cfile));
    } finally {
      reader.close();
    }

  }
}
origin: cdk/cdk

@Test
public void testFile3() throws Exception {
  String filename = "data/cml/3.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile chemFile = (IChemFile) reader.read(new ChemFile());
  reader.close();
  // test the resulting ChemFile content
  Assert.assertNotNull(chemFile);
  IAtomContainer mol = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
  for (int i = 0; i <= 3; i++) {
    Assert.assertFalse("Bond " + (i + 1) + " is not aromatic in the file",
        mol.getBond(i).getFlag(CDKConstants.ISAROMATIC));
  }
  for (int i = 4; i <= 9; i++) {
    Assert.assertTrue("Bond " + (i + 1) + " is aromatic in the file",
        mol.getBond(i).getFlag(CDKConstants.ISAROMATIC));
  }
}
origin: cdk/cdk

/**
 * @cdk.bug 2697568
 */
@Test
public void testReadReactionWithPointersToMoleculeSet() throws Exception {
  String filename = "data/cml/AlanineTree.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile chemFile = new ChemFile();
  chemFile = (IChemFile) reader.read(chemFile);
  reader.close();
  Assert.assertSame(chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0), chemFile
      .getChemSequence(0).getChemModel(0).getReactionSet().getReaction(0).getReactants().getAtomContainer(0));
}
origin: cdk/cdk

/**
 * @cdk.bug 2697568
 */
@Test
public void testBug2697568() throws Exception {
  String filename = "data/cml/AlanineTreeReverse.cml";
  InputStream ins = this.getClass().getClassLoader().getResourceAsStream(filename);
  CMLReader reader = new CMLReader(ins);
  IChemFile chemFile = new ChemFile();
  chemFile = (IChemFile) reader.read(chemFile);
  reader.close();
  Assert.assertSame(chemFile.getChemSequence(0).getChemModel(0).getMoleculeSet().getAtomContainer(0), chemFile
      .getChemSequence(0).getChemModel(0).getReactionSet().getReaction(0).getReactants().getAtomContainer(0));
}
origin: cdk/cdk

public static IChemModel roundTripChemModel(Convertor convertor, IChemModel model) throws Exception {
  String cmlString = "<!-- failed -->";
  Element cmlDOM = convertor.cdkChemModelToCMLList(model);
  cmlString = cmlDOM.toXML();
  logger.debug("CML string: ", cmlString);
  CMLReader reader = new CMLReader(new ByteArrayInputStream(cmlString.getBytes()));
  reader.close();
  IChemFile file = (IChemFile) reader.read(model.getBuilder().newInstance(IChemFile.class));
  Assert.assertNotNull(file);
  Assert.assertEquals(1, file.getChemSequenceCount());
  IChemSequence sequence = file.getChemSequence(0);
  Assert.assertNotNull(sequence);
  Assert.assertEquals(1, sequence.getChemModelCount());
  IChemModel chemModel = sequence.getChemModel(0);
  Assert.assertNotNull(chemModel);
  return chemModel;
}
org.openscience.cdk.ioCMLReaderread

Javadoc

Read a IChemObject from input.

Popular methods of CMLReader

  • <init>
    Define this CMLReader to take the input from a java.io.Reader class. Possible readers are (among oth
  • close
  • accepts
  • init
  • readChemFile
  • registerConvention

Popular in Java

  • Reactive rest calls using spring rest template
  • onRequestPermissionsResult (Fragment)
  • getApplicationContext (Context)
  • getSharedPreferences (Context)
  • Rectangle (java.awt)
    A Rectangle specifies an area in a coordinate space that is enclosed by the Rectangle object's top-
  • PrintWriter (java.io)
    Wraps either an existing OutputStream or an existing Writerand provides convenience methods for prin
  • URLEncoder (java.net)
    This class is used to encode a string using the format required by application/x-www-form-urlencoded
  • Timestamp (java.sql)
    A Java representation of the SQL TIMESTAMP type. It provides the capability of representing the SQL
  • TimerTask (java.util)
    The TimerTask class represents a task to run at a specified time. The task may be run once or repeat
  • SAXParseException (org.xml.sax)
    Encapsulate an XML parse error or warning.> This module, both source code and documentation, is in t
  • Top Vim plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

    FAQBlogTabnine AcademyTerms of usePrivacy policyJava Code IndexJavascript Code Index
Get Tabnine for your IDE now