This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Extract sequences from fasta EXCEPT regions given in the bed file

I want to extract sequences from a genome.fasta, EXCLUDING the regions listed in the Bed file. So I need an output fasta file that does not contain the regions present in the Bed file. See For example:

cat genome.fasta

chr1

ATCGGAGTCGAATTCAATCTT

cat bed.txt

chr1 6 17

cat my_ouput.fasta

chr1

ATCGGA

chr1

TCTT

I tried Bedtools getfasta and intersect commands, but it seems they do not have any option to fulfill my need. I would appreciate any suggestion or a script. Thank you.

genome sequence

2 answers

perhaps combine bedtools complement with bedtools getfasta?

Thanks so much ! The bedtools complement worked. Amazing..

Log in to answer this question.