Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re: How to match the sequences with headers

by Cristoforo (Deacon)
on Jun 14, 2012 at 04:21 UTC ( #976109=note: print w/ replies, xml ) Need Help??


in reply to How to match the sequences with headers

Note how simple the BioPerl solution is.

#!/usr/bin/perl use strict; use warnings; use Bio::SeqIO; my $in = Bio::SeqIO->new( -file => "933212.txt" , -format => 'fasta'); my $out_seq = Bio::SeqIO->new( -file => '>sequence.dat', -format => 'fasta'); my $out_secstr = Bio::SeqIO->new( -file => '>secstr.dat', -format => 'fasta'); while ( my $seq = $in->next_seq() ) { if ($seq->id =~ /sequence$/) { $out_seq->write_seq($seq); } elsif ($seq->id =~ /secstr$/) { $out_secstr->write_seq($seq); } }

Chris


Comment on Re: How to match the sequences with headers
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://976109]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others surveying the Monastery: (7)
As of 2014-08-23 03:51 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (172 votes), past polls