use of org.openscience.cdk.interfaces.ICrystal in project ambit-mirror by ideaconsult.
the class CdkJmolAdapter method getNotionalUnitcell.
/*
this needs to be handled through the StructureIterator
String[] getPdbStructureRecords(Object clientFile) {
ChemFile chemFile = (ChemFile)clientFile;
ChemSequence chemSequence = chemFile.getChemSequence(0);
ChemModel chemModel = chemSequence.getChemModel(0);
Vector structureVector =
(Vector)chemModel.getProperty("pdb.structure.records");
if (structureVector == null)
return null;
String[] t = new String[structureVector.size()];
structureVector.copyInto(t);
return t;
}
*/
public float[] getNotionalUnitcell(Object clientFile) {
if (clientFile instanceof ICrystal) {
ICrystal crystal = (ICrystal) clientFile;
double[] notional = CrystalGeometryTools.cartesianToNotional(crystal.getA(), crystal.getB(), crystal.getC());
float[] fNotional = new float[6];
for (int i = 0; i < 6; i++) {
fNotional[i] = (float) notional[i];
}
return fNotional;
}
// else: no crystal thus no unit cell info
return null;
}
use of org.openscience.cdk.interfaces.ICrystal in project cdk by cdk.
the class IDCreator method createIDsForChemModel.
private static void createIDsForChemModel(IChemModel model, List<String> tabuList) {
if (tabuList == null)
tabuList = ChemModelManipulator.getAllIDs(model);
if (null == model.getID()) {
chemModelCount = setID(CHEMMODEL_PREFIX, chemModelCount, model, tabuList);
}
ICrystal crystal = model.getCrystal();
if (crystal != null) {
if (policy == OBJECT_UNIQUE_POLICY) {
atomCount = 0;
bondCount = 0;
}
createIDsForAtomContainer(crystal, tabuList);
}
IAtomContainerSet moleculeSet = model.getMoleculeSet();
if (moleculeSet != null) {
if (policy == OBJECT_UNIQUE_POLICY) {
atomContainerSetCount = 0;
atomContainerCount = 0;
}
createIDsForAtomContainerSet(moleculeSet, tabuList);
}
IReactionSet reactionSet = model.getReactionSet();
if (reactionSet != null) {
if (policy == OBJECT_UNIQUE_POLICY) {
reactionSetCount = 0;
reactionCount = 0;
}
createIDsForReactionSet(reactionSet, tabuList);
}
}
use of org.openscience.cdk.interfaces.ICrystal in project cdk by cdk.
the class CrystalTest method testCrystal.
@Test
public void testCrystal() {
ICrystal crystal = new Crystal();
Assert.assertNotNull(crystal);
Assert.assertEquals(0, crystal.getAtomCount());
Assert.assertEquals(0, crystal.getBondCount());
}
use of org.openscience.cdk.interfaces.ICrystal in project cdk by cdk.
the class ChemModelTest method testChemModel.
@Test
public void testChemModel() {
IChemModel chemModel = new ChemModel();
Assert.assertNotNull(chemModel);
Assert.assertTrue(chemModel.isEmpty());
IAtom atom = new Atom("N");
IAtomContainer mol = new AtomContainer();
IAtomContainerSet mset = new AtomContainerSet();
mol.addAtom(atom);
mset.addAtomContainer(mol);
chemModel.setMoleculeSet(mset);
Assert.assertFalse(chemModel.isEmpty());
mol.removeAtomOnly(atom);
Assert.assertFalse(chemModel.isEmpty());
chemModel.setMoleculeSet(null);
Assert.assertTrue(chemModel.isEmpty());
IChemModel model1 = new ChemModel();
mol.addAtom(atom);
IReaction react = new Reaction();
react.addReactant(mol);
IReactionSet rset = new ReactionSet();
rset.addReaction(react);
model1.setReactionSet(rset);
Assert.assertFalse(model1.isEmpty());
mol.removeAtomOnly(atom);
Assert.assertFalse(model1.isEmpty());
model1.setReactionSet(null);
Assert.assertTrue(model1.isEmpty());
IChemModel model2 = new ChemModel();
mol.addAtom(atom);
IRingSet ringset = new RingSet();
ringset.add(mset);
model2.setRingSet(ringset);
Assert.assertFalse(model2.isEmpty());
mol.removeAtomOnly(atom);
Assert.assertFalse(model2.isEmpty());
model2.setRingSet(null);
Assert.assertTrue(model2.isEmpty());
IChemModel model3 = new ChemModel();
mol.addAtom(atom);
ICrystal cry = new Crystal(mol);
model3.setCrystal(cry);
Assert.assertFalse(model3.isEmpty());
mol.removeAtomOnly(atom);
Assert.assertFalse(model3.isEmpty());
model3.setCrystal(null);
Assert.assertTrue(model3.isEmpty());
}
use of org.openscience.cdk.interfaces.ICrystal in project cdk by cdk.
the class CrystalTest method testCrystal_IAtomContainer.
@Test
public void testCrystal_IAtomContainer() {
IChemObject object = newChemObject();
IAtomContainer acetone = object.getBuilder().newInstance(IAtomContainer.class);
IAtom c1 = acetone.getBuilder().newInstance(IAtom.class, "C");
IAtom c2 = acetone.getBuilder().newInstance(IAtom.class, "C");
IAtom o = acetone.getBuilder().newInstance(IAtom.class, "O");
IAtom c3 = acetone.getBuilder().newInstance(IAtom.class, "C");
acetone.addAtom(c1);
acetone.addAtom(c2);
acetone.addAtom(c3);
acetone.addAtom(o);
IBond b1 = acetone.getBuilder().newInstance(IBond.class, c1, c2, IBond.Order.SINGLE);
IBond b2 = acetone.getBuilder().newInstance(IBond.class, c1, o, IBond.Order.DOUBLE);
IBond b3 = acetone.getBuilder().newInstance(IBond.class, c1, c3, IBond.Order.SINGLE);
acetone.addBond(b1);
acetone.addBond(b2);
acetone.addBond(b3);
ICrystal crystal = new Crystal(acetone);
Assert.assertNotNull(crystal);
Assert.assertEquals(4, crystal.getAtomCount());
Assert.assertEquals(3, crystal.getBondCount());
}
Aggregations