Example #1
0
        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);
            }
        }