This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Renaming Bcftools lsec for multiple runs

Hello!

I have a reference file

x.vcf.gz

I also have multiple query files say

1y.vcf.gz

2y.vcf.gz

3y.vcf.gz

.... 603y.vcf.gz

I want to intersect the reference with each separate query file.

Since I have the query files all in one folder, I did

for i in *.vcf.gz; do bcftools isec $i /mnt/projects/x.vcf.gz -p $i -n =2 -w 1; done

This generated multiple folders called 1y.vcf.gz 2y.vcf.gz 3y.vcf.gz.

If I don't specify -p it will just overwrite the files.

Each of these folders contain files with the same name.

Is there any way to simply just rename the files with a prefix and not create multiple folders?

bcftools isec

Thank you @genomax for the edits. I need to specify there is an option -o $i.vcf. This gives me one of the output files and if i specify -p i get 3 outputs. Thank you.

Can you not create separate folders for each query and then send the output to that folder in your for loop? Following is NOT a solution just an idea for you to think about.

for i in *.vcf.gz; do name=$(basename ${i} .vcf.gz); mkdir ${name}; bcftools isec $i /mnt/projects/x.vcf.gz -o ${name}/{name}.vcf -p $i -n =2 -w 1; done

0 answers

No answers yet.

Log in to answer this question.