public void TestEditingWhenIsReadOnlyIsTrue() { QualitativeSequence qualSequence = new QualitativeSequence(Alphabets.RNA, FastQFormatType.Illumina, "ACUGGA", 65); Assert.IsTrue(qualSequence.IsReadOnly); try { qualSequence.Clear(); Assert.Fail(); } catch { Assert.AreEqual(qualSequence.Count, 6); } try { qualSequence.Add(Alphabets.RNA.AC); Assert.Fail(); } catch { Assert.AreEqual(qualSequence.Count, 6); } try { qualSequence.Remove(Alphabets.RNA.AC); Assert.Fail(); } catch { Assert.AreEqual(qualSequence.Count, 6); } try { qualSequence.Replace(0, Alphabets.RNA.AC.Symbol); Assert.Fail(); } catch { Assert.AreEqual(qualSequence.Count, 6); } }
public void AllEditableScenarios() { string filepathOriginal = @"TestData\FastQ\SRR002012_5.fastq"; FastQParser fastqParser = new FastQParser(); IList <IQualitativeSequence> qualitativeSequences; string[] expectedSequences = new string[] { "GGCGCACTTACACCCTACATCCATTG", "GTCTGCATTATCTACCAGCACTTCCC", "GCTGTCTTCCCGCTGTTTTATCCCCC", "GTAGTTTACCTGTTCATATGTTTCTG", "GGAAGGAAGAGGCTAGCCCAGCCTTT" }; fastqParser.EnforceDataVirtualization = true; fastqParser.AutoDetectFastQFormat = false; fastqParser.FastqType = FastQFormatType.Sanger; qualitativeSequences = fastqParser.Parse(filepathOriginal, true); int sequenceCount = qualitativeSequences.Count; for (int i = 0; i < sequenceCount; i++) { QualitativeSequence actualSequence = qualitativeSequences[i] as QualitativeSequence; actualSequence.IsReadOnly = false; ISequenceItem item = actualSequence[1]; actualSequence.Add(item); expectedSequences[i] += item.Symbol; Assert.AreEqual(expectedSequences[i], actualSequence.ToString()); actualSequence.Remove(item); int indexOfItem = expectedSequences[i].IndexOf(item.Symbol); expectedSequences[i] = expectedSequences[i].Remove(indexOfItem, 1); Assert.AreEqual(expectedSequences[i], actualSequence.ToString()); actualSequence.RemoveAt(0); expectedSequences[i] = expectedSequences[i].Remove(0, 1); Assert.AreEqual(expectedSequences[i], actualSequence.ToString()); actualSequence.RemoveRange(2, 5); expectedSequences[i] = expectedSequences[i].Remove(2, 5); Assert.AreEqual(expectedSequences[i], actualSequence.ToString()); actualSequence.Replace(0, 'C'); expectedSequences[i] = expectedSequences[i].Remove(0, 1); expectedSequences[i] = expectedSequences[i].Insert(0, "C"); Assert.AreEqual(expectedSequences[i], actualSequence.ToString()); actualSequence.ReplaceRange(5, "GG"); expectedSequences[i] = expectedSequences[i].Remove(5, 2); expectedSequences[i] = expectedSequences[i].Insert(5, "GG"); Assert.AreEqual(expectedSequences[i], actualSequence.ToString()); actualSequence.Insert(10, item); expectedSequences[i] = expectedSequences[i].Insert(10, item.Symbol.ToString()); Assert.AreEqual(expectedSequences[i], actualSequence.ToString()); actualSequence.InsertRange(2, "CC"); expectedSequences[i] = expectedSequences[i].Insert(2, "CC"); Assert.AreEqual(expectedSequences[i], actualSequence.ToString()); bool actualContainsValue = actualSequence.Contains(actualSequence[3]); bool expectedContainsValue = expectedSequences[i].Contains(actualSequence[3].Symbol.ToString()); Assert.AreEqual(actualContainsValue, expectedContainsValue); } }
public void TestEditingwhenIsReadOnlyIsFalse() { QualitativeSequence qualSequence = new QualitativeSequence(Alphabets.RNA, FastQFormatType.Illumina, "ACUGGA", 65); Assert.IsTrue(qualSequence.IsReadOnly); qualSequence.IsReadOnly = false; Assert.AreEqual(qualSequence.Count, 6); Assert.AreEqual(qualSequence.ToString(), "ACUGGA"); qualSequence.Clear(); Assert.AreEqual(qualSequence.Count, 0); Assert.AreEqual(qualSequence.Scores.Length, 0); qualSequence.Add(Alphabets.RNA.A, 65); Assert.AreEqual(qualSequence.Count, 1); Assert.AreEqual(qualSequence.Scores.Length, 1); Assert.AreSame(qualSequence[0], Alphabets.RNA.A); Assert.AreEqual(qualSequence.Scores[0], 65); qualSequence.Insert(0, Alphabets.RNA.G, 70); Assert.AreEqual(qualSequence.Count, 2); Assert.AreEqual(qualSequence.Scores.Length, 2); Assert.AreSame(qualSequence[0], Alphabets.RNA.G); Assert.AreSame(qualSequence[1], Alphabets.RNA.A); Assert.AreEqual(qualSequence.Scores[0], 70); Assert.AreEqual(qualSequence.Scores[1], 65); qualSequence.Replace(0, Alphabets.RNA.U, 75); Assert.AreEqual(qualSequence.Count, 2); Assert.AreEqual(qualSequence.Scores.Length, 2); Assert.AreSame(qualSequence[0], Alphabets.RNA.U); Assert.AreSame(qualSequence[1], Alphabets.RNA.A); Assert.AreEqual(qualSequence.Scores[0], 75); Assert.AreEqual(qualSequence.Scores[1], 65); qualSequence.Remove(Alphabets.RNA.C); Assert.AreEqual(qualSequence.Count, 2); Assert.AreEqual(qualSequence.Scores.Length, 2); Assert.AreSame(qualSequence[0], Alphabets.RNA.U); Assert.AreSame(qualSequence[1], Alphabets.RNA.A); Assert.AreEqual(qualSequence.Scores[0], 75); Assert.AreEqual(qualSequence.Scores[1], 65); qualSequence.Remove(Alphabets.RNA.A); Assert.AreEqual(qualSequence.Count, 1); Assert.AreEqual(qualSequence.Scores.Length, 1); Assert.AreSame(qualSequence[0], Alphabets.RNA.U); Assert.AreEqual(qualSequence.Scores[0], 75); qualSequence.Add(Alphabets.RNA.A, 65); Assert.AreEqual(qualSequence.Count, 2); Assert.AreEqual(qualSequence.Scores.Length, 2); Assert.AreSame(qualSequence[0], Alphabets.RNA.U); Assert.AreSame(qualSequence[1], Alphabets.RNA.A); Assert.AreEqual(qualSequence.Scores[0], 75); Assert.AreEqual(qualSequence.Scores[1], 65); qualSequence.RemoveAt(1); Assert.AreEqual(qualSequence.Count, 1); Assert.AreEqual(qualSequence.Scores.Length, 1); }