首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在第二个选择中删除路径的bash

在第二个选择中删除路径的bash
EN

Stack Overflow用户
提问于 2016-07-25 15:41:35
回答 1查看 32关注 0票数 0

在下面的bash中,用户选择要在第一个select中使用的文件,然后该文件中的数字被用来自动‘选择the second file. The problem is that when the second file is selected the path appears in the name so thebash`’错误。我似乎无法修复这个错误,需要一些帮助。我为冗长的帖子道歉,只是想确保所有需要的文件都在这里。谢谢:)。

Bash

代码语言:javascript
复制
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)

代码语言:javascript
复制
12311_base_counts.txt
45611_base_counts.txt

第二次选择文件的

代码语言:javascript
复制
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/)

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2016-07-25 15:56:07

应:

代码语言:javascript
复制
file2=$(ls ${ANNOVARDIR}/`basename ${file%%_*}`*)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/38572095

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档