Esempio n. 1
0
 public void TestConvertFromSangerToIllumina()
 {
     byte[] bs;
     byte[] bs1 = new byte[2];
     bs1[0] = (byte)33;
     bs1[1] = (byte)33;
     bs     = QualitativeSequence.ConvertFromSangerToIllumina(bs1);
     Assert.IsNotNull((object)bs);
     Assert.AreEqual <int>(2, bs.Length);
     Assert.AreEqual <byte>((byte)64, bs[0]);
     Assert.AreEqual <byte>((byte)64, bs[1]);
 }
Esempio n. 2
0
 public void TestConvertFromSangerToIllumina()
 {
     byte[] illuminaScores;
     byte[] sangerScores = new byte[2];
     sangerScores[0] = (byte)33;
     sangerScores[1] = (byte)33;
     illuminaScores  = QualitativeSequence.ConvertFromSangerToIllumina(sangerScores);
     Assert.IsNotNull((object)illuminaScores);
     Assert.AreEqual <int>(2, illuminaScores.Length);
     Assert.AreEqual <byte>((byte)64, illuminaScores[0]);
     Assert.AreEqual <byte>((byte)64, illuminaScores[1]);
 }
Esempio n. 3
0
        public void ConvertSangerToSolexaAndIllumina()
        {
            // Gets the actual sequence and the Qual score from the Xml
            string sangerSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.SangerSequence);
            string expectedSolexaSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.SolexaSequence);
            string expectedIlluminaSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.IlluminaSequence);
            string sangerQualScore = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.SangerQualScore);
            string expectedSolexaQualScore = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.SolexaQualScore);
            string expectedIlluminaQualScore = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.IlluminaQualScore);

            //string solexaQualScore = null;
            //string illuminaQualScore = null;
            byte[] scoreValue = ASCIIEncoding.ASCII.GetBytes(sangerQualScore);

            // Create a Sanger qualitative sequence.
            //QualitativeSequence sangerQualSequence = new QualitativeSequence(
            //    Alphabets.DNA, FastQFormatType.Sanger, sangerSequence, scoreValue);

            //QualitativeSequence sangerQualSequence = new QualitativeSequence(*********************
            //    Alphabets.DNA, FastQFormatType.Sanger, sangerSequence, sangerQualScore);


            // Convert Sanger to Solexa.
            //QualitativeSequence solexaQualSequence = sangerQualSequence.ConvertTo(
            //    FastQFormatType.Solexa);

            byte[] sangerToSolexa = QualitativeSequence.ConvertFromSangerToSolexa(scoreValue);


            //solexaQualScore = ASCIIEncoding.ASCII.GetString(solexaQualSequence.Scores);

            // Validate converted solexa score.

            string qualSequence = new string(encodingObj.GetChars(sangerToSolexa));

            Assert.AreEqual(expectedSolexaQualScore, qualSequence);


            //Assert.AreEqual(solexaQualScore, expectedSolexaQualScore);

            //Assert.AreEqual(solexaQualSequence.ToString(), expectedSolexaSequence);



            //ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
            //    "Qualitative Sequence BVT:Qualitative Solexa score type {0} is as expected.",
            //    solexaQualScore));
            //Console.WriteLine(string.Format((IFormatProvider)null,
            //    "Qualitative Sequence BVT:Qualitative Solexa score type {0} is as expected.",
            //solexaQualSequence.ToString()));

            // Convert Sanger to Illumina.

            //QualitativeSequence illuminaQualSequence = sangerQualSequence.ConvertTo(
            //    FastQFormatType.Illumina);
            //illuminaQualScore = ASCIIEncoding.ASCII.GetString(illuminaQualSequence.Scores);

            byte[] sangerToIllumina = QualitativeSequence.ConvertFromSangerToIllumina(scoreValue);

            //// Validate converted illumina score.
            //Assert.AreEqual(illuminaQualScore, expectedIlluminaQualScore);
            //Assert.AreEqual(illuminaQualSequence.ToString(), expectedIlluminaSequence);

            string sangerToIlluminaString = new string(encodingObj.GetChars(sangerToIllumina));

            Assert.AreEqual(expectedIlluminaQualScore, sangerToIlluminaString);

            //ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
            //    "Qualitative Sequence BVT:Qualitative Illumina score type {0} is as expected.",
            //    illuminaQualScore));
            //Console.WriteLine(string.Format((IFormatProvider)null,
            //    "Qualitative Sequence BVT:Qualitative Illumina score type {0} is as expected.",
            //    illuminaQualSequence.ToString()));
        }
Esempio n. 4
0
        public void ConvertSangerToSolexaAndIllumina()
        {
            // Gets the actual sequence and the Qual score from the Xml
            string sangerSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.SangerSequence);
            string expectedSolexaSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.SolexaSequence);
            string expectedIlluminaSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.IlluminaSequence);
            string sangerQualScore = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.SangerQualScore);
            string expectedSolexaQualScore = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.SolexaQualScore);
            string expectedIlluminaQualScore = utilityObj.xmlUtil.GetTextValue(
                Constants.SangerToSolexaAndIlluminaNode, Constants.IlluminaQualScore);

            string solexaQualScore   = null;
            string illuminaQualScore = null;

            byte[] scoreValue = UTF8Encoding.UTF8.GetBytes(sangerQualScore);

            // Create a Sanger qualitative sequence.
            QualitativeSequence sangerQualSequence = new QualitativeSequence(Alphabets.DNA,
                                                                             FastQFormatType.Sanger, sangerSequence, sangerQualScore);

            // Convert Sanger to Solexa.
            QualitativeSequence solexaQualSequence = sangerQualSequence.ConvertTo(
                FastQFormatType.Solexa);

            byte[] sangerToSolexa = QualitativeSequence.ConvertFromSangerToSolexa(scoreValue);
            var    scores         = solexaQualSequence.QualityScores.ToArray();

            solexaQualScore = UTF8Encoding.UTF8.GetString(scores, 0, scores.Length);

            // Validate converted solexa score.

            string qualSequence = new string(UTF8Encoding.UTF8.GetChars(sangerToSolexa));

            Assert.AreEqual(expectedSolexaQualScore, qualSequence);
            Assert.AreEqual(solexaQualScore, expectedSolexaQualScore);

            string solexaQualString = new string(solexaQualSequence.Select(a => (char)a).ToArray());

            Assert.AreEqual(solexaQualString, expectedSolexaSequence);

            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Qualitative Sequence BVT:Qualitative Solexa score type {0} is as expected.",
                                                   solexaQualScore));
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "Qualitative Sequence BVT:Qualitative Solexa score type {0} is as expected.",
                                            solexaQualString));

            // Convert Sanger to Illumina.
            QualitativeSequence illuminaQualSequence = sangerQualSequence.ConvertTo(
                FastQFormatType.Illumina);

            scores            = illuminaQualSequence.QualityScores.ToArray();
            illuminaQualScore = UTF8Encoding.UTF8.GetString(scores, 0, scores.Length);

            byte[] sangerToIllumina = QualitativeSequence.ConvertFromSangerToIllumina(scoreValue);
            string illuminaQualSeq  = new string(illuminaQualSequence.Select(a => (char)a).ToArray());

            //// Validate converted illumina score.
            Assert.AreEqual(illuminaQualScore, expectedIlluminaQualScore);
            Assert.AreEqual(illuminaQualSeq, expectedIlluminaSequence);

            string sangerToIlluminaString = new string(UTF8Encoding.UTF8.GetChars(sangerToIllumina));

            Assert.AreEqual(expectedIlluminaQualScore, sangerToIlluminaString);

            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Qualitative Sequence BVT:Qualitative Illumina score type {0} is as expected.",
                                                   illuminaQualScore));
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "Qualitative Sequence BVT:Qualitative Illumina score type {0} is as expected.",
                                            illuminaQualSeq));
        }