changeset 13:37d00e22959b draft

Fixed major bug in barcode length calculation.
author nikos
date Wed, 05 Nov 2014 12:34:49 -0500
parents 52ff42c85994
children 68af3d2260aa
files summarize_unique_barcodes.sh
diffstat 1 files changed, 3 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/summarize_unique_barcodes.sh	Wed Nov 05 11:44:47 2014 -0500
+++ b/summarize_unique_barcodes.sh	Wed Nov 05 12:34:49 2014 -0500
@@ -155,7 +155,7 @@
 #Computing barcode length (Use the first line and compute the string length of the second column)
 if [ "$barcodes" != "None" ]; then
 
-    TMP=`head -1 $barcodes | awk '{print $2}'`
+    TMP=$(for line in `cut -f 2 $barcodes`; do if [ ! -z "$line" ]; then echo $line; break; fi; done)
     BAR_LEN=`echo ${#TMP}`
 
     #Remove "@" from barcodes and sort them
@@ -218,9 +218,8 @@
 
 #Produce k2n file
 if [ "$k2n" == "True" ]; then
-    bar_length=$(head -n 1 $barcodes | cut -f 2 | xargs expr length)
-    Rscript $R_SCRIPT_PATH/k2n.R merged_temp.gz $output_dir/read_counts.txt ${max_observed_barcodes} $bar_length $output_dir/k2n.txt
+    Rscript $R_SCRIPT_PATH/k2n.R merged_temp.gz $output_dir/read_counts.txt ${max_observed_barcodes} $BAR_LEN $output_dir/k2n.txt
 fi
 
 #Remove temp files
-rm paired merged_temp.gz positions_temp_sorted.gz
+rm merged_temp2 merged_temp.gz positions_temp_sorted.gz paired