当前位置: 首页>>代码示例>>C#>>正文


C# FastA.FastAParser类代码示例

本文整理汇总了C#中Bio.IO.FastA.FastAParser的典型用法代码示例。如果您正苦于以下问题:C# FastAParser类的具体用法?C# FastAParser怎么用?C# FastAParser使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


FastAParser类属于Bio.IO.FastA命名空间,在下文中一共展示了FastAParser类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestFastaFor186972391

        public void TestFastaFor186972391()
        {
            string expectedSequence =

                "IFYEPVEILGYDNKSSLVLVKRLITRMYQQKSLISSLNDSNQNEFWGHKNSFSSHFSSQMVSEGFGVILE" +
                "IPFSSRLVSSLEEKRIPKSQNLRSIHSIFPFLEDKLSHLNYVSDLLIPHPIHLEILVQILQCWIKDVPSL" +
                "HLLRLFFHEYHNLNSLITLNKSIYVFSKRKKRFFGFLHNSYVYECEYLFLFIRKKSSYLRSISSGVFLER" +
                "THFYGKIKYLLVVCCNSFQRILWFLKDTFIHYVRYQGKAIMASKGTLILMKKWKFHLVNFWQSYFHFWFQ" +
                "PYRINIKQLPNYSFSFLGYFSSVRKNPLVVRNQMLENSFLINTLTQKLDTIVPAISLIGSLSKAQFCTVL" +
                "GHPISKPIWTDLSDSDILDRFCRICRNLCRYHSGSSKKQVLYRIKYIFRLSCARTLARKHKSTVRTFMRR" +
                "LGSGFLEEFFLEEE";

            // parse
            string filepath = System.IO.Path.Combine("TestUtils","Fasta", "186972391.fasta");


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

            FastAParser parser = new FastAParser { Alphabet = Alphabets.Protein };
            foreach (ISequence seq in parser.Parse(filepath))
            {
                Assert.IsNotNull(seq);
                Assert.AreEqual(434, seq.Count);

                string actual = seq.Aggregate("", (current, b) => current + (char)b);

                Assert.AreEqual(expectedSequence, actual);
                Assert.AreEqual(seq.Alphabet.Name, "Protein");

                Assert.AreEqual("gi|186972391|gb|ACC99454.1| maturase K [Scaphosepalum rapax]", seq.ID);
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:32,代码来源:FastaTests.cs

示例2: MismatchTest

 public MismatchTest()
 {
     //
     // TODO: Add constructor logic here
     //
     FastAParser Reference = new FastAParser(@"Reference.txt");
     Mismatch_Test = new Mismatcher(Reference.Parse().First());
 }
开发者ID:krendil,项目名称:mismatcher,代码行数:8,代码来源:MismatchTest.cs

示例3: ValidateMUMmerAlignGeneralTestCases

        private void ValidateMUMmerAlignGeneralTestCases(string nodeName)
        {
            // Gets the reference sequence from the configuration file
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.FilePathNode);

            Assert.IsNotNull(filePath);
            ApplicationLog.WriteLine(string.Format(null, "MUMmer P2 : Successfully validated the File Path '{0}'.", filePath));

            var fastaParserObj = new FastAParser();
            IEnumerable<ISequence> referenceSeqs = fastaParserObj.Parse(filePath);

            ISequence referenceSeq = referenceSeqs.ElementAt(0);

            // Gets the reference sequence from the configuration file
            string queryFilePath = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.SearchSequenceFilePathNode);

            Assert.IsNotNull(queryFilePath);
            ApplicationLog.WriteLine(string.Format(null, "MUMmer P2 : Successfully validated the Search File Path '{0}'.", queryFilePath));

            var fastaParserObj1 = new FastAParser();
            IEnumerable<ISequence> querySeqs = fastaParserObj1.Parse(queryFilePath);

            string mumLength = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.MUMAlignLengthNode);

            var mum = new MUMmerAligner
            {
                LengthOfMUM = long.Parse(mumLength, null),
                StoreMUMs = true,
                PairWiseAlgorithm = new NeedlemanWunschAligner(),
                GapOpenCost = int.Parse(utilityObj.xmlUtil.GetTextValue(nodeName, Constants.GapOpenCostNode), null)
            };

            IList<IPairwiseSequenceAlignment> align = mum.Align(referenceSeq, querySeqs);

            // Validate FinalMUMs and MUMs Properties.
            Assert.IsNotNull(mum.MUMs);

            string expectedScore = utilityObj.xmlUtil.GetTextValue(nodeName, Constants.ScoreNodeName);

            string[] expectedSequences = utilityObj.xmlUtil.GetTextValues(nodeName, Constants.ExpectedSequencesNode);
            IList<IPairwiseSequenceAlignment> expectedOutput = new List<IPairwiseSequenceAlignment>();

            IPairwiseSequenceAlignment seqAlign = new PairwiseSequenceAlignment();
            var alignedSeq = new PairwiseAlignedSequence
            {
                FirstSequence = new Sequence(referenceSeq.Alphabet, expectedSequences[0]),
                SecondSequence = new Sequence(referenceSeq.Alphabet, expectedSequences[1]),
                Score = Convert.ToInt32(expectedScore, null),
                FirstOffset = Int32.MinValue,
                SecondOffset = Int32.MinValue,
            };
            seqAlign.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(seqAlign);
            Assert.IsTrue(AlignmentHelpers.CompareAlignment(align, expectedOutput));

            ApplicationLog.WriteLine("MUMmer P2 : Successfully validated the aligned sequences.");
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:57,代码来源:MUMmerP2TestCases.cs

示例4: FastASequencePositionParser

        /// <summary>
        /// Initializes a new instance of the FastASequencePositionParser class by 
        /// loading the specified stream.
        /// </summary>
        /// <param name="stream">Stream to load</param>
        /// <param name="reverseReversePairedRead">Flag to indicate to get the forward strand sequence of a reverse paired read.</param>
        public FastASequencePositionParser(Stream stream, bool reverseReversePairedRead = false)
        {
            if (stream == null)
            {
                throw new ArgumentNullException("stream");
            }

            this.fastaParser = new FastAParser();
            this.stream = stream;
            this.reverseReversePairedRead = reverseReversePairedRead;
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:17,代码来源:FastASequencePositionParser.cs

示例5: TestMethod1

        public void TestMethod1()
        {
            FastAParser Query = new FastAParser(@"Query.txt");
            var Mismatches_query = Mismatch_Test.GetMismatches(Query.Parse().First());
            Assert.AreEqual(2,Mismatches_query.Count());

            var first = Mismatches_query.First();
            Assert.AreEqual(0, first.QuerySequenceOffset);

            var last = Mismatches_query.Last();
            Assert.AreEqual(179, last.QuerySequenceOffset);
        }
开发者ID:krendil,项目名称:mismatcher,代码行数:12,代码来源:MismatchTest.cs

示例6: Execute

        /// <summary>
        /// Executes the cross-link search for LC-IMS-TOF data.
        /// </summary>
        /// <param name="settings">Settings object to control parameters for cross-linking.</param>
        /// <param name="fastAFile">The FileInfo object for the FASTA file containg all protein sequences you want to search.</param>
        /// <param name="featureFile">The FileInfo object for the LC-IMS-MS features file, created by the LC-IMS-MS Feature Finder. (email [email protected] for more info)</param>
        /// <param name="peaksFile">The FileInfo object for the Isotopic Peaks file, created by DeconTools. (email [email protected] for more info)</param>
        /// <returns>An enumerable of CrossLinkResult objects.</returns>
        public static IList<CrossLinkResult> Execute(CrossLinkSettings settings, FileInfo fastAFile, FileInfo featureFile, FileInfo peaksFile)
        {
            IEnumerable<ISequence> sequenceEnumerable;
            List<LcImsMsFeature> featureList;
            List<IsotopicPeak> peakEnumerable;

            Console.WriteLine();

            try
            {

                // Read in FASTA File
                var fastAParser = new FastAParser(fastAFile.FullName);
                sequenceEnumerable = fastAParser.Parse();
                Console.WriteLine("FASTA file:     " + GetRelativePath(fastAFile.FullName));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error reading the FASTA file: " + ex.Message);
                throw;
            }

            try
            {
                // Read in LC-IMS-MS Features
                featureList = LcImsMsFeatureReader.ReadFile(featureFile);
                Console.WriteLine("Features file:  " + GetRelativePath(featureFile.FullName));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error reading the LCMSFeatures file: " + ex.Message);
                throw;
            }

            try
            {
                // Read in Isotopic Peaks (not Isotopic Profile)
                peakEnumerable = IsotopicPeakReader.ReadFile(peaksFile);
                Console.WriteLine("Peaks file:     " + GetRelativePath(peaksFile.FullName));
            }
            catch (Exception ex)
            {
                Console.WriteLine("Error reading the Isotopic Peaks file: " + ex.Message);
                throw;
            }

            // Now call the executor that expects the opbjects instead of the file locations
            return Execute(settings, sequenceEnumerable, featureList, peakEnumerable);
        }
开发者ID:PNNL-Comp-Mass-Spec,项目名称:CrossLinkingIMS,代码行数:57,代码来源:CrossLinkingIMSController.cs

示例7: TestFastaWhenParsingOneOfMany

        public void TestFastaWhenParsingOneOfMany()
        {
            // parse

            string filepath = System.IO.Path.Combine("TestUtils","Fasta","5_sequences.fasta");
            FastAParser parser = new FastAParser { Alphabet = Alphabets.Protein };
            using (parser.Open(filepath))
            {
                int[] sequenceCountArray = { 27, 29, 30, 35, 32 };

                int i = 0;
                foreach (ISequence seq in parser.Parse())
                {
                    Assert.IsNotNull(seq);
                    Assert.AreEqual(seq.Count, sequenceCountArray[i]);
                    i++;
                }
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:19,代码来源:FastaTests.cs

示例8: ValidateSequenceToString

        public void ValidateSequenceToString()
        {
            ISequence seqSmall = new Sequence(Alphabets.DNA, "ATCG");
            string seqLargeString = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName,
                                                                    Constants.seqLargeStringNode);
            ISequence seqLarge = new Sequence(Alphabets.DNA, seqLargeString);
            string ActualSmallString = seqSmall.ToString();
            string ActualLargeString = seqLarge.ToString();
            string ExpectedSmallString = "ATCG";
            string seqLargeExpected = this.utilityObj.xmlUtil.GetTextValue(Constants.ToStringNodeName,
                                                                      Constants.seqLargeExpected2Node);
            string expectedLargeString = string.Format(CultureInfo.CurrentCulture,
                                                       seqLargeExpected,
                                                       (seqLarge.Count - Helper.AlphabetsToShowInToString));
            Assert.AreEqual(ExpectedSmallString, ActualSmallString);
            Assert.AreEqual(expectedLargeString, ActualLargeString);

            //check with blank sequence
            var seqBlank = new Sequence(Alphabets.DNA, "");
            string blankString = seqBlank.ToString();
            Assert.AreEqual(string.Empty, blankString);

            // Gets the expected sequence from the Xml
            string filePath = this.utilityObj.xmlUtil.GetTextValue(Constants.SimpleFastaNodeName,
                                                              Constants.FilePathNode);
            //read sequence from file
            var parser = new FastAParser { Alphabet = Alphabets.Protein };
            List<ISequence> seqsList = parser.Parse(filePath).ToList();

            var seqString = new string(seqsList[0].Select(a => (char) a).ToArray());
            if (seqString.Length > Helper.AlphabetsToShowInToString)
            {
                //check if the whole sequence string contains the string retrieved from ToString
                Assert.IsTrue(seqString.Contains(seqsList[0].ToString().Substring(0, Helper.AlphabetsToShowInToString)));
                Assert.IsTrue(seqsList[0].ToString().Contains("... +["));
            }
            else
            {
                Assert.AreEqual(seqString, seqsList[0].ToString());
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:41,代码来源:ToStringBvtTestCases.cs

示例9: ValidateSAMFormatter

        /// <summary>
        /// General method to validate SAM Formatter method.
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        /// <param name="parseTypes">enum type to execute different overload</param>
        void ValidateSAMFormatter(string nodeName)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string expectedSequenceFile = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequence);
            SAMParser parser = new SAMParser();
            {
                SequenceAlignmentMap alignments = (SequenceAlignmentMap) parser.ParseOne(filePath);
                SAMFormatter formatter = new SAMFormatter();

                using (var writer =
                            File.Create(Constants.SAMTempFileName))
                {
                    formatter.Format(writer, alignments);
                }

                alignments = parser.ParseOne<SequenceAlignmentMap>(Constants.SAMTempFileName);

                // Get expected sequences
                FastAParser parserObj = new FastAParser();
                {
                    IEnumerable<ISequence> expectedSequences =
                        parserObj.Parse(expectedSequenceFile);

                    IList<ISequence> expectedSequencesList = expectedSequences.ToList();

                    // Validate parsed output with expected output
                    for (int index = 0;
                        index < alignments.QuerySequences.Count;
                        index++)
                    {
                        for (int count = 0;
                            count < alignments.QuerySequences[index].Sequences.Count;
                            count++)
                        {
                            Assert.AreEqual(
                                new string(expectedSequencesList[index].Select(a => (char)a).ToArray()),
                                new string(alignments.QuerySequences[index].Sequences[count].Select(a => (char)a).ToArray()));
                        }
                    }
                }
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:50,代码来源:SAMP1TestCases.cs

示例10: ValidateSAMParser

        /// <summary>
        /// General method to validate SAM parser method.
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        /// <param name="parseTypes">enum type to execute different overload</param>
        void ValidateSAMParser(string nodeName)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string expectedSequenceFile = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequence);
            var parser = new SAMParser();
            {
                SequenceAlignmentMap alignments = null;

                // Parse SAM File
                using (var reader = File.OpenRead(filePath))
                {
                    alignments = parser.Parse(reader);
                }

                // Get expected sequences
                FastAParser parserObj = new FastAParser();
                {
                    IEnumerable<ISequence> expectedSequences = parserObj.Parse(expectedSequenceFile);
                    IList<ISequence> expectedSequencesList = expectedSequences.ToList();

                    // Validate parsed output with expected output
                    for (int index = 0;
                        index < alignments.QuerySequences.Count;
                        index++)
                    {
                        for (int count = 0;
                            count < alignments.QuerySequences[index].Sequences.Count;
                            count++)
                        {
                            Assert.AreEqual(new string(expectedSequencesList[index].Select(a => (char)a).ToArray()),
                                new string(alignments.QuerySequences[index].Sequences[count].Select(a => (char)a).ToArray()));
                        }
                    }
                }
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:44,代码来源:SAMP1TestCases.cs

示例11: GetReads

        /// <summary>
        /// Method to get the reads from file/xml.
        /// </summary>
        /// <param name="nodeName">Parent node in Xml</param>
        /// <returns></returns>
        public List<ISequence> GetReads(string nodeName)
        {
            List<ISequence> readSeqList = new List<ISequence>();

            // Gets the reads from the FastA file
            string readFilePath = utilityObj.xmlUtil.GetTextValue(nodeName,
                Constants.FilePathNode2);

            Assert.IsNotNull(readFilePath);
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                "Comparative P1 : Successfully validated the File Path '{0}'.", readFilePath));

            using (FastAParser queryParser = new FastAParser(readFilePath))
            {
                IEnumerable<ISequence> querySeqList = queryParser.Parse();

                foreach (ISequence seq in querySeqList)
                {
                    readSeqList.Add(seq);
                }
            }
            return readSeqList;
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:28,代码来源:ComparativeP1TestCases.cs

示例12: ValidateComparativeAssembleMethod

        /// <summary>
        /// Validates Assemble method .Step 1-5.        
        /// </summary>
        /// <param name="nodeName">Parent Node name in Xml</param>
        /// <param name="isFilePath">Sequence location.</param>
        public void ValidateComparativeAssembleMethod(string nodeName, bool isEcOli)
        {
            ComparativeGenomeAssembler assemble = new ComparativeGenomeAssembler();
            List<ISequence> referenceSeqList = new List<ISequence>();
            string expectedSequence = null;
            string LengthOfMUM = utilityObj.xmlUtil.GetTextValue(nodeName,
                     Constants.MUMLengthNode);
            string kmerLength = utilityObj.xmlUtil.GetTextValue(nodeName,
                     Constants.KmerLengthNode);
            string fixedSeparation = utilityObj.xmlUtil.GetTextValue(nodeName,
                     Constants.FixedSeparationNode);

            string minimumScore = utilityObj.xmlUtil.GetTextValue(nodeName,
                     Constants.MinimumScoreNode);
            string separationFactor = utilityObj.xmlUtil.GetTextValue(nodeName,
                     Constants.SeparationFactorNode);
            string maximumSeparation = utilityObj.xmlUtil.GetTextValue(nodeName,
                     Constants.MaximumSeparationNode);
            string breakLength = utilityObj.xmlUtil.GetTextValue(nodeName,
                   Constants.BreakLengthNode);
            // Gets the reference sequence from the FastA file
            string filePath = utilityObj.xmlUtil.GetTextValue(nodeName,
                Constants.FilePathNode1);

            Assert.IsNotNull(filePath);
            ApplicationLog.WriteLine(string.Format((IFormatProvider)null,
                "Comparative P1 : Successfully validated the File Path '{0}'.", filePath));

            using (FastAParser parser = new FastAParser(filePath))
            {
                IEnumerable<ISequence> referenceList = parser.Parse();

                foreach (ISequence seq in referenceList)
                {
                    referenceSeqList.Add(seq);
                }
            }

            //Get the reads from configurtion file .
            string readFilePath = utilityObj.xmlUtil.GetTextValue(nodeName,
                Constants.FilePathNode2);
            assemble.LengthOfMum = int.Parse(LengthOfMUM, CultureInfo.InvariantCulture);
            assemble.KmerLength = int.Parse(kmerLength, CultureInfo.InvariantCulture);
            assemble.FixedSeparation = int.Parse(fixedSeparation, CultureInfo.InvariantCulture);
            assemble.MinimumScore = int.Parse(minimumScore, CultureInfo.InvariantCulture);
            assemble.SeparationFactor = float.Parse(separationFactor, CultureInfo.InvariantCulture);
            assemble.MaximumSeparation = int.Parse(maximumSeparation, CultureInfo.InvariantCulture);
            assemble.BreakLength = int.Parse(breakLength, CultureInfo.InvariantCulture);

            using (FastASequencePositionParser queryparser = new FastASequencePositionParser(readFilePath))
            {
                IEnumerable<ISequence> outputAssemble = assemble.Assemble(referenceSeqList, queryparser);

                if (isEcOli)
                {
                    expectedSequence = utilityObj.xmlUtil.GetFileTextValue(nodeName,
                                        Constants.ExpectedSequenceNode);
                }
                else
                {
                    expectedSequence = utilityObj.xmlUtil.GetTextValue(nodeName,
                                        Constants.ExpectedSequenceNode);
                }

                var outputStrings = outputAssemble.Select(seq => seq.ConvertToString()).ToList();
                outputStrings.Sort();
                Assert.AreEqual(expectedSequence.ToUpperInvariant(), String.Join("", outputStrings).ToUpperInvariant());
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:74,代码来源:ComparativeP1TestCases.cs

示例13: ValidateSAMParseAndFormatWithCIGARFormat

        /// <summary>
        /// Validate parser and formatter by parsing the same file which contains 
        /// extended CIGAR string. Validate the CIGAR property in aligned sequence
        /// metadata information is updated as expected.
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        void ValidateSAMParseAndFormatWithCIGARFormat(string nodeName)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string expectedSequenceFile = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequence);
            string expectedCIGARString = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.CIGARNode);
            // Create parser using encoding
            ISequenceAlignmentParser parser = new SAMParser();
            try
            {
                var alignments = parser.Parse(filePath).ToList();

                // Get expected sequences
                FastAParser parserObj = new FastAParser();
                {
                    IEnumerable<ISequence> expectedSequences = parserObj.Parse(expectedSequenceFile);
                    IList<ISequence> expectedSequencesList = expectedSequences.ToList();

                    // Validate parsed output with expected output
                    int count = 0;
                    for (int index = 0; index < alignments.Count; index++)
                    {
                        for (int ialigned = 0; ialigned <
                            alignments[index].AlignedSequences.Count; ialigned++)
                        {
                            for (int iseq = 0; iseq <
                                alignments[index].AlignedSequences[ialigned].Sequences.Count; iseq++)
                            {
                                Assert.AreEqual(new string(expectedSequencesList[count].Select(a => (char)a).ToArray()),
                                    new string(alignments[index].AlignedSequences[ialigned].Sequences[iseq].Select(a => (char)a).ToArray()));
                                foreach (string key in alignments[index].AlignedSequences[ialigned].Metadata.Keys)
                                {
                                    SAMAlignedSequenceHeader header = (SAMAlignedSequenceHeader)
                                        alignments[index].AlignedSequences[ialigned].Metadata[key];
                                    Assert.AreEqual(expectedCIGARString, header.CIGAR);
                                }
                                count++;
                            }
                        }
                    }
                }
            }
            finally
            {
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:55,代码来源:SAMBvtTestCases.cs

示例14: ValidateSAMParseAndFormatWithQualityValues

        /// <summary>
        /// Validate parser and formatter by parsing the sam file with quality values
        /// </summary>
        /// <param name="nodeName">xml node name</param>
        void ValidateSAMParseAndFormatWithQualityValues(string nodeName)
        {
            // Gets the expected sequence from the Xml
            string filePath = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.FilePathNode);
            string expectedSequenceFile = utilityObj.xmlUtil.GetTextValue(
                nodeName, Constants.ExpectedSequence);
            // Create parser using encoding
            ISequenceAlignmentParser parser = new SAMParser();
            try
            {
                var alignments = parser.Parse(filePath).ToList();

                // Get expected sequences
                FastAParser parserObj = new FastAParser();
                {
                    var expectedSequencesList = parserObj.Parse(expectedSequenceFile).ToList();

                    // Validate parsed output with expected output
                    int count = 0;
                    for (int index = 0; index < alignments.Count; index++)
                    {
                        for (int ialigned = 0; ialigned <
                            alignments[index].AlignedSequences.Count; ialigned++)
                        {
                            for (int iseq = 0; iseq <
                                alignments[index].AlignedSequences[ialigned].Sequences.Count; iseq++)
                            {
                                Assert.IsInstanceOf<QualitativeSequence>(alignments[index].AlignedSequences[ialigned].Sequences[iseq]);
                                QualitativeSequence qualSequence =
                                 (QualitativeSequence)alignments[index].AlignedSequences[ialigned].Sequences[iseq];
                                Assert.AreEqual(
                                    new string(expectedSequencesList[count].Select(a => (char)a).ToArray()),
                                    new string(qualSequence.Select(a => (char)a).ToArray()));
                                count++;
                            }
                        }
                    }
                }
            }
            finally
            {
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:48,代码来源:SAMBvtTestCases.cs

示例15: ValidateFastaAFileSequence

        public void ValidateFastaAFileSequence()
        {
            // Gets the expected sequence from the Xml
            string expectedSequence = this.utilityObj.xmlUtil.GetTextValue(
                Constants.SimpleFastaNodeName, Constants.ExpectedSequenceNode);
            string fastAFilePath = this.utilityObj.xmlUtil.GetTextValue(
                Constants.SimpleFastaNodeName, Constants.FilePathNode);
            string alphabet = this.utilityObj.xmlUtil.GetTextValue(Constants.SimpleFastaNodeName,
                Constants.AlphabetNameNode);
            Assert.IsTrue(File.Exists(fastAFilePath));

            // Logs information to the log file
            ApplicationLog.WriteLine(string.Concat(
                "Sequence BVT: The File exist in the Path ", fastAFilePath));

            IEnumerable<ISequence> sequence = null;
            FastAParser parser = new FastAParser();
            {
                // Parse a FastA file Using Parse method and convert the same to sequence.
                parser.Alphabet = Utility.GetAlphabet(alphabet);
                sequence = parser.Parse(fastAFilePath);

                Assert.IsNotNull(sequence);
                Sequence fastASequence = (Sequence)sequence.ElementAt(0);
                Assert.IsNotNull(fastASequence);

                char[] seqString = sequence.ElementAt(0).Select(a => (char)a).ToArray();
                string newSequence = new string(seqString);

                Assert.AreEqual(expectedSequence, newSequence);
                ApplicationLog.WriteLine(string.Concat(
                    "Sequence BVT: The Sequence is as expected."));

                byte[] tmpEncodedSeq = new byte[fastASequence.Count];
                (fastASequence as IEnumerable<byte>).ToArray().CopyTo(tmpEncodedSeq, 0);

                Assert.AreEqual(expectedSequence.Length, tmpEncodedSeq.Length);
                ApplicationLog.WriteLine(string.Concat(
                    "Sequence BVT: Sequence Length is as expected."));

                Assert.AreEqual(this.utilityObj.xmlUtil.GetTextValue(
                    Constants.SimpleProteinAlphabetNode, Constants.SequenceIdNode), fastASequence.ID);
                ApplicationLog.WriteLine(string.Concat(
                    "Sequence BVT: SequenceID is as expected."));


                Assert.AreEqual(fastASequence.Alphabet.Name,
                    this.utilityObj.xmlUtil.GetTextValue(Constants.SimpleFastaNodeName, Constants.AlphabetNameNode));
                ApplicationLog.WriteLine(string.Concat(
                    "Sequence BVT: Sequence Alphabet is as expected."));
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:52,代码来源:SequenceBvtTestCases.cs


注:本文中的Bio.IO.FastA.FastAParser类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。