Beefy Boxes and Bandwidth Generously Provided by pair Networks
"be consistent"
 
PerlMonks  

Re: how to merge the files of DNA sequences?

by stajich (Chaplain)
on Jul 24, 2004 at 13:20 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://377122]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others imbibing at the Monastery: (4)
As of 2024-03-29 07:34 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found