Mercurial > repos > nick > duplex
comparison 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 |
comparison
equal
deleted
inserted
replaced
17:836fa4fe9494 | 18:e4d75f9efb90 |
---|---|
1 #!/usr/bin/env bash | |
2 if [ x$BASH = x ] || [ ! $BASH_VERSINFO ] || [ $BASH_VERSINFO -lt 4 ]; then | |
3 echo "Error: Must use bash version 4+." >&2 | |
4 exit 1 | |
5 fi | |
6 set -ue | |
7 | |
8 INITIAL_BARCODES_DEFAULT=20 | |
9 | |
10 Usage="Usage: \$ $(basename $0) [barcodes to try]" | |
11 | |
12 function main { | |
13 if [[ $# -ge 1 ]] && [[ $1 == '-h' ]]; then | |
14 fail "$Usage" | |
15 fi | |
16 | |
17 initial_barcodes="$INITIAL_BARCODES_DEFAULT" | |
18 if [[ $# -ge 1 ]]; then | |
19 initial_barcodes=$1 | |
20 fi | |
21 | |
22 cat border-families.txt | paste - - | shuf --random-source=border-families.txt \ | |
23 | head -n $initial_barcodes | while read count1 barcode order count2 rest; do | |
24 echo -ne "$barcode\t$count1\t$count2\t" | |
25 read_name=$(grep -B 1 $barcode barcodes.fq | head -n 1 | tail -c +2) | |
26 echo "$read_name" | |
27 samtools view -f 256 barcodes.bam | awk '$1 == '$read_name' && $5 > 25 {print $3}' | while read read_name2; do | |
28 barcode=$(grep -A 1 -E '^@'$read_name2'$' barcodes.fq | tail -n 1) | |
29 done | |
30 done | |
31 | |
32 } | |
33 | |
34 function fail { | |
35 echo "$@" >&2 | |
36 exit 1 | |
37 } | |
38 | |
39 main "$@" |