Beispiel #1
0
 public void SnpParserPropertiesTest()
 {
     SimpleSnpParser snpParser = new SimpleSnpParser(Alphabets.DNA);
     Assert.AreEqual("Basic SNP Parser that uses XSV format", snpParser.Description);
     Assert.AreEqual("Basic SNP", snpParser.Name);
     Assert.IsTrue(snpParser.ParseAlleleOne);
     Assert.AreEqual(".tsv", snpParser.SupportedFileTypes);
 }
Beispiel #2
0
        public void SnpBvtParserProperties()
        {
            string filepath = utilityObj.xmlUtil.GetTextValue(Constants.SimpleSnpNodeName,
               Constants.FilePathNode);
            SimpleSnpParser snpParser = new SimpleSnpParser();
            Assert.AreEqual(Constants.SnpDescription, snpParser.Description);
            Assert.AreEqual(Constants.SnpFileTypes, snpParser.SupportedFileTypes);
            Assert.AreEqual(Constants.SnpName, snpParser.Name);
            Assert.IsTrue(snpParser.ParseAlleleOne);
            Assert.AreEqual(Constants.SnpFileTypes, snpParser.SupportedFileTypes);

            ApplicationLog.WriteLine
                ("Successfully validated all the properties of Snp Parser class.");
        }
Beispiel #3
0
        /// <summary>
        /// Snp parser generic method called by all the test cases 
        /// to validate the test case based on the parameters passed.
        /// </summary>
        /// <param name="switchParam">Additional parameter 
        /// based on which the validation of  test case is done.</param>
        void SnpParserGeneralTestCases(string switchParam)
        {
            Assert.IsTrue(File.Exists(snpFileName));

            IList<ISequence> seqList = null;
            SparseSequence sparseSeq = null;
            SimpleSnpParser parser = new SimpleSnpParser();

            string expectedPosition = "45162,72434,145160,172534,245162,292534";

            string[] expectedPositions = expectedPosition.Split(',');
            string[] expectedCharacters = null;

            switch (switchParam)
            {
                case "ParseAlleleTwo":
                    parser.ParseAlleleOne = false;
                    string expectedAlleleTwoSequence = "T,A,T,C,T,A";
                        
                    expectedCharacters = expectedAlleleTwoSequence.Split(',');
                    break;
                default:
                    string expectedSequence = "C,G,A,G,C,G";
                    expectedCharacters = expectedSequence.Split(',');
                    break;
            }

            seqList = parser.Parse(snpFileName).ToList();
                    sparseSeq = (SparseSequence)seqList[0];

            if (null == sparseSeq)
            {
                Assert.IsNotNull(seqList);
                Assert.AreEqual(1, seqList.Count);
            }

            for (int i = 0; i < expectedPositions.Length; i++)
            {
                byte item = sparseSeq[int.Parse(expectedPositions[i], null)];
                char s = (char)item;
                Assert.AreEqual(expectedCharacters[i], s.ToString());
            }

            Assert.IsNotNull(sparseSeq.Alphabet);
            Assert.AreEqual(sparseSeq.Alphabet.Name.ToLower(), AmbiguousDnaAlphabet.Instance.Name.ToLower());
            string expSequenceID = "Chr1";
            Assert.AreEqual(expSequenceID, sparseSeq.ID);
        }
Beispiel #4
0
        /// <summary>
        /// Snp parser generic method called by all the test cases 
        /// to validate the test case based on the parameters passed.
        /// </summary>
        /// <param name="nodename">Xml node Name.</param>
        /// <param name="additionalParam">Additional parameter 
        /// based on which the validation of  test case is done.</param>
        void SnpParserGeneralTestCases(string nodename, AdditionalParameters additionalParam)
        {
            // Gets the expected sequence from the Xml
            string filepath = utilityObj.xmlUtil.GetTextValue(nodename,
                Constants.FilePathNode);

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

            IList<ISequence> seqList = null;
            SparseSequence sparseSeq = null;
            SimpleSnpParser parser = new SimpleSnpParser();

            string expectedPosition = utilityObj.xmlUtil.GetTextValue(nodename,
                Constants.ExpectedPositionNode);

            string[] expectedPositions = expectedPosition.Split(',');
            string[] expectedCharacters = null;

            switch (additionalParam)
            {
                case AdditionalParameters.ParseAlleleTwo:
                    parser.ParseAlleleOne = false;
                    string expectedAlleleTwoSequence =
                        utilityObj.xmlUtil.GetTextValue(nodename,
                        Constants.ExpectedSequenceAllele2Node);
                    expectedCharacters = expectedAlleleTwoSequence.Split(',');
                    break;
                default:
                    string expectedSequence = utilityObj.xmlUtil.GetTextValue(nodename,
              Constants.ExpectedSequenceNode);
                    expectedCharacters = expectedSequence.Split(',');
                    break;
            }

            seqList = parser.Parse(filepath).ToList();
            sparseSeq = (SparseSequence)seqList[0];


            if (null == sparseSeq)
            {
                Assert.IsNotNull(seqList);
                Assert.AreEqual(1, seqList.Count);
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                    "Snp Parser BVT: Number of Sequences found are '{0}'.",
                    seqList.Count.ToString((IFormatProvider)null)));
            }

            for (int i = 0; i < expectedPositions.Length; i++)
            {
                byte item = sparseSeq[int.Parse(expectedPositions[i], (IFormatProvider)null)];

                ASCIIEncoding enc = new ASCIIEncoding();

                Assert.AreEqual(enc.GetBytes(expectedCharacters[i])[0].ToString((IFormatProvider)null),
                    item.ToString((IFormatProvider)null));
            }

            ApplicationLog.WriteLine(
                "Snp Parser BVT: The Snp sequence with position is validated successfully with Parse() method.");

            Assert.IsNotNull(sparseSeq.Alphabet);
            Assert.IsTrue(sparseSeq.Alphabet.Name.ToLower(CultureInfo.CurrentCulture).Contains(utilityObj.xmlUtil.GetTextValue(nodename,
                Constants.AlphabetNameNode).ToLower(CultureInfo.CurrentCulture)));

            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                "Snp Parser BVT: The Sequence Alphabet is '{0}' and is as expected.",
                sparseSeq.Alphabet.Name));

            string expSequenceID = utilityObj.xmlUtil.GetTextValue(nodename,
                Constants.SequenceIdNode);

            Assert.AreEqual(expSequenceID, sparseSeq.ID);
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                "Snp Parser BVT: The Sequence ID is '{0}' and is as expected.", sparseSeq.ID));
        }
Beispiel #5
0
        /// <summary>
        /// Snp parser generic method called by all the test cases to 
        /// validate the test case based on the parameters passed.
        /// </summary>
        /// <param name="nodename">Xml node Name.</param>
        /// <param name="additionalParam">Additional parameter based on which 
        /// the validation of  test case is done.</param>
        void SnpParserGeneralTestCases(string nodename,
            AdditionalParameters additionalParam)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(nodename,
                Constants.FilePathNode);

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

            IList<ISequence> seqList = null;
            SparseSequence sparseSeq = null;
            SimpleSnpParser parser = new SimpleSnpParser();

            switch (additionalParam)
            {
                case AdditionalParameters.ParseAlleleOne:
                    parser.ParseAlleleOne = true;
                    break;
                default:
                    break;
            }

            string noOfChromos = utilityObj.xmlUtil.GetTextValue(nodename,
                 Constants.NumberOfChromosomesNode);

            seqList = parser.Parse(filePath).ToList();
            sparseSeq = (SparseSequence)seqList[0];

            // Based on the number of chromosomes the validation is done reading from the xml
            if (0 == string.Compare(noOfChromos, "1", true, CultureInfo.CurrentCulture))
            {
                string expectedPosition = utilityObj.xmlUtil.GetTextValue(nodename,
               Constants.ExpectedPositionNode);

                string[] expectedPositions = expectedPosition.Split(',');
                string[] expectedCharacters = null;
                string expectedSequence = utilityObj.xmlUtil.GetTextValue(nodename,
                  Constants.ExpectedSequenceNode);

                expectedCharacters = expectedSequence.Split(',');

                Assert.IsNotNull(seqList);
                Assert.AreEqual(noOfChromos, seqList.Count.ToString((IFormatProvider)null));
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                    "Snp Parser P1: Number of Sequences found are '{0}'.",
                    seqList.Count.ToString((IFormatProvider)null)));

                // Validation of sequences with positions and xml is done in this section.
                for (int i = 0; i < expectedPositions.Length; i++)
                {
                    byte item = sparseSeq[int.Parse(expectedPositions[i], (IFormatProvider)null)];

                    Assert.AreEqual(encodingObj.GetBytes(expectedCharacters[i])[0].ToString((IFormatProvider)null),
                        item.ToString((IFormatProvider)null));
                }

                string expSequenceID = utilityObj.xmlUtil.GetTextValue(nodename,
                Constants.SequenceIdNode);

                Assert.AreEqual(expSequenceID, sparseSeq.ID);
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                    "Snp Parser P1: The Sequence ID is '{0}' and is as expected.", sparseSeq.ID));
            }
            else
            {
                string[] expectedPositions = utilityObj.xmlUtil.GetTextValues(nodename,
                    Constants.ExpectedPositionsNode);

                string[] expectedSequences = utilityObj.xmlUtil.GetTextValues(nodename,
                    Constants.ExpectedSequencesNode);

                string[] expectedSequenceIds = utilityObj.xmlUtil.GetTextValues(nodename,
                    Constants.SequenceIdsNode);

                // Validation of sequences with positions and xml is done in this section.
                for (int i = 0; i < int.Parse(noOfChromos, (IFormatProvider)null); i++)
                {
                    string[] expectedChromoPositions = expectedPositions[i].Split(',');
                    string[] expectedChromoSequences = expectedSequences[i].Split(',');

                    SparseSequence tempSparseSeq = (SparseSequence)seqList[i];

                    for (int j = 0; j < expectedChromoPositions.Length; j++)
                    {
                        byte item = tempSparseSeq[int.Parse(expectedChromoPositions[j], (IFormatProvider)null)];
                        Assert.AreEqual(encodingObj.GetBytes(expectedChromoSequences[j])[0].ToString((IFormatProvider)null),
                            item.ToString((IFormatProvider)null));
                    }

                    // Validation of Id are done in this section.
                    Assert.AreEqual(expectedSequenceIds[i], tempSparseSeq.ID);
                    ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                        "Snp Parser P1: The Sequence ID is '{0}' and is as expected.", tempSparseSeq.ID));
                }
            }

            ApplicationLog.WriteLine(
                "Snp Parser P1: The Snp sequence with position is validated successfully with Parse() method.");

            Assert.IsNotNull(sparseSeq.Alphabet);
            Assert.IsTrue(sparseSeq.Alphabet.Name.ToLower(CultureInfo.CurrentCulture).Contains(utilityObj.xmlUtil.GetTextValue(nodename,
                Constants.AlphabetNameNode).ToLower(CultureInfo.CurrentCulture)));

            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                "Snp Parser P1: The Sequence Alphabet is '{0}' and is as expected.",
                sparseSeq.Alphabet.Name));
        }