Tabnine Logo
CMLReader
Code IndexAdd Tabnine to your IDE (free)

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

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

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: org.openscience.cdk/cdk-io

@Override
public boolean accepts(Class<? extends IChemObject> classObject) {
  Class<?>[] interfaces = classObject.getInterfaces();
  for (int i = 0; i < interfaces.length; i++) {
    if (IChemFile.class.equals(interfaces[i])) return true;
  }
  if (IChemFile.class.equals(classObject)) return true;
  Class superClass = classObject.getSuperclass();
  if (superClass != null) return this.accepts(superClass);
  return false;
}
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

logger.debug("******************************");
CMLReader reader = new CMLReader(new ByteArrayInputStream(serializedMol.getBytes()));
reader.registerConvention("md:mdMolecule", new MDMoleculeConvention(new ChemFile()));
IChemFile file = (IChemFile) reader.read(new ChemFile());
reader.close();
List containers = ChemFileManipulator.getAllAtomContainers(file);
Assert.assertEquals(1, containers.size());
origin: asad/SMSD

private ISimpleChemObjectReader getReader(String type, String filename) throws IOException {
  File input = new File(filename);
  if (input.isDirectory()) {
    throw new IOException(
        "Input path " + filename + " is a directory, not a file");
  }
  switch (type) {
    case "MOL":
      return new MDLV2000Reader(
          new FileReader(input), IChemObjectReader.Mode.RELAXED);
    case "CML":
      return new CMLReader(new FileInputStream(input));
    case "ML2":
      return new Mol2Reader(new FileReader(input));
    case "PDB":
      return new PDBReader(new FileReader(input));
  }
  return null;
}
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: asad/SMSD

private ISimpleChemObjectReader getReader(File file, String extension) throws IOException, CDKException {
  if (file.isDirectory()) {
    throw new IOException(
        "Input path " + file + " is a directory, not a file");
  }
  switch (extension) {
    case "mol":
      return new MDLV2000Reader(
          new FileReader(file), IChemObjectReader.Mode.RELAXED);
    case "sdf":
      return new MDLV2000Reader(
          new FileReader(file));
    case "cml":
      return new CMLReader(new FileInputStream(file));
    case "ml2":
      return new Mol2Reader(new FileReader(file));
    case "pdb":
      PDBReader reader = new PDBReader(new FileReader(file));
      reader.getSetting("UseRebondTool").setSetting("false");      // UseRebondTool
      reader.getSetting("ReadConnectSection").setSetting("true");  // ReadConnectSection
      return reader;
  }
  return null;
}
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: org.openscience.cdk/cdk-sdg

LOGGER.debug("Attempting to read template ", line);
try {
  CMLReader structureReader = new CMLReader(this.getClass().getClassLoader()
                         .getResourceAsStream(line));
  IChemFile file = (IChemFile) structureReader.read(builder.newInstance(IChemFile.class));
  List<IAtomContainer> files = ChemFileManipulator.getAllAtomContainers(file);
  for (int i = 0; i < files.size(); i++)
origin: cdk/cdk

@BeforeClass
public static void setup() {
  setSimpleChemObjectReader(new CMLReader(), "data/cml/3.cml");
}
origin: cdk/cdk

@Override
public boolean accepts(Class<? extends IChemObject> classObject) {
  Class<?>[] interfaces = classObject.getInterfaces();
  for (int i = 0; i < interfaces.length; i++) {
    if (IChemFile.class.equals(interfaces[i])) return true;
  }
  if (IChemFile.class.equals(classObject)) return true;
  Class superClass = classObject.getSuperclass();
  if (superClass != null) return this.accepts(superClass);
  return false;
}
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

LOGGER.debug("Attempting to read template ", line);
try {
  CMLReader structureReader = new CMLReader(this.getClass().getClassLoader()
                         .getResourceAsStream(line));
  IChemFile file = (IChemFile) structureReader.read(builder.newInstance(IChemFile.class));
  List<IAtomContainer> files = ChemFileManipulator.getAllAtomContainers(file);
  for (int i = 0; i < files.size(); i++)
origin: JChemPaint/jchempaint

  cor = new CMLReader(urlString);
  cor.setReader(url.openStream());
cor = new CMLReader(urlString);
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

@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: JChemPaint/jchempaint

reader = new CMLReader(new ByteArrayInputStream(content.getBytes()));
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

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

/**
 * @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());
  }
}
org.openscience.cdk.ioCMLReader

Javadoc

Reads a molecule in CML 1.x and 2.0 format. CML is an XML based application PMR99, and this Reader applies the method described in WIL01.

Most used methods

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

Popular in Java

  • Reading from database using SQL prepared statement
  • runOnUiThread (Activity)
  • requestLocationUpdates (LocationManager)
  • getExternalFilesDir (Context)
  • Component (java.awt)
    A component is an object having a graphical representation that can be displayed on the screen and t
  • URLConnection (java.net)
    A connection to a URL for reading or writing. For HTTP connections, see HttpURLConnection for docume
  • KeyStore (java.security)
    KeyStore is responsible for maintaining cryptographic keys and their owners. The type of the syste
  • Map (java.util)
    A Map is a data structure consisting of a set of keys and values in which each key is mapped to a si
  • ResourceBundle (java.util)
    ResourceBundle is an abstract class which is the superclass of classes which provide Locale-specifi
  • HttpServlet (javax.servlet.http)
    Provides an abstract class to be subclassed to create an HTTP servlet suitable for a Web site. A sub
  • Top Sublime Text 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