/// <summary> /// Allows the sequence to function like an array, getting and setting /// the sequence item at the particular index specified. Note that the /// index value starts its count at 0. /// </summary> public ISequenceItem this[int index] { get { ISequenceItem item = Source[GetSourceIndex(index)]; // SparseSequence will return null if there is no sequence item present in the specified position. if (item == null) { return(null); } if (Complemented) { if (Alphabet == Alphabets.DNA) { return(Complementation.GetDnaComplement((Nucleotide)item)); } else { return(Complementation.GetRnaComplement((Nucleotide)item)); } } else { return(item); } } set { string message = Properties.Resource.NotSupportedInBasicDerivedSequence; Trace.Report(message); throw new NotSupportedException(message); } }
/// <summary> /// Gets or Sets the byte value of the sequence item at the given index /// </summary> /// <param name="index">Index of the item to retrieve</param> /// <returns>Byte value at the given index</returns> byte IList <byte> .this[int index] { get { if (Complemented) { if (UseEncoding) { return(Encoding.GetComplement((Source as IList <byte>)[GetSourceIndex(index)])); } else if (Alphabet == Alphabets.DNA) { return(Complementation.GetDnaComplement(Alphabet.LookupByValue((Source as IList <byte>)[GetSourceIndex(index)]) as Nucleotide).Value); } else if (Alphabet == Alphabets.RNA) { return(Complementation.GetRnaComplement(Alphabet.LookupByValue((Source as IList <byte>)[GetSourceIndex(index)]) as Nucleotide).Value); } } return((Source as IList <byte>)[GetSourceIndex(index)]); } set { throw new NotSupportedException(Properties.Resource.NotSupportedInBasicDerivedSequence); } }
/// <summary> /// Allows the sequence to function like an array, getting and setting /// the sequence item at the particular index specified. Note that the /// index value starts its count at 0. /// </summary> public ISequenceItem this[int index] { get { if (index < 0 || index >= Count) { throw new ArgumentOutOfRangeException( Properties.Resource.ParameterNameIndex, Properties.Resource.ParameterMustLessThanCount); } int sourceLength = Source.Count; int trueIndex = index; int start = RangeStart; // If RangeStart is negative then treat it as zero. if (start < 0) { start = 0; } // Get the true index (index of the source sequence). if (Reversed) { trueIndex = (start + Count - 1) - index; } else { trueIndex += start; } ISequenceItem item = Source[trueIndex]; // SparseSequence will return null if there is no sequence item present in the specified position. if (item == null) { return(null); } if (Complemented) { if (Alphabet == Alphabets.DNA) { return(Complementation.GetDnaComplement((Nucleotide)item)); } else { return(Complementation.GetRnaComplement((Nucleotide)item)); } } else { return(item); } } set { string message = "Modifying a source sequence through a derived sequence is not supported."; Trace.Report(message); throw new NotSupportedException(message); } }