Skip to content

Commit

Permalink
Merge pull request #2696 from vgteam/xdrop-features
Browse files Browse the repository at this point in the history
Improved pinning in XdropAligner
  • Loading branch information
jeizenga authored Mar 28, 2020
2 parents 92567a2 + 178a53e commit d95bd06
Show file tree
Hide file tree
Showing 3 changed files with 192 additions and 130 deletions.
57 changes: 57 additions & 0 deletions src/unittest/xdrop_aligner.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
#include "../vg.hpp"
#include "../xdrop_aligner.hpp"
#include "catch.hpp"
#include "bdsg/hash_graph.hpp"

namespace vg {
namespace unittest {
Expand Down Expand Up @@ -477,6 +478,62 @@ TEST_CASE("XdropAligner can align pinned left when the entire read is an inserti
REQUIRE(aln.path().mapping(0).rank() == 1);
}

TEST_CASE("XdropAligner can select the best head and tail nodes automatically in pinned alignment", "[xdrop][alignment][mapping]") {

bdsg::HashGraph graph;

handle_t h1 = graph.create_handle("ATA");
handle_t h2 = graph.create_handle("CGC");
handle_t h3 = graph.create_handle("A");
handle_t h4 = graph.create_handle("AGA");
handle_t h5 = graph.create_handle("CTC");

graph.create_edge(h1, h3);
graph.create_edge(h2, h3);
graph.create_edge(h3, h4);
graph.create_edge(h3, h5);

Alignment aln1;
aln1.set_sequence("ATA");

Alignment aln2;
aln2.set_sequence("CGC");

Alignment aln3;
aln3.set_sequence("AGA");

Alignment aln4;
aln4.set_sequence("CTC");

// Last parameter here is max gap length.
XdropAligner aligner(1, 4, 6, 1, 5, 40);

aligner.align_pinned(aln1, graph, true);
aligner.align_pinned(aln2, graph, true);
aligner.align_pinned(aln3, graph, false);
aligner.align_pinned(aln4, graph, false);

REQUIRE(aln1.score() == 8);
REQUIRE(aln2.score() == 8);
REQUIRE(aln3.score() == 8);
REQUIRE(aln4.score() == 8);

REQUIRE(aln1.path().mapping_size() == 1);
REQUIRE(aln2.path().mapping_size() == 1);
REQUIRE(aln3.path().mapping_size() == 1);
REQUIRE(aln4.path().mapping_size() == 1);

REQUIRE(aln1.path().mapping(0).edit_size() == 1);
REQUIRE(aln2.path().mapping(0).edit_size() == 1);
REQUIRE(aln3.path().mapping(0).edit_size() == 1);
REQUIRE(aln4.path().mapping(0).edit_size() == 1);

REQUIRE(aln1.path().mapping(0).position().node_id() == graph.get_id(h1));
REQUIRE(aln2.path().mapping(0).position().node_id() == graph.get_id(h2));
REQUIRE(aln3.path().mapping(0).position().node_id() == graph.get_id(h4));
REQUIRE(aln4.path().mapping(0).position().node_id() == graph.get_id(h5));
}



}
Expand Down
Loading

2 comments on commit d95bd06

@adamnovak
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vg CI tests complete for merge to master. View the full report here.

16 tests passed, 0 tests failed and 0 tests skipped in 13805 seconds

Tests produced 681 warnings. 680 were for lower-than-expected alignment scores

@adamnovak
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

vg CI tests complete for branch v1.23.0. View the full report here.

16 tests passed, 0 tests failed and 0 tests skipped in 13877 seconds

Tests produced 680 warnings. 680 were for lower-than-expected alignment scores

Please sign in to comment.