Search in sources :

Example 1 with IBioPolymer

use of org.openscience.cdk.interfaces.IBioPolymer in project cdk by cdk.

the class BioPolymerTest method testBioPolymer.

@Test
public void testBioPolymer() {
    IBioPolymer oBioPolymer = new BioPolymer();
    Assert.assertNotNull(oBioPolymer);
    Assert.assertEquals(oBioPolymer.getMonomerCount(), 0);
    IStrand oStrand1 = oBioPolymer.getBuilder().newInstance(IStrand.class);
    oStrand1.setStrandName("A");
    IStrand oStrand2 = oBioPolymer.getBuilder().newInstance(IStrand.class);
    oStrand2.setStrandName("B");
    IMonomer oMono1 = oBioPolymer.getBuilder().newInstance(IMonomer.class);
    oMono1.setMonomerName("TRP279");
    IMonomer oMono2 = oBioPolymer.getBuilder().newInstance(IMonomer.class);
    oMono2.setMonomerName("HOH");
    IMonomer oMono3 = oBioPolymer.getBuilder().newInstance(IMonomer.class);
    oMono3.setMonomerName("GLYA16");
    IAtom oAtom1 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C");
    IAtom oAtom2 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C");
    IAtom oAtom3 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C");
    IAtom oAtom4 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C");
    IAtom oAtom5 = oBioPolymer.getBuilder().newInstance(IAtom.class, "C");
    oBioPolymer.addAtom(oAtom1);
    oBioPolymer.addAtom(oAtom2, oStrand1);
    oBioPolymer.addAtom(oAtom3, oMono1, oStrand1);
    oBioPolymer.addAtom(oAtom4, oMono2, oStrand2);
    oBioPolymer.addAtom(oAtom5, oMono3, oStrand2);
    Assert.assertNotNull(oBioPolymer.getAtom(0));
    Assert.assertNotNull(oBioPolymer.getAtom(1));
    Assert.assertNotNull(oBioPolymer.getAtom(2));
    Assert.assertNotNull(oBioPolymer.getAtom(3));
    Assert.assertNotNull(oBioPolymer.getAtom(4));
    Assert.assertEquals(oAtom1, oBioPolymer.getAtom(0));
    Assert.assertEquals(oAtom2, oBioPolymer.getAtom(1));
    Assert.assertEquals(oAtom3, oBioPolymer.getAtom(2));
    Assert.assertEquals(oAtom4, oBioPolymer.getAtom(3));
    Assert.assertEquals(oAtom5, oBioPolymer.getAtom(4));
    Assert.assertNull(oBioPolymer.getMonomer("0815", "A"));
    Assert.assertNull(oBioPolymer.getMonomer("0815", "B"));
    Assert.assertNull(oBioPolymer.getMonomer("0815", ""));
    Assert.assertNull(oBioPolymer.getStrand(""));
    Assert.assertNotNull(oBioPolymer.getMonomer("TRP279", "A"));
    Assert.assertEquals(oMono1, oBioPolymer.getMonomer("TRP279", "A"));
    Assert.assertEquals(oBioPolymer.getMonomer("TRP279", "A").getAtomCount(), 1);
    Assert.assertNotNull(oBioPolymer.getMonomer("HOH", "B"));
    Assert.assertEquals(oMono2, oBioPolymer.getMonomer("HOH", "B"));
    Assert.assertEquals(oBioPolymer.getMonomer("HOH", "B").getAtomCount(), 1);
    Assert.assertEquals(oBioPolymer.getStrand("B").getAtomCount(), 2);
    Assert.assertEquals(oBioPolymer.getStrand("B").getMonomerCount(), 2);
    Assert.assertNull(oBioPolymer.getStrand("C"));
    Assert.assertNotNull(oBioPolymer.getStrand("B"));
}
Also used : IBioPolymer(org.openscience.cdk.interfaces.IBioPolymer) IBioPolymer(org.openscience.cdk.interfaces.IBioPolymer) IStrand(org.openscience.cdk.interfaces.IStrand) IAtom(org.openscience.cdk.interfaces.IAtom) IMonomer(org.openscience.cdk.interfaces.IMonomer) AbstractBioPolymerTest(org.openscience.cdk.test.interfaces.AbstractBioPolymerTest) Test(org.junit.Test)

Example 2 with IBioPolymer

use of org.openscience.cdk.interfaces.IBioPolymer in project cdk by cdk.

the class BioPolymer method clone.

@Override
public IBioPolymer clone() throws CloneNotSupportedException {
    BioPolymer clone = (BioPolymer) super.clone();
    clone.strands.clear();
    for (String value : clone.getStrandNames()) {
        Strand strand = (Strand) clone.getStrand(value.toString()).clone();
        for (String s : strand.getMonomerNames()) {
            IMonomer monomer = strand.getMonomer(s.toString());
            for (IAtom iAtom : monomer.atoms()) {
                clone.addAtom(iAtom, monomer, strand);
            }
        }
    }
    return clone;
}
Also used : IBioPolymer(org.openscience.cdk.interfaces.IBioPolymer) IStrand(org.openscience.cdk.interfaces.IStrand) IAtom(org.openscience.cdk.interfaces.IAtom) IMonomer(org.openscience.cdk.interfaces.IMonomer)

Example 3 with IBioPolymer

use of org.openscience.cdk.interfaces.IBioPolymer in project cdk by cdk.

the class AminoAcidCountDescriptorTest method testAACount.

@Test
public void testAACount() throws Exception {
    IBioPolymer protein = ProteinBuilderTool.createProtein("ARNDCFQEGHIPLKMSTYVW", SilentChemObjectBuilder.getInstance());
    IDescriptorResult result = descriptor.calculate(protein).getValue();
    Assert.assertTrue(result instanceof IntegerArrayResult);
    IntegerArrayResult iaResult = (IntegerArrayResult) result;
    for (int i = 0; i < iaResult.length(); i++) {
        // all AAs are found at least once
        Assert.assertTrue(iaResult.get(i) >= 1);
    }
    // glycine is in all of them, so 20 times
    Assert.assertEquals(20, iaResult.get(8));
}
Also used : IDescriptorResult(org.openscience.cdk.qsar.result.IDescriptorResult) IntegerArrayResult(org.openscience.cdk.qsar.result.IntegerArrayResult) IBioPolymer(org.openscience.cdk.interfaces.IBioPolymer) Test(org.junit.Test)

Example 4 with IBioPolymer

use of org.openscience.cdk.interfaces.IBioPolymer in project cdk by cdk.

the class AminoAcidCountDescriptorTest method testTCount.

@Test
public void testTCount() throws Exception {
    IBioPolymer protein = ProteinBuilderTool.createProtein("TT", SilentChemObjectBuilder.getInstance());
    IDescriptorResult result = descriptor.calculate(protein).getValue();
    Assert.assertTrue(result instanceof IntegerArrayResult);
    IntegerArrayResult iaResult = (IntegerArrayResult) result;
    Assert.assertEquals(2, iaResult.get(8));
    Assert.assertEquals(2, iaResult.get(16));
}
Also used : IDescriptorResult(org.openscience.cdk.qsar.result.IDescriptorResult) IntegerArrayResult(org.openscience.cdk.qsar.result.IntegerArrayResult) IBioPolymer(org.openscience.cdk.interfaces.IBioPolymer) Test(org.junit.Test)

Example 5 with IBioPolymer

use of org.openscience.cdk.interfaces.IBioPolymer in project cdk by cdk.

the class AminoAcidCountDescriptorTest method testFCount.

@Test
public void testFCount() throws Exception {
    IBioPolymer protein = ProteinBuilderTool.createProtein("FF", SilentChemObjectBuilder.getInstance());
    IDescriptorResult result = descriptor.calculate(protein).getValue();
    Assert.assertTrue(result instanceof IntegerArrayResult);
    IntegerArrayResult iaResult = (IntegerArrayResult) result;
    Assert.assertEquals(2, iaResult.get(8));
    // thingy is symmetrical, so two mappings at each AA position possible
    Assert.assertEquals(4, iaResult.get(5));
}
Also used : IDescriptorResult(org.openscience.cdk.qsar.result.IDescriptorResult) IntegerArrayResult(org.openscience.cdk.qsar.result.IntegerArrayResult) IBioPolymer(org.openscience.cdk.interfaces.IBioPolymer) Test(org.junit.Test)

Aggregations

IBioPolymer (org.openscience.cdk.interfaces.IBioPolymer)33 Test (org.junit.Test)28 IAtom (org.openscience.cdk.interfaces.IAtom)19 IMonomer (org.openscience.cdk.interfaces.IMonomer)18 IStrand (org.openscience.cdk.interfaces.IStrand)16 IAtomContainer (org.openscience.cdk.interfaces.IAtomContainer)6 InputStream (java.io.InputStream)5 ChemFile (org.openscience.cdk.ChemFile)5 IChemFile (org.openscience.cdk.interfaces.IChemFile)5 IChemModel (org.openscience.cdk.interfaces.IChemModel)5 IChemSequence (org.openscience.cdk.interfaces.IChemSequence)5 PDBPolymer (org.openscience.cdk.protein.data.PDBPolymer)4 SlowTest (org.openscience.cdk.test.SlowTest)4 SimpleChemObjectReaderTest (org.openscience.cdk.test.io.SimpleChemObjectReaderTest)4 IDescriptorResult (org.openscience.cdk.qsar.result.IDescriptorResult)3 IntegerArrayResult (org.openscience.cdk.qsar.result.IntegerArrayResult)3 AbstractBioPolymerTest (org.openscience.cdk.test.interfaces.AbstractBioPolymerTest)3 Hashtable (java.util.Hashtable)2 CDKException (org.openscience.cdk.exception.CDKException)2 IPDBAtom (org.openscience.cdk.interfaces.IPDBAtom)2