Tabnine Logo
CMLReader.<init>
Code IndexAdd Tabnine to your IDE (free)

How to use
org.openscience.cdk.io.CMLReader
constructor

Best Java code snippets using org.openscience.cdk.io.CMLReader.<init> (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

@BeforeClass
public static void setup() {
  setSimpleChemObjectReader(new CMLReader(), "data/cml/3.cml");
}
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

  /**
   */
  @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.ioCMLReader<init>

Javadoc

Reads CML from an java.io.InputStream, for example the FileInputStream.

Popular methods of CMLReader

  • read
    Read a IChemObject from input.
  • close
  • accepts
  • init
  • readChemFile
  • registerConvention

Popular in Java

  • Making http post requests using okhttp
  • runOnUiThread (Activity)
  • compareTo (BigDecimal)
  • putExtra (Intent)
  • System (java.lang)
    Provides access to system-related information and resources including standard input and output. Ena
  • Thread (java.lang)
    A thread is a thread of execution in a program. The Java Virtual Machine allows an application to ha
  • Time (java.sql)
    Java representation of an SQL TIME value. Provides utilities to format and parse the time's represen
  • Arrays (java.util)
    This class contains various methods for manipulating arrays (such as sorting and searching). This cl
  • ConcurrentHashMap (java.util.concurrent)
    A plug-in replacement for JDK1.5 java.util.concurrent.ConcurrentHashMap. This version is based on or
  • Project (org.apache.tools.ant)
    Central representation of an Ant project. This class defines an Ant project with all of its targets,
  • Top 15 Vim Plugins
Tabnine Logo
  • Products

    Search for Java codeSearch for JavaScript code
  • IDE Plugins

    IntelliJ IDEAWebStormVisual StudioAndroid StudioEclipseVisual Studio CodePyCharmSublime TextPhpStormVimAtomGoLandRubyMineEmacsJupyter NotebookJupyter LabRiderDataGripAppCode
  • Company

    About UsContact UsCareers
  • Resources

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