Commit dd94f8bb authored by Mathieu Giraud's avatar Mathieu Giraud

Merge branch 'feature-a/4225-missing-affectations' into 'dev'

Missing affectations

Closes #4225

See merge request !633
parents 9c70b2c5 2b32c47d
Pipeline #131478 failed with stages
in 16 minutes and 3 seconds
......@@ -135,8 +135,19 @@ void PointerACAutomaton<Info>::build_failure_functions() {
q.pop();
current_state = couple.first;
pointer_state<Info> *failed_state = couple.second;
if (failed_state->is_final)
if (failed_state->is_final) {
current_state->is_final = true;
if (! current_state->informations.front().isNull()) {
if (! this->multiple_info)
current_state->informations.front() += failed_state->informations.front();
else
current_state->informations.insert(current_state->informations.end(),
failed_state->informations.begin(),
failed_state->informations.end());
} else {
current_state->informations = failed_state->informations;
}
}
for (size_t i = 0; i < NB_TRANSITIONS; i++) {
if (current_state->transitions[i] != NULL) {
q.push(pair<pointer_state<Info>*, pointer_state<Info>*>(current_state->transitions[i],
......@@ -266,10 +277,24 @@ vector<Info> PointerACAutomaton<Info>::getResults(const seqtype &seq, bool no_re
size_t seq_len = seq.length();
vector<Info> result(seq.length());
unsigned char previous_length = 0;
for (size_t i = 0; i < seq_len; i++) {
current_state = (pointer_state<Info> *)next(current_state, seq[i]);
Info info = current_state->informations.front();
result[i - info.getLength()+1] = info;
if (! info.isNull()) {
if (info.isAmbiguous() && ! result[i - info.getLength() + 1].isNull()
&& previous_length > 0)
// We try to maintain a consistency as the length for an ambiguous
// affect is a bit tricky to guess. So if we see that we gonna
// overwrite a result, we try to prevent that
result[i - previous_length + 1] = info;
else {
result[i - info.getLength()+1] = info;
if (! info.isAmbiguous())
previous_length = info.getLength();
}
}
}
return result;
......
......@@ -118,18 +118,14 @@ KmerAffect &KmerAffect::operator+=(const KmerAffect &kmer) {
if (kmer.affect != affect) {
if (isUnknown())
*this = kmer;
else if (affect_char(affect) == affect_char(kmer.affect)
&& (affect_strand(affect) != affect_strand(kmer.affect))) {
// Same label but different strand
else {
// If we have same label but different strand
// -> we put ambiguous, we could have something to say that
// strand is ambiguous but not the label, but we don't have enough space
// in 1 byte…
unsigned char length = affect.length;
*this = AFFECT_AMBIGUOUS;
affect.length = kmer.getLength();
} else {
assert(affect.c != kmer.affect.c || getLength() == kmer.getLength());
*this = AFFECT_AMBIGUOUS;
affect.length = kmer.getLength();
affect.length = length;
}
}
return *this;
......
......@@ -61,6 +61,9 @@ bool Kmer::isNull() const{
bool Kmer::isUnknown() const{
return false;
}
bool Kmer::isAmbiguous() const{
return false;
}
ostream &operator<<(ostream &os, const Kmer &kmer) {
os << kmer.count << ",";
......
......@@ -52,6 +52,11 @@ public:
* it only there for a reason of compatibility with KmerAffect)
*/
bool isUnknown() const;
/**
* @return true iff the kmer is ambiguous (which doesn't make sense here but
* it only there for a reason of compatibility with KmerAffect)
*/
bool isAmbiguous() const;
} ;
ostream &operator<<(ostream &os, const Kmer &kmer);
bool operator==(const Kmer &k1, const Kmer &k2);
......
>igkj1
gtggacgttcggccaagggaccaaggtggaaatcaaac
!LAUNCH: $VIDJIL_DIR/$EXEC -g $VIDJIL_DIR/germline -r 1 -1 -2 -K bug4225-j.fa
!OUTPUT_FILE: out/bug4225-j.affects
$ Find only +k and ? affects before the stretch of _ for all loci
16: seed .*(\+k| \?){28}( _)+$
!LAUNCH: $VIDJIL_DIR/$EXEC -g $VIDJIL_DIR/germline -r 1 -4 -K ../data/chimera-fake-half.fa
!OUTPUT_FILE: out/chimera-fake-half.affects
$ Find only +B and ? affects on the TRB and unexpected lines
2: seed .* _(\+B| \?){48} _
......@@ -156,7 +156,7 @@ AGCTCTGCTGATTTGTGGGCACTTATGAACCCGAAAGGACATGGCCATGGGGTGGGTAGGGACATAGGGACAGATGCCAG
CGCCCCACTTGATATTCCTTTTAGCCAGCTATGCCATGAGCTGGGTCCGCCAGGCTCCAGGGAAGGGGCTGGAGTGGGTCTCAGCTATTAGTGGTAGTGGTGGTAGCACATACTACGCAGACTCCGTGAAGGGCCGGTTCACCATCTCCAGAGACAATTCCAAGAACACGCTGTATCTGCAAATGAACAGCCTGAGAGCCGAGGACACGGCCGTATATTACTGTGCGAAAGGGTGGGAGGTATTAAACTATGGTTCGGGGAGTTATTATAACGTTGATGCTTTTGATATCTGGGGCCAAGGGACAATGGTCACCGTCTCCTCAGGTAACTC
#1347 vh2
>IGHV2-26*02 0/5/5 IGHD5-24*01 4/13/7 IGHJ4*02 [IGH] BUG-LOCUS
>IGHV2-26*02 0/5/5 IGHD5-24*01 4/13/7 IGHJ4*02 [IGH]
TCAGAGACCTCACGCTGACCTGCACCGTCTCTGGGTTCTCACTCAGCAATGCTAGAATGGGTGTGAGCTGGATCCGTCAGCCCCCAGGGAAGGCCCTGGAGTGGCTTGCACACATTTTTTCGAATGACAAAAAATCCTACAGCACATCTCTGAAGAGCAGGCTCACCATCTCCAAGGACACCTCCAAAAGCCAGGTGGTCCTTACCATGACCAATATGGACCCTGTGGACACAGCCACATATTACTGTGCATGGATACCCGAGGATGGCTACAACGACAAGAGCCAATGACTACTGGGGCCAGGGAACGCTGGTCACCGTCTCCTCAGGTAAATCCATGCACAGTAATATGTGGCTGTGTCCACAGGGTCCATATTGGTCATGGTAAGGACCACCTGGCTTTTGGAGGTGTCCTTGGAGA
#1339 vh3
......
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