This is a test version of Biostars. For the public version, visit https://www.biostars.org.
Getting Sequence Based On Chromosome No And Coordinates From Whole Genome Fasta File

I am having chromosome no or fasta header and coordinates and their orientation. For example

Chr:start:end:strand
chr8:1100023:1100050:+

(this list is quite long say about 15000 coordinates)

and whole genome sequence in fasta format in other file, for example:

>(fasta)chr8
sequence

Is there any tool or program or utility available to extract the sequences on the basis of coordinates from genome sequence file.

Any help will be highly appreciated.

Thanks in advance

sequence

3 answers

Samtools can do this.

#First, index your fasta file (only have to do this once)
samtools faidx reference.fa

#then extract the sequences you want
samtools faidx ref.fasta 1:1234-9876

You could also convert your coordinates into the standard BED format then use BEDtools' getfasta command to extract sequences.

sed -e 's/:/\t/ig' Your_coordinate_file > Coordinates.bed
bedtools getfasta -fi Your_fasta_File.fa -bed Coordinates.bed -fo Output_Sequences.fa

look at extractseq from emboss

you could do something like (not tested) in bash:

  extractseq chr8.fasta -reg $(awk 'BEGIN{FS=":" ; ORS=","}{print $2 ".." $3 }' inputfile) stdout -separate

Log in to answer this question.