Commit 009524b9 authored by Mathieu Giraud's avatar Mathieu Giraud

core/kmerstore.h: labels in IKmerStore are now a reference to a Fasta object

Labels were introduced in df19d79c, for -c germlines, and were later used for -2.
Even if they were previously strings, they always designated some file.
parent 1e4c9328
......@@ -54,7 +54,7 @@ public:
int id; // id of this index
int refs; // number of germlines using this index
list< pair <T, string> > labels;
list< pair <T, Fasta> > labels;
/**
* @param input: A single FASTA file
......@@ -125,7 +125,7 @@ public:
* @param kmer: a kmer
* @return one label associated with the kmer
*/
string getLabel(T kmer) const;
Fasta getLabel(T kmer) const;
/**
* @param seq: a sequence
......@@ -225,10 +225,10 @@ void IKmerStore<T>::insert(Fasta& input,
insert(input.sequence(r), label, true, keep_only);
}
labels.push_back(make_pair(T(label, 1), label)) ;
labels.push_back(make_pair(T(label, 1), input)) ;
if (revcomp_indexed && ! T::hasRevcompSymetry()) {
labels.push_back(make_pair(T(label, -1), label)) ;
labels.push_back(make_pair(T(label, -1), input)) ;
}
}
......@@ -334,11 +334,11 @@ string IKmerStore<T>::getSeed() const {
}
template<class T>
string IKmerStore<T>::getLabel(T kmer) const {
for (typename list< pair<T, string> >::const_iterator it = labels.begin(); it != labels.end(); ++it)
Fasta IKmerStore<T>::getLabel(T kmer) const {
for (typename list< pair<T, Fasta> >::const_iterator it = labels.begin(); it != labels.end(); ++it)
if (it->first == kmer)
return it->second ;
return "?" ;
return FASTA_AMBIGUOUS ;
}
// .getResults()
......
......@@ -706,9 +706,9 @@ FineSegmenter::FineSegmenter(Sequence seq, Germline *germline, Cost segment_c,
code_short = "Unexpected ";
code_short += left.toStringSigns() + germline->index->getLabel(left);
code_short += left.toStringSigns() + germline->index->getLabel(left).name;
code_short += "/";
code_short += right.toStringSigns() + germline->index->getLabel(right);
code_short += right.toStringSigns() + germline->index->getLabel(right).name;
info_extra += " " + left.toString() + "/" + right.toString() + " (" + code_short + ")";
}
return ;
......
......@@ -917,10 +917,10 @@ int main (int argc, char **argv)
IKmerStore<KmerAffect> *index = multigermline->index ;
// Initialize statistics, with two additional categories
index->labels.push_back(make_pair(KmerAffect::getAmbiguous(), AFFECT_AMBIGUOUS_SYMBOL));
index->labels.push_back(make_pair(KmerAffect::getUnknown(), AFFECT_UNKNOWN_SYMBOL));
index->labels.push_back(make_pair(KmerAffect::getAmbiguous(), FASTA_AMBIGUOUS));
index->labels.push_back(make_pair(KmerAffect::getUnknown(), FASTA_UNKNOWN));
for (list< pair <KmerAffect, string> >::const_iterator it = index->labels.begin(); it != index->labels.end(); ++it)
for (list< pair <KmerAffect, Fasta> >::const_iterator it = index->labels.begin(); it != index->labels.end(); ++it)
{
char key = affect_char(it->first.affect) ;
stats_kmer[key] = 0 ;
......@@ -972,7 +972,7 @@ int main (int argc, char **argv)
<< endl ;
cout << "\t" << " max" << "\t\t" << " kmers" << "\n" ;
for (list< pair <KmerAffect, string> >::const_iterator it = index->labels.begin(); it != index->labels.end(); ++it)
for (list< pair <KmerAffect, Fasta> >::const_iterator it = index->labels.begin(); it != index->labels.end(); ++it)
{
if (it->first.getStrand() == -1)
continue ;
......@@ -987,7 +987,7 @@ int main (int argc, char **argv)
cout << setw(12) << stats_kmer[key] << " " ;
cout << setw(6) << fixed << setprecision(2) << (float) stats_kmer[key] / total_length * 100 << "%" ;
cout << " " << key << " " << it->second << endl ;
cout << " " << key << " " << it->second.name << endl ;
}
delete index;
......
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