/// <summary> /// Gets the value of the given INucleotide in the parent IGeneticCode. /// The INucleotide's value is determined by its index position in the IGeneticCode's /// list of INucleotides. /// /// The 0th INucleotide has a value of 0. /// The nth INucleotide has a value of n. /// </summary> /// <param name="nucleotide"></param> /// <returns></returns> protected int GetValueOfNucleotide(INucleotide nucleotide) { for (var i = 0; i < this.Parent.Nucleotides.Count; i++) if (this.Parent.Nucleotides.Values[i].Equals(nucleotide)) return i; throw new ValueNotYetSupported(nucleotide, typeof(INucleotide)); }
/// <summary> /// Creates an IGEPCodon for the given IFunctionPair and INucleotide Sequence. /// /// Adds the IGEPCodon to the IGEPGeneticCode. /// </summary> /// <param name="functionPair"></param> /// <param name="nucleotideSequence"></param> private void AddCodonFunctionPair(IFunctionPair functionPair, INucleotide[] nucleotideSequence, Action onCodonAdded = null) { var codon = new GEPCodon(geneticCode: this, codonIdentifier: new CodonIdentifier(nucleotideSequence.Select(n => n.Identifier.ToString()).ConcatContents()), codonType: CodonType.Standard, nucleotides: nucleotideSequence, functions: functionPair); this.AddCodon(codon); if (onCodonAdded != null) onCodonAdded(); }
/// <summary> /// Adds the specified INucleotide to the IGeneticCode. /// </summary> /// <param name="nucleotide"></param> public void AddNucleotide(INucleotide nucleotide) { this.Nucleotides.Add(key: nucleotide.Identifier, value: nucleotide); }
/// <summary> /// Gets the previous INucleotide before the given INucleotide. /// /// Returns null if the given INucleotide is the first INucleotide. /// </summary> /// <param name="currentNucleotide"></param> /// <returns></returns> public INucleotide GetPreviousNucleotide(INucleotide currentNucleotide) { for (var i = this.Nucleotides.Count - 1; i > 0; i--) { if (this.Nucleotides.Values[i].Equals(currentNucleotide)) return this.Nucleotides.Values[i - 1]; } return null; }
/// <summary> /// Gets the next INucleotide after the given INucleotide. /// /// Returns null if the given INucleotide is the last INucleotide. /// </summary> /// <param name="currentNucleotide"></param> /// <returns></returns> public INucleotide GetNextNucleotide(INucleotide currentNucleotide) { for (var i = 0; i < this.Nucleotides.Count; i++) { if (this.Nucleotides.Values[i].Equals(currentNucleotide)) return this.Nucleotides.Values[i + 1]; } return null; }
public int IndexOf(INucleotide item) { return this.Nucleotides.IndexOf(item: item); }
public void Insert(int index, INucleotide item) { this.Nucleotides.Insert(index: index, item: item); }
public void CopyTo(INucleotide[] array, int arrayIndex) { this.Nucleotides.CopyTo(array: array, arrayIndex: arrayIndex); }
public bool Remove(INucleotide item) { return this.Nucleotides.Remove(item: item); }
public bool Contains(INucleotide item) { return this.Nucleotides.Contains(item: item); }
public void Add(INucleotide item) { this.Nucleotides.Add(item: item); }
public bool Equals(INucleotide other) { return this.Identifier.Equals(other.Identifier); }
public int CompareTo(INucleotide other) { return this.Identifier.CompareTo(other.Identifier); }
public NucleotideEditorModel(INucleotide nucleotide, string geneticCodeName, int? geneticCodePrimaryKey) : base(nucleotide: nucleotide, geneticCodeName: geneticCodeName, geneticCodePrimaryKey: geneticCodePrimaryKey) { }