Skip to content

Commit

Permalink
Adding a test for the CIF cell constant read.
Browse files Browse the repository at this point in the history
  • Loading branch information
sauliusg committed Feb 28, 2018
1 parent 3dee9f0 commit 80dc2a3
Showing 1 changed file with 22 additions and 2 deletions.
24 changes: 22 additions & 2 deletions storage/io/src/test/java/org/openscience/cdk/io/CIFReaderTest.java
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,8 @@
import java.io.IOException;
import java.io.InputStream;

import javax.vecmath.Vector3d;

import static org.hamcrest.CoreMatchers.is;

/**
Expand Down Expand Up @@ -66,14 +68,32 @@ public void cod1100784() throws IOException, CDKException {
}

@Test()
public void cod1100784Cell() throws IOException, CDKException {
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() - 10.9754) < 1E-5 );
Assert.assertTrue( java.lang.Math.abs(crystal.getC().length() - 12.9314) < 1E-5 );
cifReader.close();
}

@Test()
public void cod1100784CellAngles() 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();
Vector3d a = crystal.getA();
Vector3d b = crystal.getB();
Vector3d c = crystal.getC();
double alpha = java.lang.Math.acos(b.dot(c)/(b.length()*c.length()))*180/java.lang.Math.PI;
double beta = java.lang.Math.acos(c.dot(a)/(c.length()*a.length()))*180/java.lang.Math.PI;
double gamma = java.lang.Math.acos(a.dot(b)/(a.length()*b.length()))*180/java.lang.Math.PI;
Assert.assertTrue( java.lang.Math.abs(alpha - 109.1080) < 1E-5 );
Assert.assertTrue( java.lang.Math.abs(beta - 98.4090) < 1E-5 );
Assert.assertTrue( java.lang.Math.abs(gamma - 102.7470) < 1E-5 );
cifReader.close();
}

Expand Down

0 comments on commit 80dc2a3

Please sign in to comment.