Class MRecordImporter


  • @PublicAPI
    public class MRecordImporter
    extends Object
    Marvin molecule file reader. By default, in case of machines with multiple processors processing is concurrent, otherwise single-threaded. By default, the number of worker threads is the number of processors - the number of concurrent threads can be set in setThreadCount(int).
    Since:
    Marvin 5.0, 05/07/2007
    • Method Detail

      • setThreadCount

        public void setThreadCount​(int threadCount)
                            throws IllegalStateException
        Sets the number of threads for concurrent processing. Default: the number of CPUs, single-threaded processing if there is 1 CPU. Note, that in concurrent mode the import is not rewindable.
        Parameters:
        threadCount - the number of threads, set 0 for the number of CPUs, 1 for single-threaded mode
        Throws:
        IllegalStateException - if called after isSeekable() or readMol(chemaxon.struc.Molecule) or readDoc().
        Since:
        Marvin 5.3
      • setProgressMonitor

        public void setProgressMonitor​(MProgressMonitor pmon)
        Sets the progress monitor.
        Parameters:
        pmon - the progress monitor
      • getOptions

        public String getOptions()
        Gets the options for the import module.
        Returns:
        the import options
      • readMolMovie

        public MDocument readMolMovie​(MDocument doc)
                               throws MolFormatException,
                                      IOException
        Reads molecules as a movie. Processing is single-threaded.
        Parameters:
        doc - the output document object or null
        Returns:
        the document if success, null otherwise
        Throws:
        MolFormatException - invalid molecule file
        IOException - cannot read molecule (bad format or I/O error)
        Since:
        Marvin 5.2, 02/12/2009
      • getGlobalProperties

        public MPropertyContainer getGlobalProperties()
        Gets the global properties.
        Returns:
        the global properties or null
      • isSeekable

        public boolean isSeekable()
        Tests whether the record reader is seekable. In concurrent mode always returns false. Therefore this method should not be called before calling setThreadCount(int).
        Returns:
        true if it is seekable, false otherwise
        See Also:
        setThreadCount(int)
      • getFormat

        public String getFormat()
        Gets the file format.
        Returns:
        the format
      • getQueryMode

        public boolean getQueryMode()
        Gets the query mode. SMILES strings are imported as SMARTS if query mode is set.
        Returns:
        query mode
      • setQueryMode

        public void setQueryMode​(boolean q)
        Sets the query mode. SMILES strings are imported as SMARTS if query mode is set. IMPORTANT: call this before any call to readDoc() or readMol(chemaxon.struc.Molecule).
        Parameters:
        q - query mode
        Throws:
        IllegalStateException - if the concurrent processor is already running
      • getFilePointer

        public long getFilePointer()
        Gets the current position in the input file.
        Returns:
        the position
        Throws:
        IllegalStateException - if the concurrent processor is running
      • length

        public long length()
                    throws IOException
        Gets the length of the input file.
        Returns:
        the length
        Throws:
        IOException - if the length cannot be determined
      • getLineCount

        public int getLineCount()
        Gets the current line number in the input file.
        Returns:
        the position
      • seek

        public void seek​(long p,
                         int lcount,
                         int k)
                  throws IOException
        Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.
        Parameters:
        p - the file pointer
        lcount - the line count at the specified position
        k - the record count at the specified position
        Throws:
        IOException - if pos is less than 0 or if an I/O error occurs.
        UnsupportedOperationException - if the concurrent processor is running
      • close

        public void close()
                   throws IOException
        Closes the input stream. IMPORTANT: call this after reading molecules to close concurrent processing properly.
        Throws:
        IOException - If I/O error occurred
      • getMoleculeString

        public String getMoleculeString()
        Gets the last molecule as a string.
        Returns:
        the molecule as a string
      • createMolIfNeeded

        public Molecule createMolIfNeeded()
        Creates an empty target molecule for import if non-concurrent mode, returns null if concurrent mode.
        Returns:
        an empty molecule or null
        Since:
        Marvin 5.3
      • createMol

        public Molecule createMol()
        Creates an empty target molecule for import.
        Returns:
        an empty molecule
      • getRecordReader

        public MRecordReader getRecordReader()
        Gets the record reader.
        Returns:
        the record reader