Skip to content

@hyphaltip /gist:202528
Created

Embed URL

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
# 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
Something went wrong with that request. Please try again.