Logo Search packages:      
Sourcecode: cdk version File versions

IChemObject org::openscience::cdk::io::Mol2Reader::read ( IChemObject  object  )  throws CDKException [inline]

Takes an object which subclasses IChemObject, e.g.Molecule, and will read this from from the Reader. If the specific implementation does not support a specific IChemObject it will throw an Exception.

Parameters:
object The object that subclasses IChemObject
Returns:
The IChemObject read
Exceptions:
CDKException 

Implements org::openscience::cdk::io::IChemObjectReader.

Definition at line 123 of file Mol2Reader.java.

References org::openscience::cdk::interfaces::IChemSequence::addChemModel(), org::openscience::cdk::interfaces::IChemFile::addChemSequence(), org::openscience::cdk::interfaces::IMoleculeSet::addMolecule(), org::openscience::cdk::interfaces::IChemObject::getBuilder(), org::openscience::cdk::interfaces::IChemObjectBuilder::newChemModel(), org::openscience::cdk::interfaces::IChemObjectBuilder::newChemSequence(), org::openscience::cdk::interfaces::IChemObjectBuilder::newMolecule(), org::openscience::cdk::interfaces::IChemObjectBuilder::newMoleculeSet(), readMolecule(), and org::openscience::cdk::interfaces::IChemModel::setMoleculeSet().

                                                                     {
         if (object instanceof IChemFile) {
             IChemFile file = (IChemFile)object;
             IChemSequence sequence = file.getBuilder().newChemSequence();
             IChemModel model = file.getBuilder().newChemModel();
             IMoleculeSet moleculeSet = file.getBuilder().newMoleculeSet();
             moleculeSet.addMolecule(readMolecule(
                 model.getBuilder().newMolecule()
             ));
             model.setMoleculeSet(moleculeSet);
             sequence.addChemModel(model);
             file.addChemSequence(sequence);
             return file;
         } else if (object instanceof IChemModel) {
             IChemModel model = (IChemModel)object;
             IMoleculeSet moleculeSet = model.getBuilder().newMoleculeSet();
             moleculeSet.addMolecule(readMolecule(
                 model.getBuilder().newMolecule()
             ));
             model.setMoleculeSet(moleculeSet);
             return model;
         } else {
             throw new CDKException("Only supported is ChemModel, and not " +
                 object.getClass().getName() + "."
             );
         }
     }


Generated by  Doxygen 1.6.0   Back to index