use of org.openscience.cdk.interfaces.IChemSequence in project cdk by cdk.
the class VASPReader method readChemFile.
private IChemFile readChemFile(IChemFile file) throws CDKException, IOException {
IChemSequence seq = readChemSequence(file.getBuilder().newInstance(IChemSequence.class));
file.addChemSequence(seq);
return file;
}
use of org.openscience.cdk.interfaces.IChemSequence in project cdk by cdk.
the class MDLRXNV2000Reader method read.
/**
* Takes an object which subclasses IChemObject, e.g.Molecule, and will read
* this (from file, database, internet etc). If the specific implementation
* does not support a specific IChemObject it will throw an Exception.
*
* @param object The object that subclasses
* IChemObject
* @return The IChemObject read
* @exception CDKException
*/
@Override
public <T extends IChemObject> T read(T object) throws CDKException {
if (object instanceof IReaction) {
return (T) readReaction(object.getBuilder());
} else if (object instanceof IReactionSet) {
IReactionSet reactionSet = object.getBuilder().newInstance(IReactionSet.class);
reactionSet.addReaction(readReaction(object.getBuilder()));
return (T) reactionSet;
} else if (object instanceof IChemModel) {
IChemModel model = object.getBuilder().newInstance(IChemModel.class);
IReactionSet reactionSet = object.getBuilder().newInstance(IReactionSet.class);
reactionSet.addReaction(readReaction(object.getBuilder()));
model.setReactionSet(reactionSet);
return (T) model;
} else if (object instanceof IChemFile) {
IChemFile chemFile = object.getBuilder().newInstance(IChemFile.class);
IChemSequence sequence = object.getBuilder().newInstance(IChemSequence.class);
sequence.addChemModel(read(object.getBuilder().newInstance(IChemModel.class)));
chemFile.addChemSequence(sequence);
return (T) chemFile;
} else {
throw new CDKException("Only supported are Reaction and ChemModel, and not " + object.getClass().getName() + ".");
}
}
use of org.openscience.cdk.interfaces.IChemSequence in project cdk by cdk.
the class SDFReaderTest method testMultipleDataFields.
@Test
public void testMultipleDataFields() throws Exception {
String filename = "bug1587283.mol";
InputStream ins = this.getClass().getResourceAsStream(filename);
MDLV2000Reader reader = new MDLV2000Reader(ins);
IChemFile fileContents = reader.read(new ChemFile());
reader.close();
Assert.assertEquals(1, fileContents.getChemSequenceCount());
IChemSequence sequence = fileContents.getChemSequence(0);
Assert.assertNotNull(sequence);
Assert.assertEquals(1, sequence.getChemModelCount());
IChemModel model = sequence.getChemModel(0);
Assert.assertNotNull(model);
IAtomContainerSet som = model.getMoleculeSet();
Assert.assertNotNull(som);
Assert.assertEquals(1, som.getAtomContainerCount());
IAtomContainer m = som.getAtomContainer(0);
Assert.assertNotNull(m);
Assert.assertEquals("B02", m.getProperty("id_no"));
Assert.assertEquals("2-2", m.getProperty("eductkey"));
Assert.assertEquals("1", m.getProperty("Step"));
Assert.assertEquals("2", m.getProperty("Pos"));
Assert.assertEquals("B02", m.getProperty("Tag"));
}
use of org.openscience.cdk.interfaces.IChemSequence in project cdk by cdk.
the class CML2Test method testCMLConciseFormula.
/**
* Only Molecule with concise MolecularFormula
*/
@Test
public void testCMLConciseFormula() throws Exception {
String filename = "cmlConciseFormula.cml";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getResourceAsStream(filename);
CMLReader reader = new CMLReader(ins);
IChemFile chemFile = reader.read(new ChemFile());
reader.close();
// test the resulting ChemFile content
Assert.assertNotNull(chemFile);
Assert.assertEquals(chemFile.getChemSequenceCount(), 1);
IChemSequence seq = chemFile.getChemSequence(0);
Assert.assertNotNull(seq);
Assert.assertEquals(seq.getChemModelCount(), 1);
IChemModel model = seq.getChemModel(0);
Assert.assertNotNull(model);
IAtomContainer mol = model.getMoleculeSet().getAtomContainer(0);
Assert.assertNotNull(mol);
// FIXME: REACT: It should return two different formulas
Assert.assertEquals("[C 18 H 21 Cl 2 Mn 1 N 5 O 1]", mol.getProperty(CDKConstants.FORMULA).toString());
}
use of org.openscience.cdk.interfaces.IChemSequence in project cdk by cdk.
the class CML2Test method testCMLWithFormula.
/**
* @cdk.bug 1560486
*/
@Test
public void testCMLWithFormula() throws Exception {
String filename = "cmlWithFormula.cml";
logger.info("Testing: " + filename);
InputStream ins = this.getClass().getResourceAsStream(filename);
CMLReader reader = new CMLReader(ins);
IChemFile chemFile = reader.read(new ChemFile());
reader.close();
// test the resulting ChemFile content
Assert.assertNotNull(chemFile);
Assert.assertEquals(chemFile.getChemSequenceCount(), 1);
IChemSequence seq = chemFile.getChemSequence(0);
Assert.assertNotNull(seq);
Assert.assertEquals(seq.getChemModelCount(), 1);
IChemModel model = seq.getChemModel(0);
Assert.assertNotNull(model);
IAtomContainer mol = model.getMoleculeSet().getAtomContainer(0);
Assert.assertNotNull(mol);
Assert.assertEquals("a", mol.getID());
Assert.assertEquals("a1", mol.getAtom(0).getID());
Assert.assertEquals(27, mol.getAtomCount());
Assert.assertEquals(32, mol.getBondCount());
}
Aggregations