Beefy Boxes and Bandwidth Generously Provided by pair Networks
Keep It Simple, Stupid
 
PerlMonks  

Re: how to merge the files of DNA sequences?

by stajich (Chaplain)
on Jul 24, 2004 at 13:20 UTC ( #377122=note: print w/replies, xml ) Need Help??


in reply to how to merge the files of DNA sequences?

use strict; use Bio::SeqIO; use Bio::Seq; my %seqs; my @files = qw(file1 file2); for my $file ( @files ) { my $in = Bio::SeqIO->new(-format => 'fasta', -file => $file); while( my $seq = $in->next_seq ) { $seqs{$seq->display_id} .= $seq->seq; # append the seqdata } } my $out = Bio::SeqIO->new(-format => 'fasta', -file => '>newfile.fa'); while( my ($seqname,$seqstr) = each %seqs ) { my $seq = Bio::Seq->new(-id => $seqname, -seq => $seqstr); $out->write_seq($seq); }
Of course if you wanted to have sequence data in another file format you just have to change the 'fasta' to something else like 'genbank', 'swiss', 'embl', etc...

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://377122]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others cooling their heels in the Monastery: (8)
As of 2017-12-16 00:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    What programming language do you hate the most?




















    Results (447 votes). Check out past polls.

    Notices?