This is a test version of Biostars. For the public version, visit https://www.biostars.org.
cut the sequence from fasta file

gggggaattggaggttttatcaaagtaagacagtatgatcagatactcatagaaatctgcggacataaagc

Ex- I have like this whole fasta sequence . i want to extract particular sequence like if i want 5 to 20 sequence only from my fasta sequence. then how i extract those sequence. thanks

sequence

3 answers

You can use a tool called fastx. Use fastx-trimmer and give it the start and end position of your selection (in your case 5 to 20).

fastx_trimmer -f 5 -l 20 -i input.fasta -o output.fasta

See here for the instructions.

http://hannonlab.cshl.edu/fastx_toolkit/commandline.html#fastx_trimmer_usage

It is not clear if you want to cut the sequence you pasted above from your sequences or if you just want to identify fasta sequences that contain that sequence. In either case you can use bbduk.sh from BBMap suite to do either. A guide is available here. Sequence you are looking for can be provided via a file or using literal=actual_sequence option.

What you are showing is not a valid fasta file, because the id is missing.

Assuming you have my.fasta file with this content:

>my_sequence
gggggaattggaggttttatcaaagtaagacagtatgatcagatactcatagaaatctgcggacataaagc

You can use samtools faidx

$ samtools faidx my.fasta my_sequence:5-20

Log in to answer this question.