I am trying to pass each line of a data file through a function. In addition to the data in the file, a number of other parameters are also parsed into the function. For each line, there a total of 11 total parameters are parsed. For some reason, the last two parameters are ignored by the function.
My code is below, as is a sample of the input data and the result of running the code. Any suggestions?
The Code:
function exon_parse {
data=$1
CHROM=$(awk ' {print $1}' <<< $data )
CHROM_LENGTH=$(awk ' {print $2}' <<< $data )
EXON_LENGTH=$(awk ' {print $3}' <<< $data )
STRAND=$(awk ' {print $4}' <<< $data )
START=$(awk ' {print $5}' <<< $data )
STOP=$(awk ' {print $6}' <<< $data )
POLY_SITES=$(awk ' {print $7}' <<< $data )
Av_Cov_Min=$2
Min_SNPs=$3
REF=$4
BAM1=$5
BAM2=$6
BAM3=$7
BAM4=$8
BAM4=$8
BAM6=$10
OUTPUT_FILE=$11
echo $1
echo $2
echo $3
echo $4
echo $5
echo $6
echo $7
echo $8
echo $9
echo $10
echo $11
exit 0
}
INPUT_FILE="/filepath/confused_reads.txt_"
OUTPUT_FILE="/filepath/filtered_recovered_reads.txt"
Av_Cov_Min=40
Min_SNPs=10
REF="/filepath/Renamed_pmin.scaf.fa"
BAM1="/filepath/SRR573675.realigned.bam"
BAM2="/filepath/SRR573705.realigned.bam"
BAM3="/filepathSRR573706.realigned.bam"
BAM4="/filepath/SRR573707.realigned.bam"
BAM5="/filepath/SRR573708.realigned.bam"
BAM6="/filepath/SRR573709.realigned.bam"
count=1
while read line; do
if [[ $count == 1 ]]; then
count=$(( count + 1 ))
else
data=$line
exon_parse "$data" $Av_Cov_Min $Min_SNPs $REF $BAM1 $BAM2 $BAM3 $BAM4 $BAM5 $BAM6 $OUTPUT_FILE
fi
done < ${INPUT_FILE}
Rather than print out all the parameters, I get the following:
$> ./exonTables_recoverLostReads.bsh
Scaffold10026 154793 6043 . 1 6043 93
40
10
/filepath/Renamed_pmin.scaf.fa
/filepath/SRR573675.realigned.bam
/filepath/SRR573705.realigned.bam
/filepath/SRR573706.realigned.bam
/filepath/SRR573707.realigned.bam
/filepath/SRR573708.realigned.bam
Scaffold10026 154793 6043 . 1 6043 930
Scaffold10026 154793 6043 . 1 6043 931
What happened to the last two parameters?
The first few lines of the input file are as so (my built my code so that it would not parse the header line):
scaffold scaff_length exon_length strand start stop total_polymorphic_sites
Scaffold10026 154793 6043 . 1 6043 93
Scaffold10026 154793 6043 . 1 6043 93
Scaffold10026 154793 6043 . 1 6043 93
Scaffold10575 154793 5235 . 22299 27533 103
Scaffold10575 154793 5235 . 22299 27533 103