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"));
}
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;
}
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));
}
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));
}
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));
}
Aggregations