Created
October 5, 2009 22:15
-
-
Save hyphaltip/202528 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# concat multiple nexus formatted files into one nexus format file | |
# assuming sequence IDs are the same across all files | |
# and data is all aligned and all seqs are present in all files | |
use Bio::AlignIO; | |
use Bio::SimpleAlign; | |
use strict; | |
my %seqs; | |
for my $file ( @ARGV ) { | |
my $in = Bio::AlignIO->new(-format=> 'nexus', -file => $file); | |
if ( my $aln = $in->next_aln ) { | |
for my $seq ( $aln->each_seq ) { | |
$seqs{$seq->display_id} .= $seq->seq; | |
} | |
} | |
} | |
my $newaln = Bio::SimpleAlign->new; | |
for my $id ( keys %seqs ) { | |
$newaln->add_seq(Bio::LocatableSeq->new(-id=> $id,-seq=>$seqs{$id})); | |
} | |
my $out = Bio::AlignIO->new(-format => 'nexus'); | |
$out->write_aln($newaln); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment