Package chemaxon.marvin.io
Class MRecordImporter
java.lang.Object
chemaxon.marvin.io.MRecordImporter
Marvin molecule file reader.
 
 The processing is single-threaded by default. Concurrent mode can be enabled using setThreadCount(int).
- Since:
 - Marvin 5.0, 05/07/2007
 
- 
Constructor Summary
ConstructorsConstructorDescriptionMRecordImporter(MolInputStream in, String opts) Creates a reader for the specified molecule input stream in concurrent mode. - 
Method Summary
Modifier and TypeMethodDescriptionvoidclose()Closes the input stream.static MolImportModuleCreates an importer for the specified molecule input stream.static MolImportModulecreateImportMod(String fmt) Creates an importer for the specified molecule format.Creates an empty target molecule for import.Creates an empty target molecule for import if non-concurrent mode, returnsnullif concurrent mode.longGets the current position in the input file.Gets the file format.Gets the global properties.intGets the current line number in the input file.Gets the last molecule as a string.Gets the options for the import module.booleanGets the query mode.Gets the record reader.booleanTests whether the record reader is seekable.longlength()Gets the length of the input file.readDoc()Reads the next document.Reads the next molecule.readMolMovie(MDocument doc) Reads molecules as a movie.Reads molecules as one multi-set molecule.Reads the next record.voidseek(long p, int lcount, int k) Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.voidsetOptions(String opts) Sets the options for the import module.voidSets the progress monitor.voidsetQueryMode(boolean q) Sets the query mode.voidsetThreadCount(int threadCount) Sets the number of threads for concurrent processing.Skips the next document. 
- 
Constructor Details
- 
MRecordImporter
Creates a reader for the specified molecule input stream in concurrent mode.- Parameters:
 in- the molecule input streamopts- input options ornull- Throws:
 MolFormatException- If the format is not recognizableIOException- If I/O error occurredIllegalCharsetNameException- if illegal encoding is usedUnsupportedCharsetException- if unsupported encoding is used
 
 - 
 - 
Method Details
- 
setThreadCount
Sets the number of threads for concurrent processing. The default value is 1 (single-threaded mode).In concurrent mode, multiple threads are started in the background, which adds a considerable overhead to the processing, so only use this mode if the number of molecules is huge. In single-threaded mode, no background thread is used, every action is done on the caller thread.
Note, that in concurrent mode the import is not rewindable.
- Parameters:
 threadCount- the number of threads, set0for the number of CPUs,1for single-threaded mode- Throws:
 IllegalStateException- if called afterisSeekable()orreadMol(chemaxon.struc.Molecule)orreadDoc().- Since:
 - Marvin 5.3
 
 - 
setProgressMonitor
Sets the progress monitor.- Parameters:
 pmon- the progress monitor
 - 
createImportMod
Creates an importer for the specified molecule input stream.- Parameters:
 mis- the molecule input stream- Throws:
 MolFormatException- If the format is not recognizableIOException- If I/O error occurred
 - 
createImportMod
Creates an importer for the specified molecule format.- Parameters:
 fmt- the molecule format- Throws:
 MolFormatException- If the format is not recognizableIOException- If I/O error occurred- Since:
 - Marvin 5.2
 
 - 
getOptions
Gets the options for the import module.- Returns:
 - the import options
 
 - 
setOptions
Sets the options for the import module.- Parameters:
 opts- options passed to the import module ornull- Throws:
 IllegalStateException- if called afterreadMol(chemaxon.struc.Molecule)orreadDoc().
 - 
readDoc
Reads the next document.- Returns:
 - the document or 
nullat end of file - Throws:
 MRecordParseException- If the record could not be parsedMolFormatException- If the file format is invalidIOException- If I/O error occurred
 - 
readMol
Reads the next molecule. If the 'mol' parameter is notnullthen processing is single-threaded.- Parameters:
 mol- target object ornull- Returns:
 - the molecule or 
nullat end of file - Throws:
 MRecordParseException- If the record could not be parsedMolFormatException- If the file format is invalidIOException- If I/O error occurred
 - 
readMultiSet
Reads molecules as one multi-set molecule. Processing is single-threaded.- Parameters:
 m- the output molecule object- Returns:
 - the molecule in case of success, 
nullotherwise - Throws:
 IOException- cannot read molecule (bad format or I/O error)MRecordParseException
 - 
readMolMovie
Reads molecules as a movie. Processing is single-threaded.- Parameters:
 doc- the output document object ornull- Returns:
 - the document if success, 
nullotherwise - Throws:
 MolFormatException- invalid molecule fileIOException- cannot read molecule (bad format or I/O error)- Since:
 - Marvin 5.2, 02/12/2009
 
 - 
readRecordAsText
Reads the next record. Processing is single-threaded.- Returns:
 - the record or 
nullat end of file - Throws:
 MRecordParseException- If the record could not be parsedIOException- If I/O error occurredIllegalStateException- if the concurrent processor is already running
 - 
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 returnsfalse. Therefore this method should not be called before callingsetThreadCount(int).- Returns:
 trueif it is seekable,falseotherwise- See Also:
 
 - 
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 toreadDoc()orreadMol(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
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
Sets the file-pointer offset, measured from the beginning of this file, at which the next read or write occurs.- Parameters:
 p- the file pointerlcount- the line count at the specified positionk- the record count at the specified position- Throws:
 IOException- ifposis less than0or if an I/O error occurs.UnsupportedOperationException- if the concurrent processor is running
 - 
skipRecord
Skips the next document. Not implemented for concurrent processing, in this case returns the next complete record.- Returns:
 - incomplete record info containing only the start and end
         positions, or 
nullif there are no more records - Throws:
 IOException- If I/O error occurredMRecordParseException
 - 
close
Closes the input stream. IMPORTANT: call this after reading molecules to close concurrent processing properly.- Throws:
 IOException- If I/O error occurred
 - 
getMolImportModule
 - 
getMoleculeString
Gets the last molecule as a string.- Returns:
 - the molecule as a string
 
 - 
createMolIfNeeded
Creates an empty target molecule for import if non-concurrent mode, returnsnullif concurrent mode.- Returns:
 - an empty molecule or 
null - Since:
 - Marvin 5.3
 
 - 
createMol
Creates an empty target molecule for import.- Returns:
 - an empty molecule
 
 - 
getRecordReader
Gets the record reader.- Returns:
 - the record reader
 
 
 -