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 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 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 TestNewStrand() { IChemObjectBuilder builder = RootObject.Builder; IStrand strand = builder.NewStrand(); Assert.IsNotNull(strand); }
public override void TestClone() { IStrand strand = (IStrand)NewChemObject(); object clone = strand.Clone(); Assert.IsTrue(clone is IStrand); }
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 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 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 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 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 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")); }
/// <summary> /// Adds the IPDBAtom oAtom to a specified Monomer of a specified Strand. /// 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> /// <param name="oStrand"></param> public void AddAtom(IPDBAtom oAtom, IMonomer oMonomer, IStrand oStrand) { base.AddAtom(oAtom, oMonomer, oStrand); if (!sequentialListOfMonomers.Contains(oMonomer.MonomerName)) { sequentialListOfMonomers.Add(oMonomer.MonomerName); } }
public virtual void TestGetStrandName() { IStrand oStrand = (IStrand)NewChemObject(); oStrand.StrandName = "A"; Assert.AreEqual("A", oStrand.StrandName); }
public virtual void TestSetStrandType_String() { IStrand oStrand = (IStrand)NewChemObject(); oStrand.StrandType = "DNA"; Assert.AreEqual("DNA", oStrand.StrandType); }
/// <summary> Adds the atom oAtom to a specified Monomer of a specified Strand. /// 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, IStrand oStrand) { base.addAtom(oAtom, oMonomer, oStrand); if (!sequentialListOfMonomers.Contains(oMonomer.MonomerName)) { sequentialListOfMonomers.Add(oMonomer.MonomerName); } }
public override void TestAddAtom_IAtom() { IStrand oStrand = (IStrand)NewChemObject(); IAtom oAtom1 = oStrand.Builder.NewAtom("C"); IAtom oAtom2 = oStrand.Builder.NewAtom("C"); oStrand.Atoms.Add(oAtom1); oStrand.Atoms.Add(oAtom2); Assert.AreEqual(2, oStrand.Atoms.Count); }
public override ICDKObject Clone(CDKObjectMap map) { var clone = (BioPolymer)base.Clone(map); clone.strands = new Dictionary <string, IStrand>(); foreach (var strandPair in strands) { string name = strandPair.Key; IStrand original = strandPair.Value; IStrand cloned = (IStrand)original.Clone(map); clone.strands.Add(name, cloned); } return(clone); }
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")); }
public virtual void TestAddAtom_IPDBAtom_IMonomer() { IPDBPolymer pdbPolymer = (IPDBPolymer)NewChemObject(); IPDBMonomer oMono1 = pdbPolymer.Builder.NewPDBMonomer(); oMono1.MonomerName = "TRP279"; IStrand oStrand1 = pdbPolymer.Builder.NewStrand(); oStrand1.StrandName = "A"; IPDBAtom oPDBAtom1 = pdbPolymer.Builder.NewPDBAtom("C"); pdbPolymer.AddAtom(oPDBAtom1, oMono1, oStrand1); Assert.AreEqual(1, pdbPolymer.GetMonomer("TRP279", "A").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 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 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 TestAddAtom_IAtom_IMonomer_IStrand() { 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"); IAtom oAtom2 = oBioPolymer.Builder.NewAtom("C"); oBioPolymer.AddAtom(oAtom1, oMono1, oStrand1); oBioPolymer.AddAtom(oAtom2, oMono1, oStrand1); oBioPolymer.AddAtom(oAtom1, null, oStrand1); Assert.AreEqual(2, oBioPolymer.GetMonomer("TRP279", "A").Atoms.Count); Assert.AreEqual(0, oBioPolymer.GetMonomer("", "A").Atoms.Count); }
public override void TestRemoveStrand_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.IsTrue(pdbPolymer.GetStrandNames().Contains(oStrand1.StrandName)); Assert.AreEqual(1, pdbPolymer.Atoms.Count); pdbPolymer.RemoveStrand("A"); Assert.IsFalse(pdbPolymer.GetStrandNames().Contains(oStrand1.StrandName)); Assert.AreEqual(0, pdbPolymer.Atoms.Count); }
public virtual void TestRemoveStrand_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.IsTrue(oBioPolymer.GetStrandNames().Contains(oStrand1.StrandName)); Assert.AreEqual(1, oBioPolymer.Atoms.Count); oBioPolymer.RemoveStrand("A"); Assert.IsFalse(oBioPolymer.GetStrandNames().Contains(oStrand1.StrandName)); Assert.AreEqual(0, oBioPolymer.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 }
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")); }
/// <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 virtual void addAtom(IAtom oAtom, IStrand oStrand) { int atomCount = base.AtomCount; // Add atom to AtomContainer base.addAtom(oAtom); if (atomCount != base.AtomCount && oStrand != null) { // Maybe better to throw nullpointer 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.ContainsValue(oStrand.StrandName)) { strands[oStrand.StrandName] = oStrand; } } /* notifyChanged() is called by addAtom in * AtomContainer */ }
/// <summary> Adds the atom oAtom to a specified Monomer of a specified Strand. /// 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, IStrand oStrand) { base.addAtom(oAtom, oMonomer, oStrand); if (!sequentialListOfMonomers.Contains(oMonomer.MonomerName)) sequentialListOfMonomers.Add(oMonomer.MonomerName); }
/// <summary> /// Constructor /// </summary> /// <param name="aSessionId"> /// The unique identifier of the session that the tab is in. /// </param> /// <param name="aTabKey"> /// An identifier for this tab, unique within its session. /// </param> /// <param name="aListener"> /// A listener that will be notified about changes to the state of the /// event queue. Used to implement the "server health" app. /// Important: The event-handler will be invoked while some app-state /// locks are held. To avoid deadlock, it's a good idea to use /// TabStatusQueue to transfer the events to another thread. /// </param> /// <param name="aClock"> /// Provides access to the current UTC time. Production code should /// likely use ()=>DateTime.UtcNow, testing code will want more direct /// control over the perceived time. /// </param> /// <param name="aTimeoutPolicy"> /// Policy on how long to keep long polls alive and how long to /// keep a tab alive with no outstanding long poll. /// </param> /// <param name="aTimerThread"> /// Timer for scheduling maintenance work, such as checking for /// expired tabs and long polls. /// </param> /// <param name="aAppsStateThread"> /// The soft thread for scheduling all asynchronous work. When we /// get invoked from the timer thread, we dispatch back to this /// thread before touching any of our mutable state. /// </param> /// <param name="aSession"> /// Something that wants to know when a tab should expire due to /// inactivity. /// </param> /// <param name="aAppRecord"> /// AppRecord associated with the tab. /// </param> public ServerTab( string aSessionId, string aTabKey, ITabStatusListener aListener, Func<DateTime> aClock, ServerTabTimeoutPolicy aTimeoutPolicy, ITimerThread aTimerThread, IStrand aAppsStateThread, ISession aSession, AppRecord aAppRecord) { SessionId = aSessionId; iListener = aListener; iAppsStateThread = aAppsStateThread; iSession = aSession; iTimerThread = aTimerThread; iClock = aClock; iTimeoutPolicy = aTimeoutPolicy; TabKey = aTabKey; AppRecord = aAppRecord; iEventQueue = new JsonEventQueue(12000);// aEventQueue; iLastRead = iClock(); iTimerCallback = iTimerThread.RegisterCallback( ()=>iAppsStateThread.ScheduleExclusive(DoMaintenance)); RescheduleMaintenance(); }
/// <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 * */ }
/// <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 virtual void addAtom(IAtom oAtom, IStrand oStrand) { int atomCount = base.AtomCount; // Add atom to AtomContainer base.addAtom(oAtom); if (atomCount != base.AtomCount && oStrand != null) { // Maybe better to throw nullpointer 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.ContainsValue(oStrand.StrandName)) { strands[oStrand.StrandName] = oStrand; } } /* notifyChanged() is called by addAtom in AtomContainer */ }