简体   繁体   English

在 bcftools 中使用 for 循环

[英]Using a for loop with bcftools

I have a folder with 900 files named like this:我有一个包含 900 个文件的文件夹,名称如下:

chr1_643632542_63643636.vcf.gz
chr1_23634521_626356.vcf.gz
chr2_363643262346_234324.vcf.gz
chr2_1345_21346.vcf.gz
....
chr22_134545_3245145.vcf.gz 

I was trying to index each file with the loop:我试图用循环索引每个文件:

for i in {1..22}
do 
  bcftools index -t -f chr${i}_*_*.vcf.gz 
done 

So I would end up with the following:所以我最终会得到以下结果:

chr1_643632542_63643636.vcf.gz
chr1_643632542_63643636.vcf.gz.tbi
chr1_23634521_626356.vcf.gz
chr1_23634521_626356.vcf.gz.tbi
chr2_363643262346_234324.vcf.gz
chr2_363643262346_234324.vcf.gz.tbi
chr2_1345_21346.vcf.gz
chr2_1345_21346.vcf.gz.tbi
....
chr22_134545_3245145.vcf.gz 
chr22_134545_3245145.vcf.gz.tbi

However, when I run the above loop I only get an indexed file for the first chromosme entry with the remainder being ignored (ie one chr1_ _ .vcf.gz.tbi file only is indexed and the remainder ignored and then the first chr2 file and the first chr3 file and so on).但是,当我运行上述循环时,我只得到第一个染色体条目的索引文件,其余部分被忽略(即仅对一个 chr1_ _ .vcf.gz.tbi 文件进行索引,其余部分被忽略,然后是第一个 chr2 文件和第一个 chr3 文件等等)。

Help would be much appreciated.帮助将不胜感激。

All the best祝一切顺利

Maybe loop over file names directly:也许直接循环文件名:

for i in chr*.vcf.gz
do 
  bcftools index -t -f $i 
done 

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM