diff correct.sh @ 18:e4d75f9efb90 draft

planemo upload commit b'4303231da9e48b2719b4429a29b72421d24310f4\n'-dirty
author nick
date Thu, 02 Feb 2017 18:44:31 -0500
parents
children
line wrap: on
line diff
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/correct.sh	Thu Feb 02 18:44:31 2017 -0500
@@ -0,0 +1,39 @@
+#!/usr/bin/env bash
+if [ x$BASH = x ] || [ ! $BASH_VERSINFO ] || [ $BASH_VERSINFO -lt 4 ]; then
+  echo "Error: Must use bash version 4+." >&2
+  exit 1
+fi
+set -ue
+
+INITIAL_BARCODES_DEFAULT=20
+
+Usage="Usage: \$ $(basename $0) [barcodes to try]"
+
+function main {
+  if [[ $# -ge 1 ]] && [[ $1 == '-h' ]]; then
+    fail "$Usage"
+  fi
+
+  initial_barcodes="$INITIAL_BARCODES_DEFAULT"
+  if [[ $# -ge 1 ]]; then
+    initial_barcodes=$1
+  fi
+
+  cat border-families.txt | paste - - | shuf --random-source=border-families.txt \
+      | head -n $initial_barcodes | while read count1 barcode order count2 rest; do
+    echo -ne "$barcode\t$count1\t$count2\t"
+    read_name=$(grep -B 1 $barcode barcodes.fq | head -n 1 | tail -c +2)
+    echo "$read_name"
+    samtools view -f 256 barcodes.bam | awk '$1 == '$read_name' && $5 > 25 {print $3}' | while read read_name2; do
+      barcode=$(grep -A 1 -E '^@'$read_name2'$' barcodes.fq | tail -n 1)
+    done
+  done
+
+}
+
+function fail {
+  echo "$@" >&2
+  exit 1
+}
+
+main "$@"