Commit 65a03851 authored by Mikaël Salson's avatar Mikaël Salson

Merge branch 'feature-a/3347-max-clones' into 'dev'

Feature a/3347 max clones

Closes #3347

See merge request !238
parents 6da11427 23a47b92
Pipeline #32546 passed with stages
in 56 seconds
......@@ -263,7 +263,7 @@ json WindowsStorage::computeDiversity(int nb_segmented) {
}
json WindowsStorage::sortedWindowsToJson(map <junction, json> json_data_segment) {
json WindowsStorage::sortedWindowsToJson(map <junction, json> json_data_segment, int max_json_output) {
json windowsArray;
int top = 1;
......@@ -291,6 +291,9 @@ json WindowsStorage::sortedWindowsToJson(map <junction, json> json_data_segment)
windowsList["seg_stat"] = this->statusToJson(it->first);
windowsArray.push_back(windowsList);
if (top == max_json_output + 1)
break ;
}
return windowsArray;
......
......@@ -215,10 +215,11 @@ class WindowsStorage {
/**
* Print the windows from the most abundant to the least abundant
* @max_json_output: maximal number of windows to output (<= 0: no limit)
*/
ostream &printSortedWindows(ostream &os);
json sortedWindowsToJson(map<junction, json> json_data_segment);
json sortedWindowsToJson(map<junction, json> json_data_segment, int max_json_output);
/**
* Display a window with its in size in a somewhat FASTA format
......
!REQUIRES: python $VIDJIL_DIR/tools/check_python_version.py
!LAUNCH: $VIDJIL_DIR/$EXEC $VIDJIL_DEFAULT_OPTIONS -3 --max-clones 10 -y 5 -z 1 -g $VIDJIL_DIR/germline/homo-sapiens.g:IGH -r 4 -b limits $VIDJIL_DATA/Stanford_S22.fasta > /dev/null ; cat out/limits.vidjil
# Test limits in the .vidjil json output
$ There is exactly one clone with a detailed analysis (-z 1)
w1: "cdr3"
$ There are exactly five clones with representative sequences (-y 5)
w5: "sequence": "
$ There are exactly ten clones (--max-clones 10)
w10: "id"
......@@ -17,4 +17,4 @@ $ Display advanced options
: custom Cost
$ Correct number of options
B47:^ -
B48:^ -
......@@ -15,4 +15,4 @@ $ Do not display advanced options
0: custom Cost
$ Correct number of regular options
B24:^ -
B25:^ -
......@@ -399,9 +399,11 @@ int main (int argc, char **argv)
// ----------------------------------------------------------------------------------------------------------------------
group = "Limits to report a clone (or a window)";
int max_clones_id = NO_LIMIT_VALUE ;
int min_reads_clone = DEFAULT_MIN_READS_CLONE ;
float ratio_reads_clone = DEFAULT_RATIO_READS_CLONE;
app.add_option("--max-clones", max_clones_id, "maximal number of output clones ('" NO_LIMIT "': no maximum, default)", false) -> group(group);
app.add_option("-r", min_reads_clone, "minimal number of reads supporting a clone", true) -> group(group);
app.add_option("--ratio", ratio_reads_clone, "minimal percentage of reads supporting a clone", true) -> group(group);
......@@ -1260,14 +1262,25 @@ int main (int argc, char **argv)
string label = windowsStorage->getLabel(it->first);
string window_str = ">" + clone_id + "--window" + " " + label + '\n' + it->first + '\n' ;
//$$ If max_representatives is reached, we stop here but still outputs the window
if ((max_representatives >= 0) && (num_clone >= max_representatives + 1)
&& ! windowsStorage->isInterestingJunction(it->first))
{
out_clones << window_str << endl ;
continue;
}
// interesting junctions are always handled
if (!windowsStorage->isInterestingJunction(it->first))
{
// If max_clones is reached, we stop here
if ((max_clones_id >= 0) && (num_clone >= max_clones_id + 1))
{ cout << "STOP" << endl ;
continue ;
}
// If max_representatives is reached, we stop here but still outputs the window
if ((max_representatives >= 0) && (num_clone >= max_representatives + 1))
{
out_clones << window_str << endl ;
continue;
}
}
cout << clone_id_human << endl ;
......@@ -1497,7 +1510,7 @@ int main (int argc, char **argv)
//json->add("links", jsonLevenshtein);
//out_json << json->toString();
json jsonSortedWindows = windowsStorage->sortedWindowsToJson(json_data_segment);
json jsonSortedWindows = windowsStorage->sortedWindowsToJson(json_data_segment, max_clones_id);
json reads_germline;
for (list<Germline*>::const_iterator it = multigermline->germlines.begin(); it != multigermline->germlines.end(); ++it){
......
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