Mercurial > repos > pjbriggs > pal_finder
comparison pal_finder_wrapper_utils.sh @ 15:a3af1ff4cad1 draft
pal_finder 0.02.04.7 for testing.
author | pjbriggs |
---|---|
date | Mon, 14 May 2018 11:10:19 -0400 |
parents | e95e2b7b3c84 |
children |
comparison
equal
deleted
inserted
replaced
14:3f8bf1a0403b | 15:a3af1ff4cad1 |
---|---|
36 function find_bad_primer_ranges() { | 36 function find_bad_primer_ranges() { |
37 # Parses a pr3in.txt file from pal_finder and reports | 37 # Parses a pr3in.txt file from pal_finder and reports |
38 # sequence ids where the PRIMER_PRODUCT_SIZE_RANGE has | 38 # sequence ids where the PRIMER_PRODUCT_SIZE_RANGE has |
39 # upper limit which is smaller than lower limit | 39 # upper limit which is smaller than lower limit |
40 local pr3in=$1 | 40 local pr3in=$1 |
41 local outfile=$2 | |
41 local pattern="^(SEQUENCE_ID|PRIMER_PRODUCT_SIZE_RANGE)" | 42 local pattern="^(SEQUENCE_ID|PRIMER_PRODUCT_SIZE_RANGE)" |
42 for line in $(grep -E "$pattern" $pr3in | sed 's/ /^/' | sed 'N;s/\n/*/') | 43 for line in $(grep -E "$pattern" $pr3in | sed 's/ /^/' | sed 'N;s/\n/*/') |
43 do | 44 do |
44 # Loop over pairs of SEQUENCE_ID and PRIMER_PRODUCT_SIZE_RANGE | 45 # Loop over pairs of SEQUENCE_ID and PRIMER_PRODUCT_SIZE_RANGE |
45 # keywords in the primer3 input | 46 # keywords in the primer3 input |
46 if [ ! -z "$(echo $line | grep ^SEQUENCE_ID)" ] ; then | 47 if [ ! -z "$(echo $line | grep ^SEQUENCE_ID)" ] ; then |
47 # Extract the values | 48 # Lines look like: |
49 # SEQUENCE_ID=(AT_1_16)(AT_1_16)M00879:99:000000000-AH9KG:1:2107:10006:2535*PRIMER_PRODUCT_SIZE_RANGE=194-329^59-194 | |
48 local size_range=$(echo $line | cut -d'*' -f2 | cut -d'=' -f2 | tr '^' ' ') | 50 local size_range=$(echo $line | cut -d'*' -f2 | cut -d'=' -f2 | tr '^' ' ') |
49 local seq_id=$(echo $line | cut -d'*' -f1 | cut -d'=' -f2) | 51 local seq_id=$(echo $line | cut -d'*' -f1 | cut -d'=' -f2) |
50 else | 52 elif [ ! -z "$(echo $line | grep ^PRIMER_PRODUCT_SIZE_RANGE)" ] ; then |
51 local size_range=$(echo $line | cut -d'*' -f1 | cut -d'=' -f2) | 53 # Lines look like: |
54 # PRIMER_PRODUCT_SIZE_RANGE=194-329^59-194*SEQUENCE_ID=(AT_1_16)(AT_1_16)M00879:99:000000000-AH9KG:1:2107:10006:2535 | |
55 local size_range=$(echo $line | cut -d'*' -f1 | cut -d'=' -f2 | tr '^' ' ') | |
52 local seq_id=$(echo $line | cut -d'*' -f2 | cut -d'=' -f2) | 56 local seq_id=$(echo $line | cut -d'*' -f2 | cut -d'=' -f2) |
53 fi | 57 fi |
54 seq_id=$(echo $seq_id | cut -d')' -f3) | 58 seq_id=$(echo $seq_id | cut -d')' -f3) |
55 # Check the upper and lower limits in each range | 59 # Check the upper and lower limits in each range |
56 # to see if it's okay | 60 # to see if it's okay |
57 local bad_range= | 61 local bad_range= |
58 for range in $(echo $size_range) ; do | 62 for range in $(echo $size_range) ; do |
59 local lower=$(echo $range | cut -d'-' -f1) | 63 local lower=$(echo $range | cut -d'-' -f1) |
60 local upper=$(echo $range | cut -d'-' -f2) | 64 local upper=$(echo $range | cut -d'-' -f2) |
61 if [ $lower -gt $upper ] ; then | 65 if [ "$lower" -gt "$upper" ] ; then |
62 bad_range=yes | 66 bad_range=yes |
63 break | 67 break |
64 fi | 68 fi |
65 done | 69 done |
66 # Report if the range is wrong | 70 # Report if the range is wrong |
67 if [ ! -z "$bad_range" ] ; then | 71 if [ ! -z "$bad_range" ] ; then |
68 echo "$seq_id ($size_range)" | 72 echo "${seq_id}"$'\t'"(${size_range})" >>$outfile |
69 fi | 73 fi |
70 done | 74 done |
71 } | 75 } |