Beispiel #1
0
 public MultipleWordAlignerResult(IWordAligner wordAligner, IPairwiseAlignmentScorer<Word, ShapeNode> scorer, IEnumerable<Word> words)
     : base(wordAligner)
 {
     _words = new ReadOnlyList<Word>(words.ToArray());
     _algorithm = new MultipleAlignmentAlgorithm<Word, ShapeNode>(scorer, _words, GetNodes);
     _algorithm.Compute();
 }
 public MultipleWordAlignerResult(IWordAligner wordAligner, IPairwiseAlignmentScorer <Word, ShapeNode> scorer, IEnumerable <Word> words)
     : base(wordAligner)
 {
     _words     = new ReadOnlyList <Word>(words.ToArray());
     _algorithm = new MultipleAlignmentAlgorithm <Word, ShapeNode>(scorer, _words, GetNodes);
     _algorithm.Compute();
 }
        public void AlignEmptySequence()
        {
            var scorer = new StringScorer();
            var msa = new MultipleAlignmentAlgorithm<string, char>(scorer, new[] {"car", "", "bar"}, GetChars) {UseInputOrder = true};
            msa.Compute();
            Alignment<string, char> alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                "| c a r |",
                "| - - - |",
                "| b a r |"
                ));
        }
        public void AlignEmptySequence()
        {
            var scorer = new StringScorer();
            var msa    = new MultipleAlignmentAlgorithm <string, char>(scorer, new[] { "car", "", "bar" }, GetChars)
            {
                UseInputOrder = true
            };

            msa.Compute();
            Alignment <string, char> alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                                      "| c a r |",
                                      "| - - - |",
                                      "| b a r |"
                                      ));
        }
        public void ZeroMaxScore()
        {
            var scorer = new ZeroMaxScoreStringScorer();
            var msa    = new MultipleAlignmentAlgorithm <string, char>(scorer, new[] { "car", "bar", "carp" }, GetChars)
            {
                UseInputOrder = true
            };

            msa.Compute();
            Alignment <string, char> alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                                      "| c a r - |",
                                      "| b a r - |",
                                      "| c a r p |"
                                      ));
            Assert.That(alignment.NormalizedScore, Is.EqualTo(0));
        }
        public void AlignMoreThanTwoSequences()
        {
            var scorer = new StringScorer();
            var msa    = new MultipleAlignmentAlgorithm <string, char>(scorer, new[] { "car", "bar", "carp" }, GetChars)
            {
                UseInputOrder = true
            };

            msa.Compute();
            Alignment <string, char> alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                                      "| c a r - |",
                                      "| b a r - |",
                                      "| c a r p |"
                                      ));

            msa = new MultipleAlignmentAlgorithm <string, char>(scorer, new[] { "car", "bar", "star" }, GetChars)
            {
                UseInputOrder = true
            };
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                                      "| - c a r |",
                                      "| - b a r |",
                                      "| s t a r |"
                                      ));

            msa = new MultipleAlignmentAlgorithm <string, char>(scorer, new[] { "car", "bar", "stare" }, GetChars)
            {
                UseInputOrder = true
            };
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                                      "| - c a r - |",
                                      "| - b a r - |",
                                      "| s t a r e |"
                                      ));

            msa = new MultipleAlignmentAlgorithm <string, char>(scorer, new[] { "scar", "car", "bar", "stare" }, GetChars)
            {
                UseInputOrder = true
            };
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                                      "| s c a r - |",
                                      "| - c a r - |",
                                      "| - b a r - |",
                                      "| s t a r e |"
                                      ));

            msa = new MultipleAlignmentAlgorithm <string, char>(scorer, new[] { "sane", "scar", "car", "bar", "stare" }, GetChars)
            {
                UseInputOrder = true
            };
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                                      "| s - a n e |",
                                      "| s c a r - |",
                                      "| - c a r - |",
                                      "| - b a r - |",
                                      "| s t a r e |"
                                      ));

            msa = new MultipleAlignmentAlgorithm <string, char>(scorer, new[] { "sane", "scar", "she", "car", "bar", "stare" }, GetChars)
            {
                UseInputOrder = true
            };
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                                      "| s - a n e |",
                                      "| s c a r - |",
                                      "| s - - h e |",
                                      "| - c a r - |",
                                      "| - b a r - |",
                                      "| s t a r e |"
                                      ));
        }
        public void AlignMoreThanTwoSequences()
        {
            var scorer = new StringScorer();
            var msa = new MultipleAlignmentAlgorithm<string, char>(scorer, new[] {"car", "bar", "carp"}, GetChars) {UseInputOrder = true};
            msa.Compute();
            Alignment<string, char> alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                "| c a r - |",
                "| b a r - |",
                "| c a r p |"
                ));

            msa = new MultipleAlignmentAlgorithm<string, char>(scorer, new[] {"car", "bar", "star"}, GetChars) {UseInputOrder = true};
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                "| - c a r |",
                "| - b a r |",
                "| s t a r |"
                ));

            msa = new MultipleAlignmentAlgorithm<string, char>(scorer, new[] {"car", "bar", "stare"}, GetChars) {UseInputOrder = true};
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                "| - c a r - |",
                "| - b a r - |",
                "| s t a r e |"
                ));

            msa = new MultipleAlignmentAlgorithm<string, char>(scorer, new[] {"scar", "car", "bar", "stare"}, GetChars) {UseInputOrder = true};
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                "| s c a r - |",
                "| - c a r - |",
                "| - b a r - |",
                "| s t a r e |"
                ));

            msa = new MultipleAlignmentAlgorithm<string, char>(scorer, new[] {"sane", "scar", "car", "bar", "stare"}, GetChars) {UseInputOrder = true};
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                "| s - a n e |",
                "| s c a r - |",
                "| - c a r - |",
                "| - b a r - |",
                "| s t a r e |"
                ));

            msa = new MultipleAlignmentAlgorithm<string, char>(scorer, new[] {"sane", "scar", "she", "car", "bar", "stare"}, GetChars) {UseInputOrder = true};
            msa.Compute();
            alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                "| s - a n e |",
                "| s c a r - |",
                "| s - - h e |",
                "| - c a r - |",
                "| - b a r - |",
                "| s t a r e |"
                ));
        }
        public void ZeroMaxScore()
        {
            var scorer = new ZeroMaxScoreStringScorer();
            var msa = new MultipleAlignmentAlgorithm<string, char>(scorer, new[] {"car", "bar", "carp"}, GetChars) {UseInputOrder = true};
            msa.Compute();
            Alignment<string, char> alignment = msa.GetAlignment();

            AssertAlignmentsEqual(alignment, CreateAlignment(
                "| c a r - |",
                "| b a r - |",
                "| c a r p |"
                ));
            Assert.That(alignment.NormalizedScore, Is.EqualTo(0));
        }