Skip to content
Permalink
Branch: master
Find file Copy path
Find file Copy path
Fetching contributors…
Cannot retrieve contributors at this time
34 lines (26 sloc) 638 Bytes
#! /usr/bin/perl -w
# Copyright (2005) Reed A. Cartwright. All rights reserved.
#
# converts nexus sequences to fasta
#
# usage: perl nexus2fasta.pl < infile > outfile
#
# Distributed under the same license as DAWG
#
my $state = 0;
my %seqs = ();
local $/;
my $text = <>;
my ($data) = $text =~ /begin\s+data;.+?matrix\s*(.*?);\s*end;/is;
my @lines = split(/\n/, $data);
foreach(@lines)
{
s/^\s+//;
s/\s+$//;
next unless(/\w/);
my @sec = split(/\s+/, $_);
my $name = shift(@sec);
$seqs{$name} |= '';
$seqs{$name} .= join('', @sec);
}
print ">$_\n$seqs{$_}\n\n" foreach(sort(keys(%seqs)));
You can’t perform that action at this time.