Search in sources :

Example 6 with AtomContainer

use of org.openscience.cdk.AtomContainer in project ambit-mirror by ideaconsult.

the class TestUtilities method testAtomAttribsOnChangingBond.

public void testAtomAttribsOnChangingBond() throws Exception {
    IAtomContainer mol = new AtomContainer();
    IAtom a1 = new Atom("C");
    mol.addAtom(a1);
    IAtom a2 = new Atom("C");
    mol.addAtom(a2);
    IAtom a3 = new Atom("N");
    mol.addAtom(a3);
    IAtom h1 = new Atom("H");
    mol.addAtom(h1);
    IBond bh1 = new Bond(a1, h1, IBond.Order.SINGLE);
    // IAtom h2 = new Atom("H"); mol.addAtom(h2); IBond bh2 = new
    // Bond(a2,h2, IBond.Order.SINGLE);
    IBond b = new Bond(a1, a2);
    IBond b2 = new Bond(a2, a3);
    mol.addBond(b);
    b.setOrder(IBond.Order.DOUBLE);
    mol.addBond(b2);
    b2.setOrder(IBond.Order.SINGLE);
    mol.addBond(bh1);
    // mol.addBond(bh2);
    // IAtomContainer mol = SmartsHelper.getMoleculeFromSmiles("CCCCC");
    // IBond b = mol.getBond(0);
    System.out.println(SmartsHelper.getAtomsAttributes(mol));
    System.out.println(SmartsHelper.getBondAttributes(mol));
    // FlagExplicitHAtoms = true;
    // preProcess(mol);
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
    // CDKHydrogenAdder adder =
    // CDKHydrogenAdder.getInstance(SilentChemObjectBuilder.getInstance());
    // adder.addImplicitHydrogens(mol);
    System.out.println("percieveAtomTypesAndConfigureAtoms");
    System.out.println(SmartsHelper.getAtomsAttributes(mol));
    System.out.println(SmartsHelper.getBondAttributes(mol));
    b.setOrder(IBond.Order.TRIPLE);
    for (IAtom atom : mol.atoms()) {
        atom.setHybridization((IAtomType.Hybridization) CDKConstants.UNSET);
    // atom.setImplicitHydrogenCount(null);
    // atom.setFormalNeighbourCount((Integer) CDKConstants.UNSET);
    /*
			 * atom.setAtomTypeName((String) CDKConstants.UNSET);
			 * 
			 * atom.setMaxBondOrder((IBond.Order) CDKConstants.UNSET);
			 * atom.setBondOrderSum((Double) CDKConstants.UNSET);
			 * atom.setCovalentRadius((Double) CDKConstants.UNSET);
			 * atom.setValency((Integer) CDKConstants.UNSET);
			 * atom.setFormalCharge((Integer) CDKConstants.UNSET);
			 * atom.setHybridization((IAtomType.Hybridization)
			 * CDKConstants.UNSET); atom.setFormalNeighbourCount((Integer)
			 * CDKConstants.UNSET);
			 * atom.setFlag(CDKConstants.IS_HYDROGENBOND_ACCEPTOR, false);
			 * atom.setFlag(CDKConstants.IS_HYDROGENBOND_DONOR, false);
			 * atom.setProperty(CDKConstants.CHEMICAL_GROUP_CONSTANT,
			 * CDKConstants.UNSET); atom.setFlag(CDKConstants.ISAROMATIC,
			 * false); atom.setProperty("org.openscience.cdk.renderer.color",
			 * CDKConstants.UNSET); atom.setAtomicNumber((Integer)
			 * CDKConstants.UNSET); atom.setExactMass((Double)
			 * CDKConstants.UNSET);
			 */
    }
    // AtomContainerManipulator.clearAtomConfigurations(mol);
    // a1.setHybridization((IAtomType.Hybridization)CDKConstants.UNSET);
    // a2.setHybridization((IAtomType.Hybridization)CDKConstants.UNSET);
    /*
		 * AtomContainerManipulator.clearAtomConfigurations(mol);
		 * mol.removeBond(b); IBond b1 = new Bond(a1,a2);
		 * b1.setOrder(IBond.Order.SINGLE); mol.addBond(b1);
		 */
    AtomContainerManipulator.percieveAtomTypesAndConfigureAtoms(mol);
    System.out.println("after molecule change");
    System.out.println(SmartsHelper.getAtomsAttributes(mol));
    System.out.println(SmartsHelper.getBondAttributes(mol));
}
Also used : IAtomType(org.openscience.cdk.interfaces.IAtomType) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) QueryAtomContainer(org.openscience.cdk.isomorphism.matchers.QueryAtomContainer) IQueryAtomContainer(org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer) IBond(org.openscience.cdk.interfaces.IBond) Bond(org.openscience.cdk.Bond) OrderQueryBond(org.openscience.cdk.isomorphism.matchers.smarts.OrderQueryBond) IBond(org.openscience.cdk.interfaces.IBond) IAtom(org.openscience.cdk.interfaces.IAtom) AnyAtom(org.openscience.cdk.isomorphism.matchers.smarts.AnyAtom) IQueryAtom(org.openscience.cdk.isomorphism.matchers.IQueryAtom) Atom(org.openscience.cdk.Atom) AliphaticSymbolAtom(org.openscience.cdk.isomorphism.matchers.smarts.AliphaticSymbolAtom) IAtom(org.openscience.cdk.interfaces.IAtom)

Example 7 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class SybylAtomTypeMatcherTest method testAmmonia.

@Test
public void testAmmonia() throws Exception {
    IAtomContainer mol = new AtomContainer();
    IAtom atom = new Atom("H");
    IAtom atom2 = new Atom("N");
    IAtom atom3 = new Atom("H");
    IAtom atom4 = new Atom("H");
    IAtom atom5 = new Atom("H");
    mol.addAtom(atom);
    mol.addAtom(atom2);
    atom2.setFormalCharge(+1);
    mol.addAtom(atom3);
    mol.addAtom(atom4);
    mol.addAtom(atom5);
    mol.addBond(0, 1, Order.SINGLE);
    mol.addBond(1, 2, Order.SINGLE);
    mol.addBond(1, 3, Order.SINGLE);
    mol.addBond(1, 4, Order.SINGLE);
    String[] expectedTypes = { "H", "N.4", "H", "H", "H" };
    assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) PseudoAtom(org.openscience.cdk.PseudoAtom) Atom(org.openscience.cdk.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 8 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class SybylAtomTypeMatcherTest method testThioAmide.

@Test
public void testThioAmide() throws Exception {
    IAtomContainer mol = new AtomContainer();
    IAtom atom = new Atom("S");
    IAtom atom2 = new Atom("C");
    IAtom atom3 = new Atom("N");
    mol.addAtom(atom);
    mol.addAtom(atom2);
    mol.addAtom(atom3);
    mol.addBond(0, 1, Order.DOUBLE);
    mol.addBond(1, 2, Order.SINGLE);
    String[] expectedTypes = { "S.2", "C.2", "N.am" };
    assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) PseudoAtom(org.openscience.cdk.PseudoAtom) Atom(org.openscience.cdk.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 9 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class SybylAtomTypeMatcherTest method testCarbokation.

@Test
public void testCarbokation() throws Exception {
    IAtomContainer mol = new AtomContainer();
    IAtom atom = new Atom("H");
    IAtom atom2 = new Atom("C");
    atom2.setFormalCharge(+1);
    IAtom atom3 = new Atom("H");
    IAtom atom4 = new Atom("H");
    mol.addAtom(atom);
    mol.addAtom(atom2);
    mol.addAtom(atom3);
    mol.addAtom(atom4);
    mol.addBond(0, 1, Order.SINGLE);
    mol.addBond(1, 2, Order.SINGLE);
    mol.addBond(1, 3, Order.SINGLE);
    String[] expectedTypes = { "H", "C.cat", "H", "H" };
    assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) PseudoAtom(org.openscience.cdk.PseudoAtom) Atom(org.openscience.cdk.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Example 10 with AtomContainer

use of org.openscience.cdk.AtomContainer in project cdk by cdk.

the class SybylAtomTypeMatcherTest method testMnF4.

@Test
public void testMnF4() throws Exception {
    IAtomContainer mol = new AtomContainer();
    IAtom atom = new Atom("F");
    IAtom atom2 = new Atom("Mn");
    IAtom atom3 = new Atom("F");
    IAtom atom4 = new Atom("F");
    IAtom atom5 = new Atom("F");
    mol.addAtom(atom);
    atom.setFormalCharge(-1);
    mol.addAtom(atom2);
    atom2.setFormalCharge(+2);
    mol.addAtom(atom3);
    atom3.setFormalCharge(-1);
    mol.addAtom(atom4);
    atom4.setFormalCharge(-1);
    mol.addAtom(atom5);
    atom5.setFormalCharge(-1);
    String[] expectedTypes = { "F", "Mn", "F", "F", "F" };
    assertAtomTypes(testedAtomTypes, expectedTypes, mol);
}
Also used : IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) IAtomContainer(org.openscience.cdk.interfaces.IAtomContainer) AtomContainer(org.openscience.cdk.AtomContainer) IAtom(org.openscience.cdk.interfaces.IAtom) PseudoAtom(org.openscience.cdk.PseudoAtom) Atom(org.openscience.cdk.Atom) IAtom(org.openscience.cdk.interfaces.IAtom) Test(org.junit.Test)

Aggregations

AtomContainer (org.openscience.cdk.AtomContainer)743 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)730 Test (org.junit.Test)641 IAtom (org.openscience.cdk.interfaces.IAtom)556 Atom (org.openscience.cdk.Atom)523 PseudoAtom (org.openscience.cdk.PseudoAtom)206 IBond (org.openscience.cdk.interfaces.IBond)136 Bond (org.openscience.cdk.Bond)90 Point2d (javax.vecmath.Point2d)86 InputStream (java.io.InputStream)80 IQueryAtomContainer (org.openscience.cdk.isomorphism.matchers.IQueryAtomContainer)61 QueryAtomContainer (org.openscience.cdk.isomorphism.matchers.QueryAtomContainer)57 MDLV2000Reader (org.openscience.cdk.io.MDLV2000Reader)44 SimpleChemObjectReaderTest (org.openscience.cdk.test.io.SimpleChemObjectReaderTest)43 ByteArrayInputStream (java.io.ByteArrayInputStream)41 CoreMatchers.containsString (org.hamcrest.CoreMatchers.containsString)32 SlowTest (org.openscience.cdk.test.SlowTest)32 Point3d (javax.vecmath.Point3d)30 IPseudoAtom (org.openscience.cdk.interfaces.IPseudoAtom)29 DoubleArrayResult (org.openscience.cdk.qsar.result.DoubleArrayResult)23