Esempio n. 1
0
        public void SmithWatermanProteinSeqAffineGap()
        {
            IPairwiseSequenceAligner sw = new SmithWatermanAligner
            {
                SimilarityMatrix = new SimilarityMatrix(SimilarityMatrix.StandardSimilarityMatrix.Blosum62),
                GapOpenCost      = -8,
                GapExtensionCost = -1,
            };

            ISequence sequence1 = new Sequence(Alphabets.Protein, "HEAGAWGHEE");
            ISequence sequence2 = new Sequence(Alphabets.Protein, "PAWHEAE");
            IList <IPairwiseSequenceAlignment> result = sw.Align(sequence1, sequence2);

            AlignmentHelpers.LogResult(sw, result);

            IList <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();
            IPairwiseSequenceAlignment         align          = new PairwiseSequenceAlignment();
            PairwiseAlignedSequence            alignedSeq     = new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.Protein, "AWGHE"),
                SecondSequence = new Sequence(Alphabets.Protein, "AW-HE"),
                Consensus      = new Sequence(Alphabets.AmbiguousProtein, "AWGHE"),
                Score          = 20,
                FirstOffset    = 0,
                SecondOffset   = 3
            };

            align.PairwiseAlignedSequences.Add(alignedSeq);
            expectedOutput.Add(align);

            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));
        }
Esempio n. 2
0
        public void NeedlemanWunschProteinSeqAffineGap()
        {
            IPairwiseSequenceAligner nw = new NeedlemanWunschAligner
            {
                SimilarityMatrix = new SimilarityMatrix(SimilarityMatrix.StandardSimilarityMatrix.Blosum62),
                GapOpenCost      = -8,
                GapExtensionCost = -1
            };

            ISequence sequence1 = new Sequence(Alphabets.Protein, "HEAGAWGHEE");
            ISequence sequence2 = new Sequence(Alphabets.Protein, "PAWHEAE");
            IList <IPairwiseSequenceAlignment> result = nw.Align(sequence1, sequence2);

            AlignmentHelpers.LogResult(nw, result);

            IList <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();
            IPairwiseSequenceAlignment         align          = new PairwiseSequenceAlignment();

            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.Protein, "HEAGAWGHE-E"),
                SecondSequence = new Sequence(Alphabets.Protein, "P---AW-HEAE"),
                Consensus      = new Sequence(AmbiguousProteinAlphabet.Instance, "XEAGAWGHEAE"),
                Score          = 5,
                FirstOffset    = 0,
                SecondOffset   = 0
            });
            expectedOutput.Add(align);

            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));
        }
Esempio n. 3
0
        public void NeedlemanWunschDnaSeqSimpleGap()
        {
            IPairwiseSequenceAligner nw = new NeedlemanWunschAligner
            {
                SimilarityMatrix = new DiagonalSimilarityMatrix(2, -1),
                GapOpenCost      = -2
            };

            ISequence sequence1 = new Sequence(Alphabets.DNA, "GAATTCAGTTA");
            ISequence sequence2 = new Sequence(Alphabets.DNA, "GGATCGA");
            IList <IPairwiseSequenceAlignment> result = nw.AlignSimple(sequence1, sequence2);

            AlignmentHelpers.LogResult(nw, result);

            IList <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();
            IPairwiseSequenceAlignment         align          = new PairwiseSequenceAlignment();

            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "GAATTCAGTTA"),
                SecondSequence = new Sequence(Alphabets.DNA, "GGAT-C-G--A"),
                Consensus      = new Sequence(AmbiguousDnaAlphabet.Instance, "GRATTCAGTTA"),
                Score          = 3,
                FirstOffset    = 0,
                SecondOffset   = 0
            });
            expectedOutput.Add(align);

            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));
        }
Esempio n. 4
0
        public void SmithWatermanAlignerMultipleAlignments2()
        {
            IPairwiseSequenceAligner sw = new SmithWatermanAligner
            {
                SimilarityMatrix = new DiagonalSimilarityMatrix(5, -4),
                GapOpenCost      = -5
            };

            ISequence sequence1 = new Sequence(Alphabets.DNA, "AAAAGGGGGGCCCC");
            ISequence sequence2 = new Sequence(Alphabets.DNA, "AAAATTTTTTTCCCC");
            IList <IPairwiseSequenceAlignment> result = sw.AlignSimple(sequence1, sequence2);

            AlignmentHelpers.LogResult(sw, result);

            IList <IPairwiseSequenceAlignment> expectedOutput = new List <IPairwiseSequenceAlignment>();

            // First alignment
            IPairwiseSequenceAlignment align = new PairwiseSequenceAlignment(sequence1, sequence2);

            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "AAAA"),
                SecondSequence = new Sequence(Alphabets.DNA, "AAAA"),
                Consensus      = new Sequence(Alphabets.DNA, "AAAA"),
                Score          = 20,
                FirstOffset    = 0,
                SecondOffset   = 0
            });

            // Second alignment
            align.PairwiseAlignedSequences.Add(new PairwiseAlignedSequence
            {
                FirstSequence  = new Sequence(Alphabets.DNA, "CCCC"),
                SecondSequence = new Sequence(Alphabets.DNA, "CCCC"),
                Consensus      = new Sequence(Alphabets.DNA, "CCCC"),
                Score          = 20,
                FirstOffset    = 1,
                SecondOffset   = 0
            });

            expectedOutput.Add(align);
            Assert.IsTrue(AlignmentHelpers.CompareAlignment(result, expectedOutput));
        }