/// <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 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 */ }