Sequences Collection Based On Length
Hello, I made my own database of protein sequences with formatdb. I would like to know if it is possible and how to retrieve all the sequences of a certain length (e.g all the sequences smaller than 200 aa).
Thanks
Matteo
• 2,288 views
•
link
2 answers
What Pierre said. Assuming you have dumped to fasta file myseqs.fa, here's a Bioperl approach:
#!/usr/bin/perl -w
use strict;
use Bio::SeqIO;
my $inseq = Bio::SeqIO->new(-file => "myseqs.fa", -format => "fasta");
my $outseq = Bio::SeqIO->new(-file => ">myseqs200.fa", -format => "fasta");
# write to file myseqs200.fa
while(my $seq = $inseq->next_seq) {
if($seq->length <= 200) {
$outseq->write_seq($seq);
}
}
• 1 views
•
link
Log in to answer this question.