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())); }
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 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 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); }
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 TestGetMonomer_String() { 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(oMono1, oStrand.GetMonomer("TRP279")); Assert.AreEqual(oMono2, oStrand.GetMonomer("HOH")); Assert.IsNull(oStrand.GetMonomer("TEST")); }
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); }
/// <summary> /// Adds the atom oAtom to a specified Strand, whereas the Monomer is unspecified. Hence /// the atom will be added to a Monomer of type Unknown in the specified Strand. /// </summary> /// <param name="oAtom">The atom to add</param> /// <param name="oStrand">The strand the atom belongs to</param> public void AddAtom(IAtom oAtom, IStrand oStrand) { int atomCount = base.Atoms.Count; // Add atom to AtomContainer base.Atoms.Add(oAtom); if (atomCount != base.Atoms.Count && oStrand != null) { // Maybe better to throw null pointer exception here, so user realises that // Strand == null and Atom only gets added to this BioPolymer, but not to a Strand. oStrand.AddAtom(oAtom); if (!strands.ContainsKey(oStrand.StrandName)) { strands.Add(oStrand.StrandName, oStrand); } } // NotifyChanged() is called by AddAtom in AtomContainer }