Commit 5b8ad3cc authored by Mikaël Salson's avatar Mikaël Salson Committed by Mathieu Giraud

core/segment.{h,cpp}: Dynamically adapt window length/shifts if needed

See #2913
parent 306505f1
......@@ -28,6 +28,7 @@
#include <sstream>
#include <cstring>
#include <string>
#include "windowExtractor.h"
#define NO_FORBIDDEN_ID (-1)
......@@ -215,14 +216,17 @@ string Segmenter::getJunction(int l, int shift) const {
return getSequence().sequence;
// Regular '-w'
int start = (getLeft() + getRight())/2 - l/2 + shift;
int central_pos = (getLeft() + getRight())/2 + shift;
pair<int, int> length_shift = WindowExtractor::get_best_length_shifts(getSequence().sequence.size(),
l, central_pos,
DEFAULT_WINDOW_SHIFT);
// Yield UNSEG_TOO_SHORT_FOR_WINDOW into windowExtractor
if (start < 0 or start + l > (int)sequence.size()) // TODO: +l ou +l-1 ?
if (length_shift.first < MINIMAL_WINDOW_LENGTH)
return "" ;
// Window succesfully extracted
return getSequence().sequence.substr(start, l);
return getSequence().sequence.substr(central_pos + length_shift.second - length_shift.first / 2, length_shift.first);
}
int Segmenter::getLeft() const {
......
......@@ -36,6 +36,13 @@
As we need ~10 bp to recognize the facing V/J, this value should be large enough to handle V/J deletions until ~30 bp,
(and even larger V/J deletions if there is a large facing J or V in the read). */
#define DEFAULT_WINDOW_SHIFT 5 /* Number of nucleotide to try shifting or
reducing the window when it doesn't fit at
its place */
#define MINIMAL_WINDOW_LENGTH 20 /* As we now dynamically adapt the window
length we need to specify a minimum
otherwise we could go as low as
2*DEFAULT_WINDOW_SHIFT */
using namespace std;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment