Ejemplo n.º 1
0
        public void InvalidateBioHPCBlastHandler()
        {
            try
            {
                IBlastServiceHandler handler = new BioHPCBlastHandler(null, new ConfigParameters());
                Assert.Fail();
            }
            catch (ArgumentNullException anex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentNullException : " + anex.Message);
            }

            try
            {
                IBlastParser         blastXmlParser = new BlastXmlParser();
                IBlastServiceHandler handler        = new BioHPCBlastHandler(blastXmlParser, null);
                Assert.Fail();
            }
            catch (ArgumentNullException anex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentNullException : " + anex.Message);
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Creates a sparse sequence and inserts sequence items of alphabet.
        /// Creates copy of sparse sequence object using clone() method.
        /// and Validates if copy of sparse sequence is as expected.
        /// </summary>
        /// <param name="alphabet">alphabet instance.</param>
        private void ValidateSparseSequenceCopy(IAlphabet alphabet)
        {
            SparseSequence sparseSequence = CreateSparseSequence(alphabet, 15);
            SparseSequence sparseSeqCopy  = sparseSequence.Clone();

            // Retrieve all stored sequence items and validate Sparse Sequence
            int retrieveIndex = 15;

            foreach (ISequenceItem item in alphabet)
            {
                // Validate new added items
                Assert.IsTrue(sparseSeqCopy.Contains(item));
                Assert.AreEqual(sparseSeqCopy.IndexOf(item), retrieveIndex);
                Assert.AreEqual(item, sparseSeqCopy[retrieveIndex]);
                Assert.AreEqual(item.Symbol, sparseSeqCopy[retrieveIndex].Symbol);
                retrieveIndex++;
            }

            Console.WriteLine(
                "SparseSequenceBVT: Validation of copy of sparse sequence object is completed");
            ApplicationLog.WriteLine(
                "SparseSequenceBVT:  Validation of copy of sparse sequence object is completed");
        }
Ejemplo n.º 3
0
        public void ValidateMoreThanTwelveCharsDnaComplementation()
        {
            // Get Node values from XML.
            string alphabetName = utilityObj.xmlUtil.GetTextValue(
                Constants.SimpleDnaAlphabetNode, Constants.AlphabetNameNode);
            string expectedSeq = utilityObj.xmlUtil.GetTextValue(
                Constants.ComplementNode, Constants.DnaSymbol);
            string expectedComplement = utilityObj.xmlUtil.GetTextValue(
                Constants.ComplementNode, Constants.DnaSymbolComplement);
            ISequence complement = null;

            Sequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Complement DNA Sequence.
            complement = seq.GetComplementedSequence();

            // Validate Complement for a given sequence.
            Assert.AreEqual(new string(complement.Select(a => (char)a).ToArray()), expectedComplement);
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Translation P1: Complement {0} is expected.", complement));
            ApplicationLog.WriteLine(
                "Translation P1: Complement of More than twelve DNA characters sequence was validate successfully.");
        }
Ejemplo n.º 4
0
        public void ValidateDnaComplementation()
        {
            // Get Node values from XML.
            string alphabetName = this.utilityObj.xmlUtil.GetTextValue(
                Constants.SimpleDnaAlphabetNode, Constants.AlphabetNameNode);
            string expectedSeq = this.utilityObj.xmlUtil.GetTextValue(
                Constants.ComplementNode, Constants.DnaSequence);
            string expectedComplement = this.utilityObj.xmlUtil.GetTextValue(
                Constants.ComplementNode, Constants.DnaComplement);
            ISequence complement = null;

            var seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Complement DNA Sequence.
            complement = seq.GetComplementedSequence();

            // Validate Complement.
            Assert.AreEqual(new string(complement.Select(a => (char)a).ToArray()), expectedComplement);
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Translation BVT: Complement {0} is expected.", seq));
            ApplicationLog.WriteLine(
                "Translation BVT: Complement of DNA sequence was validate successfully.");
        }
Ejemplo n.º 5
0
        public void ValidateRnaSparseSequenceConstAlpIndexByteList()
        {
            byte[] byteArrayObj = Encoding.ASCII.GetBytes("AGCU");

            IEnumerable <byte> seqItems =
                new List <Byte> {
                byteArrayObj[0], byteArrayObj[1], byteArrayObj[2], byteArrayObj[3]
            };

            var sparseSeq = new SparseSequence(Alphabets.RNA, 4, seqItems);

            Assert.IsNotNull(sparseSeq);
            Assert.IsNotNull(sparseSeq.Statistics);
            Assert.AreEqual(8, sparseSeq.Count);
            SequenceStatistics seqStatObj = sparseSeq.Statistics;

            Assert.AreEqual(1, seqStatObj.GetCount('A'));
            Assert.AreEqual(1, seqStatObj.GetCount('G'));
            Assert.AreEqual(1, seqStatObj.GetCount('C'));
            Assert.AreEqual(1, seqStatObj.GetCount('U'));

            ApplicationLog.WriteLine("SparseSequence P1: Validation of SparseSequence(alp, index, seq items) constructor is completed");
        }
Ejemplo n.º 6
0
        public void ValidateOperatorOutputFile()
        {
            OutputFile outputFile = null;
            string     filename   = Path.GetTempFileName();

            using (File.Create(filename)) { };
            FileInfo fileinfo = new FileInfo(filename);

            try
            {
                outputFile = fileinfo;
                Assert.IsNotNull(outputFile, "OutputFile BVT: OutputFile Operator OutputFile Validated successfully");
                fileinfo   = null;
                outputFile = fileinfo;
                Assert.IsNull(outputFile, "OutputFile BVT: OutputFile Operator OutputFile Validated successfully");
            }
            catch (Exception ex)
            {
                ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                       "OutputFile BVT: OutputFile OutputFile not validated successfully:", ex.Message));
                Assert.Fail("OutputFile BVT: OutputFile OutputFile not validated successfully");
            }
        }
Ejemplo n.º 7
0
        public void ValidateMoreThanTwelveCharsDnaReverseTranscribe()
        {
            // Get Node values from XML.
            string alphabetName = _utilityObj._xmlUtil.GetTextValue(
                Constants.SimpleDnaAlphabetNode, Constants.AlphabetNameNode);
            string expectedSeq = _utilityObj._xmlUtil.GetTextValue(
                Constants.ComplementNode, Constants.DnaSequenceWithMoreThanTwelveChars);
            string expectedTranscribe = _utilityObj._xmlUtil.GetTextValue(
                Constants.TranscribeNode, Constants.DnaRevTranscribeForMoreThanTwelveChars);

            ISequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Reverse Transcribe DNA Sequence.
            ISequence transcribe    = Transcription.Transcribe(seq);
            ISequence revTranscribe = Transcription.ReverseTranscribe(transcribe);

            // Validate reverse transcribe.for a given sequence.
            Assert.AreEqual(revTranscribe.ToString(), expectedTranscribe);
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Translation P1: Reverse Transcribe {0} is expected.", revTranscribe));
            ApplicationLog.WriteLine(
                "Translation P1: Reverse Transcribe of Single DNA Symbol was validate successfully.");
        }
Ejemplo n.º 8
0
        /// <summary>
        ///     Validate sequence alignment instance using different aligners
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        /// <param name="aligner">sw/nw/pw aligners</param>
        private void ValidateSequenceAlignment(string nodeName, ISequenceAligner aligner)
        {
            IAlphabet alphabet = Utility.GetAlphabet(this.utilityObj.xmlUtil.GetTextValue(nodeName,
                                                                                          Constants.AlphabetNameNode));
            string origSequence1 = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceNode1);
            string origSequence2 = this.utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SequenceNode2);

            // Create input sequences
            var inputSequences = new List <ISequence>();

            inputSequences.Add(new Sequence(alphabet, origSequence1));
            inputSequences.Add(new Sequence(alphabet, origSequence2));

            // Get aligned sequences
            IList <ISequenceAlignment> alignments = aligner.Align(inputSequences);
            ISequenceAlignment         alignment  = alignments[0];

            Assert.AreEqual(alignments[0].AlignedSequences.Count, alignment.AlignedSequences.Count);
            Assert.AreEqual(alignments[0].Metadata, alignment.Metadata);
            Assert.AreEqual(inputSequences[0].ToString(), alignment.Sequences[0].ToString());

            ApplicationLog.WriteLine(@"Alignment BVT : Validation of sequence alignment completed successfully");
        }
Ejemplo n.º 9
0
        public void ValidateReadOnlyAlignedSeqGetIEnumerable()
        {
            string filePath = Utility._xmlUtil.GetTextValue(Constants.SAMFileWithAllFieldsNode,
                                                            Constants.FilePathNode);

            SAMParser samParserObj = new SAMParser();

            samParserObj.EnforceDataVirtualization = true;
            SequenceAlignmentMap       alignedSeqList = samParserObj.Parse(filePath);
            IList <SAMAlignedSequence> samAlignedList = alignedSeqList.QuerySequences;

            IEnumerable readOnlyCollections =
                new ReadOnlyAlignedSequenceCollection(samAlignedList);

            IEnumerator enumerator = readOnlyCollections.GetEnumerator();

            Assert.IsNotNull(enumerator);

            ApplicationLog.WriteLine(string.Format(null,
                                                   "ReadOnlyAlignedSeqCollection P1 : Validated the ReadOnlyAlignedSeq GetEnumerator"));
            Console.WriteLine(string.Format(null,
                                            "ReadOnlyAlignedSeqCollection P1 : Validated the ReadOnlyAlignedSeq GetEnumerator"));
        }
Ejemplo n.º 10
0
        public void ValidateSingleSymbolDnaReverseTranscribe()
        {
            // Get Node values from XML.
            string alphabetName = Utility._xmlUtil.GetTextValue(
                Constants.SimpleDnaAlphabetNode, Constants.AlphabetNameNode);
            string expectedSeq = Utility._xmlUtil.GetTextValue(
                Constants.TranscribeNode, Constants.DnaSymbol);
            string expectedTranscribe = Utility._xmlUtil.GetTextValue(
                Constants.TranscribeNode, Constants.DnaSymbolRevTranscribe);

            ISequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Reverse Transcribe DNA Symbol.
            ISequence transcribe    = Transcription.Transcribe(seq);
            ISequence revTranscribe = Transcription.ReverseTranscribe(transcribe);

            // Validate Single DNA Symbol Reverse transcribe.
            Assert.AreEqual(revTranscribe.ToString(), expectedTranscribe);
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Translation P1: Reverse Transcribe {0} is expected.", revTranscribe));
            ApplicationLog.WriteLine(
                "Translation P1: Reverse Transcribe of Single DNA Symbol was validate successfully.");
        }
Ejemplo n.º 11
0
        public void InvalidateParseForNullArgumentsNo()
        {
            CommandLineArguments parser = new CommandLineArguments();

            //add parameters
            parser.Parameter(ArgumentType.Required, "InputFile", ArgumentValueType.String, "i", "File containing numbers to add");
            parser.Parameter(ArgumentType.Required, "ResultFile", ArgumentValueType.String, "r", "File to store output");

            string inputfileName  = Path.GetTempFileName().Replace(Path.GetTempPath(), "");
            string outputfileName = Path.GetTempFileName().Replace(Path.GetTempPath(), "");

            string[] args = { "/InputFile:" + inputfileName, "/ResultFile:" + outputfileName };

            try
            {
                parser.Parse(args, null);
                Assert.Fail("CommandLineArguments P2: Not validated parameter Method for null value");
            }
            catch (ArgumentNullException ex)
            {
                ApplicationLog.WriteLine("CommandLineArguments P2: Successfully validated Parameter Method for null value:", ex.Message);
            }
        }
Ejemplo n.º 12
0
        public void ValidateDnaDerivedSequenceProperties()
        {
            // Get input and expected values from xml
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.DnaDerivedSequenceNode, Constants.ExpectedSequence);
            string alphabetName = utilityObj.xmlUtil.GetTextValue(
                Constants.DnaDerivedSequenceNode, Constants.AlphabetNameNode);
            string derivedSequence = utilityObj.xmlUtil.GetTextValue(
                Constants.DnaDerivedSequenceNode, Constants.DerivedSequence);
            IAlphabet alphabet = Utility.GetAlphabet(alphabetName);

            // Create derived Sequence
            DerivedSequence derSequence = CreateDerivedSequence(
                alphabet, expectedSequence);

            // Validate properties of derived Sequence.
            Assert.AreEqual(derivedSequence, new string(derSequence.Select(a => (char)a).ToArray()));
            Assert.AreEqual(alphabet, derSequence.Alphabet);
            Assert.IsNotNull(derSequence.Metadata);

            ApplicationLog.WriteLine(
                "DerivedSequenceBvtTestCases:Validation of properties of derived sequence completed successfully");
        }
Ejemplo n.º 13
0
        public void ValidateCompareTwoSequenceRanges()
        {
            // Get values from xml.
            string expectedRangeId     = this.utilityObj.xmlUtil.GetTextValue(Constants.SequenceRangeNode, Constants.IDNode);
            string expectedStartIndex  = this.utilityObj.xmlUtil.GetTextValue(Constants.SequenceRangeNode, Constants.StartNode);
            string expectedEndIndex    = this.utilityObj.xmlUtil.GetTextValue(Constants.SequenceRangeNode, Constants.EndNode);
            string expectedRangeId1    = this.utilityObj.xmlUtil.GetTextValue(Constants.SequenceRangeNode, Constants.IDNode1);
            string expectedStartIndex1 = this.utilityObj.xmlUtil.GetTextValue(Constants.SequenceRangeNode, Constants.StartNode1);
            string expectedEndIndex1   = this.utilityObj.xmlUtil.GetTextValue(Constants.SequenceRangeNode, Constants.EndNode1);

            // Create first SequenceRange.
            var seqRange = new SequenceRange(expectedRangeId, long.Parse(expectedStartIndex, null), long.Parse(expectedEndIndex, null));

            // Create second SequenceRange.
            var secondSeqRange = new SequenceRange(expectedRangeId1, long.Parse(expectedStartIndex1, null), long.Parse(expectedEndIndex1, null));

            // Compare two SequenceRanges which are identical.
            int result = seqRange.CompareTo(secondSeqRange);

            // Validate result of comparison.
            Assert.AreEqual(0, result);
            ApplicationLog.WriteLine("SequenceRange BVT : Successfully validated the SequenceRange comparison");
        }
Ejemplo n.º 14
0
        public void ValidateDensePairAnsiWriteDensePairAnsi()
        {
            List <KeyValuePair <string, UOPair <char> > > keyValListObj =
                new List <KeyValuePair <string, UOPair <char> > >();

            var enumObj = keyValListObj.GroupBy(x => x.Key);

            DensePairAnsi dpaObj = DensePairAnsi.GetInstance(enumObj, '?');

            ParallelOptions paObj = new ParallelOptions();

            dpaObj.WriteDensePairAnsi(Constants.FastQTempTxtFileName, paObj);

            DensePairAnsi newDpaObj =
                DensePairAnsi.GetInstance(Constants.FastQTempTxtFileName, paObj);

            Assert.IsNotNull(newDpaObj);

            Console.WriteLine(
                "DensePairAnsi BVT : Validation of WriteDensePairAnsi() method successful");
            ApplicationLog.WriteLine(
                "DensePairAnsi BVT : Validation of WriteDensePairAnsi() method successful");
        }
Ejemplo n.º 15
0
        /// <summary>
        ///     Validates general Parse test cases with Fasta parser object name specified.
        /// </summary>
        /// <param name="parserObj">fasta parser object.</param>
        private void ValidateParserGeneralTestCases(FastAParser parserObj)
        {
            IList <ISequence> seqs = parserObj.Parse().ToList();

            Assert.AreEqual(1, seqs.Count);
            ApplicationLog.WriteLine("FastA Parser with Alphabet: Number of Sequences found are '{0}'.", seqs.Count);

            // Gets the expected sequence from the Xml
            string expectedSequence = utilityObj.xmlUtil.GetTextValue(Constants.SimpleFastaDnaNodeName, Constants.ExpectedSequenceNode);
            string newSequence      = seqs[0].ConvertToString();

            Assert.AreEqual(expectedSequence, newSequence);

            ISequence seq           = seqs[0];
            var       tmpEncodedSeq = new byte[seq.Count];

            seq.ToArray().CopyTo(tmpEncodedSeq, 0);
            Assert.AreEqual(expectedSequence.Length, tmpEncodedSeq.Length);

            Assert.IsNotNull(seq.Alphabet);
            Assert.AreEqual(seq.Alphabet.Name.ToLower(CultureInfo.CurrentCulture), utilityObj.xmlUtil.GetTextValue(Constants.SimpleFastaDnaNodeName, Constants.AlphabetNameNode).ToLower(CultureInfo.CurrentCulture));
            Assert.AreEqual(utilityObj.xmlUtil.GetTextValue(Constants.SimpleFastaDnaNodeName, Constants.SequenceIdNode), seq.ID);
        }
Ejemplo n.º 16
0
        public void ValidateLookupWithZeroOffset()
        {
            string alphabetName = Utility._xmlUtil.GetTextValue(Constants.SimpleRnaAlphabetNode,
                                                                Constants.AlphabetNameNode);
            string expectedSeq = Utility._xmlUtil.GetTextValue(Constants.CodonsNode,
                                                               Constants.SequenceWithmoreThanTweleveChars);
            string expectedAminoAcid = Utility._xmlUtil.GetTextValue(Constants.CodonsNode,
                                                                     Constants.OffsetOneMoreThanTwelveCharsAminoAcid);
            string expectedOffset = Utility._xmlUtil.GetTextValue(Constants.CodonsNode,
                                                                  Constants.OffsetVaule4);

            ISequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Validate Codons lookup method.
            AminoAcid aminoAcid = Codons.Lookup(seq, Convert.ToInt32(expectedOffset, null));

            // Validate amino acids for a given sequence.
            Assert.AreEqual(aminoAcid.Name.ToString(), expectedAminoAcid);
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Translation P2: Amino Acid {0} is expected.", aminoAcid));
            ApplicationLog.WriteLine(
                "Translation P2: Amino Acid validation for a given sequence was completed successfully.");
        }
Ejemplo n.º 17
0
        public void ValidateVectorViewColViewRemove()
        {
            DenseMatrix <string, string, double> denseMatObj =
                GetDenseMatrix();

            IDictionary <string, double> colView = denseMatObj.ColView(0);

            colView.Remove("R0");

            try
            {
                double val = colView["R0"];
                Assert.IsNotNull(val);
                Assert.Fail();
            }
            catch (KeyNotFoundException)
            {
                Console.WriteLine(
                    "VectorView BVT : Validation of Remove() method successful");
                ApplicationLog.WriteLine(
                    "VectorView BVT : Validation of Remove() method successful");
            }
        }
Ejemplo n.º 18
0
        public void ValidateDensePairAnsiColKeysInFile()
        {
            DenseMatrix <string, string, double> denseMatObj =
                GetDenseMatrix();
            ParallelOptions parOptObj = new ParallelOptions();

            denseMatObj.WriteDenseAnsi(Constants.FastQTempTxtFileName,
                                       parOptObj);
            string[] colkey =
                DensePairAnsi.ColKeysInFile(Constants.FastQTempTxtFileName);
            for (int i = 0; i < colkey.Length; i++)
            {
                Assert.AreEqual(denseMatObj.ColKeys[i], colkey[i]);
            }

            if (File.Exists(Constants.FastQTempTxtFileName))
            {
                File.Delete(Constants.FastQTempTxtFileName);
            }

            ApplicationLog.WriteLine(
                "DensePairAnsi BVT : Validation of ColKeysInFile() method successful");
        }
Ejemplo n.º 19
0
 public void InvalidateSetAlphabet()
 {
     // Create BAM Parser object
     using (BAMParser bamParserObj = new BAMParser())
     {
         // TO cover code coverage.
         try
         {
             bamParserObj.Alphabet = Alphabets.DNA;
             Assert.Fail();
         }
         catch (NotSupportedException ex)
         {
             string exceptionMessage = ex.Message;
             ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                    "BAM Parser P2 : Validated Exception {0} successfully",
                                                    exceptionMessage));
             Console.WriteLine(string.Format((IFormatProvider)null,
                                             "BAM Parser P2 : Validated Exception {0} successfully",
                                             exceptionMessage));
         }
     }
 }
Ejemplo n.º 20
0
        public void ValidateSeqFormatterProperties()
        {
            // Gets the expected sequence from the Xml
            string samFormatterName = _utilityObj._xmlUtil.GetTextValue(Constants.SamFileParserNode,
                                                                        Constants.ParserNameNode);
            string bamFormatterName = _utilityObj._xmlUtil.GetTextValue(Constants.BamFileParserNode,
                                                                        Constants.ParserNameNode);

            // Get SequenceAlignmentFormatter class properties.
            SAMFormatter actualSamFormatter = SequenceAlignmentFormatters.SAM;
            IList <ISequenceAlignmentFormatter> allFormatters = SequenceAlignmentFormatters.All;

            BAMFormatter actualBamFormatterName = SequenceAlignmentFormatters.BAM;

            // Validate Sequence Formatter
            Assert.AreEqual(samFormatterName, actualSamFormatter.Name);
            Assert.AreEqual(2, allFormatters.Count);

            Assert.AreEqual(bamFormatterName, actualBamFormatterName.Name);
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "SequenceAlignmentFormatter : Type of the parser is validated successfully"));
            ApplicationLog.WriteLine("Type of the parser is validated successfully");
        }
Ejemplo n.º 21
0
        public void ValidateLookupWithOffsetValueSix()
        {
            string alphabetName = _utilityObj._xmlUtil.GetTextValue(
                Constants.SimpleRnaAlphabetNode, Constants.AlphabetNameNode);
            string expectedSeq = _utilityObj._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.ExpectedNormalString);
            string expectedAminoAcid = _utilityObj._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.OffsetZeroSixCharsAminoAcid);
            string expectedOffset = _utilityObj._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.OffsetVaule2);

            ISequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Validate Codons lookup method.
            AminoAcid aminoAcid = Codons.Lookup(seq, Convert.ToInt32(expectedOffset, null));

            // Validate amino acids for a given sequence.
            Assert.AreEqual(aminoAcid.Name.ToString((IFormatProvider)null), expectedAminoAcid);
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Translation P1: Amino Acid {0} is expected.", aminoAcid));
            ApplicationLog.WriteLine(
                "Translation P1: Amino Acid validation for a given sequence was completed successfully.");
        }
Ejemplo n.º 22
0
        public void ValidateAminoAcid()
        {
            // Get Node values from XML.
            string expectedNucleo = Utility._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.Nucleotide);
            string expectedAminoAcid = Utility._xmlUtil.GetTextValue(
                Constants.CodonsNode, Constants.AminoAcid);

            // Create Nucleotide objects.
            Nucleotide firstNucleo1 = new Nucleotide(expectedNucleo[0], "Uracil");
            Nucleotide firstNucleo2 = new Nucleotide(expectedNucleo[1], "Uracil");
            Nucleotide firstNucleo3 = new Nucleotide(expectedNucleo[2], "Uracil");

            // Validate Codons lookup method.
            AminoAcid aminoAcid = Codons.Lookup(firstNucleo1, firstNucleo2, firstNucleo3);

            // Validate amino acids for each triplet.
            Assert.AreEqual(aminoAcid.Name.ToString(), expectedAminoAcid);
            ApplicationLog.WriteLine(string.Format(null,
                                                   "Translation BVT: Amino Acid {0} is expected.", aminoAcid));
            ApplicationLog.WriteLine(
                "Translation BVT: Amino Acid validation for a given triplets of nucleotide was completed successfully.");
        }
Ejemplo n.º 23
0
        public void InvalidateSAMParseHeaderMBFReader()
        {
            string filePath = utilityObj.xmlUtil.GetTextValue(
                Constants.InvalidSamMBFReaderNode,
                Constants.FilePathNode);

            try
            {
                using (TextReader reader = new StreamReader(filePath))
                {
                    SAMParser.ParseSAMHeader(reader);
                }

                Assert.Fail();
            }
            catch (FormatException)
            {
                ApplicationLog.WriteLine(
                    "SAM Parser P2 : Successfully validated the exception");
                Console.WriteLine(
                    "SAM Parser P2 : Successfully validated the exception");
            }
        }
Ejemplo n.º 24
0
        public void ValidateDnaAlphabetAdd()
        {
            // Gets the actual sequence and the alphabet from the Xml
            string alphabetName = _utilityObj._xmlUtil.GetTextValue(Constants.SimpleDnaAlphabetNode,
                                                                    Constants.AlphabetNameNode);
            string actualSequence = _utilityObj._xmlUtil.GetTextValue(Constants.SimpleDnaAlphabetNode,
                                                                      Constants.ExpectedSingleChar);

            ISequence   seq = new Sequence(Utility.GetAlphabet(alphabetName), actualSequence);
            DnaAlphabet alp = DnaAlphabet.Instance;

            try
            {
                alp.Add(seq[0]);
                Assert.Fail();
            }
            catch (Exception)
            {
                // Logs to the NUnit GUI window
                ApplicationLog.WriteLine("Alphabets BVT: Validation of Add() method completed successfully.");
                Console.WriteLine("Alphabets BVT: Validation of Add() method completed successfully.");
            }
        }
Ejemplo n.º 25
0
        /// <summary>
        /// Creates a sparse sequence and inserts sequence items of alphabet.
        /// Creates copy of sparse sequence object using clone() method.
        /// and Validates if copy of sparse sequence is as expected.
        /// </summary>
        /// <param name="alphabet">alphabet instance.</param>
        private void ValidateSparseSequenceCopyTo(IAlphabet alphabet)
        {
            SparseSequence sparseSequence = CreateSparseSequence(alphabet, 10);

            sparseSequence.IsReadOnly = false;

            // Copy sequence items to empty array
            ISequenceItem[] sequenceItems = new ISequenceItem[alphabet.Count + 10];
            sparseSequence.CopyTo(sequenceItems, 0);

            // Validate the copied array.
            int retrieveIndex = 10;

            foreach (ISequenceItem item in alphabet)
            {
                Assert.AreEqual(item, sequenceItems[retrieveIndex]);
                Assert.AreEqual(item.Symbol, sequenceItems[retrieveIndex].Symbol);
                retrieveIndex++;
            }

            Console.WriteLine("SparseSequenceBVT: Validation of CopyTo() method is completed");
            ApplicationLog.WriteLine("SparseSequenceBVT: Validation of CopyTo() method is completed");
        }
Ejemplo n.º 26
0
        public void ValidateMoreThanTwelveCharsDnaTranscribe()
        {
            // Get Node values from XML.
            string alphabetName = utilityObj.xmlUtil.GetTextValue(
                Constants.SimpleDnaAlphabetNode, Constants.AlphabetNameNode);
            string expectedSeq = utilityObj.xmlUtil.GetTextValue(
                Constants.ComplementNode, Constants.DnaSequenceWithMoreThanTwelveChars);
            string expectedTranscribe = utilityObj.xmlUtil.GetTextValue(
                Constants.TranscribeNode, Constants.DnaTranscribeForMoreThanTwelveCharsV2);
            ISequence transcribe = null;

            Sequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Transcribe DNA Symbol.
            transcribe = Transcription.Transcribe(seq);

            // Validate transcribe.for a given sequence.
            Assert.AreEqual(new string(transcribe.Select(a => (char)a).ToArray()), expectedTranscribe);
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Translation P1: Transcribe {0} is expected.", transcribe));
            ApplicationLog.WriteLine(
                "Translation P1: Transcribe of Single DNA Symbol was validate successfully.");
        }
Ejemplo n.º 27
0
        public void ValidateVirtualBAMAlignedSequenceListCopyTo()
        {
            VirtualAlignedSequenceList <SAMAlignedSequence> virtualASeqList =
                GetBAMAlignedSequence(Constants.BAMFileWithMultipleAlignedSeqsNode);

            SAMAlignedSequence[] samAlignedSeqList = new
                                                     SAMAlignedSequence[virtualASeqList.Count];

            // Copy virtual aligned sequence to sam aligned sequence lilst array.
            virtualASeqList.CopyTo(samAlignedSeqList, 0);

            // Validate copied aligned sequences.
            for (int i = 0; i < virtualASeqList.Count; i++)
            {
                Assert.AreEqual(samAlignedSeqList[i].QuerySequence.ToString(),
                                virtualASeqList[i].QuerySequence.ToString());
            }

            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Virtual AlignedSequenceList Bvt : Validated the VAS CopyTo"));
            Console.WriteLine(string.Format((IFormatProvider)null,
                                            "Virtual AlignedSequenceList Bvt : Validated the VAS CopyTo"));
        }
Ejemplo n.º 28
0
        /// <summary>
        /// Passes a valid DNA sequence and validates corresponding transcribe sequence i.e. RNA Sequence
        /// </summary>
        /// <param name="sequenceNode">Sequence xml node.</param>
        /// <param name="revTranscribeNode">Expected transcribe sequence.</param>
        void ValidateDnaToRnaTranscribe(string sequenceNode, string transcribeNode)
        {
            // Get Node values from XML.
            string alphabetName = utilityObj.xmlUtil.GetTextValue(Constants.SimpleDnaAlphabetNode,
                                                                  Constants.AlphabetNameNode);
            string expectedSeq = utilityObj.xmlUtil.GetTextValue(Constants.TranscribeNode,
                                                                 sequenceNode);
            string expectedTranscribe = utilityObj.xmlUtil.GetTextValue(Constants.TranscribeNode,
                                                                        transcribeNode);
            ISequence transcribe = null;

            Sequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Transcribe DNA Sequence.
            transcribe = Transcription.Transcribe(seq);

            // Validate Dna to Rna transcribe.
            Assert.AreEqual(expectedTranscribe, new string(transcribe.Select(a => (char)a).ToArray()));
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Translation P1: Transcribe {0} is expected.", transcribe));
            ApplicationLog.WriteLine(
                "Translation P1: Transcribe to Dna to Rna sequence completed successfully.");
        }
Ejemplo n.º 29
0
        public void ValidateDnaReverseComplementationWithTweleveChars()
        {
            // Get Node values from XML.
            string alphabetName = utilityObj.xmlUtil.GetTextValue(
                Constants.SimpleDnaAlphabetNode, Constants.AlphabetNameNode);
            string expectedSeq = utilityObj.xmlUtil.GetTextValue(
                Constants.ComplementNode, Constants.DnaSequence);
            string expectedRevComplement = utilityObj.xmlUtil.GetTextValue(
                Constants.ComplementNode, Constants.DnaRevComplement);
            ISequence revComplement = null;

            Sequence seq = new Sequence(Utility.GetAlphabet(alphabetName), expectedSeq);

            // Reverse Complement DNA Sequence.
            revComplement = seq.GetReverseComplementedSequence();

            // Validate Reverse Complement for a given sequence.
            Assert.AreEqual(new string(revComplement.Select(a => (char)a).ToArray()), expectedRevComplement);
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                                                   "Translation P1: Reverse Complement {0} is expected.", revComplement));
            ApplicationLog.WriteLine(
                "Translation P1: Reverse Complement of twelve DNA characters sequence validated successfully.");
        }
Ejemplo n.º 30
0
        public void ValidatePaddedDoubleGetInstanceFromSparseEnum()
        {
            RowKeyColKeyValue <string, string, double> rowKeyObj =
                new RowKeyColKeyValue <string, string, double>("R0", "C0", 2);

            List <RowKeyColKeyValue <string, string, double> > enumObj =
                new List <RowKeyColKeyValue <string, string, double> >();

            enumObj.Add(rowKeyObj);

            PaddedDouble pdObj =
                PaddedDouble.GetInstanceFromSparse(enumObj);

            Assert.AreEqual(1, pdObj.ColCount);
            Assert.AreEqual(1, pdObj.RowCount);
            Assert.AreEqual("R0", pdObj.RowKeys[0]);
            Assert.AreEqual("C0", pdObj.ColKeys[0]);

            Console.WriteLine(
                "PaddedDouble BVT : Validation of GetInstanceFromSparse(enum) method successful");
            ApplicationLog.WriteLine(
                "PaddedDouble BVT : Validation of GetInstanceFromSparse(enum) method successful");
        }