bash to remove path in second select -


in bash below user selects file used in first select , digits in file used automatically 'selectthe second file. problem when second file selected path appears in name thebash` errors. can not seem fix , need help. apologize long post, trying make sure files needed here. thank :).

bash

filesdir=/home/cmccabe/desktop/ngs/api/5-14-2016/bedtools annovardir=/home/cmccabe/desktop/ngs/api/5-14-2016/vcf/overall/annovar  ps3="please select file analyze panel: " # specify file select file in $(cd ${filesdir};ls);do break;done     file1=`basename ${filesdir}/${file}`     printf "file 1 is: ${file1} , used filter reads, identify target bases , genes less 20 , 30 reads, create low coverage bed vizulization, calculate 20x , 30x coverage, , filter vcf 98 gene epilepsy panel" file in /home/cmccabe/desktop/ngs/api/5-14-2016/bedtools/$file;  bname=$(basename $file)  pref=${bname%%.txt}  grep -wff /home/cmccabe/desktop/ngs/panels/epilepsy_unix_trim.bed $file > /home/cmccabe/desktop/ngs/api/5-14-2016/panel/reads/${pref}_epilepsy.txt  done # filter vcf printf "\n\n" file2=`basename $(ls ${annovardir}/${file%%_*}*)`         printf "file 2 is: ${file2} , used filtered using epilepsy genes"  pref=${bname%%}  awk 'nr==fnr{for (i=1;i<=nf;i++) a[$i];next} fnr==1 || ($7 in a)' /home/cmccabe/desktop/ngs/panels/epilepsy_unix_trim.bed $file2 | awk '{split($2,a,"-"); print a[1] "\t" $0}' | cut -f2-> /home/cmccabe/desktop/ngs/api/5-14-2016/vcf/panel/annovar/${pref}_epilepsyfiltered.bed 

files first select `if user selects 12311_base_counts.txt)

12311_base_counts.txt 45611_base_counts.txt 

files second select

12311_variant_strandbias_readcount.vcf.hg19_multianno_removed_final (this 1 automatically selected because has same starting digits original file) 45611_variant_strandbias_readcount.vcf.hg19_multianno_removed_final 

bash error (this portion of path problem think, /home/cmccabe/desktop/ngs/api/5-14-2016/bedtools/)

1) 12311_base_counts.txt    2) 45611_base_counts.txt     please select file analyze panel: 7 file 1 is: t31129_base_counts.txt , used filter reads, identify target bases , genes less 20 , 30 reads, create low coverage bed visualization, calculate 20x , 30x coverage, , filter vcf 98 gene epilepsy panel  ls: cannot access /home/cmccabe/desktop/ngs/api/5-14-2016/vcf/overall/annovar//home/cmccabe/desktop/ngs/api/5-14-2016/bedtools/t31129*: no such file or directory/home/cmccabe/desktop/ngs/api/5-14-2016/bedtools/ file 2 is:  , used filtered using epilepsy genes 

should be:

file2=$(ls ${annovardir}/`basename ${file%%_*}`*) 

Comments

Popular posts from this blog

jOOQ update returning clause with Oracle -

java - Warning equals/hashCode on @Data annotation lombok with inheritance -

java - BasicPathUsageException: Cannot join to attribute of basic type -