[Bioperl-l] Convert newick to nexus format
Jason Stajich
jason at bioperl.org
Mon Feb 5 18:10:42 UTC 2007
you want to write the TREE out not the TREE WRITER.
$treeout->write_tree($tree)
not
$treeout->write_tree($treeout);
On Feb 5, 2007, at 9:59 AM, Neha Nahar wrote:
> Hello everyone,
>
> I am trying to convert newick tree to nexus format.
> Using the script (refered from and email from George dated Wed Sep
> 22 11:52:47 EDT 2004) :
>
> /*------------------------------------------------------------*/
>
> $ cat nexus.pl
> #!/usr/bin/perl -w
>
> use Bio::TreeIO;
>
> ($NEWICKFILE, $NEXUSFILE) = @ARGV;
> print "newickfile=$NEWICKFILE, nexusfile=$NEXUSFILE\n";
> my $treeio = new Bio::TreeIO(-format => 'newick', -file =>
> "$NEWICKFILE");
> my $treeout = new Bio::TreeIO(-format => 'nexus', -file => ">
> $NEXUSFILE");
> while(my $tree = $treeio->next_tree) {
> $treeout->write_tree($treeout);
> }
>
> exit 0;
>
>
> /*------------------------------------------------------------*/
>
> Running the script through command line:
> Gives the following error:
>
> $ ./nexus.pl mrp-input.txt nexus.out
> newickfile=mrp-input.txt, nexusfile=nexus.out
>
> ------------- EXCEPTION -------------
> MSG: Cannot call method write_tree on Bio::TreeIO object must use a
> subclass
> STACK Bio::TreeIO::nexus::write_tree /usr/lib/perl5/vendor_perl/
> 5.8.8/Bio/TreeIO/nexus.pm:170
> STACK toplevel ./nexus.pl:23
>
> --------------------------------------
>
>
> Using bioperl-1.5.2_101.tar.gz module from http://search.cpan.org/
> ~sendu/bioperl/Bio/TreeIO.pm
>
> Questions:-
>
> 1. Please let me know if I am using the correct version.
> If not, please point me to the latest one.
>
> 2. Provided that the version I am using is the right one, please
> let me know what is wrong with the script.
>
> Thank you.
> Regards,
> Neha.
>
>
>
>
>
> -Neha Nahar
> " Work for cause and not for applause, live to express and not to
> impress !"
>
> ---------------------------------
> Here’s a new way to find what you're looking for - Yahoo! Answers
--
Jason Stajich
Miller Research Fellow
University of California, Berkeley
lab: 510.642.8441
http://pmb.berkeley.edu/~taylor/people/js.html
http://fungalgenomes.org/
More information about the Bioperl-l
mailing list