1 new changeset in galaxy-central: http://bitbucket.org/galaxy/galaxy-central/changeset/1113dcc5aaa7/ changeset: r5245:1113dcc5aaa7 user: richard_burhans date: 2011-03-22 18:45:31 summary: fixed comment bug and added additional error messages for SIFT tool affected #: 1 file (2.0 KB) --- a/tools/human_genome_variation/sift_variants_wrapper.sh Tue Mar 22 10:50:27 2011 -0400 +++ b/tools/human_genome_variation/sift_variants_wrapper.sh Tue Mar 22 13:45:31 2011 -0400 @@ -16,10 +16,48 @@ sift_input="$working_dir/sift_input.txt" sift_output="$working_dir/sift_output.txt" +################################################################################ +## make sure input file column selections are mutually exclusive ## +################################################################################ +ERROR=0 +declare -a col_use -## -## get/check the db directory from the argument org,db_loc -## +function check_col () { + local col=$1 + local use=$2 + local int=$3 + + if [ -n "${col//[0-9]}" ]; then + if [ $int -eq 1 ]; then + echo "ERROR: invalid value for $use column: $col" 1>&2 + ERROR=1 + fi + return + fi + + local cur=${col_use[$col]} + if [ -n "$cur" ]; then + echo "ERROR: $use column is the same as $cur column" 1>&2 + col_use[$col]="${cur},$use" + ERROR=1 + else + col_use[$col]=$use + fi +} + +check_col $chrom_col 'chromosome' 1 +check_col $pos_col 'position' 1 +check_col $allele_col 'allele' 1 +check_col $strand_col 'strand' 0 +check_col $comment_col 'comment' 0 + +if [ $ERROR -ne 0 ]; then + exit 1 +fi + +################################################################################ +## get/check the db directory from the argument org,db_loc ## +################################################################################ db_dir=$( awk '$1 == org { print $2 }' org=$org $db_loc ) if [ -z "$db_dir" ]; then @@ -32,9 +70,9 @@ exit 1 fi -## -## create input file for SIFT_exome_nssnvs.pl -## +################################################################################ +## create input file for SIFT_exome_nssnvs.pl ## +################################################################################ if [ ! -r "$input_file" ]; then echo "Can't read input file \"$input_file\"" 1>&2 exit 1 @@ -57,32 +95,26 @@ strand='"-1"' else strand="\$$strand_col" - strand_cvt='if ( '"${strand}"' == "+") { '"${strand}"' = "1" } else if ( '"${strand}"' == "-") { '"${strand}"' = "-1"}' + strand_cvt='if ('"${strand}"' == "+") {'"${strand}"' = "1"} else if ('"${strand}"' == "-") {'"${strand}"' = "-1"}' fi -if [ "$comment_col" = "-" ]; then - is_comment=0 -else - is_comment=1 +print_row='print $'"${chrom_col}"', $'"${beg_col}"', $'"${end_col}"', '"${strand}"', $'"${allele_col}"'' +if [ "$comment_col" != "-" ]; then + print_row=''"${print_row}"', $'"${comment_col}"'' fi awk ' BEGIN {FS="\t";OFS=","} +$'"${chrom_col}"' ~ /^[cC][hH][rR]/ {$'"${chrom_col}"' = substr($'"${chrom_col}"',4)} { - $'"${chrom_col}"' = tolower($'"${chrom_col}"') - sub(/^chr/, "", $'"${chrom_col}"') '"${strand_cvt}"' - if ('"${is_comment}"') { - print $'"${chrom_col}"', $'"${beg_col}"', $'"${end_col}"', '"${strand}"', $'"${allele_col}"', $'"${comment_col}"' - } else { - print $'"${chrom_col}"', $'"${beg_col}"', $'"${end_col}"', '"${strand}"', $'"${allele_col}"' - } + '"${print_row}"' } ' "$input_file" > "$sift_input" -## -## run SIFT variants command line program -## +################################################################################ +## run SIFT_exome_nssnvs.pl command line program ## +################################################################################ if [ "$output_opts" = "None" ]; then output_opts="" else @@ -92,18 +124,18 @@ SIFT_exome_nssnvs.pl -i "$sift_input" -d "$db_dir" -o "$working_dir" $output_opts &> "$sift_output" if [ $? -ne 0 ]; then - echo "failed: SIFT_exome_nssnvs.pl -i \"$sift_input\" -d \"$db_dir\" -o \"$working_dir\" $output_opts" - exit 1 + echo "failed: SIFT_exome_nssnvs.pl -i \"$sift_input\" -d \"$db_dir\" -o \"$working_dir\" $output_opts" + exit 1 fi -## -## locate the output file -## +################################################################################ +## locate the SIFT_exome_nssnvs.pl output file ## +################################################################################ sift_pid=$( sed -n -e 's/^.*Your job id is \([0-9][0-9]*\) and is currently running.*$/\1/p' "$sift_output" ) if [ -z "$sift_pid" ]; then - echo "Can't find SIFT pid in \"$sift_output\"" 1>&2 - exit 1 + echo "Can't find SIFT pid in \"$sift_output\"" 1>&2 + exit 1 fi sift_outdir="$working_dir/$sift_pid" @@ -118,9 +150,9 @@ exit 1 fi -## -## create output file -## +################################################################################ +## create galaxy output file ## +################################################################################ awk ' BEGIN {FS="\t";OFS="\t"} NR == 1 { @@ -139,14 +171,14 @@ print "#" $0 } NR != 1 { - if ($3 == "1") { $3 = "+" } else if ($3 == "-1") { $3 = "-" } + if ($3 == "1") {$3 = "+"} else if ($3 == "-1") {$3 = "-"} '"${pos_adj}"' print } ' > "$output_file" -## -## cleanup -## +################################################################################ +## cleanup ## +################################################################################ rm -rf "$sift_outdir" "$sift_input" "$sift_output" Repository URL: https://bitbucket.org/galaxy/galaxy-central/ -- This is a commit notification from bitbucket.org. You are receiving this because you have the service enabled, addressing the recipient of this email.