在下面的bash中,用户选择要在第一个select中使用的文件,然后该文件中的数字被用来自动‘选择the second file. The problem is that when the second file is selected the path appears in the name so thebash`’错误。我似乎无法修复这个错误,需要一些帮助。我为冗长的帖子道歉,只是想确保所有需要的文件都在这里。谢谢:)。
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 a file to analyze with a panel: " # specify file
select file in $(cd ${FILESDIR};ls);do break;done
file1=`basename ${FILESDIR}/${file}`
printf "File 1 is: ${file1} and will be used to filter reads, identify target bases and genes less than 20 and 30 reads, create a low coverage bed for vizulization, calculate 20x and 30x coverage, and filter the vcf for the 98 gene epilepsy panel"
for file in /home/cmccabe/Desktop/NGS/API/5-14-2016/bedtools/$file; do
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} and will be used filtered using the 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文件,用于第一次选择`如果用户选择12311_base_counts.txt)
12311_base_counts.txt
45611_base_counts.txt第二次选择文件的
12311_variant_strandbias_readcount.vcf.hg19_multianno_removed_final (this one is automatically selected because it has the same starting digits as the original file)
45611_variant_strandbias_readcount.vcf.hg19_multianno_removed_final带有错误的bash (this portion of the path is the problem I think, /home/cmccabe/Desktop/NGS/API/5-14-2016/bedtools/)
1) 12311_base_counts.txt
2) 45611_base_counts.txt
please select a file to analyze with a panel: 7
File 1 is: T31129_base_counts.txt and will be used to filter reads, identify target bases and genes less than 20 and 30 reads, create a low coverage bed for visualization, calculate 20x and 30x coverage, and filter the vcf for the 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: and will be used filtered using the epilepsy genes发布于 2016-07-25 15:56:07
应:
file2=$(ls ${ANNOVARDIR}/`basename ${file%%_*}`*)https://stackoverflow.com/questions/38572095
复制相似问题