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


C# Sequence.ConvertToString方法代码示例

本文整理汇总了C#中Sequence.ConvertToString方法的典型用法代码示例。如果您正苦于以下问题:C# Sequence.ConvertToString方法的具体用法?C# Sequence.ConvertToString怎么用?C# Sequence.ConvertToString使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Sequence的用法示例。


在下文中一共展示了Sequence.ConvertToString方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: TestSequenceConvertToString

 public void TestSequenceConvertToString()
 {
     ISequence seq = new Sequence(Alphabets.DNA, "ATCGATCGGATCGATCGGCTACTAATATCGATCGGCTACGATCGGCTAATCGATCGATCGGCTAATCGATCGATCGGCTAGCTA");
     const string expectedValue = "TCGATCGGCT";
     string actualValue = seq.ConvertToString(10, 10);
     Assert.AreEqual(expectedValue, actualValue);
 }
开发者ID:cpatmoore,项目名称:bio,代码行数:7,代码来源:TestToStringForBio.cs

示例2: TestSequenceConvertToStringWithException

 public void TestSequenceConvertToStringWithException()
 {
     Sequence seq = new Sequence(Alphabets.DNA, "ATCGATCGGATCGATCGGCTACTAATATCGATCGGCTACGATCGGCTAATCGATCGATCGGCTAATCGATCGATCGGCTAGCTA");
     try
     {
         seq.ConvertToString(80, 10);
         Assert.Fail();
     }
     catch (ArgumentOutOfRangeException ex)
     {
         Assert.AreEqual("length", ex.ParamName);
     }
 }
开发者ID:cpatmoore,项目名称:bio,代码行数:13,代码来源:TestToStringForBio.cs

示例3: SimpleCCSTest

        public static void SimpleCCSTest ()
        {
            string fname = System.IO.Path.Combine ("TestUtils", "PacBio", "ccs.bam");
            var csp = new PacBioCCSBamReader ();
            var seqs = csp.Parse (fname).Select(z => z as PacBioCCSRead).ToList();

            var seq4 = seqs [4];
            Assert.AreEqual (273, seq4.HoleNumber);
            Assert.AreEqual (12, seq4.NumPasses);
            Assert.AreEqual (1, seq4.ReadCountBadZscore);
            Assert.AreEqual (1946, seq4.Sequence.Count);
            Assert.AreEqual (14, seq4.ZScores.Length);
            Assert.AreEqual("m150930_045019_42194_c100916310150000001823201204291662_s1_p0/273/ccs",
                             seq4.Sequence.ID);
            var seq = new Sequence (DnaAlphabet.Instance, seq4.Sequence.ToArray (), true);
            Assert.AreEqual("TGTCACTCATCTGAGTGATCCCGCGAAATTAATACGACTCACTATAGGGGAATTGTGAGCGGATAACAATTCCCCTCTAGAAATAATTTTGTTTAACTTTAAGAAGGAGATATACATATGAAACACATGCCACGTAAAATGTATTCCTGCGACTTTGAGACTACACCAAGGTTGAAGATTGCCGCGTATGGGCATACGGTTACATGAACATCGAAGACCACTCCGAGTATAAGATTGGTAACTCCCTGGATGAATTTATGGCTTGGGTTCTGAAAGTTCAGGCTGACCTGTACTTCCACAATCTGAAATTTGATGGCGCATTCATCATCAACTGGCTGGAACGTAACGGTTTTAAATGGTCCGCAGATGGTCTGCCAAATACCTACAACACCATCATTTCTCGCATGGGCCAGTGGTATATGATTGATATTTGCCTGGGTTACAAGGGTAAACGCAAGATCCACACCGTGATCTACGACTCTCTGAAGAAACTGCCGTTTCCGGTTAAGAAAATTGCGAAAGACTTTAAGCTGACGGTACTGAAAGGCGACATCGACTATCATAAGGAGCGCCCGGTCGTTACAAAATCACCCGGAAGAATATGCCTACATTAAAAACGATATTCAGATTATCGCAGAAGCTCTGCTGATCCAGTTCAAGCAGGGTCTGGATCGTATGACGGCAGGTTCTGACTCTCTGAAAGGCTTCAAAGACATTATCACCACCAAGAAGTTTAAAAAGGTTTCCCGACCCTGAGCCTGGGTCTGGACAAGGAAGTTCGTTATGCCTACCGTGGTGGTTTCACCTGGCTGAATGACCGTTTTAAAGAAAAAGAGATCGGCGAAGGTATGGTTTTTGATGTTAATTCCCTGTACCCAGCGCAAATGTACTCTCGCCTGCTGCCGTACGGCGAGCCGATCGTATTCGAGGGTAAATACGTCTGGGACGAGGACTACCCTCTGCACATTCAGCACATTCGTTGTGAATTTGAACTGAAGGAAGGCTACATCCCGACCATCCAGATCAATCGTTCCCGTTTCTACAAGGGTAACGAATACCTGAAATCTTCCGGCGGTGAAATTGCTGACCTGTGGCTGTCTAATGTTGATCTGGAACTGATGAAAGAGCACTACGACCTGTACAATGTTGAATATATCTCTGGTCTGAAGTTCAAAGCAACCACTGGCCTGTTCAAGGACTTTATCGACAAATGGACGTATATCAAAACTACCTCTGAAGGCGCCATCAAACAGCTGGCGAAGCTGATCCTGAACAGCCTGTACGGTAAATTCGCGTCCAACCCGGACGTTACCGGTAAAGTGCCATACCTGAAAGAGAACGGTGCTCTGGGTTTTCGTCTGGGTGAGGAGGAAACGAAAGACCCTGTATATACCCGATGGGTGTCTTTATCACGGCCTGGGCACGCTATACGACCATCACGGCAGCGCAGGCTTGTTATGATCGTATTATCTACTGCGATACCGATTCTATTCACCTGACTGGTACTGAAATTCCGGACGTTATCAAAGACATCGTAGACCCGAAGAAACTGGGCTACTGGGCGCACGAATCTACTTTTAAGCGTGCAAAATATCTGCGTCAGAAAACCTACATCCAGGATATTTACATGAAAGAAGTAGACGGCAAATTGGTAGAGGGCTCTCCTGACGACTACACTGACATCAAGTTCTCTGTGAAATGCGCAGGCATGACGGACAAAATCAAAAAGGAAGTGACTTTCGAAAACTTCAAAGTGGGTTTTTCTCGTAAAATGAAACCGAAGCCTGTTCAGGTACCGGGTGGCGTAGTGCTGGTTGATGACACTTTTACTATCAAATAACTCGAGCTGCAGGAATTCAAGCTTGGATCCGGCTGCTAACAAAGCCCGAAAGGAAGCTGAGTTGGCTGCTGCCACCGCTGAGCAATAACTTGTCACTCATCTGAGT",
                seq.ConvertToString());

            Assert.AreEqual (seqs.Count, 7);
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:20,代码来源:ParserTests.cs

示例4: InvalidateSequenceConvertToString

        public void InvalidateSequenceConvertToString()
        {
            try
            {
                //check with blank sequence
                var seq = new Sequence(Alphabets.DNA, "");
                string seqStr = seq.ConvertToString(0, 3);
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException aorex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentOutOfRangeException : " + aorex.Message);
            }

            try
            {
                //check with length greater than actual length
                var seq = new Sequence(Alphabets.DNA, "ATGCCCC");
                string seqStr = seq.ConvertToString(0, 30);
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException aorex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentOutOfRangeException : " + aorex.Message);
            }

            try
            {
                //check with length < 0
                var seq = new Sequence(Alphabets.DNA, "ATGCCCC");
                string seqStr = seq.ConvertToString(0, -30);
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException aorex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentOutOfRangeException : " + aorex.Message);
            }

            try
            {
                //check with start index < 0
                var seq = new Sequence(Alphabets.DNA, "ATGCCCC");
                string seqStr = seq.ConvertToString(-10, 3);
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException aorex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentOutOfRangeException : " + aorex.Message);
            }

            try
            {
                //check with start index greater than actual length
                var seq = new Sequence(Alphabets.DNA, "ATGCCCC");
                string seqStr = seq.ConvertToString(30, 3);
                Assert.Fail();
            }
            catch (ArgumentOutOfRangeException aorex)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentOutOfRangeException : " + aorex.Message);
            }

            try
            {
                //check with null sequence
                Sequence seq = null;
                string seqStr = seq.ConvertToString(0, 3);
                Assert.Fail();
            }
            catch (NullReferenceException nre)
            {
                ApplicationLog.WriteLine("Successfully caught ArgumentOutOfRangeException : " + nre.Message);
            }
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:74,代码来源:ToStringP2TestCases.cs

示例5: ValidateDnaSequence

        public void ValidateDnaSequence()
        {

            // Gets the actual sequence and the alphabet from the Xml
            string alphabetName = this.utilityObj.xmlUtil.GetTextValue(
                Constants.SimpleDnaAlphabetNode, Constants.AlphabetNameNode);
            string actualSequence = this.utilityObj.xmlUtil.GetTextValue(
                Constants.SimpleDnaAlphabetNode, Constants.ExpectedNormalString);

            // Logs information to the log file
            ApplicationLog.WriteLine(string.Concat(
                "Sequence BVT: Sequence ", actualSequence, " and Alphabet ", alphabetName));

            ISequence createSequence = new Sequence(Utility.GetAlphabet(alphabetName),actualSequence);
            Assert.IsNotNull(createSequence);

            string seqNew = createSequence.ConvertToString();

            // Validate the createdSequence
            Assert.AreEqual(seqNew, actualSequence);
            ApplicationLog.WriteLine("Sequence BVT: Sequence is as expected.");

            Assert.AreEqual(Utility.GetAlphabet(alphabetName), createSequence.Alphabet);
            ApplicationLog.WriteLine("Sequence BVT: Sequence Alphabet is as expected.");

            ApplicationLog.WriteLine("Sequence BVT: The DNA Sequence with string is created successfully.");
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:27,代码来源:SequenceBvtTestCases.cs

示例6: TryToGetEndValidSequence

 public void TryToGetEndValidSequence()
 {
     ISequence sequence = new Sequence(DnaAlphabet.Instance, SmallSequence);
     string theString = sequence.ConvertToString(5);
     Assert.AreEqual(SmallSequence.Substring(5), theString);
 }
开发者ID:cpatmoore,项目名称:bio,代码行数:6,代码来源:SequenceExtensionTests.cs

示例7: CheckForOutOfRangeExceptionOnInvalidLength

 public void CheckForOutOfRangeExceptionOnInvalidLength()
 {
     ISequence sequence = new Sequence(DnaAlphabet.Instance, "-");
     Assert.Throws<ArgumentOutOfRangeException> ( () =>  sequence.ConvertToString(0, 10));
 }
开发者ID:cpatmoore,项目名称:bio,代码行数:5,代码来源:SequenceExtensionTests.cs

示例8: TestSimpleSequenceAssemblerWithRandomSequence

        public void TestSimpleSequenceAssemblerWithRandomSequence()
        {
            // Test parameters.
            //
            // In theory, as long as all positions in the master sequence are 
            // covered by at least one read, we should be able to pass this test.
            // But some parameter settings will make the test fail, for
            // various reasons, including:
            // 1. Short reads, caused by the strategy used to ensure full coverage
            //  at the ends, might not score well enough to merge.
            // 2. Uncovered positions are always possible due to the random 
            //  generation of reads. (Increasing the number of reads helps with this)
            // 3. The assembler might construct the reverse or complement (or both)
            //  of the master sequence.
            // 4. Too low a merge threshold could cause incorrect merges, which
            //  the algorithm will not repair.
            int matchScore = 1;
            int mismatchScore = -8;
            int gapCost = -8;
            double mergeThreshold = 3;
            double consensusThreshold = 99;
            const int MasterLength = 100;
            const int MinReadLength = 10;
            const int MaxReadLength = 30;
            const int NumReads = 200;
            const bool AssumeOrientedReads = true;

            // if this is uncommented, assembly details appear in log.
            // this is extremely verbose.
            // Trace.Set(Trace.AssemblyDetails);

            // make random master sequence
            // (use seed for repeatability, or omit seed for 
            // different test each time)
            // Random randGen = new Random();
            Random randGen = new Random(654321);

            StringBuilder randSeq = new StringBuilder();
            for (int i = 0; i < MasterLength; ++i)
            {
                int randm = randGen.Next(8);
                if (randm < 2)
                {
                    randSeq.Append('A');
                }
                else if (randm < 4)
                {
                    randSeq.Append('C');
                }
                else if (randm < 6)
                {
                    randSeq.Append('G');
                }
                else
                {
                    randSeq.Append('T');
                }
            }

            Sequence master = new Sequence(Alphabets.AmbiguousDNA, randSeq.ToString());

            // create the reads
            List<ISequence> inputs = new List<ISequence>();
            for (int i = 0; i < NumReads; ++i)
            {
                // try for uniform coverage clear to the ends (this can lead to short reads, though)
                int rndPos = Math.Max(0, randGen.Next(-MinReadLength, MasterLength - 1));
                int rndLen = Math.Min(MasterLength - rndPos, randGen.Next(MinReadLength, MaxReadLength + 1));
                string data = master.ConvertToString().Substring(Math.Max(0, rndPos), rndLen);
                bool revcomp = randGen.Next(2) > 0;
                bool reverse = randGen.Next(2) > 0 && !AssumeOrientedReads;
                ISequence read;
                if (reverse && revcomp)
                {
                    Sequence tmp = new Sequence(Alphabets.DNA, data);
                    read = new Sequence(Alphabets.DNA, tmp.GetReversedSequence().ConvertToString());
                }
                else if (revcomp)
                {
                    Sequence tmp = new Sequence(Alphabets.DNA, data);
                    read = new Sequence(Alphabets.DNA, tmp.GetReverseComplementedSequence().ConvertToString());
                }
                else
                {
                    read = new Sequence(Alphabets.DNA, data);
                }

                ApplicationLog.WriteLine("read {0}: {1}", i, read);
                inputs.Add(read);
            }

            OverlapDeNovoAssembler assembler = new OverlapDeNovoAssembler();
            assembler.MergeThreshold = mergeThreshold;
            assembler.OverlapAlgorithm = new PairwiseOverlapAligner();
            ((IPairwiseSequenceAligner)assembler.OverlapAlgorithm).SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, mismatchScore);
            ((IPairwiseSequenceAligner)assembler.OverlapAlgorithm).GapOpenCost = gapCost;
            assembler.ConsensusResolver = new SimpleConsensusResolver(consensusThreshold);
            assembler.AssumeStandardOrientation = AssumeOrientedReads;

            IOverlapDeNovoAssembly seqAssembly = (IOverlapDeNovoAssembly)assembler.Assemble(inputs);
//.........这里部分代码省略.........
开发者ID:cpatmoore,项目名称:bio,代码行数:101,代码来源:OverlapDeNovoAssemblerTests.cs

示例9: TestSimpleSequenceAssemblerWithSemiRandomSequence

        public void TestSimpleSequenceAssemblerWithSemiRandomSequence()
        {
            // test parameters
            int matchScore = 1;
            int mismatchScore = -8;
            int gapCost = -8;
            double mergeThreshold = 4;
            double consensusThreshold = 66;
            const int MasterLength = 30;
            const int ReadLength = 10;
            const int NumReads = 5;
            const bool AssumeOrientedReads = false;

            // if this is uncommented, assembly details appear in log.
            // this is extremely verbose.
            Trace.Set(Trace.AssemblyDetails);

            // make random master sequence
            // (use seed for repeatability, or omit seed for 
            // different test each time)
            // Random randGen = new Random();
            Random randGen = new Random(654321);

            StringBuilder randSeq = new StringBuilder();
            for (int i = 0; i < MasterLength; ++i)
            {
                int randm = randGen.Next(8);
                if (randm < 2)
                {
                    randSeq.Append('A');
                }
                else if (randm < 4)
                {
                    randSeq.Append('C');
                }
                else if (randm < 6)
                {
                    randSeq.Append('G');
                }
                else
                {
                    randSeq.Append('T');
                }
            }

            Sequence master = new Sequence(Alphabets.DNA, randSeq.ToString());

            // create the reads
            List<ISequence> inputs = new List<ISequence>();
            for (int i = 0; i < NumReads; ++i)
            {
                int pos = 5 * i;
                string data = master.ConvertToString().Substring(pos, ReadLength);
                bool revcomp = randGen.Next(2) > 0;
                bool reverse = randGen.Next(2) > 0 && !AssumeOrientedReads;
                ISequence read;
                if (reverse && revcomp)
                {
                    Sequence tmp = new Sequence(Alphabets.DNA, data);
                    read = new Sequence(Alphabets.DNA, tmp.GetReversedSequence().ConvertToString());
                }
                else if (revcomp)
                {
                    Sequence tmp = new Sequence(Alphabets.DNA, data);
                    read = new Sequence(Alphabets.DNA, tmp.GetReverseComplementedSequence().ConvertToString());
                }
                else
                {
                    read = new Sequence(Alphabets.DNA, data);
                }

                inputs.Add(read);
            }

            OverlapDeNovoAssembler assembler = new OverlapDeNovoAssembler();
            assembler.MergeThreshold = mergeThreshold;
            assembler.OverlapAlgorithm = new PairwiseOverlapAligner();
            ((IPairwiseSequenceAligner)assembler.OverlapAlgorithm).SimilarityMatrix = new DiagonalSimilarityMatrix(matchScore, mismatchScore);
            ((IPairwiseSequenceAligner)assembler.OverlapAlgorithm).GapOpenCost = gapCost;
            assembler.ConsensusResolver = new SimpleConsensusResolver(consensusThreshold);
            assembler.AssumeStandardOrientation = AssumeOrientedReads;

            IOverlapDeNovoAssembly seqAssembly = (IOverlapDeNovoAssembly)assembler.Assemble(inputs);

            Assert.AreEqual(0, seqAssembly.UnmergedSequences.Count);
            Assert.AreEqual(1, seqAssembly.Contigs.Count);
            Contig contig0 = seqAssembly.Contigs[0];
            ApplicationLog.WriteLine("master sequence and contig 0 consensus:");
            ApplicationLog.WriteLine(master.ConvertToString());
            ApplicationLog.WriteLine(contig0.Consensus.ConvertToString());

            // note that this is tricky, esp. without oriented reads - consensus
            // could be reversed and/or complemented relative to original
            Assert.AreEqual(master.ConvertToString(), contig0.Consensus.ConvertToString());
        }
开发者ID:cpatmoore,项目名称:bio,代码行数:95,代码来源:OverlapDeNovoAssemblerTests.cs


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