Commit a0e74c0a authored by WebTogz's avatar WebTogz

core/windows.cpp: id

parent ee8b4a42
......@@ -45,11 +45,24 @@ list<Sequence> WindowsStorage::getSample(junction window, size_t nb_sampled,
list<Sequence> &reads = getReads(window);
return SequenceSampler(reads).getLongest(nb_sampled, nb_buckets);
}
size_t WindowsStorage::size() {
return seqs_by_window.size();
}
void WindowsStorage::setIdToAll() {
int id = 0;
for (map <junction, list<Sequence> >::const_iterator it = seqs_by_window.begin();
it != seqs_by_window.end(); ++it) {
id_by_window.insert(make_pair(it->first, id));
id++;
}
}
int WindowsStorage::getId(junction window) {
return id_by_window[window];
}
void WindowsStorage::add(junction window, Sequence sequence) {
seqs_by_window[window].push_back(sequence);
}
......@@ -130,7 +143,8 @@ JsonArray WindowsStorage::sortedWindowsToJsonArray(map <junction, JsonList> json
windowsList.add("size", json_size);
//windowsList.add("ratios", normalization_ratios);
windowsList.add("top", top++);
windowsList.add("id", this->getId(it->first));
windowsArray.add(windowsList);
}
......
......@@ -25,6 +25,7 @@ class WindowsStorage {
map<junction, list<Sequence> > seqs_by_window;
map<string, string> windows_labels;
list<pair <junction, int> > sort_all_windows;
map<junction, int> id_by_window;
public:
/**
* Build an empty storage, with the labels that correspond to specific
......@@ -83,6 +84,16 @@ class WindowsStorage {
*/
size_t size();
/**
* @return the id of the window, by his sequence
*/
int getId(junction window);
/**
* Give an id to all the windows, in id_by_window map
*/
void setIdToAll();
/**
* Add a new window with its list of sequences
*/
......
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