0

我试图根据每个染色体中的一组 SNP 生成更小的 VCF 文件。我使用此语法手动生成了前 3 个

tabix ALL.chr3.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz -R chr3.tabix.txt > chr3SNPS.vcf

然后我尝试在 bash 循环中为 4 到 17 号染色体运行相同的函数。

我尝试了几种不同的方法,但只有一种有效,而不是我想要的方式。

首先我试过

for i in {4..17}; do tabix ALL.chr$i.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz -R chr$i.tabix.txt > chr$iSNPS.vcf;done

但是当运行时只输出一个名为 chr.vcf 的文件

然后我尝试了

for i in {4..17}; do tabix ALL.chr$i.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz -R chr$i.tabix.txt > chr$i_SNPS.vcf;done

但得到了完全相同的结果。

然后我尝试了这个并意识到我要走得更远

for i in {4..17}; do X="ALL.chr$i.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz";Y="chr$i.tabix.txt";Z= "chr$iSNPS.vcf";tabix $X -R $Y > $Z;done
-bash: ALL.chr4.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz: command not found
-bash: chr.vcf: command not found
-bash: ${Z}: ambiguous redirect
-bash: ALL.chr5.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz: command not found
-bash: chr.vcf: command not found
-bash: ${Z}: ambiguous redirect
…
…
…
-bash: ALL.chr17.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz: command not found
-bash: chr.vcf: command not found
-bash: ${Z}: ambiguous redirect

我终于尝试了这个:

for i in {4..17}; do tabix "ALL.chr$i.phase3_shapeit2_mvncall_integrated_v5a.20130502.genotypes.vcf.gz" -R "chr$i.tabix.txt" > "chr$i.snps.vcf";done

并且它有效,但它以 chr4.snps.vcf 的形式生成了文件,而不是我想要的 chr4SNPS.vcf

如果没有清除正在输入和输出的文件

4

0 回答 0