From 3cb93355a7e80dd4e910eadc613c61b1347067bc Mon Sep 17 00:00:00 2001 From: Calvin Morrison Date: Wed, 2 Apr 2014 13:59:34 -0400 Subject: add sort_by support for top-scores --- SelectiveGenomeAmplification | 16 +++++++++++++--- 1 file changed, 13 insertions(+), 3 deletions(-) diff --git a/SelectiveGenomeAmplification b/SelectiveGenomeAmplification index 25995c0..8fef377 100755 --- a/SelectiveGenomeAmplification +++ b/SelectiveGenomeAmplification @@ -149,6 +149,9 @@ done # scoring_func: A custom scoring function. disable by default. See README.md +# sort score by the minimum or maximum value. acceptable parameters are min or max. +: ${sort_by="max"} + export ignore_mers export min_mer_range export max_mer_range @@ -184,6 +187,15 @@ if [[ -n "$current_run" ]] && [[ ! -d "$output_directory/$current_run" ]]; then exit fi +if [[ "$sort_by" = "min" ]]; then + sort='' +elif [[ "$sort_by" = "max" ]]; then + sort="-r" +else + echo "Error: \$sort_by must either be set to max or min" + exit +fi + num=1 if [[ -z "$current_run" ]]; then while [[ -d $output_directory/run_$num ]] ; do @@ -326,7 +338,5 @@ if [[ -n "$step_score" ]] || [[ -n "$all" ]]; then echo "sorting and outputting top $output_top_nb scores" echo "top scores output file: $output_directory/$current_run/top-scores" head -n 3 $output_directory/$current_run/all-scores > $output_directory/$current_run/top-scores - tail -n +4 $output_directory/$current_run/all-scores | sort -r -t $'\t' -nk 3 | head -n $output_top_nb >> $output_directory/$current_run/top-scores + tail -n +4 $output_directory/$current_run/all-scores | sort $sort -t $'\t' -nk 3 | head -n $output_top_nb >> $output_directory/$current_run/top-scores fi - - -- cgit v1.2.3