Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re: How to match the sequences with headers

by Cristoforo (Curate)
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

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://976109]
help
Chatterbox?
[Corion]: Hi all! After 13 years or so in the same room, I've now moved to a new room (one door further) - weird :-D
[moritz]: I had an office move too, two floors up
[moritz]: so far I've managed not to get into my old office by accident, but once it was close (already stopped at the wrong floor)

How do I use this? | Other CB clients
Other Users?
Others imbibing at the Monastery: (8)
As of 2017-10-17 08:57 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    My fridge is mostly full of:

















    Results (224 votes). Check out past polls.

    Notices?