Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
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?
[huck]: im going to get the APOD https://apod.nasa. gov/apod/ap180425. htmlshiney in today , great pic of jupiter
[huck]: opps typo ... im going to get the APOD shiney in today , great pic of jupiter

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (5)
As of 2018-04-25 07:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Notices?