b0VIM 7.0fGry vivekvivek.local/Volumes/My Book/camel11_31dec2006/vivek/tmp/NEXPL/lib/Bio/NEXUS/Tools/NexPlotter.pmutf-8 0123 !"#Upt&W%j|Vn<z l$ h B H: QQU$tyw:da i&.q^&% q p [  j i Z .  } ` F 3  H q V 8 u_F)m.=P"! utC$qp; : } $my_data_obj->set_selected_char_block($block) ; if ($block->get_type =~/characters/i && $block->get_title =~/$input_block_type/i){ my $input_block_type = $runtime_options->{'character_data_type'}; foreach my $block (@{$nexusObject->get_blocks()} ) {if ($runtime_options->{'species_tree'} ne 'on') {$my_data_obj->set_title($nexusObject->get_filename);die "Error in loading the Plot module : $@\n" if ($@);} eval{'use GD::Simple;'};} else { eval{'use PDF::API2::Lite;'};} elsif ($runtime_options->{'output_type'} eq "pdf") {eval{use PostScript::Simple;};if ($runtime_options->{'output_type'} eq "ps") {$nexusObject = &__read_nexus(); # Read in the NEXUS file and extract relevant information.#print Dumper $runtime_options;## 1. print Header and the top menu for CGI $ppp_param = $runtime_options->{'ppp'};$runtime_options = $object_data->{'parameters'};#print Dumper $self;$self = bless ($object_data,$self);$object_data->{'parameters'}->{'select_char_range'} = \@column_nos;} push(@column_nos,@{&parse_number($columns)}) if $columns;foreach my $columns (@ {$object_data->{'parameters'}->{'select_char_range'} }) {my @column_nos;print Dumper $object_data;} } $object_data->{'parameters'}->{$field} = $inp_data->{$field}; if ( grep(/$field/,keys %{$inp_data}) > 0 ){foreach my $field ( keys %{ $object_data->{'parameters'} } ) {print Dumper $inp_data;}; } 'gfx' => undef, 'my_data' => undef, 'nexus_obj' => undef, 'data' => { }, 'select_sub_tree' => [], 'swap_children' => [], 'exclude_sub_tree' => [], 'reroot_node' => [], 'ppp' => undef, 'highlight_chars' => [], 'highlight_otus' => [], 'customset' => [], 'setsbyinode' => [], 'select_char_range' => [], 'color_sub_tree' => [], 'cladogrom_mode' => "normal", 'show_cladogram' => undef, 'output_type' => 'ps', 'vertical_otu_spacing' => $Bio::NEXUS::Tools::GraphicsParams::DefaultVerticalOtuSpacing, 'show_border' => undef, 'char_label_block_size' => $Bio::NEXUS::Tools::GraphicsParams::DefaultCharLabelBlockWidth , 'tree_width' => $Bio::NEXUS::Tools::GraphicsParams::DefaultTreeWidth, 'right_justify_labels' => undef, }, 'protist' => undef 'fungi' => undef, 'plant' => undef, 'invertebrate' => undef, 'vertebrate' => undef, 'kingdom' => { 'set_type' => undef, 'colorintron' => undef, 'show_inode_label' => undef, 'show_bootstrap_values' => 'on', 'species_tree' => 'off', 'character_data_type' => 'Protein', 'show_content' => 'Tree and Data', 'output_filename' => 'test.ps', 'input$inp_data = {@$inp_data = {@_} if (ref($inp_data) ne 'HASH') ;my $inp_data = shift;my $self = shift; sub new {my $ppp_param;my $DEBUG;my $nexusObject;my $my_data_obj = new MyData;my $nexusG = new Bio::NEXUS::Tools::GraphicsParams();my $runtime_options;my $main_dir ='.';## Class variablesuse Bio::NEXUS; our $VERSION = $Bio::NEXUS::VERSION;use Bio::NEXUS::Tools::GraphicsParams;use Data::Dumper;use Pod::Usage;use strict;# $Id: NexView.pm,v 1.1 2006/08/28 14:40:57 vivek Exp $# $Revision: 1.1 $# $Date: 2006/08/28 14:40:57 $# $Author: vivek $######################################################################## log from plottree.pl is in the initial version of nexplot.pl)# Derived from nexplot.pl (was plottree.pl prior to 9/15/03; the complete revision ######################################################################package Bio::NEXUS::Tools::NexPlotter;#!/usr/bin/perlda :ze9Z76% P  } V U I  _ ^ J I  q p g f _ O N     > = 8 7  ##################### End ##########################=cut Vivek Gopalan, Micheal Cheng, Weigang Qiu (with Peter Yang, Brendan O'Brien, and Arlin Stoltzfus)=head1 AUTHOR perl(1)=head1 SEE ALSO Perl 5.004, Getopt::Std, Pod::Usage, NEXUS.pm=head1 REQUIRES $Id: NexView.pm,v 1.1 2006/08/28 14:40:57 vivek Exp $ =head1 VERSION =back =over 4 =head1 FILES in the tree block), as well as any character matrix (e.g. sequences) if present in the file. B will read a NEXUS file and output a PostScript display of trees (one file for each tree =head1 DESCRIPTION -a Change page dimensions to fit plot -H Specify output page height (default: 11") -W Specify output page width (default: 8.5") -o Print on multiple pages at actual size -s Print on multiple pages, but shrink to page height PAGE SETUP even if -t (tree only) option is used -g Include gray lines after OTU labels, -B Draw a box indicating postscript\'s bounds of the plot area -F Font to use for labels and titles -R Ratio of font height to Spacing (default: 0.8; rec: 0.5-1) -S Spacing (vertically) between OTUs (default: .25") -T Specify tree width (longest branch; default: 10")-C Columns of characters per block (default = 10) -r Right-justify labels (default: left-justified) PLOT FORMATTING purple, pink, brown, gray, black Color options are red, orange, green, forest, aqua, blue, -U Display taxa sets in color (-U "set1 color1 [set2 color2 ...]") accelerated: same as normal except OTUs are aligned at end normal: all branch lengths equal(auto if no branch lengths present in tree) -c Cladogram mode:-m Matrix only (ignore any trees) (e.g. "dna", "protein", "intron") -I Specify character block (by "Title") to be used in matrix da |WkD'}aK5 M 1 { ` B )  r V R B ' z : 6 4 3   { x 4 3 jJIfG>$"!L|g } $my_data_obj-> } $my_data_obj->set_selected_char_block($block) ; if ($block->get_type =~/characters/i && $block->get_title =~/$input_block_type/i){ my $input_block_type = $runtime_options->{'character_data_type'}; foreach my $block (@{$nexusObject->get_blocks()} ) {if ($runtime_options->{'species_tree'} ne 'on') {$my_data_obj->set_title($nexusObject->get_filename);die "Error in loading the Plot module : $@\n" if ($@);} eval{'use GD::Simple;'};} else { eval{'use PDF::API2::Lite;'};} elsif ($runtime_options->{'output_type'} eq "pdf") {eval{use PostScript::Simple;};if ($runtime_options->{'output_type'} eq "ps") {$nexusObject = &__read_nexus(); # Read in the NEXUS file and extract relevant information.#print Dumper $runtime_options;## 1. print Header and the top menu for CGI $ppp_param = $runtime_options->{'ppp'};$runtime_options = $object_data->{'parameters'};#print Dumper $self;$self = bless ($object_data,$self);$object_data->{'parameters'}->{'select_char_range'} = \@column_nos;} push(@column_nos,@{&parse_number($columns)}) if $columns;foreach my $columns (@ {$object_data->{'parameters'}->{'select_char_range'} }) {my @column_nos;#print Dumper $object_data;} } $object_data->{'parameters'}->{$field} = $inp_data->{$field}; if ( grep(/.?$field/,keys %{$inp_data}) > 0 ){foreach my $field ( keys %{ $object_data->{'parameters'} } ) {}; } 'gfx' => undef, 'my_data' => undef, 'nexus_obj' => undef, 'data' => { }, 'select_sub_tree' => [], 'swap_children' => [], 'exclude_sub_tree' => [], 'reroot_node' => [], 'ppp' => undef, 'highlight_chars' => [], 'highlight_otus' => [], 'customset' => [], 'setsbyinode' => [], 'select_char_range' => [], 'color_sub_tree' => [], 'cladogrom_mode' => "normal", 'show_cladogram' => undef, 'output_type' => 'ps', 'vertical_otu_spacing' => $Bio::NEXUS::Tools::GraphicsParams::DefaultVerticalOtuSpacing, 'show_border' => undef, 'char_label_block_size' => $Bio::NEXUS::Tools::GraphicsParams::DefaultCharLabelBlockWidth , 'tree_width' => $Bio::NEXUS::Tools::GraphicsParams::DefaultTreeWidth, 'right_justify_labels' => undef, }, 'protist' => undef 'fungi' => undef, 'plant' => undef, 'invertebrate' => undef, 'vertebrate' => undef, 'kingdom' => { 'set_type' => undef, 'colorintron' => undef, 'show_inode_label' => undef, 'show_bootstrap_values' => 'on', 'species_tree' => 'off', 'character_data_type' => 'Protein', 'show_content' => 'Tree and Data', 'output_filename' => 'test.ps', 'input_filename' => 'test.nex', 'parameters' => {my $object_data = {da`jxAli@ C  = < : 9 g J w 6 - -VVs\KJ{n\?!wR _D*tIHmy $tree = $my_data_obj->get_selected_tree;# PRINT TREE AND OTHER ELEMENTS IF PRESENT# Assgn state to nodes by taxonomy##############################} $my_data_obj->set_font(gdSmallFont()); $my_data_obj->allocate_colors; $my_data_obj->set_image_handler($im); $im->interlaced('true');#$im->transparent($white);# make the background transparent and interlaced my $im = new GD::Simple($nexusG->get_xsize,$nexusG->get_ysize);else {} $my_data_obj->set_font($font); $my_data_obj->set_image_handler($p); $p->page($nexusG->get_xsize,$nexusG->get_ysize); my $font = $p->corefont("Courier"); my $p = new PDF::API2::Lite;elsif ( $runtime_options->{'output_type'} eq "pdf" ) {} $my_data_obj->set_image_handler($p); $p->setfont("Courier",10); $p->newpage; direction => "RightDown"); coordorigin => "LeftTop", units => "pt", eps => 0, colour => 1, ysize => $nexusG->get_ysize, xsize => $nexusG->get_xsize, my $p = new PostScript::Simple(if ($runtime_options->{'output_type'} eq "ps" ) {### 5. Open the image handlers for drawing#print "";#print Dumper $nexusG;#print "
";$nexusG->set_ysize;$nexusG->set_xsize;$nexusG->set_upperYbound;$nexusG->set_upperXbound;}	&__set_node_coords($my_data_obj->get_selected_tree);	$nexusG->set_TreeWidth($runtime_options->{'tree_width'}*72);if ($runtime_options->{'show_content'} ne 'Data only' && defined $my_data_obj->get_selected_tree) {$nexusG->set_lowerYbound;$nexusG->set_lowerXbound;#print "
";#print "
";}	$nexusG->set_longestCharLabelLength(@col_labels) if @col_labels;	my @col_labels = $my_data_obj->get_char_column_labels;	$nexusG->set_charactersXwidth($block);	my $block = $my_data_obj->get_selected_char_block;	$nexusG->set_histogramHeight if $my_data_obj->get_char_block_wts;if ($my_data_obj->get_selected_char_block && ( $runtime_options->{'show_content'} ne "Tree only")) {$nexusG->set_paneHeight(scalar @$taxlabels);$nexusG->set_maxTaxLabelwidth($taxlabels);}	$taxlabels = $nexusObject->get_block('taxa')->get_taxlabels();} else {	$taxlabels = $my_data_obj->get_selected_tree->get_node_names();if ($my_data_obj->get_selected_tree) {my $taxlabels;$nexusG->set_charLabelBlockWidth($runtime_options->{'char_label_block_size'});$nexusG->set_verticalOtuSpacing($runtime_options->{'vertical_otu_spacing'});$nexusG->set_fontHeight(13);$nexusG->set_fontWidth(6);#gdSmallFont->width####    CGI options and content of the NEXUS file.#### 4. Graphics Layout and pupulating my_data object - set all  size of the canvas and the panes based on the}	$my_data_obj->set_species_tree( $hist_dup->get_tree('species_tree') ); 	$my_data_obj->set_gene_tree( $hist_dup->get_tree('gene_tree') ); 	$my_data_obj->set_selected_tree( $hist_dup->get_tree('species_tree') ); 	$my_data_obj->set_selected_char_block(undef); 	my $hist_dup = $nexusObject->get_block('history','duplication_speciation');	$my_data_obj->set_selected_tree( $nexusObject->get_block );} else {	}		$my_data_obj->set_selected_tree( $tree );		my $tree = $nexusObject->get_block("trees")->get_tree;	if ($nexusObject->get_block("trees")) {	}		$nexusObject = $nexusObject->select_chars(\@selectchar_params,$my_data_obj->get_selected_char_block->get_title) if (@selectchar_params);		my @selectchar_params  = @{ $runtime_options->{'select_char_range'} };		if (defined $my_data_obj->get_selected_char_block) { 	$my_data_obj->set_selected_char_block( $nexusObject->get_block("character") ) if not defined $my_data_obj->get_selected_char_block;	}da}VWV"{8



x
w
H
T :51.,


p
L					e	3	!PNMLbYGW42}NY=<}|if ($runtime_options->{'output_type'} eq "ps") {# 11. Convert the image handler output to PNG, PS and PDF format based on the output option.  #print "
",Dumper($nexusObject),"
";#&__save_session($session);&__plot_scale_border_title($my_data_obj); } &__plot_wts($my_data_obj,$my_data_obj->get_char_block_wts) if ( $my_data_obj->get_char_block_wts ) ; } &__highlight_char($my_data_obj,$block); &__print_char_labels($my_data_obj,$block); if ($my_data_obj->get_char_column_labels) { my $block = $my_data_obj->get_selected_char_block; if ($my_data_obj->get_selected_char_block && $runtime_options->{'show_content'} ne 'Tree only') { # Character labels, weights} &__print_boot_strap($my_data_obj,$tree->get_nodes) if ($runtime_options->{'show_bootstrap_values'} eq 'on') ; &__print_inode_names($my_data_obj,$tree->get_nodes) if ($runtime_options->{'show_inode_label'} eq 'on') ; } &__print_piechart($my_data_obj,$tree->get_rootnode, $otu_seq_hash); %{$otu_seq_hash} = map {$_->get_name => $_->get_seq} @{$otus}; my $otu_seq_hash; my $otus = $nexusObject->get_block("history",'intron')->get_otuset->get_otus; if (defined $nexusObject->get_block("history",'intron') && $ppp_param) { &__print_matrix($my_data_obj,$nexusG->get_lowerXbound, $nexusG->get_lowerYbound,$taxlabels,0) if ($runtime_options->{'show_content'} eq 'Tree and Data'); &__print_tree($my_data_obj,$tree->get_rootnode, $nexusG->get_lowerXbound, $nexusG->get_lowerYbound) if defined $tree;} else { &__print_matrix($my_data_obj,$nexusG->get_lowerXbound, $nexusG->get_lowerYbound,$taxlabels,1);if (($runtime_options->{'show_content'} eq 'Data only') || (not defined $tree)) {##### 10. Drawing the tree and character matrix data.} &AssignStateToSubNode($my_data_obj,$node,'highlighter') if ($colornode_params[0] ne '' && $node); } &AssignStateToSuperNode($my_data_obj,$root,$highlight_param,\@nodes_list,'gold') if ($highlight_param); my @nodes_list; foreach my $highlight_param(@highlight_params) { my @highlight_params = @{ $runtime_options->{'highlight_otus'} }; &AssignStateToNode( $my_data_obj->get_nodes_hash,$root,'black'); my $node = $tree->find($colornode_params[$#colornode_params]) if ($colornode_params[0] ne ''); my $root = $tree->get_rootnode(); if (defined $tree) { my @colornode_params = @{ $runtime_options->{'color_sub_tree'} }; # Color a node and its children##### 9. propagating coloring options on the tree } } } } $my_data_obj->set_node_color($taxon,$col_name) if $col_name =~/\S+/; my $col_name = $setsColors{$taxSetName}; for my $taxon (@{$taxSets->{$taxSetName}}) { for my $taxSetName (sort keys %{$taxSets}) { } $count++; $setsColors{$key} = $customset_params[$count-1]; foreach my $key (sort keys %{$taxSets}) { my @customset_params = @{ $runtime_options->{'customset'} }; my $count = 1; my %setsColors; my $taxSets = $block->get_taxsets(); warn("Grabbing sets block from NEXUS file...\n") if $DEBUG; my $block = $nexusObject->get_block('sets'); my $taxSets = $nexusObject->get_block('sets')->get_taxsets(); if ($nexusObject->get_block('sets')) { } $my_data_obj->set_node_color($taxlabel,'black'); for my $taxlabel (@$taxlabels) { my $taxlabels = $nexusObject->get_block('taxa')->get_taxlabels();if ($runtime_options->{'set_type'} eq 'Custom') {##### 8. Custom set processing for taxa label colors #######} &__assign_ncbi_taxonomy($my_data_obj,$taxlabels);if ($runtime_options->{'set_type'} eq 'Taxonomy') {##### 7. Coloring data and tree based on the NCBI Taxonomy optionmy $taxlabels = ($tree) ? $tree->get_node_names() : $nexusObject->get_block('taxa')->get_taxlabels();dany(&|pn:,)( R P O @ -  v _ "  M  l  V !LHb2zWTRQ; @HY-mMJB( } } $im_h->lineTo($x2,$y2); $im_h->fgcolor($color_val); $im_h->penSize($size,1); $im_h->moveTo($x1,$y1); else { } $im_h->line($x1,$y1,$x2,$y2); $im_h->setcolour(@{$color_val}); else { $im_h->setlinewidth(1.5); } if ($size == 0.5) { $im_h->setlinewidth(0.5); } }elsif ($my_data->get_image_handler_type eq 'ps') { $im_h->stroke; $im_h->line($x2, $nexusG->get_ysize-$y2); $im_h->move($x1, $nexusG->get_ysize-$y1); #$im_h->linewidth(1); $im_h->strokecolor($color_val); if ($my_data->get_image_handler_type eq 'pdf') { my $color_val = $my_data->get_color($color); my $im_h = $my_data->get_image_handler; my ($my_data,$x1, $y1, $x2, $y2, $color, $size) = @_;sub __draw_line {} $im_h->polygon({filled=>1},$x,$y,$x+$radius/2*cos($start_rad),$y+$radius/2*sin($start_rad),$x+$radius/2*cos($prob_rad+$start_rad),$y+$radius/2*sin($prob_rad+$start_rad)); $im_h->arc({filled=>1},$x,$y,$radius/2,360-($start+$prob*360),$start); my $prob_rad = $prob * 2 * $pi; my $start_rad = $start/180 * $pi; my $pi = 3.14159265; my $im_h = $my_data->get_image_handler; my ($my_data,$x,$y,$radius,$prob,$start) = @_;sub __draw_pieslice {} } $im_h->ellipse($radius,$radius); $im_h->fgcolor('black'); $im_h->bgcolor(undef); $im_h->moveTo($x,$y); $im_h->arc($radius,$radius,0,$prob*360,gdEdged()|gdArc()); $im_h->bgcolor($my_data->get_color('red')); $im_h->fgcolor($my_data->get_color('black')); $im_h->arc($radius,$radius,0,360,gdArc()); $im_h->bgcolor($my_data->get_color('silver'));#$im->bgcolor(undef); $im_h->penSize(1,1); $im_h->moveTo($x,$y); } else { &__draw_pieslice($my_data,$x,$y,$radius,$prob,$start); } $im_h->arc({filled=>1}, $x, $y, $radius/2, 180, 0); $prob -= 0.5; $start = 180; if ($prob >= 0.5) { my $start = 0; $im_h->setcolour(@{$my_data->get_color('red')}); $im_h->circle($x,$y,$radius/2); $im_h->setcolour(@{$my_data->get_color('black')}); $im_h->circle({filled => 1},$x,$y,$radius/2); $im_h->setcolour(@{$my_data->get_color('silver')}); $im_h->setlinewidth(1); }elsif ($my_data->get_image_handler_type eq 'ps') { $im_h->fill; $im_h->arc($x,$nexusG->get_ysize - $y,$radius/2,$radius/2,0,$prob*360 + 0.1,1); $im_h->fillcolor($my_data->get_color('red')); $im_h->stroke; $im_h->circle($x,$nexusG->get_ysize-$y,$radius/2); $im_h->strokecolor($my_data->get_color('black')); $im_h->circle($x, $nexusG->get_ysize-$y, $radius/2); $im_h->strokecolor($my_data->get_color('silver')); if ($my_data->get_image_handler_type eq 'pdf') { my $im_h = $my_data->get_image_handler; my ($my_data,$x, $y, $radius, $prob) = @_;sub __draw_piechart {} return "#". join "", map {sprintf "%2.2X",$_} @{$rgb_hash}; my $rgb_hash = shift;sub rgb2hex {} $self->{'data'}->{'gfx'} = $gfx; $self->{'data'}->{'my_data'} = $my_data; $self->{'data'}->{'nexus_obj'} = $nexus_obj; my ($nexus_obj,$my_data,$gfx) = @_; my $self = shift;sub set_data {} return ($self->{'data'}->{'nexus_obj'},$self->{'data'}->{'my_data'},$self->{'data'}->{'gfx'} ) ; my $self = shift;sub get_data {#################################################################### SUBROUTINES};return $self;$self->set_data($nexusObject,$my_data_obj,$nexusG);} close PNG; print PNG $my_data_obj->get_image_handler->png() || die "DIED"; binmode PNG; open(PNG,">$runtime_options->{'output_filename'}") || die "cannot open file\n"; else {} $my_data_obj->get_image_handler->saveas($runtime_options->{'output_filename'});elsif ($runtime_options->{'output_type'} eq "pdf") {} $my_data_obj->get_image_handler->output($runtime_options->{'output_filename'})dazvHpM  | ^ D A ? > * t R :   ] T <  m ?  v r ( hF<~{yxiYI%k_0&~:VUxwA $nexusObject = $nexusObject->exclude_subtree($excludesub_param); foreach my $excludesub_param (@excludesub_params) { $nexusObject = $nexusObject->select_subtree($selectsub_params[$#selectsub_params]) if ( $selectsub_params[0] ne '' ); $nexusObject = $nexusObject->reroot($reroot_params[$#reroot_params]) if ($reroot_params[0] ne ''); if ($nexusObject->get_block('trees')) { my $tree; my @setsbyinode_params = @{ $runtime_options->{'setsbyinode'} }; my @excludesub_params = @{ $runtime_options->{'exclude_sub_tree'} }; # Exclude a subtree my @swap_params = @{ $runtime_options->{'swap_children'} }; # Swap the children of the node my @reroot_params = @{ $runtime_options->{'reroot_node'} }; # Reroot a subtree my @selectsub_params = @{ $runtime_options->{'select_sub_tree'} }; # Select a subtree# Read in NEXUS blocks from NEXUS object } return $nexusObject; if ($runtime_options->{'species_tree'} eq 'on') { } $nexusObject = new Bio::NEXUS($inputFile); } else { $nexusObject = new Bio::NEXUS($inputFile,1); $DEBUG=1; if($nexusG->get_isVerbose) { my $nexusObject; my $inputFile = $runtime_options->{'input_filename'}; my $mydata = shift;sub __read_nexus {} } return 0; } else { return 1; if ($arg =~ /(\d+\.?\d*|\.\d+)/) { my $var=$_[1]; my $arg=$_[0];sub isNumber {} } return undef; } else { return $arg; if ($arg =~ /(\d+\.?\d*|\.\d+)/) { my $arg=$_[0];sub checkNumber {} } $im_h->rectangle($x1,$y1,$x2,$y2); } $im_h->bgcolor($color_val); }else { $im_h->bgcolor(@{$color_val}); if (ref $color_val) { } else { $im_h->box({filled=>1},$x1,$y1,$x2,$y2); $im_h->setcolour(map {$_*1} @{$color_val}); } elsif ($my_data->get_image_handler_type eq 'ps') { $im_h->fill; $im_h->rectxy($x1,$nexusG->get_ysize - $y1,$x2,$nexusG->get_ysize-$y2); } $im_h->fillcolor($color_val); }else { $im_h->fillcolor(&rgb2hex($color_val)); if (ref $color_val) { if ($my_data->get_image_handler_type eq 'pdf') { my $im_h = $my_data->get_image_handler; my $color_val = $my_data->get_color($color); my ($my_data,$x1, $y1, $x2, $y2, $color,$transparency) = @_;sub __draw_filledRect {} } $im_h->arc($radius,$radius,0,360,gdEdged()|gdArc()); $im_h->bgcolor($color_val); $im_h->fgcolor($color_val); $im_h->moveTo($x,$y); }else { $im_h->circle($x,$y,$radius/2); $im_h->setcolour(@{$color_val}); $im_h->setlinewidth(1); }elsif ($my_data->get_image_handler_type eq 'ps') { $im_h->stroke; $im_h->circle($x,$nexusG->get_ysize - $y, $radius/2); #$im_h->linewidth(1); $im_h->strokecolor($color_val); if ($my_data->get_image_handler_type eq 'pdf') { my $color_val = $my_data->get_color($color); my $im_h = $my_data->get_image_handler; my ($my_data,$x, $y, $radius, $color) = @_;sub __draw_circle {} } $im_h->string($string); $im_h->fgcolor($color_val); $im_h->fontsize(14) if ($font eq 'Times'); $im_h->font($font); $im_h->moveTo($x,$y+($nexusG->get_fontHeight)/2);#$font="Courier"; else { } $im_h->text($x, $y + ($nexusG->get_fontHeight/4),$string); $im_h->setcolour(@{$color_val}); }elsif ($my_data->get_image_handler_type eq 'ps') { $im_h->fill; $im_h->print($font,10,$x,$nexusG->get_ysize-$y,0,0,$string); $im_h->fillcolor($color_val); if ($my_data->get_image_handler_type eq 'pdf') { my $color_val = $my_data->get_color($color); my $im_h = $my_data->get_image_handler; my $font = $my_data->get_font; my ($my_data, $x, $y, $string, $color) = @_;sub __draw_text {da l?;1 C $   { O  l a *  | ] ;    wvcOJ fGB5{O+w53[H)C my $name = $node->get_name; my ($map, $node, $unknownState) = @_;#$map # hash with any available states#$unknownState # state to assign when no other assignment can be made #$node # node object# any undefined states of OTUs *will remain undefined*# * does not assume all OTUs have defined states, but note that # * allows for polytomies; # * maps states to the *names* of nodes, not to their object refs;# "AssignAncestralStatesByConsensus"; # * probably should be put in a library and named something like # this function ## _i_ if and only if all of its descendants are assigned to state _i_. # transitions are allowed. Thus, an ancestor is assigned to a state # based on a transition model of infinite cost (zero rate), so that no # Technically, what we are doing here is reconstructing ancestral states ## AssignStateToNode -- propagate colors or other states up a treesub AssignStateToNode { } return \@arr; @arr = sort {$a<=>$b} @arr; } } die "non-number was used for column number\n"; } elsif ($item) { push ( @arr, $item-1 ); } elsif ($item =~ /^\d+$/) { # eg 4 for (my $i = $1; $i <= $2; $i++) { push ( @arr, $i-1 ); } $item =~ /([0-9]+)\s*-\s*([0-9]+)/; if ($item =~ /-/) { # eg 1-3 foreach my $item (@cols) { my @arr; my @cols = split(/,/, $s); $s =~ s/,?\s+/,/g; # use ',' as separator $s =~ s/^\s+|\s+$//g; } die "Invalid number format. Use 1 or 1-3 or 1, 3, 5-8 or 1 3 5 6-10.\n"; if (! $s =~ /^\s*(\d+(-\d+)?)([,\s]\s*\d+(-\d+)?)*\s*$/ ) { my $s = shift;sub parse_number {#Taken from nextool.pl# parse numbers in format "1-3, 4 6 8-10"}return $nexusObject;#die "No tree in file $inputFile\n" unless $tree;# EXTRACT TREE DATA#}# print "Tree: $myTreeName
";# $myTreeName = $myTree->{name};#foreach my $myTree (@trees) {#my @trees = @{$block->get_trees()}; ##### Get names of all trees in the file######### } } $nexusObject->add_block($setsblock); $setsblock->set_taxsets($sets); $setsblock = Bio::NEXUS::SetsBlock->new('Sets',[]); } else { $nexusObject->get_block('Sets')->add_taxsets($sets); if ($nexusObject->get_block('Sets')) { } $$sets{$inodename} = $otus; my $otus = $subtree->get_otus(); my $subtree = $nexusObject->select_subtree($inodename); for my $inodename (@setsbyinode_params) { my $setsblock; my $sets; if (defined $nexusObject->get_block("Trees") && $nexusObject->get_block("trees")->get_tree) {#### Set by Inode ### } $nexusObject = $nexusObject->select_chars(\@intron_present_cols) if (lc($runtime_options->{'character_data_type'}) eq 'intron'); } } } last; push @intron_present_cols, $c; if (substr($sequence,$c,1) ne '0') { my $sequence = $intron_seqs{$taxon}; foreach my $taxon (@taxa) { for (my $c=0; $c < length($intron_seqs{$taxa[0]}); $c++) { my %intron_seqs = %{$nexusObject->get_block("characters","intron")->get_otuset->get_seq_string_hash} if $nexusObject->get_block("characters","intron"); my @taxa = @{$nexusObject->get_block("characters")->get_taxlabels()} if $nexusObject->get_block("characters"); my @intron_present_cols=(); if ($selectsub_params[0] ne '' || $excludesub_params[0] ne '') { } $nexusObject = $nexusObject->exclude_otus(\@excludesub_params); } else { } &swap_children($tree,$swapnode) if ($tree->find($swapnode)); last if ($swapnode eq ''); foreach my $swapnode(@swap_params){ $tree = $nexusObject->get_block("trees")->get_tree(); }daMh\[v3 * x P ) n ' $ #    { ^ 6 5  v J ) k#xY6) wHm5mjB if ( not $ppp_param ) { my $y2 = int( $y1 + $treeNodeRadius ); my $x2 = int( $x1 + $treeNodeRadius ); } &__print_label($my_data, $x1+$pieChartRadius*.75, $y1,$node->get_name,$color) ; if ($node->is_otu()) { } &__draw_line($my_data,$x0, $y0, $x0, $y1, $color, 2) unless $node->get_name eq 'root' ; &__draw_line($my_data,$x0, $y1, $x1, $y1, $color, 2); $y1 = int($node->_get_ycoord); else { } } &__draw_line($my_data,$x0, $y1, $x0, $y0 - $pieChartRadius / 2, $color, 2) unless $node->get_name eq 'root' ; else { } &__draw_line($my_data,$x0, $y1, $x0, $y0 + $pieChartRadius/2, $color, 2) unless $node->get_name eq 'root' ; if ($y1 > $y0) { &__draw_line($my_data,$x0, $y1, $x1, $y1, $color, 2); $y1 = int($node->_get_ycoord); $prob_val = ":p(1) = ". $prob_val; $prob_val = (ref $seq) ? $seq->[1] : $seq; my $seq = $otuseqs->{$name}->[$ppp_param-1]; if ($ppp_param && $nexusObject->get_block('history','intron')) {#$y1 += $nexusG->get_fontHeight; $color = (!$runtime_options->{'set_type'} || $runtime_options->{'set_type'} eq 'None') ? $my_data->get_node_color($name)||'black' : $my_data->get_node_color($name)||'gray'; my $pieChartRadius = $nexusG->get_pieChartRadius; my $treeNodeRadius = $nexusG->get_treeNodeRadius; my $prob_val = ''; my $color; my $y1 = 0; my $x1 = int($node->_get_xcoord); my $name = $node->get_name(); my ($my_data,$node, $x0, $y0,$otuseqs) = @_;sub __print_tree {} } &__print_piechart($my_data,$child,$otu_seq_hash); foreach my $child (@{$node->get_children()}) { &__draw_piechart($my_data,$x, $y, $nexusG->get_pieChartRadius, $prob); $prob = ((ref $seq) eq 'ARRAY') ? $seq->[1] : $seq; my $prob = 0; my $seq = $otu_seq_hash->{$name}->[$ppp_param-1]; my $y = $node->_get_ycoord; my $x = $node->_get_xcoord; my $name = $node->get_name(); my ($my_data, $node, $otu_seq_hash) = @_;sub __print_piechart {} return; } &AssignStateToSubNode($my_data, $child, $color); $my_data->set_node_color($child->get_name,$color); foreach my $child (@{$node->get_children()}) { return if (!$node || $node->is_otu()); my $name = $node->get_name; my ($my_data, $node, $color) = @_;# AssignStateToNode -- propagate colors or other states down a tree once a node is selectedsub AssignStateToSubNode { } return; } &AssignStateToSuperNode($my_data,$child,$OTU,\@newNodesList,$color); push @newNodesList,$child->get_name; my @newNodesList = @nodesList; foreach my $child (@{$node->get_children()}) { } return; } $my_data->set_node_color($node_name, $color); foreach my $node_name (@nodesList) { if ($nodesList[$#nodesList] eq $OTU) { return if ($node && $node->is_otu() && ($name ne $OTU)); my $name = $node->get_name; my @nodesList = @$nodesListRef; my ($my_data, $node, $OTU, $nodesListRef, $color) = @_;# AssignStateToSuperNode -- propogate color up a tree to highlight a sequence's branch pathsub AssignStateToSuperNode {} return( $map->{ $name } = ( $assignable ? $lastState : $unknownState ) ); } $lastState = $map->{$childname}; } $assignable = 0; if ( defined($lastState) && $$map{$childname} ne $lastState ) { &AssignStateToNode($map, $child, $unknownState) unless $map->{$childname}; my $childname = $child->get_name; foreach my $child (@{$node->get_children()}) {# Go through children and make sure all children are the same state return if (defined($map->{$name}) || $node->is_otu() ); # return if state already exists OR if the node is an OTU my $assignable = 1; my $lastState = undef; da9B9 q n f 3 0  w <   y K c ` ^ ] I  rq:j^)uT3UI*GXUSR98sub __print_sequence() {} } &__draw_line($my_data,$x1,$y1,$x2,$y1,'gray',1) if (($x1 < $x2) && ($runtime_options->{'show_content'} ne 'Tree only') && $my_data->get_char_column_labels); $x1 += length($taxon_name) * $nexusG->get_fontWidth + $nexusG->get_fontWidth; #$areaMap.= sprintf "\n",$x1,$y2,$x1+length($taxon_name)*$nexusG->get_fontWidth,$y2+$nexusG->get_fontHeight, $taxon_name if ($runtime_options->{'output_type'} ne "ps" && $runtime_options->{'output_type'} ne "pdf"); $my_data->set_label_map_coord( $taxon_name, [$x1,$y2,$x1+length($taxon_name)*$nexusG->get_fontWidth,$y2+$nexusG->get_fontHeight] ) if $runtime_options->{'output_type'} eq 'png'; &__draw_text($my_data,$x1,$y2,$taxon_name,$color); $y2 = $y; #$y2 = $y-( $nexusG->get_fontHeight/2); $y1 = $y; $x2 = $nexusG->get_characterStartXpos - $nexusG->get_labelMatrixGapWidth; $x1 = $x; } else { &__draw_line($my_data,$x1,$y1,$x2,$y1,'gray',1) if (($x1 < $x2) && ($runtime_options->{'show_content'} ne 'Data only')); $x2 -= $nexusG->get_fontWidth; $x1 += $nexusG->get_fontWidth; $my_data->set_label_map_coord( $taxon_name, [$x2,$y2,$x2+length($taxon_name)*$nexusG->get_fontWidth,$y2+$nexusG->get_fontHeight] ) if $runtime_options->{'output_type'} eq 'png'; &__draw_text($my_data,$x2,$y2,$taxon_name,$color); $y2 = $y; $x2 = $nexusG->get_characterStartXpos - (length($taxon_name) * $nexusG->get_fontWidth) - $nexusG->get_labelMatrixGapWidth; $y1 = $y; $x1 = $x; if ($runtime_options->{'right_justify_labels'} eq 'on') {# Print either left justified or right justified names my $tip = ($color ne 'gray') ? 'OTU options' : 'Taxonomy not identified for this sequence'; $color = ( defined($color) ? $color : 'black' ); my ($x1,$x2,$y1,$y2); my ($my_data, $x, $y,$taxon_name, $color) = @_;sub __print_label {} } $y0 += $nexusG->get_verticalOtuSpacing; &__print_sequence($my_data, $xPos,$y0,$seqs->{$taxa},$taxa, $color) if defined $seqs; $color = 'gray' if ( (defined @{ $runtime_options->{'highlight_otus'} }) and ($color eq 'black') ); my $xPos = $nexusG->get_characterStartXpos; &__print_label($my_data,$x0,$y0,$taxa,$color) if $is_print_labels; my $color = $my_data->get_node_color($taxa); foreach my $taxa (@{$taxlabels}) { my $seqs = $my_data->get_char_block_seq; my ($my_data, $x0, $y0,$taxlabels,$is_print_labels) = @_;sub __print_matrix {} } } &__print_tree($my_data,$child, $x1, $y1,$otuseqs); foreach my $child (@nodes) { my @nodes = @{$node->get_children()}; if (not $node->is_otu) { } #$areaMap .= qq(\n); else { } #$areaMap .= qq(\n); $node->_set_ycoord($y1); $node->_set_xcoord($x1);#$query->delete("session") if ($runtime_options->{'session'}); if ($node->{name} ne "root") { $my_data->set_tree_map_coord( $node->get_name, [$x1,$y1,$x2,$y2] ) if $runtime_options->{'output_type'} eq 'png'; } &__draw_circle($my_data,$x1, $y1,$treeNodeRadius,$color) if (!$node->is_otu); da%YHdY x M  c u P &  ` E SuVb[O#$}yvWYX for (my $c = 0,my $index = 0; $c < length($intronSeq); $c++, $index++) { # Get positions only where introns are present my @intron_present_pos = (); my @intronLabels = @{$nexusObject->get_block("characters","intron")->get_charlabels}; my $intronSeq = $intronSequences{$taxName}; my %intronSequences = %{$nexusObject->get_block("characters","intron")->get_otuset->get_seq_string_hash}; elsif (($runtime_options->{'colorintron'}) ne '' && (lc($runtime_options->{'character_data_type'}) ne 'intron')) { } } $xpos += $fontWidth if ($columnCount% ($blockWidth) == 0); $columnCount++; $xpos += $fontWidth; } #$floatMap .=sprintf "\n",$xpos,$y,$xpos+$fontWidth,$y+$fontHeight; &__draw_line($my_data,$xpos,$y+$fontHeight,$xpos+$fontWidth,$y+$fontHeight,'black',0.5); # Bottom border &__draw_line($my_data,$xpos,$y+$fontHeight-($fontHeight*$colorscale),$xpos+$fontWidth,$y+$fontHeight-($fontHeight*$colorscale),'black',0.5); # Top border &__draw_line($my_data,$xpos+$fontWidth,$y+$fontHeight-($fontHeight*$colorscale),$xpos+$fontWidth,$y+$fontHeight,'black',0.5); # Right border &__draw_line($my_data,$xpos,$y+$fontHeight-($fontHeight*$colorscale),$xpos,$y+$fontHeight,'black',0.5); # Left border &__draw_filledRect($my_data,$xpos,$y+$fontHeight-($fontHeight*$colorscale),$xpos+$fontWidth,$y+$fontHeight,$color); } $color = [0,$colorscale/.25*255,255]; else { } $color = [0,255,(1-($colorscale-0.25)/0.25)*255]; elsif ($colorscale > 0.25) { } $color = [($colorscale-0.5)/0.25*255,255,0]; elsif ($colorscale > 0.5) { } $color = [255,(1-($colorscale-0.75)/0.25)*255,0]; if ($colorscale > 0.75) { $colorscale = ($max == 0) ? 0 : $val/$max; else { } #$floatMap .=sprintf "\n",$xpos,$y,$xpos+$fontWidth,$y+$fontHeight; &__draw_text($my_data,$xpos,$y,'?','black'); elsif ($missing_val eq $val) { } #$floatMap .=sprintf "\n",$xpos,$y,$xpos+$fontWidth,$y+$fontHeight; if ($gap_val eq $val) { $my_data->add_contin_data_map_coord($taxName,[$xpos,$y,$xpos+$fontWidth,$y+$fontHeight]) if $runtime_options->{'output_type'} eq 'png'; my $val = $states[$_-1]; for (1 .. scalar(@states)) { my $im_h = $my_data->get_image_handler; my @states = split(' ',$sequence); my $color; my $colorscale; my $columnCount = 0; my $xpos = $x; my $max = $max_val || $continuousMax; } $continuousMax = pop @array; my @array = sort { $a <=>$b } split(' ',$my_data->get_char_block_seq->{$taxName}); if (not $max_val) { ##Find largest value in continuous data my $continuousMax; # Largest value in a continuous data matrix if ($data_type eq 'continuous') { my $xnew = $x; my $blockWidth = $nexusG->get_charLabelBlockWidth; my $fontHeight = $nexusG->get_fontHeight; my $fontWidth = $nexusG->get_fontWidth; $sequence = uc (&__processSeqForDisplay($sequence)) if ($data_type ne 'continuous'); my $max_val = $block->get_format()->{'max'} if ($block->get_format()->{'max'}); my $missing_val = $block->get_format()->{'missing'} if ($block->get_format()->{'missing'}); my $gap_val = $block->get_format()->{'gap'} if ($block->get_format()->{'gap'}); my $data_type = $block->get_format()->{'datatype'} if ($block->get_format()); $color = ( defined($color) ? $color : 'black' ); my $block = $my_data->get_selected_char_block; my ($my_data, $x, $y, $sequence, $taxName, $color) = @_;da bQ7! tb0 f 9 k e s +  ; ) GbVH,&!fP["!ba warn "WARNING: No labels\n" unless @columnLabels; my @columnLabelsAll = @{$nexusObject->get_block("characters","intron")->get_charlabels} if $nexusObject->get_block("characters","intron"); my @columnLabels = $my_data->get_char_column_labels; warn("Grabbing characters block from NEXUS file...\n") if $DEBUG; my ($my_data, $block) = @_;sub __print_char_labels {} return $string; $string =~ s/(.{$char_block_width})/$1 /g; my $char_block_width = $nexusG->get_charLabelBlockWidth; my $tmp_string = ""; my @tmp = split (//, $string); $string =~ tr/01/.+/; my $string = shift;sub __processSeqForDisplay() {} } &__draw_text($my_data,$xnew,$y,uc($sequence),$color); else { } } &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$frontPos+int($frontPos/$blockWidth),length($sequence)-$frontPos+int($aaNum/$blockWidth)-int($frontPos/$blockWidth))),$color); my $frontPx = ($frontPos+int($frontPos/$blockWidth))*$fontWidth; } } $frontPos = $dnaNum+3; &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$dnaNum+int(($dnaNum-1)/$blockWidth),3+$length)),$phaseColor); my $length = 1 if (int($dnaNum+1)/$blockWidth > int($dnaNum-1)/$blockWidth); $frontPx += ($dnaNum-$frontPos+$numBlanks)*$fontWidth; &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$frontPos+int(($frontPos-1)/$blockWidth),$dnaNum-$frontPos+$numBlanks)),$color); if ($dnaNum+$phaseNum < length($sequence)) { my $frontPx = ($frontPos+int(($frontPos-1)/$blockWidth))*$fontWidth; my $numBlanks = int(($dnaNum-1)/$blockWidth)-int(($frontPos-1)/$blockWidth); my $phaseColor = $phaseColor[$phaseNum]; next if $dnaNum < 0; my $dnaNum = ($aaNum-1)*3; (my $phaseNum = $intron_pos) =~ s/(.*-)//; $aaNum -= 3 * $runtime_options->{'select_char_range'}->[0] if defined @{$runtime_options->{'select_char_range'}}; ($aaNum = $intron_pos) =~ s/(-.)//; foreach my $intron_pos (@intron_present_pos) { $aaNum = 0; $frontPos = 0; elsif (lc ($runtime_options->{'character_data_type'}) eq 'dna') { } &__draw_text( $my_data,$xnew + $frontPx, $y, uc( substr( $sequence,$frontPos + int ( $frontPos/$blockWidth), length($sequence) - $frontPos + $numBlanks) ), $color); my $frontPx = ($frontPos + int($frontPos/$blockWidth)) * $fontWidth; $numBlanks = $aaNum < 0 ? 0 : int($aaNum/$blockWidth)-int($frontPos/$blockWidth); } } $frontPos = $aaNum; &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$aaNum-1+int(($aaNum-1)/$blockWidth),1)),$phaseColor); $frontPx -= $fontWidth if ($aaNum%$blockWidth == 0); $frontPx += ($aaNum-1-$frontPos+$numBlanks)*$fontWidth; &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$frontPos+int($frontPos/$blockWidth),$aaNum-1-$frontPos+$numBlanks)),$color); if ($aaNum <= length($sequence)) { next if $aaNum < 1; my $frontPx = ($frontPos+int($frontPos/$blockWidth))*$fontWidth; $numBlanks = int($aaNum/$blockWidth)-int($frontPos/$blockWidth); my $phaseColor = $phaseColor[$phaseNum]; (my $phaseNum = $intron_pos) =~ s/(.*-)//; $aaNum -= $runtime_options->{'select_char_range'}->[0] if defined @{$runtime_options->{'select_char_range'}}; ($aaNum = $intron_pos) =~ s/(-.)//; foreach my $intron_pos (@intron_present_pos) { my $numBlanks; $aaNum = 0; $frontPos = 0; if (lc($runtime_options->{'character_data_type'}) eq 'protein') { my @phaseColor = ('red','blue','darkgreen'); my $aaNum = 0; my $frontPos = 0; #print "
 $taxName ";print Dumper \@intron_present_pos;print"
"; } push @intron_present_pos, $intronLabels[$index]; last if ($index == -1); $index = index($intronSeq,'1',$index);daYQu>=o  a O E @ < ; ? > ' y v t ^ A w H W V Z96"SQP38aO>\X my $x2 = $x1 + ($nexusG->get_fontWidth/2); my $x1 = $nexusG->get_characterStartXpos + $blank + $i * $nexusG->get_fontWidth + (0.25 * $nexusG->get_fontWidth); } $blank += $nexusG->get_fontWidth; if ( $i && ($i % ($nexusG->get_charLabelBlockWidth)) == 0 ) { # char #11, #21, etc. my $height = $weights[$i] * $nexusG->get_histogramHeight ; for (my $i = 0; $i <= $#weights; $i++) { my $is_weights; my $blank = 0; my ($my_data, @weights) = @_;sub __plot_wts {}#$labelAreaMap .=sprintf "\n",$x, $y, $x + $nexusG->get_fontWidth, $y + $nexusG->get_fontHeight if ($runtime_options->{'output_type'} ne "ps" && $runtime_options->{'output_type'} ne "pdf"); $my_data->set_intron_map_coord($label,[$x,$y,$x+$nexusG->get_fontWidth,$y+$nexusG->get_fontHeight]) if $runtime_options->{'output_type'} eq 'png'; &__draw_text($my_data,$x,$y,'H','blue'); my ($my_data, $x, $y, $label,$color,@columnLabelsAll) = @_;sub __print_intron_history {} &__print_intron_history($my_data,$x,$y,$label,$color,@columnLabelsAll) if ( (lc $runtime_options->{'character_data_type'}) eq 'intron') && ($nexusObject->get_block('history','intron')); $label =~ s/\s//g; $label =~ s/\|/-/; } $y += $nexusG->get_fontHeight; &__draw_text($my_data,$x,$y,$letter,$color); foreach my $letter (split(//,$label)) { my ($my_data, $x, $y, $label, $color,@columnLabelsAll) = @_;sub __print_vertical_label {} } } &__draw_filledRect($my_data,$x,$nexusG->get_upperYbound,$x+$nexusG->get_fontWidth,$nexusG->get_ysize-1,'pink'); &__draw_filledRect($my_data,$x,1,$x+$nexusG->get_fontWidth,$nexusG->get_lowerYMargin,'pink'); if (my $char_highlight_pos = grep /^$columnLabels[$i]$/ , @{$runtime_options->{'highlight_chars'} } ) { my $x = $nexusG->get_characterStartXpos + $blank + $i * $nexusG->get_fontWidth; my $label=$columnLabels[$i]; } $blank += $nexusG ->get_fontWidth; if ( $i && ($i % ($nexusG->get_charLabelBlockWidth) == 0) ) { # char #11, #21, etc. for (my $i = 0; $i <= $#columnLabels; $i++) { my $blank = 0; warn "WARNING: No labels\n" unless @columnLabels; my @columnLabels = $my_data->get_char_column_labels; warn("Grabbing characters block from NEXUS file...\n") if $DEBUG; my ($my_data, $block) = @_;sub __highlight_char{} } &__print_vertical_label($my_data, $x, $yPosition, $label, $color, @columnLabelsAll); substr($label,0,0) = ' ' x (($longestLabel/$nexusG->get_fontHeight)-length($label)); $label =~ s/-|_/\|/; $my_data->set_label_map_coord($label,[$x,$yPosition,$x+$nexusG->get_fontWidth,$nexusG->get_lowerYbound-$nexusG->get_fontHeight]) if $runtime_options->{'output_type'} eq 'png'; my $color = ($ppp_param && ($colpos==($i+1))) ? 'darkgreen': 'darkred'; } } last; $colpos = $_; if ($highlightcol eq $columnLabels[$_-1]) {#print "@columnLabels
";#print "$highlightcol , $columnLabelsAll[$_-1]
"; for (1 .. scalar(@columnLabelsAll)) { my $colpos = 0; my $x = $nexusG->get_characterStartXpos + $blank + $i * $nexusG->get_fontWidth; my $label=$columnLabels[$i]; } $blank += $nexusG ->get_fontWidth; if ( $i && ($i % ($nexusG->get_charLabelBlockWidth) == 0) ) { # char #11, #21, etc. for (my $i = 0; $i <= $#columnLabels; $i++) { my $highlightcol = $columnLabelsAll[$ppp_param-1]; my $yPosition = $nexusG->get_lowerYMargin ; my $longestLabel = $nexusG->get_longestCharLabelLength(); my $blank = 0;da#UZW ` S :   o Q  } g G . C @ > #  a{8Q0/ }K]IFDC&% my $dbh = DBI->connect("dbi:mysql:taxonomy", "root", "") || die "Can't connect to taxonomy: $DBI::errstr"; my ($my_data , $taxlabels) = @_; use DBI;sub __assign_ncbi_taxonomy {} } &__draw_line($my_data,$lowerXBorder,$upperYBorder,$lowerXBorder,$lowerYBorder,'black',2); &__draw_line($my_data,$upperXBorder,$upperYBorder,$lowerXBorder,$upperYBorder,'black',2); &__draw_line($my_data,$upperXBorder,$lowerYBorder,$upperXBorder,$upperYBorder,'black',2); &__draw_line($my_data,$lowerXBorder,$lowerYBorder,$upperXBorder,$lowerYBorder,'black',2); my $upperYBorder = $nexusG->get_ysize - ($nexusG->get_upperYMargin/2); my $upperXBorder = $nexusG->get_xsize - ($nexusG->get_upperXMargin/2); my $lowerYBorder = $nexusG->get_lowerYMargin/2; my $lowerXBorder = $nexusG->get_lowerXMargin/2; if ($runtime_options->{'show_border'} eq 'on' ){ # draw a box around what Postscript has determined is the plot# PRINT BORDER &__draw_text($my_data,$nexusG->get_lowerXbound, $nexusG->get_fontHeight+5, uc($file_param), 'black'); my $file_param = 'Test'; #my $file_param = $my_data->get_title;# PRINT TITLE }#&__print_line($lowerXbound + $amp / 10, $lowerYbound+5, $lowerXbound + $amp / 10, $lowerYbound, 2);#&__print_line($lowerXbound, $lowerYbound+5, $lowerXbound, $lowerYbound, 2);#&__print_line($lowerXbound, $lowerYbound, $lowerXbound + $amp / 10, $lowerYbound, 2);#$lowerYbound -= $nexusGi->get_fontHeight if ($runtimeOptions{t});#$lowerYbound -= $nexusG->get_histogramHeight/2 if (!($runtimeOptions{t}) && &__get_column_labels); if ( ($runtime_options->{'show_content'} ne 'Data only') && $nexusObject->get_block('trees') && (not $cladogram_type)) { my $cladogram_type = $runtime_options->{'cladogram_mode'} if $runtime_options->{'show_cladogram'};# PRINT SCALE my ($my_data) = @_;sub __plot_scale_border_title {} } &__draw_text($my_data,$node->_get_xcoord - ($nexusG->get_fontWidth * 4),$node->_get_ycoord + ($nexusG->get_fontHeight)/2,$node->get_support_value,'red'); next unless $node->get_support_value; # print only non-zero values and only if defined in the tree my $name = $node->get_name(); foreach my $node (@{$nodes}) { my ($my_data, $nodes) = @_;sub __print_boot_strap() {} } &__draw_text($my_data,$xnew, $y1,$node->get_name, 'darkgray'); $xnew += $nexusG->get_pieChartRadius* 0.5 if ($ppp_param); $xnew = $x1 + $nexusG->get_fontWidth/2; $y1 = int($node->_get_ycoord); $x1 = int($node->_get_xcoord); next if $node->is_otu; foreach my $node (@{$nodes}) { my ($xnew,$x1, $y1); my ($my_data, $nodes) = @_;sub __print_inode_names() {} } $node->_set_ycoord($node->_get_ycoord + $nexusG->get_lowerYbound); $node->_set_xcoord(($node->_get_xcoord* $amp) + $nexusG->get_lowerXbound); foreach my $node (@nodes) { my $amp = $nexusG->get_TreeWidth / $sortedNum if ($sortedNum != 0); # unit of branch length my $sortedNum = pop @sorted; @sorted = sort { $a <=> $b } @sorted; } push @sorted, $node->_get_xcoord(); for my $node (@nodes) { my @sorted; warn("Getting names of OTUs in tree...\n") if ( $DEBUG ); my $root = $tree->get_rootnode(); my @nodes = @{$tree->get_nodes()}; $tree->_set_ycoord(0,$nexusG->get_verticalOtuSpacing); $tree->_set_xcoord($nexusG->get_TreeWidth,$cladogram_type); my $cladogram_type = $runtime_options->{'cladogram_mode'} if $runtime_options->{'show_cladogram'}; my $treeName = $tree->get_name() || "unnamed"; my $tree = shift; sub __set_node_coords {} } &__draw_filledRect($my_data,$x1,$y1,$x2,$y2,'darkgreen'); my $y2 = $nexusG->get_lowerYbound - $nexusG->get_charLabelMatrixGapWidth; my $y1 = $nexusG->get_lowerYbound - $height - $nexusG->get_charLabelMatrixGapWidth;da tAaF=' ^ [ D y = c P F  + V   pDK6{zmlYC'~eL7v[;oS3mFB,  my ($self,$title) = @_;sub set_title {} return $data; bless ($data,$self); }; 'gd_contin_data_map_coord' => undef, 'gd_intron_map_coord' => undef, 'gd_label_map_coord' => undef, 'gd_tree_map_coord' => undef, 'gd_color_hash' => {}, 'ps_color_hash' => $RGBcolorHash, 'nodes_color_hash' => {}, 'char_column_labels' => [], 'char_block_wts' => [], 'char_block_seq' => undef, 'species_tree' => undef, 'selected_tree' => undef, 'title' => undef, 'selected_character_block' => undef, my $data = { }; tranparent_pink => [255,34,179] highlighter => [51,184,215], yellow => [255,255,0], silver => [230,232,250], darkgreen => [0,140,0], darkred => [170,0,0], darkpurple => [111,0,111], darkgray => [110,110,110], orange => [255,120,0], purple => [111,0,111], black => [0,0,0], brown => [139,69,19], pink => [255,34,179], gray => [130,130,130], gold => [255,185,15], aqua => [152,245,255], forest => [34,139,34], blue => [0,0,250], green => [0,150,0], red => [250,0,0], white => [250,250,250], my $RGBcolorHash = { my $self = shift;sub new () {use Data::Dumper;package MyData;} $self = $tree->clone; $swapnode->get_children()->[0] = $tempnode; } $swapnode->get_children()->[$index] = $swapnode->get_children()->[$index-1]; print $index, " "; for (my $index = $childcount-1; $index > 0; $index--) { my $tempnode = $swapnode->get_children()->[$childcount-1]; my $childcount = scalar(@{$swapnode->get_children()}); $swapnode or die "ERROR: Node $nodename not found in $treename\n"; my $swapnode = $tree->find($nodename); my $tree = $self->clone(); my $treename = $self->get_name(); my ($self,$nodename) = @_;sub swap_children {} $dbh->disconnect; } } $my_data->set_node_color($taxlabel,$kingdom->{$$matrix_ref[0][$rowNo]}); for (my $rowNo = 0;$rowNo < $num_of_rows;$rowNo++) { my $matrix_ref = $sth->fetchall_arrayref; my $num_of_rows = $sth->rows; my $rc = $sth->execute($id) || die "Can't execute statement: $DBI::errstr"; my $sth = $dbh->prepare($sql_statement) || die "Can't prepare statement: $DBI::errstr"; } $id = ($dir_param eq 'pandit') ? $id : "$id%"; chop($id) if ($dir_param eq 'NEXUS' or $dir_param eq 'uploads'); chop($id) if ($dir_param eq 'NEXUS' or $dir_param eq 'uploads'); }else {## some conditions if ($dir_param eq 'uploads') { (my $id=$taxlabel_tmp)=~s/^.*_//g; my $taxlabel_tmp=(split(/\//,$taxlabel))[0]; for my $taxlabel (@$taxlabels) { }; protist => lc $runtime_options->{'kingdom'}->{'protist'} fungi => lc $runtime_options->{'kingdom'}->{'fungi'}, plants => lc $runtime_options->{'kingdom'}->{'plant'}, invertebrata => lc $runtime_options->{'kingdom'}->{'invertebrate'}, vertebrata => lc $runtime_options->{'kingdom'}->{'vertebrate'}, my $kingdom = { } $table_name.$field_name $search_cond limit 10}; name_class='scientific name' and where $table_name.taxon_id=taxon_name.taxon_id and from $table_name,taxon_name SELECT kingdom,name $sql_statement=qq{ }else { taxon_id= ? limit 10}; where name_class='scientific name' and from taxon_name SELECT kingdom,name $sql_statement=qq{ if($dir_param eq 'uploads') { my $sql_statement; my $search_cond=($dir_param eq 'pandit') ? "= ?" : "like ?"; my $field_name = ($dir_param eq 'pandit') ? 'sptr_id' : 'prot_id'; my $table_name = ($dir_param eq 'pandit') ? 'sptr_taxa' : 'cds'; my $dir_param = $runtime_options->{'directory_param'}; daOg1/.r532 g     a # !  m . , + i g O <    { h O M L / zkaQNL6sytpmk[D"uD;}jPxtPbON my $self = shift;sub get_char_column_labels {} return $self->{'char_block_seq'}; } } $self->{'char_block_seq'} = $block->get_otuset->get_seq_string_hash; else { } $self->{'char_block_seq'} = $block->get_otuset->get_seq_string_hash(' '); if ($data_type eq 'continuous') { } $data_type = $block->get_format()->{'datatype'} ; if ($block->get_format()) { if ( not defined $self->{'char_block_seq'} and defined $block) { my $data_type; my $block = $self->{'selected_character_block'}; my $taxon_name = shift; my $self = shift;sub get_char_block_seq {} return $color || $name; } $color = "#". join "", map {sprintf "%2.2X",$_} @{ $self->{'ps_color_hash'}->{lc $name} } if $self->{'ps_color_hash'}->{lc $name}; }else { $color = $self->{'ps_color_hash'}->{lc $name}; }elsif ((ref $img_h) =~/Postscript/i) { $color = $self->{'gd_color_hash'}->{lc $name}; if ((ref $img_h) =~ /GD/i) { my $color; my $img_h = $self->{'image_handle'}; my $name = shift || 'black'; my $self = shift;sub get_color {} } } } $self->{'gd_color_hash'}->{$color_val} = $img_h->colorAllocate( @{ $self->{'ps_color_hash'}->{$color_val} } ); }else { $self->{'gd_color_hash'}->{$color_val} = $img_h->colorAllocateAlpha( @{ $self->{'ps_color_hash'}->{$color_val} },120); if ($color_val eq 'tranparent_pink'){ if ((ref $img_h) =~/GD/i) { foreach my $color_val (keys %{ $self->{'ps_color_hash'} }) { my $img_h = $self->{'image_handle'}; my $self = shift;sub allocate_colors {} } return 'pdf'; } else { return 'ps'; } elsif ((ref $self->{'image_handle'}) =~/Post/i) { return 'gd'; if ((ref $self->{'image_handle'}) =~/GD/i) { return if not defined $self->{'image_handle'}; my $self = shift;sub get_image_handler_type {} return $self->{'font'}; my $self = shift;sub get_font {} $self->{'font'} = shift; my $self = shift;sub set_font {} return $self->{'image_handle'}; my $self = shift;sub get_image_handler {} $self->{'image_handle'} = shift; my $self = shift;sub set_image_handler {} return $self->{'selected_character_block'}; my $self = shift;sub get_selected_char_block {} $self->{'selected_character_block'} = shift; my $self = shift;sub set_selected_char_block {} return $self->{'gd_intron_map_coord'}->{$col_label}; ## black my ($self, $col_label) = @_;sub get_intron_map_coord {} $self->{'gd_intron_map_coord'}->{$col_label} = $coord; my ($self,$col_label,$coord) = @_;sub set_intron_map_coord {} return $self->{'gd_label_map_coord'}->{$col_label}; ## black my ($self, $col_label) = @_;sub get_label_map_coord {} $self->{'gd_label_map_coord'}->{$col_label} = $coord; my ($self,$col_label,$coord) = @_;sub set_label_map_coord {} push (@{ $self->{'gd_contin_data_map_coord'}->{$node_name} }, $coord); ## black my ($self, $node_name,$coord) = @_;sub add_contin_data_map_coord {} return $self->{'gd_contin_data_map_coord'}->{$node_name}; ## black my ($self, $node_name) = @_;sub get_contin_data_map_coord {} $self->{'gd_contin_data_map_coord'}->{$node_name} = $coord; my ($self,$node_name,$coord) = @_;sub set_contin_data_map_coord {} return $self->{'gd_tree_map_coord'}->{$node_name}; ## black my ($self, $node_name) = @_;sub get_tree_map_coord {} $self->{'gd_tree_map_coord'}->{$node_name} = $coord; my ($self,$node_name,$coord) = @_;sub set_tree_map_coord {} return $self->{'title'}; my ($self) = @_;sub get_title {} $self->{'title'} = $title;da8{K&NJ y w v a B p > ) { 3 W E  r c (  `XQKFBnLJ7hfeCyS'nKIHED   hgWV>&^8-t Tree only (ignore any characters) -i Turn on internal node labeling -b Turn on bootstrap values, if any INFORMATION TO DISPLAY-f Specify output file (default: STDOUT) -V Print version information and quit -v Verbose mode -d Full documentation -h Brief help message =head1 OPTIONS nexplot.pl [options] foo.nex [tree_name] > foo.ps =head1 SYNOPSISnexplot.pl - PostScript plot of tree + data table (from NEXUS infile)=head1 NAME__END__################# POD Documentation ##################1;} return $self->{'selected_tree'}; my $self = shift;sub get_selected_tree {} return undef; } return $gene_node->get_name if $species_name eq $species_node_name; my ($species_name) = $comment =~ /:?S=([^:]*)/g; $comment = $gene_node->get_support_value; for my $gene_node (@gene_nodelist) { my $species_name; my $comment; my @gene_nodelist = @{ $gene_tree->get_nodes}; my $species_tree = $self->get_species_tree; my $gene_tree = $self->get_gene_tree; my ($self,$species_node_name) = @_;sub get_nodename_from_gene_tree {} return $self->{'gene_tree'}; my ($self) = @_;sub get_gene_tree {} return $self->{'species_tree'}; my ($self,$tree) = @_;sub get_species_tree {} $self->{'gene_tree'} = $tree; my ($self,$tree) = @_;sub set_gene_tree{} $self->{'species_tree'} = $tree; my ($self,$tree) = @_;sub set_species_tree {} $self->{'selected_tree'} = shift; my $self = shift;sub set_selected_tree {} return @{$self->{'char_block_wts'}}; } $self->{'char_block_wts'} = \@weights; } } } } } warn("Weights have been found in this file\n") if $is_weights; warn("No weights found in this file\n") unless $is_weights; if ( $DEBUG ) { } $is_weights = 0; } $weight = ($max_wt != 0 ) ? ($weight/$max_wt) : 0; }else { $weight = 0; if ($weight eq '-') { foreach my $weight(@weights) {#}# $max_wt = $weight if ($weight > $max_wt) #foreach my $weight(@weights) { $max_wt = $nexusG->get_maximumWtvalue; my $max_wt; @weights = @{ $assumption->get_weights() }; if( $assumption->is_wt() ) { foreach my $assumption(@{$asmpt_block->get_assumptions()}) { warn("Grabbing assumptions block from NEXUS file...\n") if $DEBUG; if ($asmpt_block->get_link( 'characters' ) eq $block->get_title()) { for my $asmpt_block (@assumptions_blocks) { my @weights; if (not @{$self->{'char_block_wts'}}) { my @assumptions_blocks = @{ $nexusObject->get_blocks('assumptions') }; my $is_weights = 0; my $block = $self->{'selected_character_block'}; my $self = shift;sub get_char_block_wts {} return $self->{'nodes_color_hash'}; my ($self,$name,$color) = @_;sub get_nodes_hash {} return $self->{'nodes_color_hash'}->{$node_name} || 'black'; ## black my ($self, $node_name) = @_;sub get_node_color {} $self->{'nodes_color_hash'}->{$node_name} = $color; my ($self,$node_name,$color) = @_;sub set_node_color {} return @{$self->{'char_column_labels'}}; } $self->{'char_column_labels'} = \@columnLabels; } for (1 .. $seqLength) {push @columnLabels, $_;} } elsif ($seqLength) { # not labeled, e.g., typical dna or aa seq alignment @columnLabels = @$characterLabels; if ($characterLabels && @$characterLabels) { my $seqLength = $block->get_nchar; my $characterLabels = $block->get_charlabels; if (defined $block && (not @{$self->{'char_column_labels'}})){ my @columnLabels; my $block = $self->{'selected_character_block'};