use of org.openscience.cdk.silent.ChemFile in project cdk by cdk.
the class CIFReaderTest method cod1100784.
/**
* Ensure a CIF file from the crystallography open database can be read.
* Example input <a href="http://www.crystallography.net/1100784.cif">1100784</a>.
*/
@Test
public void cod1100784() throws IOException, CDKException {
InputStream in = getClass().getResourceAsStream("1100784.cif");
CIFReader cifReader = new CIFReader(in);
// try {
IChemFile chemFile = cifReader.read(new ChemFile());
org.hamcrest.MatcherAssert.assertThat(chemFile.getChemSequenceCount(), is(1));
org.hamcrest.MatcherAssert.assertThat(chemFile.getChemSequence(0).getChemModelCount(), is(1));
Assert.assertNotNull(chemFile.getChemSequence(0).getChemModel(0).getCrystal());
// } finally {
cifReader.close();
// }
}
use of org.openscience.cdk.silent.ChemFile in project cdk by cdk.
the class CIFReaderTest method cod1100784AtomCount.
@Test
public void cod1100784AtomCount() throws IOException, CDKException {
InputStream in = getClass().getResourceAsStream("1100784.cif");
CIFReader cifReader = new CIFReader(in);
IChemFile chemFile = cifReader.read(new ChemFile());
ICrystal crystal = chemFile.getChemSequence(0).getChemModel(0).getCrystal();
Assert.assertEquals(72, crystal.getAtomCount());
cifReader.close();
}
use of org.openscience.cdk.silent.ChemFile in project cdk by cdk.
the class CIFReaderTest method cod1100784CellLengths.
@Test()
public void cod1100784CellLengths() throws IOException, CDKException {
InputStream in = getClass().getResourceAsStream("1100784.cif");
CIFReader cifReader = new CIFReader(in);
IChemFile chemFile = cifReader.read(new ChemFile());
ICrystal crystal = chemFile.getChemSequence(0).getChemModel(0).getCrystal();
Assert.assertTrue(java.lang.Math.abs(crystal.getA().length() - 10.9754) < 1E-5);
Assert.assertTrue(java.lang.Math.abs(crystal.getB().length() - 11.4045) < 1E-5);
Assert.assertTrue(java.lang.Math.abs(crystal.getC().length() - 12.9314) < 1E-5);
cifReader.close();
}
use of org.openscience.cdk.silent.ChemFile in project cdk by cdk.
the class CDKAtomTypeMatcherFilesTest method testSmilesFiles.
@Test
public void testSmilesFiles() throws Exception {
CDKAtomTypeMatcher atomTypeMatcher = CDKAtomTypeMatcher.getInstance(SilentChemObjectBuilder.getInstance());
// Read the first file
String filename = "smiles1.cml";
InputStream ins = this.getClass().getResourceAsStream(filename);
CMLReader reader = new CMLReader(ins);
IChemFile chemFile = reader.read(new ChemFile());
Assert.assertNotNull(chemFile);
IAtomContainer mol1 = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
// Read the second file
filename = "smiles2.cml";
ins = this.getClass().getResourceAsStream(filename);
reader = new CMLReader(ins);
chemFile = reader.read(new ChemFile());
Assert.assertNotNull(chemFile);
IAtomContainer mol2 = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
IAtomType[] types1 = atomTypeMatcher.findMatchingAtomTypes(mol1);
IAtomType[] types2 = atomTypeMatcher.findMatchingAtomTypes(mol2);
for (int i = 0; i < mol1.getAtomCount(); i++) {
Assert.assertNotNull("Atom typing in mol1 failed for atom " + (i + 1), types1[i]);
Assert.assertNotNull("Atom typing in mol2 failed for atom " + (i + 1), types2[i]);
Assert.assertEquals("Atom type mismatch for the " + (i + 1) + " atom", types1[i].getAtomTypeName(), types2[i].getAtomTypeName());
}
}
use of org.openscience.cdk.silent.ChemFile in project cdk by cdk.
the class CDKAtomTypeMatcherFilesTest method testFile3.
@Test
public void testFile3() throws Exception {
String filename = "3.cml";
InputStream ins = this.getClass().getResourceAsStream(filename);
CMLReader reader = new CMLReader(ins);
IChemFile chemFile = reader.read(new ChemFile());
// test the resulting ChemFile content
Assert.assertNotNull(chemFile);
IAtomContainer mol = ChemFileManipulator.getAllAtomContainers(chemFile).get(0);
String[] expectedTypes = { "C.sp2", "N.sp2", "C.sp2", "N.sp3", "C.sp2", "N.sp2", "O.sp3", "C.sp2", "C.sp2", "C.sp2" };
assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
Aggregations