I have written a bash script, with a python script embedded in it, to extract flanking regions from a BED using hg19 as the reference and save these flanking regions into separate FASTA files using their record IDs. I have a FASTA file with all the flanking regions sequences upstream and downstream of my target site, my problem is when I try to save these flanking regions into separate FASTA files I only get the upstream sequences for every record id. How can I get the flanking regions sequences with the same record ID saved into different FASTA files?
Here's part of the code:
bedtools flank -i input.bed -g hg19_Ensembl.bed -b 150 > output.bed bedtools getfasta -fi hg19.fa -bed output.bed -fo output.fa -name python - <<END #!usr/bin/python from Bio import SeqIO for seq in SeqIO.parse("output.fa", "fasta"): SeqIO.write(seq, seq.id + ".fa","fasta")