Search in sources :

Example 1 with ICrystal

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;
}
Also used : ICrystal(org.openscience.cdk.interfaces.ICrystal)

Example 2 with ICrystal

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);
    }
}
Also used : ICrystal(org.openscience.cdk.interfaces.ICrystal) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet)

Example 3 with ICrystal

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());
}
Also used : ICrystal(org.openscience.cdk.interfaces.ICrystal) ICrystal(org.openscience.cdk.interfaces.ICrystal) Test(org.junit.Test) AbstractCrystalTest(org.openscience.cdk.test.interfaces.AbstractCrystalTest)

Example 4 with ICrystal

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());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IChemModel(org.openscience.cdk.interfaces.IChemModel) IReaction(org.openscience.cdk.interfaces.IReaction) IAtom(org.openscience.cdk.interfaces.IAtom) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) ICrystal(org.openscience.cdk.interfaces.ICrystal) IChemModel(org.openscience.cdk.interfaces.IChemModel) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IReactionSet(org.openscience.cdk.interfaces.IReactionSet) IRingSet(org.openscience.cdk.interfaces.IRingSet) IAtomContainerSet(org.openscience.cdk.interfaces.IAtomContainerSet) IRingSet(org.openscience.cdk.interfaces.IRingSet) IReaction(org.openscience.cdk.interfaces.IReaction) IAtom(org.openscience.cdk.interfaces.IAtom) ICrystal(org.openscience.cdk.interfaces.ICrystal) AbstractChemModelTest(org.openscience.cdk.test.interfaces.AbstractChemModelTest) Test(org.junit.Test)

Example 5 with ICrystal

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());
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) ICrystal(org.openscience.cdk.interfaces.ICrystal) IChemObject(org.openscience.cdk.interfaces.IChemObject) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) ICrystal(org.openscience.cdk.interfaces.ICrystal) Test(org.junit.Test) AbstractCrystalTest(org.openscience.cdk.test.interfaces.AbstractCrystalTest)

Aggregations

ICrystal (org.openscience.cdk.interfaces.ICrystal)62 Test (org.junit.Test)39 Vector3d (javax.vecmath.Vector3d)19 IChemModel (org.openscience.cdk.interfaces.IChemModel)19 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)18 IAtom (org.openscience.cdk.interfaces.IAtom)14 IAtomContainerSet (org.openscience.cdk.interfaces.IAtomContainerSet)14 IReactionSet (org.openscience.cdk.interfaces.IReactionSet)11 IChemSequence (org.openscience.cdk.interfaces.IChemSequence)10 IChemFile (org.openscience.cdk.interfaces.IChemFile)8 IBond (org.openscience.cdk.interfaces.IBond)7 InputStream (java.io.InputStream)6 CDKException (org.openscience.cdk.exception.CDKException)6 AbstractCrystalTest (org.openscience.cdk.test.interfaces.AbstractCrystalTest)6 IOException (java.io.IOException)5 Point3d (javax.vecmath.Point3d)5 StringTokenizer (java.util.StringTokenizer)4 ChemObjectIOTest (org.openscience.cdk.test.io.ChemObjectIOTest)4 StringWriter (java.io.StringWriter)3 ArrayList (java.util.ArrayList)3