在下面的bash
中,用户选择要在第一个select
中使用的文件,然后该文件中的该数字用于自动“选择the second file. The problem is that when the second file is selected the path appears in the name so the
bash”错误。我似乎无法解决这个问题,需要一些帮助。我为长篇文章道歉,只是试图确保所需的所有文件都在这里。谢谢你:)。
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 with error (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
答案 0 :(得分:0)
应该是:
file2=$(ls ${ANNOVARDIR}/`basename ${file%%_*}`*)