public override void TestGetMonomer_String_String() { IPDBPolymer pdbPolymer = (IPDBPolymer)NewChemObject(); IStrand oStrand1 = pdbPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; IStrand oStrand2 = pdbPolymer.Builder.NewStrand(); oStrand2.StrandName = "B"; IMonomer oMono1 = pdbPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = pdbPolymer.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IPDBAtom oPDBAtom1 = pdbPolymer.Builder.NewPDBAtom("C"); IPDBAtom oPDBAtom2 = pdbPolymer.Builder.NewPDBAtom("C"); IPDBAtom oPDBAtom3 = pdbPolymer.Builder.NewPDBAtom("C"); pdbPolymer.AddAtom(oPDBAtom1, oMono1, oStrand1); pdbPolymer.AddAtom(oPDBAtom2, oMono1, oStrand1); pdbPolymer.AddAtom(oPDBAtom3, oMono2, oStrand2); Assert.AreEqual(oMono1, pdbPolymer.GetMonomer("TRP279", "A")); Assert.AreEqual(oMono2, pdbPolymer.GetMonomer("HOH", "B")); }
public virtual void TestGetStrandNames() { IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject(); IStrand oStrand1 = oBioPolymer.Builder.NewStrand(); IStrand oStrand2 = oBioPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; oStrand2.StrandName = "B"; IMonomer oMono1 = oBioPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = oBioPolymer.Builder.NewMonomer(); oMono2.MonomerName = "GLY123"; IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C"); IAtom oAtom2 = oBioPolymer.Builder.NewAtom("C"); oBioPolymer.AddAtom(oAtom1, oMono1, oStrand1); oBioPolymer.AddAtom(oAtom2, oMono2, oStrand2); IDictionary <string, IStrand> strands = new Dictionary <string, IStrand> { { "A", oStrand1 }, { "B", oStrand2 } }; Assert.IsTrue(Compares.AreDeepEqual(strands.Keys, oBioPolymer.GetStrandNames())); }
public virtual void TestGetMonomerNames() { IPolymer oPolymer = (IPolymer)NewChemObject(); Assert.AreEqual(0, oPolymer.GetMonomerNames().Count()); IMonomer oMono1 = oPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = oPolymer.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IAtom oAtom1 = oPolymer.Builder.NewAtom("C"); IAtom oAtom2 = oPolymer.Builder.NewAtom("C"); IAtom oAtom3 = oPolymer.Builder.NewAtom("C"); oPolymer.Atoms.Add(oAtom1); oPolymer.AddAtom(oAtom2, oMono1); oPolymer.AddAtom(oAtom3, oMono2); IDictionary <string, IMonomer> monomers = new Dictionary <string, IMonomer> { //IMonomer oMon = Builder.NewMonomer(); { "TRP279", oMono1 }, { "HOH", oMono2 } }; Assert.AreEqual(2, oPolymer.GetMonomerNames().Count()); Assert.IsTrue(oPolymer.GetMonomerNames().Contains(oMono1.MonomerName)); Assert.IsTrue(oPolymer.GetMonomerNames().Contains(oMono2.MonomerName)); Assert.IsTrue(Compares.AreDeepEqual(monomers.Keys, oPolymer.GetMonomerNames())); }
public virtual void TestGetMonomer_String_String() { IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject(); IStrand oStrand1 = oBioPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; IStrand oStrand2 = oBioPolymer.Builder.NewStrand(); oStrand2.StrandName = "B"; IMonomer oMono1 = oBioPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = oBioPolymer.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C"); IAtom oAtom2 = oBioPolymer.Builder.NewAtom("C"); IAtom oAtom3 = oBioPolymer.Builder.NewAtom("C"); oBioPolymer.AddAtom(oAtom1, oMono1, oStrand1); oBioPolymer.AddAtom(oAtom2, oMono1, oStrand1); oBioPolymer.AddAtom(oAtom3, oMono2, oStrand2); Assert.AreEqual(oMono1, oBioPolymer.GetMonomer("TRP279", "A")); Assert.AreEqual(oMono2, oBioPolymer.GetMonomer("HOH", "B")); }
public void TestGetMonomerNamesInSequentialOrder() { PDBPolymer pdbPolymer = new PDBPolymer(); Assert.AreEqual(0, pdbPolymer.GetMonomerNames().Count()); IStrand oStrand1 = pdbPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; IMonomer oMono1 = pdbPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = pdbPolymer.Builder.NewMonomer(); oMono2.MonomerName = "CYS280"; IPDBAtom oPDBAtom2 = pdbPolymer.Builder.NewPDBAtom("C"); IPDBAtom oPDBAtom3 = pdbPolymer.Builder.NewPDBAtom("C"); pdbPolymer.AddAtom(oPDBAtom2, oMono1, oStrand1); pdbPolymer.AddAtom(oPDBAtom3, oMono2, oStrand1); Assert.IsNotNull(pdbPolymer.Atoms[0]); Assert.IsNotNull(pdbPolymer.Atoms[1]); Assert.AreEqual(oPDBAtom2, pdbPolymer.Atoms[0]); Assert.AreEqual(oPDBAtom3, pdbPolymer.Atoms[1]); var monomers = pdbPolymer.GetMonomerNamesInSequentialOrder().GetEnumerator(); monomers.MoveNext(); Assert.AreEqual("TRP279", monomers.Current); monomers.MoveNext(); Assert.AreEqual("CYS280", monomers.Current); }
public void AddAtom(IAtom oAtom, IMonomer oMonomer, IStrand oStrand) { int atomCount = Atoms.Count; // Add atom to AtomContainer base.Atoms.Add(oAtom); if (atomCount != base.Atoms.Count // OK, super did not yet contain the atom // Add atom to Strand (also adds the atom to the monomer). && oStrand != null) { oStrand.AddAtom(oAtom, oMonomer); // Same problem as above: better to throw nullpointer exception? if (!strands.ContainsKey(oStrand.StrandName)) { strands.Add(oStrand.StrandName, oStrand); } } // The reasoning above is: All Monomers have to belong to a Strand and // all atoms belonging to strands have to belong to a Monomer => ? // oMonomer != null and oStrand != null, oAtom is added to BioPolymer // and to oMonomer in oStrand ? oMonomer == null and oStrand != null, // oAtom is added to BioPolymer and default Monomer in oStrand ? // oMonomer != null and oStrand == null, oAtom is added to BioPolymer, // but not to a Monomer or Strand (especially good to maybe throw // exception in this case) ? oMonomer == null and oStrand == null, oAtom // is added to BioPolymer, but not to a Monomer or Strand }
public override void TestGetMonomerCount() { IPDBPolymer pdbPolymer = (IPDBPolymer)NewChemObject(); Assert.AreEqual(0, pdbPolymer.GetMonomerMap().Count()); IStrand oStrand1 = pdbPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; IStrand oStrand2 = pdbPolymer.Builder.NewStrand(); oStrand2.StrandName = "B"; IMonomer oMono1 = pdbPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = pdbPolymer.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IPDBAtom oPDBAtom1 = pdbPolymer.Builder.NewPDBAtom("C"); IPDBAtom oPDBAtom2 = pdbPolymer.Builder.NewPDBAtom("C"); IPDBAtom oPDBAtom3 = pdbPolymer.Builder.NewPDBAtom("C"); pdbPolymer.Add(oPDBAtom1); pdbPolymer.AddAtom(oPDBAtom2, oMono1, oStrand1); pdbPolymer.AddAtom(oPDBAtom3, oMono2, oStrand2); Assert.IsNotNull(pdbPolymer.Atoms[0]); Assert.IsNotNull(pdbPolymer.Atoms[1]); Assert.IsNotNull(pdbPolymer.Atoms[2]); Assert.AreEqual(oPDBAtom1, pdbPolymer.Atoms[0]); Assert.AreEqual(oPDBAtom2, pdbPolymer.Atoms[1]); Assert.AreEqual(oPDBAtom3, pdbPolymer.Atoms[2]); Assert.AreEqual(2, pdbPolymer.GetMonomerMap().Count()); }
public void TestNewMonomer() { IChemObjectBuilder builder = RootObject.Builder; IMonomer monomer = builder.NewMonomer(); Assert.IsNotNull(monomer); }
public virtual void TestAddAtom_IAtom_IMonomer() { IPolymer oPolymer = (IPolymer)NewChemObject(); IMonomer oMono1 = oPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = null; IAtom oAtom1 = oPolymer.Builder.NewAtom("C"); IAtom oAtom2 = oPolymer.Builder.NewAtom("C"); IAtom oAtom3 = oPolymer.Builder.NewAtom("C"); oPolymer.Atoms.Add(oAtom1); oPolymer.AddAtom(oAtom2, oMono1); oPolymer.AddAtom(oAtom3, oMono2); Assert.IsNotNull(oPolymer.Atoms[0]); Assert.IsNotNull(oPolymer.Atoms[1]); Assert.IsNotNull(oPolymer.Atoms[2]); Assert.AreEqual(oAtom1, oPolymer.Atoms[0]); Assert.AreEqual(oAtom2, oPolymer.Atoms[1]); Assert.AreEqual(oAtom3, oPolymer.Atoms[2]); Assert.AreEqual(3, oPolymer.Atoms.Count); Assert.AreEqual(1, oPolymer.GetMonomer("TRP279").Atoms.Count); Assert.AreEqual(1, oPolymer.GetMonomerMap().Count()); Assert.IsNotNull(oPolymer.GetMonomer("TRP279")); Assert.AreEqual(oMono1, oPolymer.GetMonomer("TRP279")); }
public virtual void TestGetMonomers() { IStrand oStrand = (IStrand)NewChemObject(); IMonomer oMono1 = oStrand.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = oStrand.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IAtom oAtom2 = oStrand.Builder.NewAtom("C"); IAtom oAtom3 = oStrand.Builder.NewAtom("C"); oStrand.AddAtom(oAtom2, oMono1); oStrand.AddAtom(oAtom3, oMono2); IDictionary <string, IMonomer> monomers = new Dictionary <string, IMonomer>(); IMonomer oMon = oStrand.Builder.NewMonomer(); oMon.MonomerName = ""; oMon.MonomerType = "Unknown"; monomers.Add("", oMon); monomers.Add("TRP279", oMono1); monomers.Add("HOH", oMono2); Assert.IsTrue(Compares.AreDeepEqual(monomers.Keys, oStrand.GetMonomerNames())); }
private CMLMolecule CDKPDBPolymerToCMLMolecule(IPDBPolymer pdbPolymer, bool setIDs) { var cmlMolecule = new CMLMolecule { Convention = "PDB", DictRef = "pdb:model" }; var mapS = pdbPolymer.GetStrandMap(); foreach (var key in mapS.Keys) { var strand = mapS[key]; var monomerNames = new List <string>(strand.GetMonomerNames()); monomerNames.Sort(); foreach (var name in monomerNames) { IMonomer monomer = strand.GetMonomer(name); CMLMolecule clmono = CDKMonomerToCMLMolecule(monomer, true); cmlMolecule.Add(clmono); } } return(cmlMolecule); }
public override void TestToString() { IStrand oStrand = (IStrand)NewChemObject(); IMonomer oMono1 = oStrand.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = oStrand.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IAtom oAtom2 = oStrand.Builder.NewAtom("C"); IAtom oAtom3 = oStrand.Builder.NewAtom("C"); oStrand.AddAtom(oAtom2, oMono1); oStrand.AddAtom(oAtom3, oMono2); IDictionary <string, IMonomer> monomers = new Dictionary <string, IMonomer>(); IMonomer oMon = oStrand.Builder.NewMonomer(); oMon.MonomerName = ""; oMon.MonomerType = "Unknown"; monomers.Add("", oMon); monomers.Add("TRP279", oMono1); monomers.Add("HOH", oMono2); string description = oStrand.ToString(); for (int i = 0; i < description.Length; i++) { Assert.IsTrue('\n' != description[i]); Assert.IsTrue('\r' != description[i]); } }
public virtual void TestSetMonomerType_String() { IMonomer oMonomer = (IMonomer)NewChemObject(); oMonomer.MonomerType = "TRP"; Assert.AreEqual("TRP", oMonomer.MonomerType); }
public virtual void TestSetMonomerName_String() { IMonomer m = (IMonomer)NewChemObject(); m.MonomerName = "TRP279"; Assert.AreEqual("TRP279", m.MonomerName); }
public override void TestGetStrands() { IPDBPolymer pdbPolymer = (IPDBPolymer)NewChemObject(); IStrand oStrand1 = pdbPolymer.Builder.NewStrand(); IStrand oStrand2 = pdbPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; oStrand2.StrandName = "B"; IMonomer oMono1 = pdbPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = pdbPolymer.Builder.NewMonomer(); oMono2.MonomerName = "GLY123"; IPDBAtom oPDBAtom1 = pdbPolymer.Builder.NewPDBAtom("C"); IPDBAtom oPDBAtom2 = pdbPolymer.Builder.NewPDBAtom("C"); pdbPolymer.AddAtom(oPDBAtom1, oMono1, oStrand1); pdbPolymer.AddAtom(oPDBAtom2, oMono2, oStrand2); IDictionary <string, IStrand> strands = new Dictionary <string, IStrand> { { "A", oStrand1 }, { "B", oStrand2 } }; Assert.IsTrue(Compares.AreDeepEqual(strands, pdbPolymer.GetStrandMap())); }
public override void TestToString() { IPolymer polymer = (IPolymer)NewChemObject(); IMonomer oMono1 = polymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = polymer.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IAtom oAtom2 = polymer.Builder.NewAtom("C"); IAtom oAtom3 = polymer.Builder.NewAtom("C"); polymer.AddAtom(oAtom2, oMono1); polymer.AddAtom(oAtom3, oMono2); IDictionary <string, IMonomer> monomers = new Dictionary <string, IMonomer> { { "TRP279", oMono1 }, { "HOH", oMono2 } }; string description = polymer.ToString(); for (int i = 0; i < description.Length; i++) { Assert.IsTrue('\n' != description[i]); Assert.IsTrue('\r' != description[i]); } }
public void TestBioPolymer() { IBioPolymer oBioPolymer = new BioPolymer(); Assert.IsNotNull(oBioPolymer); Assert.AreEqual(oBioPolymer.GetMonomerMap().Count(), 0); IStrand oStrand1 = oBioPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; IStrand oStrand2 = oBioPolymer.Builder.NewStrand(); oStrand2.StrandName = "B"; IMonomer oMono1 = oBioPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = oBioPolymer.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IMonomer oMono3 = oBioPolymer.Builder.NewMonomer(); oMono3.MonomerName = "GLYA16"; IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C"); IAtom oAtom2 = oBioPolymer.Builder.NewAtom("C"); IAtom oAtom3 = oBioPolymer.Builder.NewAtom("C"); IAtom oAtom4 = oBioPolymer.Builder.NewAtom("C"); IAtom oAtom5 = oBioPolymer.Builder.NewAtom("C"); oBioPolymer.Atoms.Add(oAtom1); oBioPolymer.AddAtom(oAtom2, oStrand1); oBioPolymer.AddAtom(oAtom3, oMono1, oStrand1); oBioPolymer.AddAtom(oAtom4, oMono2, oStrand2); oBioPolymer.AddAtom(oAtom5, oMono3, oStrand2); Assert.IsNotNull(oBioPolymer.Atoms[0]); Assert.IsNotNull(oBioPolymer.Atoms[1]); Assert.IsNotNull(oBioPolymer.Atoms[2]); Assert.IsNotNull(oBioPolymer.Atoms[3]); Assert.IsNotNull(oBioPolymer.Atoms[4]); Assert.AreEqual(oAtom1, oBioPolymer.Atoms[0]); Assert.AreEqual(oAtom2, oBioPolymer.Atoms[1]); Assert.AreEqual(oAtom3, oBioPolymer.Atoms[2]); Assert.AreEqual(oAtom4, oBioPolymer.Atoms[3]); Assert.AreEqual(oAtom5, oBioPolymer.Atoms[4]); Assert.IsNull(oBioPolymer.GetMonomer("0815", "A")); Assert.IsNull(oBioPolymer.GetMonomer("0815", "B")); Assert.IsNull(oBioPolymer.GetMonomer("0815", "")); Assert.IsNull(oBioPolymer.GetStrand("")); Assert.IsNotNull(oBioPolymer.GetMonomer("TRP279", "A")); Assert.AreEqual(oMono1, oBioPolymer.GetMonomer("TRP279", "A")); Assert.AreEqual(oBioPolymer.GetMonomer("TRP279", "A").Atoms.Count, 1); Assert.IsNotNull(oBioPolymer.GetMonomer("HOH", "B")); Assert.AreEqual(oMono2, oBioPolymer.GetMonomer("HOH", "B")); Assert.AreEqual(oBioPolymer.GetMonomer("HOH", "B").Atoms.Count, 1); Assert.AreEqual(oBioPolymer.GetStrand("B").Atoms.Count, 2); Assert.AreEqual(oBioPolymer.GetStrand("B").GetMonomerMap().Count(), 2); Assert.IsNull(oBioPolymer.GetStrand("C")); Assert.IsNotNull(oBioPolymer.GetStrand("B")); }
public override void TestClone() { IMonomer oMonomer = (IMonomer)NewChemObject(); object clone = oMonomer.Clone(); Assert.IsTrue(clone is IMonomer); Assert.AreNotSame(oMonomer, clone); }
/// <summary> Adds the atom oAtom to a specified Monomer. Additionally, it keeps /// record of the iCode. /// /// </summary> /// <param name="oAtom"> The atom to add /// </param> /// <param name="oMonomer"> The monomer the atom belongs to /// </param> public override void addAtom(IAtom oAtom, IMonomer oMonomer) { base.addAtom(oAtom, oMonomer); if (!sequentialListOfMonomers.Contains(oMonomer.MonomerName)) { sequentialListOfMonomers.Add(oMonomer.MonomerName); } }
/// <summary> /// Adds the atom oAtom to a specified Monomer. Additionally, it keeps /// record of the iCode. /// </summary> /// <param name="oAtom">The IPDBAtom to add</param> /// <param name="oMonomer">The monomer the atom belongs to</param> public void AddAtom(IPDBAtom oAtom, IMonomer oMonomer) { base.AddAtom(oAtom, oMonomer); if (!sequentialListOfMonomers.Contains(oMonomer.MonomerName)) { sequentialListOfMonomers.Add(oMonomer.MonomerName); } }
private Group TranslateCDKMonomer(IMonomer iMonomer) { // find type Type cdkType = iMonomer.GetType(); if (cdkType is AminoAcid) { AminoAcid amino = (AminoAcid)iMonomer; //AminoMonomer monomer = new AminoMonomer(); } return(null); }
public override void TestToString() { IMonomer oMonomer = (IMonomer)NewChemObject(); oMonomer.MonomerType = "TRP"; string description = oMonomer.ToString(); for (int i = 0; i < description.Length; i++) { Assert.IsTrue('\n' != description[i]); Assert.IsTrue('\r' != description[i]); } }
public override ICDKObject Clone(CDKObjectMap map) { var clone = (Strand)base.Clone(map); clone.monomers = new Dictionary <string, IMonomer>(); foreach (var pair in monomers) { string monomerName = pair.Key; IMonomer monomer = pair.Value; var clonedMonomer = (IMonomer)monomer.Clone(map); clone.monomers.Add(monomerName, clonedMonomer); } return(clone); }
public void TestStrand() { IStrand oStrand = new Strand(); Assert.IsNotNull(oStrand); Assert.AreEqual(oStrand.GetMonomerMap().Count(), 0); IMonomer oMono1 = oStrand.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = oStrand.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IMonomer oMono3 = oStrand.Builder.NewMonomer(); oMono3.MonomerName = "GLYA16"; IAtom oAtom1 = oStrand.Builder.NewAtom("C"); IAtom oAtom2 = oStrand.Builder.NewAtom("C"); IAtom oAtom3 = oStrand.Builder.NewAtom("C"); IAtom oAtom4 = oStrand.Builder.NewAtom("C"); IAtom oAtom5 = oStrand.Builder.NewAtom("C"); oStrand.AddAtom(oAtom1); oStrand.AddAtom(oAtom2); oStrand.AddAtom(oAtom3, oMono1); oStrand.AddAtom(oAtom4, oMono2); oStrand.AddAtom(oAtom5, oMono3); Assert.IsNotNull(oStrand.Atoms[0]); Assert.IsNotNull(oStrand.Atoms[1]); Assert.IsNotNull(oStrand.Atoms[2]); Assert.IsNotNull(oStrand.Atoms[3]); Assert.IsNotNull(oStrand.Atoms[4]); Assert.AreEqual(oAtom1, oStrand.Atoms[0]); Assert.AreEqual(oAtom2, oStrand.Atoms[1]); Assert.AreEqual(oAtom3, oStrand.Atoms[2]); Assert.AreEqual(oAtom4, oStrand.Atoms[3]); Assert.AreEqual(oAtom5, oStrand.Atoms[4]); Assert.IsNull(oStrand.GetMonomer("0815")); Assert.IsNotNull(oStrand.GetMonomer("")); Assert.IsNotNull(oStrand.GetMonomer("TRP279")); Assert.AreEqual(oMono1, oStrand.GetMonomer("TRP279")); Assert.AreEqual(oStrand.GetMonomer("TRP279").Atoms.Count, 1); Assert.IsNotNull(oStrand.GetMonomer("HOH")); Assert.AreEqual(oMono2, oStrand.GetMonomer("HOH")); Assert.AreEqual(oStrand.GetMonomer("HOH").Atoms.Count, 1); Assert.AreEqual(oStrand.GetMonomer("").Atoms.Count, 2); Assert.AreEqual(oStrand.Atoms.Count, 5); Assert.AreEqual(oStrand.GetMonomerMap().Count(), 3); }
public virtual void TestRemoveMonomer_String() { IStrand oStrand = (IStrand)NewChemObject(); IMonomer oMono1 = oStrand.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IAtom oAtom1 = oStrand.Builder.NewAtom("C"); oStrand.AddAtom(oAtom1, oMono1); Assert.IsTrue(oStrand.GetMonomerNames().Contains(oMono1.MonomerName)); Assert.AreEqual(1, oStrand.Atoms.Count); oStrand.RemoveMonomer("TRP279"); Assert.IsFalse(oStrand.GetMonomerNames().Contains(oMono1.MonomerName)); Assert.AreEqual(0, oStrand.Atoms.Count); }
public virtual void TestGetStrand_String() { IBioPolymer oBioPolymer = (IBioPolymer)NewChemObject(); IStrand oStrand1 = oBioPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; IMonomer oMono1 = oBioPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IAtom oAtom1 = oBioPolymer.Builder.NewAtom("C"); oBioPolymer.AddAtom(oAtom1, oMono1, oStrand1); Assert.AreEqual(oStrand1, oBioPolymer.GetStrand("A")); }
public override void TestGetStrand_String() { IPDBPolymer pdbPolymer = (IPDBPolymer)NewChemObject(); IStrand oStrand1 = pdbPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; IMonomer oMono1 = pdbPolymer.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IPDBAtom oPDBAtom1 = pdbPolymer.Builder.NewPDBAtom("C"); pdbPolymer.AddAtom(oPDBAtom1, oMono1, oStrand1); Assert.AreEqual(oStrand1, pdbPolymer.GetStrand("A")); }
/// <summary> /// Adds the atom oAtom to a specified Monomer. /// </summary> /// <param name="oAtom">The atom to add</param> /// <param name="oMonomer">The monomer the atom belongs to</param> public void AddAtom(IAtom oAtom, IMonomer oMonomer) { if (!Contains(oAtom)) { base.Atoms.Add(oAtom); // this calls notify if (oMonomer != null) { // Not sure what's better here...throw nullpointer exception? oMonomer.Atoms.Add(oAtom); if (!monomers.ContainsKey(oMonomer.MonomerName)) { monomers.Add(oMonomer.MonomerName, oMonomer); } } } }
public virtual void TestGetMonomerCount() { IStrand oStrand = (IStrand)NewChemObject(); IMonomer oMono1 = oStrand.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IMonomer oMono2 = oStrand.Builder.NewMonomer(); oMono2.MonomerName = "HOH"; IAtom oAtom2 = oStrand.Builder.NewAtom("C"); IAtom oAtom3 = oStrand.Builder.NewAtom("C"); oStrand.AddAtom(oAtom2, oMono1); oStrand.AddAtom(oAtom3, oMono2); Assert.AreEqual(2, oStrand.GetMonomerMap().Count()); }
public virtual void TestAddAtom_IAtom_IMonomer() { IStrand oStrand = (IStrand)NewChemObject(); IMonomer oMono1 = oStrand.Builder.NewMonomer(); oMono1.MonomerName = "TRP279"; IAtom oAtom1 = oStrand.Builder.NewAtom("C"); IAtom oAtom2 = oStrand.Builder.NewAtom("C"); IAtom oAtom3 = oStrand.Builder.NewAtom("C"); oStrand.AddAtom(oAtom1); oStrand.AddAtom(oAtom2); oStrand.AddAtom(oAtom3, oMono1); Assert.AreEqual(2, oStrand.GetMonomer("").Atoms.Count); Assert.AreEqual(1, oStrand.GetMonomer("TRP279").Atoms.Count); }
/// <summary> Adds the atom oAtom to a specified Monomer. Additionally, it keeps /// record of the iCode. /// /// </summary> /// <param name="oAtom"> The atom to add /// </param> /// <param name="oMonomer"> The monomer the atom belongs to /// </param> public override void addAtom(IAtom oAtom, IMonomer oMonomer) { base.addAtom(oAtom, oMonomer); if (!sequentialListOfMonomers.Contains(oMonomer.MonomerName)) sequentialListOfMonomers.Add(oMonomer.MonomerName); }
/// <summary> Adds the atom oAtom to a specified Monomer. /// /// </summary> /// <param name="oAtom"> The atom to add /// </param> /// <param name="oMonomer"> The monomer the atom belongs to /// </param> public virtual void addAtom(IAtom oAtom, IMonomer oMonomer) { if (!contains(oAtom)) { base.addAtom(oAtom); if (oMonomer != null) { // Not sure what's better here...throw nullpointer exception? oMonomer.addAtom(oAtom); if (!monomers.ContainsKey(oMonomer.MonomerName)) { monomers[oMonomer.MonomerName] = oMonomer; } } } /* notifyChanged() is called by addAtom in AtomContainer */ }
/// <summary> Adds the atom to a specified Strand and a specified Monomer. /// /// </summary> /// <param name="oAtom"> /// </param> /// <param name="oMonomer"> /// </param> /// <param name="oStrand"> /// </param> public virtual void addAtom(IAtom oAtom, IMonomer oMonomer, IStrand oStrand) { int atomCount = base.AtomCount; // Add atom to AtomContainer base.addAtom(oAtom); if (atomCount != base.AtomCount && oStrand != null) { oStrand.addAtom(oAtom, oMonomer); // Same problem as above: better to throw nullpointer exception? if (!strands.ContainsKey(oStrand.StrandName)) { strands[oStrand.StrandName] = oStrand; } } /* The reasoning above is: * All Monomers have to belong to a Strand and all atoms belonging to strands have to belong to a Monomer => * ? oMonomer != null and oStrand != null, oAtom is added to BioPolymer and to oMonomer in oStrand * ? oMonomer == null and oStrand != null, oAtom is added to BioPolymer and default Monomer in oStrand * ? oMonomer != null and oStrand == null, oAtom is added to BioPolymer, but not to a Monomer or Strand (especially good to maybe throw exception in this case) * ? oMonomer == null and oStrand == null, oAtom is added to BioPolymer, but not to a Monomer or Strand * */ }