コード例 #1
0
        public void GffParserValidateParseWithOneLineFeatures()
        {
            // Gets the expected sequence from the Xml
            string filePath = Utility._xmlUtil.GetTextValue(
                Constants.SimpleGffFeaturesNode,
                Constants.FilePathNode);

            Assert.IsTrue(File.Exists(filePath));
            IList <ISequence>   seqs      = null;
            BasicSequenceParser parserObj = new GffParser(Encodings.Ncbi4NA);

            seqs = parserObj.Parse(filePath);
            Sequence originalSequence = (Sequence)seqs[0];

            bool val = ValidateFeatures(originalSequence,
                                        Constants.OneLineSeqGffNodeName);

            Assert.IsTrue(val);

            filePath = Utility._xmlUtil.GetTextValue(
                Constants.SimpleGffFeaturesReaderNode,
                Constants.FilePathNode);

            using (StreamReader reader = File.OpenText(filePath))
            {
                seqs.Add(parserObj.ParseOne(reader));
            }

            originalSequence = (Sequence)seqs[0];

            val = ValidateFeatures(originalSequence,
                                   Constants.OneLineSeqGffNodeName);

            Assert.IsTrue(val);
            ApplicationLog.WriteLine(
                "GFF Parser BVT : All the features validated successfully.");
            Console.WriteLine(
                "GFF Parser BVT : All the features validated successfully.");
        }
コード例 #2
0
        /// <summary>
        /// Parses all test cases related to ParseOne() method based on the
        /// parameters passed and validates the same.
        /// </summary>
        /// <param name="nodeName">Xml Node name to be read.</param>
        /// <param name="isFilePath">Is file path passed as parameter?</param>
        static void ValidateParseOneGeneralTestCases(string nodeName,
                                                     bool isFilePath)
        {
            // Gets the expected sequence from the Xml
            string filePath = Utility._xmlUtil.GetTextValue(nodeName,
                                                            Constants.FilePathNode);

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

            // Logs information to the log file
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Gff Parser BVT : File Exists in the Path '{0}'.", filePath));

            ISequence originalSeq = null;
            GffParser parserObj   = new GffParser();

            if (isFilePath)
            {
                originalSeq = parserObj.ParseOne(filePath);
            }
            else
            {
                using (StreamReader reader = File.OpenText(filePath))
                {
                    originalSeq = parserObj.ParseOne(reader);
                }
            }

            Assert.IsNotNull(originalSeq);
            Assert.IsTrue(ValidateFeatures(originalSeq, nodeName));
            ApplicationLog.WriteLine(
                "Gff Parser BVT : Successfully validated all the Features for a give Sequence in GFF File.");
            Console.WriteLine(
                "Gff Parser BVT : Successfully validated all the Features for a give Sequence in GFF File.");

            string expectedSequence = Utility._xmlUtil.GetTextValue(nodeName,
                                                                    Constants.ExpectedSequenceNode);

            Sequence seq = (Sequence)originalSeq;

            Assert.IsNotNull(seq);
            Assert.AreEqual(expectedSequence, seq.ToString());
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Gff Parser BVT: The Gff sequence '{0}' validation after ParseOne() is found to be as expected.",
                                                   seq.ToString()));

            // Logs to the NUnit GUI (Console.Out) window
            Console.WriteLine(string.Format(null,
                                            "Gff Parser BVT: The Gff sequence '{0}' validation after ParseOne() is found to be as expected.",
                                            seq.ToString()));

            Assert.AreEqual(expectedSequence.Length, seq.EncodedValues.Length);
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Gff Parser BVT: The Gff Length sequence '{0}' is as expected.",
                                                   expectedSequence.Length));

            string expectedAlphabet = Utility._xmlUtil.GetTextValue(nodeName,
                                                                    Constants.AlphabetNameNode).ToLower(CultureInfo.CurrentCulture);

            Assert.IsNotNull(seq.Alphabet);
            Assert.AreEqual(seq.Alphabet.Name.ToLower(CultureInfo.CurrentCulture),
                            expectedAlphabet);
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Gff Parser BVT: The Sequence Alphabet is '{0}' and is as expected.",
                                                   seq.Alphabet.Name));

            string expectedSequenceId = Utility._xmlUtil.GetTextValue(nodeName,
                                                                      Constants.SequenceIdNode);

            Assert.AreEqual(expectedSequenceId, seq.DisplayID);
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Gff Parser BVT: The Sequence ID is '{0}' and is as expected.",
                                                   seq.DisplayID));
            // Logs to the NUnit GUI (Console.Out) window
            Console.WriteLine(string.Format(null,
                                            "Gff Parser BVT: The Sequence ID is '{0}' and is as expected.",
                                            seq.DisplayID));
        }