Class MoleculeImporter

java.lang.Object
chemaxon.marvin.io.formats.MoleculeImporter
All Implemented Interfaces:
chemaxon.marvin.io.formats.MoleculeImporterIface

@PublicAPI public class MoleculeImporter extends Object implements chemaxon.marvin.io.formats.MoleculeImporterIface
Molecule importer. Wrapper for MolImporter. Can only read the stream forward (not seekable stream). In some cases (mrv, cml) it can be faster than MolImporter.

The input file format is guessed automatically or specified as an import option to the constructor. Many different formats are supported like "mol", "rgf", "sdf", "rdf", "csmol", "csrgf", "cssdf", "csrdf", "mol2", "cml", "mrv", "smiles", "cxsmiles", "pdb", "xyz", "cube", "name". For more information on formats, please visit File Formats in Marvin.

Since:
Marvin 5.7
  • Field Details

    • importer

      protected final chemaxon.marvin.io.formats.MoleculeImporterIface importer
      The wrapped importer. Created in the constructor, the interface methods delegates the functionality to this importer.
  • Constructor Details

    • MoleculeImporter

      public MoleculeImporter(String fileName) throws IOException
      Constructs a new importer for the file.
      Parameters:
      fileName - the name of the file to import.
      Throws:
      IOException - if an I/O error occurs.
    • MoleculeImporter

      public MoleculeImporter(String fileName, String opts) throws IOException
      Constructs a new importer for the file.
      Parameters:
      fileName - the name of the file to import.
      opts - the file format and options separated by a colon. Autorecognition is called if null or format is not specified.
      Throws:
      IOException - if an I/O error occurs.
    • MoleculeImporter

      public MoleculeImporter(File f) throws IOException
      Constructs a new importer for the file.
      Parameters:
      f - the file to import.
      Throws:
      IOException - if an I/O error occurs.
    • MoleculeImporter

      public MoleculeImporter(File f, String opts) throws IOException
      Constructs a new importer for the file.
      Parameters:
      f - the file to import.
      opts - the file format and options separated by a colon. Autorecognition is called if null or format is not specified.
      Throws:
      IOException - if an I/O error occurs.
    • MoleculeImporter

      public MoleculeImporter(InputStream inputStream) throws IOException
      Constructs a new importer for the input stream.
      Parameters:
      inputStream - the stream to import from.
      Throws:
      IOException - if an I/O error occurs.
    • MoleculeImporter

      public MoleculeImporter(InputStream inputStream, String opts) throws IOException
      Constructs a new importer for the stream.
      Parameters:
      inputStream - the stream to import from.
      opts - the file format and options separated by a colon. Autorecognition is called if null or format is not specified.
      Throws:
      IOException - if an I/O error occurs.
    • MoleculeImporter

      public MoleculeImporter(InputStream inputStream, String opts, String enc) throws IOException
      Constructs a new importer for the stream.
      Parameters:
      inputStream - the stream to import from.
      opts - the file format and options separated by a colon. Autorecognition is called if null or format is not specified.
      enc - the encoding of the stream. Autorecognition may be called if null.
      Throws:
      IOException - if an I/O error occurs.
  • Method Details

    • read

      public Molecule read() throws IOException
      Specified by:
      read in interface chemaxon.marvin.io.formats.MoleculeImporterIface
      Throws:
      IOException
    • getIterator

      public Iterator<Molecule> getIterator()
      Returns an iterator that iterates through all molecules in the file/stream.
      Returns:
      the iterator.
    • close

      public void close() throws IOException
      Specified by:
      close in interface chemaxon.marvin.io.formats.MoleculeImporterIface
      Throws:
      IOException