Esempio n. 1
0
        void GeneralQualitativeSequence(
            string nodeName, QualitativeSequenceParameters parameters)
        {
            // Gets the actual sequence and the alphabet from the Xml
            IAlphabet alphabet = Utility.GetAlphabet(utilityObj.xmlUtil.GetTextValue(
                                                         nodeName, Constants.AlphabetNameNode));
            FastQFormatType expectedFormatType = Utility.GetFastQFormatType(
                utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FastQFormatType));
            string expectedScore = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedScore);
            QualitativeSequence createdQualitativeSequence = null;
            string inputSequence = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.inputSequenceNode);
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequenceNode);
            string expectedSequenceCount = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.QSequenceCount);
            string expectedMaxScore = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.MaxScoreNode);
            string inputScore = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.InputScoreNode);
            string expectedOuptutScore = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.InputScoreNode);
            string inputQuality = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.InputByteArrayNode);

            byte[] byteArray       = ASCIIEncoding.ASCII.GetBytes(inputQuality);
            Byte[] inputScoreArray = encodingObj.GetBytes(inputQuality);


            // Create and validate Qualitative Sequence.
            switch (parameters)
            {
            case QualitativeSequenceParameters.Score:
                createdQualitativeSequence = new QualitativeSequence(alphabet, expectedFormatType,
                                                                     inputSequence, inputQuality);
                int count = 0;
                // Validate score
                foreach (byte qualScore in createdQualitativeSequence.QualityScores)
                {
                    Assert.AreEqual(qualScore, inputScoreArray[count]);
                    count++;
                }
                break;

            case QualitativeSequenceParameters.ByteArray:
                byte[] scoreValue = ASCIIEncoding.ASCII.GetBytes(inputSequence);
                int    index      = 0;
                createdQualitativeSequence = new QualitativeSequence(alphabet, expectedFormatType,
                                                                     scoreValue, inputScoreArray);

                // Validate score
                foreach (byte qualScore in createdQualitativeSequence.QualityScores)
                {
                    Assert.AreEqual(qualScore, inputScoreArray[index]);
                    index++;
                }
                break;

            default:
                break;
            }

            string qualitativeSequence = new string(createdQualitativeSequence.Select(a => (char)a).ToArray());

            // Validate createdSequence qualitative sequence.
            Assert.IsNotNull(createdQualitativeSequence);
            Assert.AreEqual(alphabet, createdQualitativeSequence.Alphabet);
            Assert.AreEqual(expectedSequence, qualitativeSequence);
            Assert.AreEqual(expectedSequenceCount, createdQualitativeSequence.Count.ToString((IFormatProvider)null));
            Assert.AreEqual(expectedScore, createdQualitativeSequence.QualityScores.Count().ToString((IFormatProvider)null));
            Assert.AreEqual(expectedFormatType, createdQualitativeSequence.FormatType);

            // Logs to the NUnit GUI (Console.Out) window
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "Qualitative Sequence BVT:Qualitative Sequence {0} is as expected.",
                                            qualitativeSequence));

            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "Qualitative Sequence BVT:Qualitative Sequence Score {0} is as expected.",
                                            createdQualitativeSequence.Count().ToString((IFormatProvider)null)));

            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "Qualitative Sequence BVT:Qualitative format type {0} is as expected.",
                                            createdQualitativeSequence.FormatType));
        }
        void GeneralQualitativeSequence(
            string nodeName, QualitativeSequenceParameters parameters)
        {
            //// Gets the actual sequence and the alphabet from the Xml
            IAlphabet alphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.AlphabetNameNode));
            FastQFormatType expectedFormatType = Utility.GetFastQFormatType(
                this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FastQFormatType));
            string expectedScore = this.utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedScore);
            QualitativeSequence createdQualitativeSequence = null;
            string inputSequence = this.utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.inputSequenceNode);
            string expectedSequence = this.utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequenceNode);
            string expectedSequenceCount = this.utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.QSequenceCount);           
            string inputQuality = this.utilityObj.xmlUtil.GetTextValue(
            nodeName, Constants.InputByteArrayNode);            
            Byte[] inputScoreArray = Encoding.UTF8.GetBytes(inputQuality);

            // Create and validate Qualitative Sequence.
            switch (parameters)
            {

                case QualitativeSequenceParameters.Score:
                    createdQualitativeSequence = new QualitativeSequence(alphabet, expectedFormatType,
                    inputSequence, inputQuality);
                    int count = 0;
                    // Validate score
                    foreach (byte qualScore in createdQualitativeSequence.GetEncodedQualityScores())
                    {
                        Assert.AreEqual(qualScore, inputScoreArray[count]);
                        count++;
                    }
                    break;
                case QualitativeSequenceParameters.ByteArray:
                    byte[] scoreValue = Encoding.UTF8.GetBytes(inputSequence);          
                    int index = 0;
                    createdQualitativeSequence = new QualitativeSequence(alphabet, expectedFormatType,
                    scoreValue, inputScoreArray);

                    // Validate score
                    foreach (byte qualScore in createdQualitativeSequence.GetEncodedQualityScores())
                    {
                        Assert.AreEqual(qualScore, inputScoreArray[index]);
                        index++;
                    }
                    break;
                default:
                    break;
            }

            string qualitativeSequence = new string(createdQualitativeSequence.Select(a => (char)a).ToArray());

            // Validate createdSequence qualitative sequence.
            Assert.IsNotNull(createdQualitativeSequence);
            Assert.AreEqual(alphabet, createdQualitativeSequence.Alphabet);

            Assert.AreEqual(expectedSequence, qualitativeSequence);
            Assert.AreEqual(expectedSequenceCount, createdQualitativeSequence.Count.ToString((IFormatProvider)null));
            ApplicationLog.WriteLine(string.Format(null, "Qualitative Sequence BVT:Qualitative Sequence {0} is as expected.", qualitativeSequence));

            Assert.AreEqual(expectedScore, createdQualitativeSequence.GetEncodedQualityScores().Count().ToString((IFormatProvider)null));
            ApplicationLog.WriteLine(string.Format(null, "Qualitative Sequence BVT:Qualitative Sequence Score {0} is as expected.", createdQualitativeSequence.Count().ToString((IFormatProvider)null)));

            Assert.AreEqual(expectedFormatType, createdQualitativeSequence.FormatType);
            ApplicationLog.WriteLine(string.Format(null, "Qualitative Sequence BVT:Qualitative format type {0} is as expected.", createdQualitativeSequence.FormatType));
        }