|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||
java.lang.Objectchemaxon.marvin.io.MDocSource
chemaxon.formats.MolImporter
public class MolImporter
Molecule file importer.
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". For more information on formats, please visit File Formats in Marvin. MolImporter can also import gzip compressed and base64 encoded structures.
Serialized Molecule objects can also be imported using the "chemaxon.struc.Molecule" format.
| Field Summary | |
|---|---|
static int |
F_MOLMOVIE
Read multi-molecule XYZ files as movies. |
| Constructor Summary | |
|---|---|
MolImporter()
Create an empty MolImporter object. |
|
MolImporter(java.io.File f,
java.lang.String opts)
Create a molecule importer for a file. |
|
MolImporter(java.io.InputStream is)
Create a molecule importer for an input stream. |
|
MolImporter(java.io.InputStream is,
java.lang.String opts)
Create a molecule importer for an input stream. |
|
MolImporter(java.io.InputStream is,
java.lang.String opts,
java.lang.String enc)
Create a molecule importer for an input stream. |
|
MolImporter(java.lang.String fname)
Create a molecule importer for a file. |
|
MolImporter(java.lang.String fname,
java.lang.Object component,
java.lang.String msg)
Create a molecule importer with a progress monitor. |
|
| Method Summary | |
|---|---|
void |
close()
Close the underlying input stream. |
Molecule |
createMol()
Creates a target molecule object for import. |
int |
estimateNumRecords()
Estimates the total number of records. |
java.io.File |
getFile()
Gets the file object for the input. |
java.lang.String |
getFileName()
Gets the name of the input file |
java.lang.String |
getFormat()
Get the file format. |
MPropertyContainer |
getGlobalProperties()
Gets the global properties in a container that was retrieved from the input stream, earlier. |
java.lang.String |
getGrabbedMoleculeString()
Gets the last grabbed molecule string. |
int |
getLineCount()
Gets the current line number. |
int |
getOptionFlags()
Gets options. |
java.lang.String |
getOptions()
Gets the import options. |
boolean |
getQueryMode()
Gets query mode. |
int |
getRecordCount()
Gets the current record number. |
int |
getRecordCountMax()
Gets the total number of records read. |
static MDocument |
importDoc(byte[] b)
Reads a document from a byte array. |
static MDocument |
importDoc(byte[] b,
java.lang.String opts,
java.lang.String enc)
Reads a document from a byte array. |
static Molecule |
importMol(byte[] b)
Read a molecule from a byte array. |
static boolean |
importMol(byte[] b,
Molecule mol)
Read a molecule from a byte array. |
static Molecule |
importMol(byte[] b,
java.lang.String opts,
java.lang.String enc)
Read a molecule from a byte array. |
static boolean |
importMol(byte[] b,
java.lang.String opts,
java.lang.String enc,
Molecule mol)
Read a molecule from a byte array. |
static Molecule |
importMol(java.lang.String s)
Read a molecule from a string. |
static boolean |
importMol(java.lang.String s,
Molecule mol)
Read a molecule from a string. |
static Molecule |
importMol(java.lang.String s,
java.lang.String opts)
Read a molecule from a string. |
static Molecule |
importMol(java.lang.String s,
java.lang.String opts,
java.lang.String enc)
Read a molecule from a string. |
static boolean |
importMol(java.lang.String s,
java.lang.String opts,
java.lang.String enc,
Molecule mol)
Read a molecule from a string. |
boolean |
isEndReached()
Tests whether the end of input is already reached. |
boolean |
isGrabbingEnabled()
Tests whether molecule file content grabbing is enabled. |
boolean |
isMultiSet()
Are the imported molecules merged into one multi-set molecule? |
boolean |
isRewindable()
Tests whether rewinding (seeking backwards) is possible in the underlying input stream. |
MDocument |
nextDoc()
Reads the next document. |
Molecule |
read()
Read the next molecule. |
boolean |
read(Molecule mol)
Read the next molecule. |
MDocument |
readDoc(MDocument doc,
Molecule buf)
Read the next document. |
Molecule |
readMol(Molecule mol)
Read the next molecule. |
java.lang.String |
readRecordAsText()
Reads the next molecule in text format without creating a Molecule object. |
void |
seekRecord(int k,
MProgressMonitor pmon)
Seek the specified record. |
protected void |
seekVisitedRecord(int k)
Seeks an already visited position in case of rewindable input. |
void |
setFileName(java.lang.String fname)
Sets the name of the input file and (re)initalize the molecule importer. |
void |
setGrabbingEnabled(boolean v)
Enables or disables molecule file content grabbing. |
void |
setOptionFlags(int f)
Sets options. |
void |
setOptions(java.lang.String opts)
Sets the import options. |
void |
setQueryMode(boolean q)
Sets query mode. |
boolean |
skipRecord()
Skips the next molecule or document instead of reading it into memory. |
boolean |
skipToNext()
Deprecated. As of Marvin 5.0, the record reading/molecule import separation makes this method unusable |
long |
tell()
Returns the current file offset. |
| Methods inherited from class chemaxon.marvin.io.MDocSource |
|---|
getDocLabel, getMoleculeIterator, seekForward, seekRecordAtFraction, skipRecords |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
|---|
public static final int F_MOLMOVIE
| Constructor Detail |
|---|
public MolImporter()
setFileName(java.lang.String)
public MolImporter(java.io.InputStream is)
throws java.io.IOException,
MolFormatException
is - the input stream to read
java.io.IOException - If I/O error occured when determining
the file format.
MolFormatException - If the molecule file is in a
format that cannot be read
java.nio.charset.IllegalCharsetNameException - if illegal encoding is used
java.nio.charset.UnsupportedCharsetException - if unsupported encoding is used
public MolImporter(java.io.InputStream is,
java.lang.String opts)
throws java.io.IOException,
MolFormatException
is - the input stream to readopts - the file format and/or options separated by a colon;
use null for automatic format recognition
and default options
java.io.IOException - If I/O error occured when determining
the file format.
MolFormatException - If the molecule file is in a
format that cannot be read
java.nio.charset.IllegalCharsetNameException - if illegal encoding is used
java.nio.charset.UnsupportedCharsetException - if unsupported encoding is used
public MolImporter(java.io.InputStream is,
java.lang.String opts,
java.lang.String enc)
throws java.io.IOException,
MolFormatException
is - the input stream to readopts - the file format and/or options separated by a colon;
use null for automatic format recognition
and default optionsenc - charset name or null
java.io.IOException - If I/O error occured when determining
the file format.
MolFormatException - If the molecule file is in a
format that cannot be read
java.nio.charset.IllegalCharsetNameException - if illegal encoding is used
java.nio.charset.UnsupportedCharsetException - if unsupported encoding is used
public MolImporter(java.io.File f,
java.lang.String opts)
throws java.io.IOException,
MolFormatException
f - the file to readopts - the file format and/or options separated by a colon;
use null for automatic format recognition
and default options
java.io.IOException - If I/O error occured when determining
the file format.
MolFormatException - If the molecule file is in a
format that cannot be read
java.nio.charset.IllegalCharsetNameException - if illegal encoding is used
java.nio.charset.UnsupportedCharsetException - if unsupported encoding is usedtell(),
close()
public MolImporter(java.lang.String fname)
throws java.io.IOException,
MolFormatException
fname - name of the file to read
java.io.IOException - If I/O error occured when determining
the file format.
MolFormatException - If the molecule file is in a
format that cannot be read
java.nio.charset.IllegalCharsetNameException - if illegal encoding is used
java.nio.charset.UnsupportedCharsetException - if unsupported encoding is usedtell(),
close()
public MolImporter(java.lang.String fname,
java.lang.Object component,
java.lang.String msg)
throws java.io.IOException,
MolFormatException
fname - name of the file to readcomponent - the parent componentmsg - displayed message, where %p is replaced by the
file path
java.io.IOException - If I/O error occured when determining
the file format.
MolFormatException - If the molecule file is in a
format that cannot be read
java.nio.charset.IllegalCharsetNameException - if illegal encoding is used
java.nio.charset.UnsupportedCharsetException - if unsupported encoding is usedtell(),
close()| Method Detail |
|---|
public java.lang.String getFileName()
public void setFileName(java.lang.String fname)
throws java.io.IOException,
MolFormatException
fname - name of the file to read
java.io.IOException - If I/O error occured when determining
the file format.
MolFormatException - If the molecule file is in a
format that cannot be readgetOptions(),
setOptions(java.lang.String)public java.io.File getFile()
public java.lang.String getOptions()
public void setOptions(java.lang.String opts)
opts - options passed to the import module or nullpublic boolean isGrabbingEnabled()
true if enabled, false if disabledpublic void setGrabbingEnabled(boolean v)
v - true enables, false disables itpublic java.lang.String getGrabbedMoleculeString()
public int getOptionFlags()
F_MOLMOVIEpublic void setOptionFlags(int f)
f - the optionsF_MOLMOVIEpublic boolean isMultiSet()
true if the input is a multi-set moleculepublic boolean getQueryMode()
public void setQueryMode(boolean q)
q - query mode
public Molecule read()
throws java.io.IOException
null at end of file
java.io.IOException - If I/O error occured
public Molecule createMol()
throws java.io.IOException
java.io.IOException
public MDocument nextDoc()
throws java.io.IOException
nextDoc in class MDocSourcenull at end of file
java.io.IOException - If I/O error occured
public MDocument readDoc(MDocument doc,
Molecule buf)
throws MolFormatException,
java.io.IOException
doc - target document object or nullbuf - target molecule object or null
null at end of file
java.io.IOException - If I/O error occured
MolFormatExceptionF_MOLMOVIE
public Molecule readMol(Molecule mol)
throws MolFormatException,
java.io.IOException
mol - target molecule object
null at end of file
java.io.IOException - If I/O error occured
MolFormatException
public boolean read(Molecule mol)
throws java.io.IOException
mol - target molecule object
true after success,
false at end of file
java.io.IOException - If I/O error occured
public boolean skipRecord()
throws MolFormatException,
java.io.IOException
skipRecord in class MDocSourcetrue if the end of molecule is found,
false if there is no chance to continue
java.io.IOException - if read error occured
MolFormatExceptionpublic boolean skipToNext()
public java.lang.String readRecordAsText()
throws MRecordParseException,
MolExportException,
java.io.IOException
Molecule object.
null at end of file
MRecordParseException - If the record could not be parsed
MolExportException - if binary data cannot be exported
to MRV format text
java.io.IOException - if read error occuredpublic boolean isRewindable()
isRewindable in class MDocSourcetrue if rewinding is possible,
false otherwiseseekRecord(int, MProgressMonitor)
public void seekRecord(int k,
MProgressMonitor pmon)
throws java.io.EOFException,
java.io.IOException
cancels the progress dialog.
seekRecord in class MDocSourcek - positionpmon - progress monitor or null
java.io.EOFException - if end of file reached while trying to seek
java.io.IOException - if read error occuredisRewindable()
protected void seekVisitedRecord(int k)
throws java.io.IOException
seekVisitedRecord in class MDocSourcek - the record index
java.io.IOException - if read error occuredpublic boolean isEndReached()
isEndReached in class MDocSourcetrue if the end was reached,
false otherwisepublic int estimateNumRecords()
estimateNumRecords in class MDocSource
public long tell()
throws java.io.IOException
java.io.IOException - if the position cannot be determinedpublic int getLineCount()
public int getRecordCount()
getRecordCount in class MDocSourcepublic int getRecordCountMax()
getRecordCountMax in class MDocSource
public void close()
throws java.io.IOException
java.io.IOException - If an I/O error has occurred.public java.lang.String getFormat()
public static Molecule importMol(byte[] b)
throws MolFormatException
b - the molecule file contents
MolFormatException - If the molecule file is in a
format that cannot be read
public static Molecule importMol(byte[] b,
java.lang.String opts,
java.lang.String enc)
throws MolFormatException
b - the molecule file contentsopts - the file format and/or options separated by a colon;
use null for automatic format recognition
and default optionsenc - encoding or null
MolFormatException - If the molecule file is in a
format that cannot be read
public static boolean importMol(byte[] b,
Molecule mol)
throws MolFormatException
b - the molecule file contentsmol - target molecule object
MolFormatException - If the molecule file is in a
format that cannot be read
public static boolean importMol(byte[] b,
java.lang.String opts,
java.lang.String enc,
Molecule mol)
throws MolFormatException
b - the molecule file contentsopts - the file format and/or options separated by a colon;
use null for automatic format recognition
and default optionsenc - encoding or nullmol - target molecule object
MolFormatException - If the molecule file is in a
format that cannot be read
public static MDocument importDoc(byte[] b)
throws MolFormatException
b - the file contents
null if no document found in input
MolFormatException - If the molecule file is in a
format that cannot be read
public static MDocument importDoc(byte[] b,
java.lang.String opts,
java.lang.String enc)
throws MolFormatException
b - the file contentsopts - the file format and/or options separated by a colon;
use null for automatic format recognition
and default optionsenc - encoding or null
null if no document found in input
MolFormatException - If the molecule file is in a
format that cannot be read
public static Molecule importMol(java.lang.String s)
throws MolFormatException
importMol(String,String) to avoid
wasting time with format recognition.
s - the molecule file contents
MolFormatException - If the molecule file is in a
format that cannot be read
public static Molecule importMol(java.lang.String s,
java.lang.String opts)
throws MolFormatException
s - the molecule file contentsopts - the file format and/or options separated by a colon;
use null for automatic format recognition
and default options
MolFormatException - If the molecule file is in a
format that cannot be read
public static Molecule importMol(java.lang.String s,
java.lang.String opts,
java.lang.String enc)
throws MolFormatException
s - the molecule file contentsopts - the file format and/or options separated by a colon;
use null for automatic format recognition
and default optionsenc - encoding or null
MolFormatException - If the molecule file is in a
format that cannot be read
public static boolean importMol(java.lang.String s,
Molecule mol)
throws MolFormatException
s - the file contentsmol - target molecule object
MolFormatException - If the molecule file is in a
format that cannot be read
public static boolean importMol(java.lang.String s,
java.lang.String opts,
java.lang.String enc,
Molecule mol)
throws MolFormatException
s - the file contentsopts - the file format and/or options separated by a colon;
use null for automatic format recognition
and default optionsenc - encoding or nullmol - target molecule object
MolFormatException - If the molecule file is in a
format that cannot be readpublic MPropertyContainer getGlobalProperties()
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||