-
Notifications
You must be signed in to change notification settings - Fork 201
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Break out mpmap band padding algorithm
- Loading branch information
Showing
7 changed files
with
82 additions
and
38 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
/** | ||
* \file pad_band.cpp | ||
* | ||
* Defines implementation for band padding functions for banded global alignment. | ||
*/ | ||
|
||
#include "pad_band.hpp" | ||
|
||
namespace vg { | ||
namespace algorithms { | ||
|
||
std::function<size_t(const Alignment&, const HandleGraph&)> pad_band_random_walk(double band_padding_multiplier, size_t band_padding_memo_size) { | ||
|
||
// We're goign to capture this vector by value into the closure | ||
std::vector<size_t> band_padding_memo; | ||
|
||
// Fill it in to initialize | ||
band_padding_memo.resize(band_padding_memo_size); | ||
for (size_t i = 0; i < band_padding_memo.size(); i++) { | ||
band_padding_memo[i] = size_t(band_padding_multiplier * sqrt(i)) + 1; | ||
} | ||
|
||
function<size_t(const Alignment&, const HandleGraph&)> choose_band_padding = [band_padding_multiplier, band_padding_memo](const Alignment& seq, const HandleGraph& graph) { | ||
size_t read_length = seq.sequence().size(); | ||
return read_length < band_padding_memo.size() ? band_padding_memo.at(read_length) | ||
: size_t(band_padding_multiplier * sqrt(read_length)) + 1; | ||
}; | ||
|
||
// And return the closure which now owns the memo table. | ||
return choose_band_padding; | ||
} | ||
|
||
std::function<size_t(const Alignment&, const HandleGraph&)> pad_band_constant(size_t band_padding) { | ||
// don't dynamically choose band padding, shim constant value into a function type | ||
function<size_t(const Alignment&,const HandleGraph&)> constant_padding = [band_padding](const Alignment& seq, const HandleGraph& graph) { | ||
return band_padding; | ||
}; | ||
|
||
return constant_padding; | ||
} | ||
|
||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef VG_ALGORITHMS_PAD_BAND_HPP_INCLUDED | ||
#define VG_ALGORITHMS_PAD_BAND_HPP_INCLUDED | ||
|
||
/** | ||
* \file pad_band.hpp | ||
* | ||
* Defines algorithm for computing band padding for banded alignment. | ||
*/ | ||
|
||
#include "../handle.hpp" | ||
#include <vg/vg.pb.h> | ||
|
||
namespace vg { | ||
namespace algorithms { | ||
|
||
using namespace std; | ||
|
||
/// Get a band padding function that uses the expected distance of a random | ||
/// walk, memoized out to the given length. | ||
std::function<size_t(const Alignment&, const HandleGraph&)> pad_band_random_walk(double band_padding_multiplier = 1.0, size_t band_padding_memo_size = 2000); | ||
|
||
/// Get a band padding function that uses a constant value. | ||
std::function<size_t(const Alignment&, const HandleGraph&)> pad_band_constant(size_t band_padding); | ||
|
||
} | ||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters