This is a test version of Biostars. For the public version, visit https://www.biostars.org.
How to concatenate samtools output into one single file?

I need to extract the genome sequence of >10000 regions. For one example:

samtools faidx GRCh38.primary_assembly.genome.fa chr12:9074800-9074802

output:

AGA

But there are >10000 output. I don't know how to efficiently concatenate them into one single file just like:

AGA
GTA
GG
ATC
TGG
..
..
..

A possible solution I could find out is adding samtools faidx GRCh38.primary_assembly.genome.fa chr12:9074800-9074802> 1.txt to create >10000 files. Then I concatenate all these files using other scripts. But it looks stupid.

Is there any other way to achieve this purpose? Thank you.

samtools

1 answer

-r, --region-file FILE

    Read regions from a file. Format is chr:from-to, one per line. 

Thank you so much! I forgot samtools parameters.

Log in to answer this question.