Пример #1
0
        public void FastQFormatter()
        {
            const string FilepathOriginal = @"TestUtils\FASTQ\SRR002012_5.fastq";

            Assert.IsTrue(File.Exists(FilepathOriginal));

            IList <IQualitativeSequence> seqsOriginal;
            string filepathTmp = Path.GetTempFileName();

            FastQParser parser = new FastQParser();

            using (parser.Open(FilepathOriginal))
            {
                // Read the original file
                seqsOriginal = parser.Parse().ToList();
                Assert.IsNotNull(seqsOriginal);

                // Use the formatter to write the original sequences to a temp file
                new FastQFormatter()
                .Format(seqsOriginal, filepathTmp);
            }

            // Read the new file, then compare the sequences
            using (parser.Open(filepathTmp))
            {
                IList <IQualitativeSequence> seqsNew = parser.Parse().ToList();
                Assert.IsNotNull(seqsNew);

                // Now compare the sequences.
                int countOriginal = seqsOriginal.Count();
                int countNew      = seqsNew.Count();
                Assert.AreEqual(countOriginal, countNew);

                int i;
                for (i = 0; i < countOriginal; i++)
                {
                    var orgSequence = seqsOriginal[i];
                    var sequence    = seqsNew[i];

                    Assert.AreEqual(seqsOriginal[i].ID, sequence.ID);
                    string orgSeq    = Encoding.ASCII.GetString(orgSequence.ToArray());
                    string newSeq    = Encoding.ASCII.GetString(sequence.ToArray());
                    string orgscores = Encoding.ASCII.GetString(orgSequence.GetEncodedQualityScores());
                    string newscores = Encoding.ASCII.GetString(sequence.GetEncodedQualityScores());
                    Assert.AreEqual(orgSeq, newSeq);
                    Assert.AreEqual(orgscores, newscores);
                }
            }

            // Passed all the tests, delete the tmp file. If we failed an Assert,
            // the tmp file will still be there in case we need it for debugging.
            File.Delete(filepathTmp);
        }
Пример #2
0
        public void FastQFormatter()
        {
            const string FilepathOriginal = @"TestUtils\FASTQ\SRR002012_5.fastq";
            Assert.IsTrue(File.Exists(FilepathOriginal));
            
            IList<IQualitativeSequence> seqsOriginal;
            string filepathTmp = Path.GetTempFileName();

            FastQParser parser = new FastQParser();
            using (parser.Open(FilepathOriginal))
            {
                // Read the original file
                seqsOriginal = parser.Parse().ToList();
                Assert.IsNotNull(seqsOriginal);

                // Use the formatter to write the original sequences to a temp file
                new FastQFormatter()
                    .Format(seqsOriginal, filepathTmp);
            }

            // Read the new file, then compare the sequences
            using (parser.Open(filepathTmp))
            {
                IList<IQualitativeSequence> seqsNew = parser.Parse().ToList();
                Assert.IsNotNull(seqsNew);

                // Now compare the sequences.
                int countOriginal = seqsOriginal.Count();
                int countNew = seqsNew.Count();
                Assert.AreEqual(countOriginal, countNew);

                int i;
                for (i = 0; i < countOriginal; i++)
                {
                    var orgSequence = seqsOriginal[i];
                    var sequence = seqsNew[i];

                    Assert.AreEqual(seqsOriginal[i].ID, sequence.ID);
                    string orgSeq = Encoding.ASCII.GetString(orgSequence.ToArray());
                    string newSeq = Encoding.ASCII.GetString(sequence.ToArray());
                    string orgscores = Encoding.ASCII.GetString(orgSequence.GetEncodedQualityScores());
                    string newscores = Encoding.ASCII.GetString(sequence.GetEncodedQualityScores());
                    Assert.AreEqual(orgSeq, newSeq);
                    Assert.AreEqual(orgscores, newscores);
                }
            }

            // Passed all the tests, delete the tmp file. If we failed an Assert,
            // the tmp file will still be there in case we need it for debugging.
            File.Delete(filepathTmp);

        }
Пример #3
0
        /// <summary>
        ///     General method to validate FastQ Parser.
        ///     <param name="nodeName">xml node name.</param>
        /// </summary>
        private void ValidateFastQParser(string nodeName)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string expectedQualitativeSequence = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequenceNode);
            string expectedSequenceId = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.SequenceIdNode);
            int expectedSeqCount = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeqsCount));

            // Parse a FastQ file.
            var fastQParserObj = new FastQParser();

            using (fastQParserObj.Open(filePath))
            {
                IList <IQualitativeSequence> qualSequenceList = fastQParserObj.Parse().ToList();

                // Validate qualitative Sequence upon parsing FastQ file.
                Assert.AreEqual(expectedSeqCount, qualSequenceList.Count);
                Assert.AreEqual(expectedQualitativeSequence, qualSequenceList[0].ConvertToString());
                Assert.AreEqual(expectedSequenceId, qualSequenceList[0].ID);

                ApplicationLog.WriteLine(string.Format("FastQ Parser BVT: The FASTQ sequence '{0}' validation after Parse() is found to be as expected.",
                                                       qualSequenceList[0].ConvertToString()));
                ApplicationLog.WriteLine(string.Format("FastQ Parser BVT: The FASTQ sequence ID '{0}' validation after Parse() is found to be as expected.",
                                                       qualSequenceList[0].ID));
            }
        }
Пример #4
0
        private void InValidateFastQFormatter(FastQFormatParameters param)
        {
            // Gets the expected sequence from the Xml
            string filepath = utilityObj.xmlUtil.GetTextValue(
                Constants.MultiSeqSangerRnaProNode, Constants.FilePathNode);

            // Parse a FastQ file.
            var fastQParser = new FastQParser();

            using (fastQParser.Open(filepath))
            {
                FastQFormatter fastQFormatter = null;

                switch (param)
                {
                case FastQFormatParameters.Sequence:
                    try
                    {
                        fastQFormatter = new FastQFormatter();
                        fastQFormatter.Format(null as ISequence, filepath);
                        Assert.Fail();
                    }
                    catch (ArgumentNullException)
                    {
                        fastQFormatter.Close();
                        ApplicationLog.WriteLine(
                            "FastQ Parser P2 : Successfully validated the exception");
                    }
                    break;

                default:
                    try
                    {
                        IEnumerable <IQualitativeSequence> sequence = fastQParser.Parse();
                        fastQFormatter = new FastQFormatter();
                        fastQFormatter.Format(sequence, null);
                        Assert.Fail();
                    }
                    catch (ArgumentNullException)
                    {
                        ApplicationLog.WriteLine("FastQ Parser P2 : Successfully validated the exception");
                    }
                    break;
                }
            }
        }
Пример #5
0
        /// <summary>
        ///     General method to validate FastQ Formatter.
        ///     <param name="nodeName">xml node name.</param>
        ///     <param name="fileExtension">Different temporary file extensions</param>
        /// </summary>
        private void ValidateFastQFormatter(string nodeName, FastQFileParameters fileExtension)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
            string expectedQualitativeSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequenceNode);
            string expectedSequenceId          = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceIdNode);
            string tempFileName = Path.GetTempFileName();

            // Parse a FastQ file using parseOne method.
            var fastQParserObj = new FastQParser();

            using (fastQParserObj.Open(filePath))
            {
                IQualitativeSequence oneSequence = fastQParserObj.ParseOne();

                // Format Parsed Sequence to temp file with different extension.
                var fastQFormatter = new FastQFormatter();
                using (fastQFormatter.Open(tempFileName))
                {
                    fastQFormatter.Format(oneSequence);
                }

                string parsedValue;
                string parsedId;

                var fastQParserObjTemp = new FastQParser();
                using (fastQParserObjTemp.Open(tempFileName))
                {
                    oneSequence = fastQParserObjTemp.Parse().First();
                    parsedValue = oneSequence.ConvertToString();
                    parsedId    = oneSequence.ID;
                }

                // Validate qualitative parsing temporary file.
                Assert.AreEqual(expectedQualitativeSequence, parsedValue);
                Assert.AreEqual(expectedSequenceId, parsedId);
                ApplicationLog.WriteLine(string.Format("FastQ Formatter BVT: The FASTQ sequence '{0}' validation after Write() and Parse() is found to be as expected.",
                                                       parsedValue));
                ApplicationLog.WriteLine(string.Format("FastQ Formatter BVT: The FASTQ sequence '{0}' validation after Write() and Parse() is found to be as expected.",
                                                       parsedId));

                File.Delete(tempFileName);
            }
        }
Пример #6
0
        public void TestFastQWhenParsingOneOfMany()
        {
            string filepath = @"TestUtils\FASTQ\SRR002012_5.fastq";
            
            // Parse
            ISequence seq = new FastQParser().ParseOne(filepath);
            Assert.IsNotNull(seq);

            FastQParser fqParser = new FastQParser
            {
                FormatType = FastQFormatType.Sanger, 
                Alphabet = Alphabets.DNA
            };
            using (fqParser.Open(filepath))
            {
                var qualSeq = fqParser.Parse().First() as QualitativeSequence;
                Assert.IsNotNull(qualSeq);
            }
        }
Пример #7
0
        public void TestFastQWhenParsingOneOfMany()
        {
            string filepath = @"TestUtils\FASTQ\SRR002012_5.fastq";

            // Parse
            ISequence seq = new FastQParser().ParseOne(filepath);

            Assert.IsNotNull(seq);

            FastQParser fqParser = new FastQParser
            {
                FormatType = FastQFormatType.Sanger,
                Alphabet   = Alphabets.DNA
            };

            using (fqParser.Open(filepath))
            {
                var qualSeq = fqParser.Parse().First() as QualitativeSequence;
                Assert.IsNotNull(qualSeq);
            }
        }
Пример #8
0
        private void InValidateFastQFormatter(FastQFormatParameters param)
        {
            // Gets the expected sequence from the Xml
            string filepath = utilityObj.xmlUtil.GetTextValue(
                Constants.MultiSeqSangerRnaProNode, Constants.FilePathNode);

            // Parse a FastQ file.
            var fastQParser = new FastQParser();
            using (fastQParser.Open(filepath))
            {
                FastQFormatter fastQFormatter = null;

                switch (param)
                {
                    case FastQFormatParameters.Sequence:
                        try
                        {
                            fastQFormatter = new FastQFormatter();
                            fastQFormatter.Format(null as ISequence, filepath);
                            Assert.Fail();
                        }
                        catch (ArgumentNullException)
                        {
                            fastQFormatter.Close();
                            ApplicationLog.WriteLine(
                                "FastQ Parser P2 : Successfully validated the exception");
                        }
                        break;
                    default:
                        try
                        {
                            IEnumerable<IQualitativeSequence> sequence = fastQParser.Parse();
                            fastQFormatter = new FastQFormatter();
                            fastQFormatter.Format(sequence, null);
                            Assert.Fail();
                        }
                        catch (ArgumentNullException)
                        {
                            ApplicationLog.WriteLine("FastQ Parser P2 : Successfully validated the exception");
                        }
                        break;
                }
            }
        }
Пример #9
0
        public void FastQFormatterUsingInterface()
        {
            string filepathOriginal = @"TestUtils\FASTQ\SRR002012_5.fastq";

            Assert.IsTrue(File.Exists(filepathOriginal));

            IList <QualitativeSequence> seqsOriginal = null;
            string filepathTmp = Path.GetTempFileName();

            using (FastQParser parser = new FastQParser())
            {
                parser.Open(filepathOriginal);

                // Read the original file
                seqsOriginal = parser.Parse().ToList();
                Assert.IsNotNull(seqsOriginal);

                // Use the formatter to write the original sequences to a temp file
                ISequenceFormatter formatter = null;
                try
                {
                    formatter = new FastQFormatter();
                    formatter.Open(filepathTmp);
                    foreach (ISequence s in seqsOriginal)
                    {
                        formatter.Write(s);
                    }

                    formatter.Close();
                }
                finally
                {
                    if (formatter != null)
                    {
                        ((FastQFormatter)formatter).Dispose();
                    }
                }
            }

            // Read the new file, then compare the sequences
            IList <QualitativeSequence> seqsNew = null;

            using (FastQParser parser = new FastQParser(filepathTmp))
            {
                seqsNew = parser.Parse().ToList();
                Assert.IsNotNull(seqsNew);

                // Now compare the sequences.
                int countOriginal = seqsOriginal.Count();
                int countNew      = seqsNew.Count();
                Assert.AreEqual(countOriginal, countNew);

                int i;
                for (i = 0; i < countOriginal; i++)
                {
                    Assert.AreEqual(seqsOriginal[i].ID, seqsNew[i].ID);
                    string orgSeq    = ASCIIEncoding.ASCII.GetString(seqsOriginal[i].ToArray());
                    string newSeq    = ASCIIEncoding.ASCII.GetString(seqsNew[i].ToArray());
                    string orgscores = ASCIIEncoding.ASCII.GetString(seqsOriginal[i].GetEncodedQualityScores());
                    string newscores = ASCIIEncoding.ASCII.GetString(seqsNew[i].GetEncodedQualityScores());
                    Assert.AreEqual(orgSeq, newSeq);
                    Assert.AreEqual(orgscores, newscores);
                }

                // Passed all the tests, delete the tmp file. If we failed an Assert,
                // the tmp file will still be there in case we need it for debugging.
                File.Delete(filepathTmp);
            }
        }
Пример #10
0
        /// <summary>
        ///     General method to validate multi sequence FastQ Format.
        /// </summary>
        /// <param name="nodeName">xml node name.</param>
        private void ValidateMultiSeqFastQFormatter(string nodeName)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
            string expectedQualitativeSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequenceNode);
            string expectedSequenceId = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceIdNode);
            string expectedSecondQualitativeSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequence2Node);
            string expectedSecondSeqID = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequenceId1Node);

            // Parse a FastQ file.
            var fastQParserObj = new FastQParser();
            using (fastQParserObj.Open(filePath))
            {
                var qualSequenceList = fastQParserObj.Parse().ToList();

                // Format a first Qualitative sequence
                new FastQFormatter().Format(qualSequenceList[0], Constants.FastQTempFileName);

                // Read it back
                var seqsNew = new FastQParser().Parse(Constants.FastQTempFileName).ToList();

                // Format a Second Qualitative sequence
                new FastQFormatter().Format(qualSequenceList[1], Constants.StreamWriterFastQTempFileName);
                var secondSeqsNew = new FastQParser().Parse(Constants.StreamWriterFastQTempFileName).ToList();

                // Validate Second qualitative Sequence upon parsing FastQ file.
                Assert.AreEqual(expectedSecondQualitativeSequence, secondSeqsNew[0].ConvertToString());
                Assert.AreEqual(expectedSecondSeqID, secondSeqsNew[0].ID);

                // Validate first qualitative Sequence upon parsing FastQ file.
                Assert.AreEqual(expectedQualitativeSequence, seqsNew[0].ConvertToString());
                Assert.AreEqual(expectedSequenceId, seqsNew[0].ID);

                ApplicationLog.WriteLine(string.Format("FastQ Parser P1: The FASTQ sequence '{0}' validation after Parse() is found to be as expected.", seqsNew[0]));

                File.Delete(Constants.FastQTempFileName);
                File.Delete(Constants.StreamWriterFastQTempFileName);
            }
        }
Пример #11
0
        private void ValidateFastQFormatter(string nodeName, bool writeMultipleSequences)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
            string expectedQualitativeSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequenceNode);
            string expectedSequenceId = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceIdNode);
            string tempFileName = Path.GetTempFileName();

            // Parse a FastQ file.
            var fastQParserObj = new FastQParser();
            using (fastQParserObj.Open(filePath))
            {
                IEnumerable<IQualitativeSequence> qualSequenceList = fastQParserObj.Parse();

                var fastQFormatter = new FastQFormatter();
                using (fastQFormatter.Open(tempFileName))
                {
                    if (writeMultipleSequences)
                    {
                        foreach (IQualitativeSequence newQualSeq in qualSequenceList)
                        {
                            fastQFormatter.Format(newQualSeq);
                        }
                    }                    
                    else
                    {
                        fastQFormatter.Format(qualSequenceList.First());
                    }
                } // temp file is closed.

                // Read the new file and validate the first Sequence.
                FastQParser fastQParserObjNew = new FastQParser();
                IQualitativeSequence firstSequence = fastQParserObjNew.ParseOne(tempFileName);

                // Validate qualitative Sequence upon parsing FastQ file.
                Assert.AreEqual(expectedQualitativeSequence, firstSequence.ConvertToString());
                Assert.AreEqual(expectedSequenceId, firstSequence.ID);

                ApplicationLog.WriteLine(string.Format("FastQ Parser P1: The FASTQ sequence '{0}' validation after Parse() is found to be as expected.", firstSequence));

                File.Delete(tempFileName);
            }
        }
Пример #12
0
        /// <summary>
        ///     General method to validate FastQ formatting
        ///     Qualitative Sequence by passing TextWriter as a parameter
        ///     <param name="nodeName">xml node name.</param>
        /// </summary>
        private void ValidateFastQFormatByFormattingQualSeqeunce(string nodeName)
        {
            // Gets the actual sequence and the alphabet from the Xml
            IAlphabet alphabet = Utility.GetAlphabet(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.AlphabetNameNodeV2));
            FastQFormatType expectedFormatType = Utility.GetFastQFormatType(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FastQFormatType));
            string qualSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequenceNode);
            string expectedQualitativeSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequenceNode);
            string qualityScores = "";
            int i;

            for (i = 0; i < qualSequence.Length; i++)
                qualityScores = qualityScores + "}";

            byte[] seq = Encoding.UTF8.GetBytes(qualSequence);
            byte[] qScore = Encoding.UTF8.GetBytes(qualityScores);
            string tempFileName = Path.GetTempFileName();

            // Create a Qualitative Sequence.
            var qualSeq = new QualitativeSequence(alphabet, expectedFormatType, seq, qScore);

            var formatter = new FastQFormatter();
            using (formatter.Open(tempFileName))
            {
                formatter.Format(qualSeq);
                formatter.Close();

                var fastQParserObj = new FastQParser();
                using (fastQParserObj.Open(tempFileName))
                {
                    // Read the new file and validate Sequences.
                    var seqsNew = fastQParserObj.Parse();
                    var firstSequence = seqsNew.First();

                    // Validate qualitative Sequence upon parsing FastQ file.
                    Assert.AreEqual(expectedQualitativeSequence, firstSequence.ConvertToString());
                    Assert.IsTrue(string.IsNullOrEmpty(firstSequence.ID));

                    ApplicationLog.WriteLine(string.Format("FastQ Parser P1: The FASTQ sequence '{0}' validation after Parse() is found to be as expected.", firstSequence));
                }

                File.Delete(tempFileName);
            }
        }
Пример #13
0
        /// <summary>
        ///     General method to validate FastQ Parser for Multiple sequence with
        ///     different alphabets.
        ///     <param name="nodeName">xml node name.</param>
        ///     <param name="triSeq">Tri Sequence</param>
        /// </summary>
        private void ValidateMulitpleSequenceFastQParser(string nodeName, string triSeq)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
            string expectedFirstQualitativeSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequence1Node);
            string expectedSecondQualitativeSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequence2Node);
            string expectedthirdQualitativeSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequence3Node);
            string expectedSequenceId = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceIdNode);
            int expectedSeqCount = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeqsCount));

            // Parse a multiple sequence FastQ file.
            var fastQParserObj = new FastQParser();
            using (fastQParserObj.Open(filePath))
            {
                IList<IQualitativeSequence> qualSequenceList = fastQParserObj.Parse().ToList();

                // Validate first qualitative Sequence upon parsing FastQ file.
                Assert.AreEqual(expectedSeqCount, qualSequenceList.Count);
                Assert.AreEqual(expectedFirstQualitativeSequence, qualSequenceList[0].ConvertToString());
                Assert.AreEqual(expectedSequenceId, qualSequenceList[0].ID);

                // Validate second qualitative Sequence upon parsing FastQ file.
                Assert.AreEqual(expectedSecondQualitativeSequence, qualSequenceList[1].ConvertToString());
                Assert.AreEqual(expectedSequenceId, qualSequenceList[1].ID);

                // Validate third sequence in FastQ file if it is tri sequence FastQ file.
                if (0 == string.Compare(triSeq, "MultiSequenceFastQ", CultureInfo.CurrentCulture, CompareOptions.IgnoreCase))
                {
                    // Validate second qualitative Sequence upon parsing FastQ file.
                    Assert.AreEqual(expectedthirdQualitativeSequence, qualSequenceList[2].ConvertToString());
                    Assert.AreEqual(expectedSequenceId, qualSequenceList[2].ID);
                }

                ApplicationLog.WriteLine(string.Format("FastQ Parser P1: The FASTQ sequence '{0}' validation after Parse() is found to be as expected.",
                                                       qualSequenceList[0]));
            }
        }
Пример #14
0
        /// <summary>
        ///     General method to validate FastQ Formatter on a Stream.
        ///     <param name="nodeName">xml node name.</param>
        /// </summary>
        private void ValidateFastQFormatterOnAStream(string nodeName)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);
            string expectedQualitativeSequence = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ExpectedSequenceNode);
            string expectedSequenceId = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceIdNode);
            string tempFileName1 = Path.GetTempFileName();

            // Parse a FastQ file using parseOne method.
            var fastQParserObj = new FastQParser();
            using (fastQParserObj.Open(filePath))
            {
                var oneSequence = fastQParserObj.ParseOne();

                // New Sequence after formatting file.                
                var fastQFormatter = new FastQFormatter();
                using (fastQFormatter.Open(tempFileName1))
                    fastQFormatter.Format(oneSequence);

                var fastQParserObjTemp = new FastQParser();
                string parsedValue, parsedId;
                using (fastQParserObjTemp.Open(tempFileName1))
                {
                    oneSequence = fastQParserObjTemp.Parse().First();
                    parsedValue = oneSequence.ConvertToString();
                    parsedId = oneSequence.ID;
                }

                // Validate qualitative parsing temporary file.                
                Assert.AreEqual(expectedQualitativeSequence, parsedValue);
                Assert.AreEqual(expectedSequenceId, parsedId);
                ApplicationLog.WriteLine(string.Format("FastQ Formatter BVT: The FASTQ sequence '{0}' validation after Write() and Parse() is found to be as expected.", parsedValue));
                ApplicationLog.WriteLine(string.Format("FastQ Formatter BVT: The FASTQ sequence '{0}' validation after Write() and Parse() is found to be as expected.", parsedId));

                File.Delete(tempFileName1);
            }
        }
Пример #15
0
        /// <summary>
        ///     General method to validate FastQ Parser.
        ///     <param name="nodeName">xml node name.</param>
        /// </summary>
        private void ValidateFastQParser(string nodeName)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string expectedQualitativeSequence = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequenceNode);
            string expectedSequenceId = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.SequenceIdNode);
            int expectedSeqCount = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SeqsCount));

            // Parse a FastQ file.
            var fastQParserObj = new FastQParser();
            using (fastQParserObj.Open(filePath))
            {
                IList<IQualitativeSequence> qualSequenceList = fastQParserObj.Parse().ToList();

                // Validate qualitative Sequence upon parsing FastQ file.                                                
                Assert.AreEqual(expectedSeqCount, qualSequenceList.Count);
                Assert.AreEqual(expectedQualitativeSequence, qualSequenceList[0].ConvertToString());
                Assert.AreEqual(expectedSequenceId, qualSequenceList[0].ID);

                ApplicationLog.WriteLine(string.Format("FastQ Parser BVT: The FASTQ sequence '{0}' validation after Parse() is found to be as expected.",
                                                       qualSequenceList[0].ConvertToString()));
                ApplicationLog.WriteLine(string.Format("FastQ Parser BVT: The FASTQ sequence ID '{0}' validation after Parse() is found to be as expected.",
                                                       qualSequenceList[0].ID));
            }
        }