2016-07-25 9 views
0

In der folgenden bash wählt ein Benutzer eine Datei aus, die in der ersten select verwendet werden soll, und dann werden die Ziffern in dieser Datei automatisch 'the second file. The problem is that when the second file is selected the path appears in the name so the bash'-Fehler auswählen. Ich kann das anscheinend nicht beheben und brauche Hilfe. Ich entschuldige mich für die lange Post, nur um sicherzustellen, dass alle benötigten Dateien hier sind. Vielen Dank :).Bash zum Entfernen des Pfades in der Sekunde Wählen Sie

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 

Dateien für die erste wählen `wenn der Benutzer 12311_base_counts.txt)

12311_base_counts.txt 
45611_base_counts.txt 

Dateien für die zweite wählen

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 mit Fehler (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

ich die 'basename' an der falschen Stelle gerade hatte. Dummer Fehler ich entschuldige mich und danke :). – Chris

Antwort

0

Sollte sein:

file2=$(ls ${ANNOVARDIR}/`basename ${file%%_*}`*) 
+1

Ewww. Siehe http://mywiki.wooledge.org/ParsingLs - und führe das ganze über http://shellcheck.net/ aus. –

Verwandte Themen