| 1 | #!/usr/bin/perl | ||||||||||||||||||||||||||||||||||||||||||||||||
| 2 | package Bio::NEXUS::Tools::NexPlotter; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 3 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||
| 4 | # Derived from nexplot.pl (was plottree.pl prior to 9/15/03; the complete revision | ||||||||||||||||||||||||||||||||||||||||||||||||
| 5 | # log from plottree.pl is in the initial version of nexplot.pl) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 6 | ###################################################################### | ||||||||||||||||||||||||||||||||||||||||||||||||
| 7 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 8 | # $Author: astoltzfus $ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 9 | # $Date: 2008/06/16 19:53:41 $ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 10 | # $Revision: 1.2 $ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 11 | # $Id: NexPlotter.pm,v 1.2 2008/06/16 19:53:41 astoltzfus Exp $ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 12 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 13 | 1 | ▶ | use strict; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 14 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 15 | 1 | ▶ | use Pod::Usage; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 16 | 1 | ▶ | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 17 | 1 | ▶ | use Bio::NEXUS::Tools::GraphicsParams; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 18 | 1 | ▶ | use Bio::NEXUS; our $VERSION = $Bio::NEXUS::VERSION; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
BEGIN: called CC=1 SCAR=0.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 19 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 20 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 21 | ## Class variables | ||||||||||||||||||||||||||||||||||||||||||||||||
| 22 | my $main_dir ='.'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 23 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 24 | my $runtime_options; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 25 | my $nexusG = new Bio::NEXUS::Tools::GraphicsParams(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 26 | my $my_data_obj = new MyData; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 27 | my $nexusObject; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 28 | my $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 29 | my $ppp_param; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 30 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 31 | 0 | ▶ | sub new { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
new: not called CC=58 SCAR=81.4
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 32 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 33 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 34 | 0 | my $inp_data = $_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 35 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 36 | 0 | ▶ | $inp_data = {@_} if (ref($inp_data) ne 'HASH') ; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 37 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 38 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 39 | 0 | my $object_data = { | |||||||||||||||||||||||||||||||||||||||||||||||
| 40 | 'parameters' => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 41 | 'input_file' => 'test.nex', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 42 | 'output_file' => 'test.ps', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 43 | 'show_content' => 'Tree and Data', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 44 | 'character_data_type' => 'Protein', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 45 | 'species_tree' => 'off', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 46 | 'show_bootstrap_values' => 'on', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 47 | 'show_inode_label' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 48 | 'colorintron' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 49 | 'set_type' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 50 | 'kingdom' => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 51 | 'vertebrate' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 52 | 'invertebrate' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 53 | 'plant' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 54 | 'fungi' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 55 | 'protist' => undef | ||||||||||||||||||||||||||||||||||||||||||||||||
| 56 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 57 | 'right_justify_labels' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 58 | 'tree_width' => $Bio::NEXUS::Tools::GraphicsParams::DefaultTreeWidth, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 59 | 'char_label_block_size' => $Bio::NEXUS::Tools::GraphicsParams::DefaultCharLabelBlockWidth , | ||||||||||||||||||||||||||||||||||||||||||||||||
| 60 | 'show_border' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 61 | 'vertical_otu_spacing' => $Bio::NEXUS::Tools::GraphicsParams::DefaultVerticalOtuSpacing, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 62 | 'output_type' => 'ps', | ||||||||||||||||||||||||||||||||||||||||||||||||
| 63 | 'show_cladogram' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 64 | 'cladogrom_mode' => "normal", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 65 | 'color_sub_tree' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 66 | 'select_char_range' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 67 | 'setsbyinode' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 68 | 'customset' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 69 | 'highlight_otus' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 70 | 'highlight_chars' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 71 | 'ppp' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 72 | 'reroot_node' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 73 | 'exclude_sub_tree' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 74 | 'swap_children' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 75 | 'select_sub_tree' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 76 | }, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 77 | 'data' => { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 78 | 'nexus_obj' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 79 | 'my_data' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 80 | 'gfx' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 81 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 82 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 83 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 84 | 0 | foreach my $field ( keys %{ $object_data->{'parameters'} } ) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 85 | 0 | my @field1 = grep(/^.?$field$/,keys %{$inp_data}) ; | |||||||||||||||||||||||||||||||||||||||||||||||
| 86 | 0 | ▶ | if ( scalar @field1 > 0 ){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 87 | 0 | $object_data->{'parameters'}->{$field} = $inp_data->{$field1[0]}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 88 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 89 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 90 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 91 | #print Dumper $object_data; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 92 | 0 | my @column_nos; | |||||||||||||||||||||||||||||||||||||||||||||||
| 93 | 0 | foreach my $columns (@ {$object_data->{'parameters'}->{'select_char_range'} }) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 94 | 0 | ▶ | push(@column_nos,@{&parse_number($columns)}) if $columns; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 95 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 96 | 0 | $object_data->{'parameters'}->{'select_char_range'} = \@column_nos; | |||||||||||||||||||||||||||||||||||||||||||||||
| 97 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 98 | 0 | $self = bless ($object_data,$self); | |||||||||||||||||||||||||||||||||||||||||||||||
| 99 | #print Dumper $self; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 100 | 0 | $runtime_options = $object_data->{'parameters'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 101 | 0 | $ppp_param = $runtime_options->{'ppp'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 102 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 103 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 104 | ## 1. print Header and the top menu for CGI | ||||||||||||||||||||||||||||||||||||||||||||||||
| 105 | #print Dumper $runtime_options; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 106 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 107 | 0 | $nexusObject = &__read_nexus(); # Read in the NEXUS file and extract relevant information. | |||||||||||||||||||||||||||||||||||||||||||||||
| 108 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 109 | 0 | ▶ | die "Error in loading the Plot module : $@\n" if ($@); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 110 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 111 | 0 | $my_data_obj->set_title($nexusObject->get_filename); | |||||||||||||||||||||||||||||||||||||||||||||||
| 112 | 0 | ▶ | if ($runtime_options->{'species_tree'} ne 'on') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 113 | 0 | foreach my $block (@{$nexusObject->get_blocks()} ) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 114 | 0 | my $input_block_type = $runtime_options->{'character_data_type'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 115 | 0 | ▶ | if ($block->get_type =~/characters/i && $block->get_title =~/$input_block_type/i){ | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$block->get_type =~ /characters/i and $block->get_title =~ /$input_block_type/i
MC/DC0%0/2
$block->get_type =~ /characters/i and $block->get_title =~ /$input_block_type/i
$block->get_type =~ /characters/i
$block->get_title =~ /$input_block_type/i
Truth table0%0/3
A and B
A= $block->get_type =~ /characters/iB= $block->get_title =~ /$input_block_type/i
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 116 | 0 | $my_data_obj->set_selected_char_block($block) ; | |||||||||||||||||||||||||||||||||||||||||||||||
| 117 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 118 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 119 | 0 | ▶ | $my_data_obj->set_selected_char_block( $nexusObject->get_block("character") ) if not defined $my_data_obj->get_selected_char_block; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 120 | 0 | ▶ | if (defined $my_data_obj->get_selected_char_block) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 121 | 0 | my @selectchar_params = @{ $runtime_options->{'select_char_range'} }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 122 | 0 | ▶ | $nexusObject = $nexusObject->select_chars(\@selectchar_params,$my_data_obj->get_selected_char_block->get_title) if (@selectchar_params); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 123 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 124 | 0 | ▶ | if ($nexusObject->get_block("trees")) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 125 | 0 | my $tree = $nexusObject->get_block("trees")->get_tree; | |||||||||||||||||||||||||||||||||||||||||||||||
| 126 | 0 | $my_data_obj->set_selected_tree( $tree ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 128 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 129 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 130 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 131 | 0 | $my_data_obj->set_selected_tree( $nexusObject->get_block ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 132 | 0 | my $hist_dup = $nexusObject->get_block('history','duplication_speciation'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 133 | 0 | $my_data_obj->set_selected_char_block(undef); | |||||||||||||||||||||||||||||||||||||||||||||||
| 134 | 0 | $my_data_obj->set_selected_tree( $hist_dup->get_tree('species_tree') ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 135 | 0 | $my_data_obj->set_gene_tree( $hist_dup->get_tree('gene_tree') ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 136 | 0 | $my_data_obj->set_species_tree( $hist_dup->get_tree('species_tree') ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 137 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 138 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 139 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 140 | #### 4. Graphics Layout and pupulating my_data object - set all size of the canvas and the panes based on the | ||||||||||||||||||||||||||||||||||||||||||||||||
| 141 | #### CGI options and content of the NEXUS file. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 142 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 143 | #gdSmallFont->width | ||||||||||||||||||||||||||||||||||||||||||||||||
| 144 | 0 | $nexusG->set_fontWidth(6); | |||||||||||||||||||||||||||||||||||||||||||||||
| 145 | 0 | $nexusG->set_fontHeight(13); | |||||||||||||||||||||||||||||||||||||||||||||||
| 146 | 0 | $nexusG->set_verticalOtuSpacing($runtime_options->{'vertical_otu_spacing'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 147 | 0 | $nexusG->set_charLabelBlockWidth($runtime_options->{'char_label_block_size'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 148 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 149 | 0 | my $taxlabels; | |||||||||||||||||||||||||||||||||||||||||||||||
| 150 | 0 | ▶ | if ($my_data_obj->get_selected_tree) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 151 | 0 | $taxlabels = $my_data_obj->get_selected_tree->get_node_names(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 152 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 153 | 0 | $taxlabels = $nexusObject->get_block('taxa')->get_taxlabels(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 154 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 155 | 0 | $nexusG->set_maxTaxLabelwidth($taxlabels); | |||||||||||||||||||||||||||||||||||||||||||||||
| 156 | 0 | $nexusG->set_paneHeight(scalar @$taxlabels); | |||||||||||||||||||||||||||||||||||||||||||||||
| 157 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 158 | 0 | ▶ | if ($my_data_obj->get_selected_char_block && ( $runtime_options->{'show_content'} ne "Tree only")) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$my_data_obj->get_selected_char_block and $runtime_options->{"show_content"} ne "Tree only"
MC/DC0%0/2
$my_data_obj->get_selected_char_block and $runtime_options->{"show_content"} ne "Tree only"
$my_data_obj->get_selected_char_block
$runtime_options->{"show_content"} ne "Tree only"
Truth table0%0/3
A and B
A= $my_data_obj->get_selected_char_blockB= $runtime_options->{"show_content"} ne "Tree only"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 159 | 0 | ▶ | $nexusG->set_histogramHeight if $my_data_obj->get_char_block_wts; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 160 | 0 | my $block = $my_data_obj->get_selected_char_block; | |||||||||||||||||||||||||||||||||||||||||||||||
| 161 | 0 | $nexusG->set_charactersXwidth($block); | |||||||||||||||||||||||||||||||||||||||||||||||
| 162 | 0 | my @col_labels = $my_data_obj->get_char_column_labels; | |||||||||||||||||||||||||||||||||||||||||||||||
| 163 | 0 | ▶ | $nexusG->set_longestCharLabelLength(@col_labels) if @col_labels; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 165 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 166 | #print "<PRE>"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 167 | #print "</PRE>"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 168 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 169 | 0 | $nexusG->set_lowerXbound; | |||||||||||||||||||||||||||||||||||||||||||||||
| 170 | 0 | $nexusG->set_lowerYbound; | |||||||||||||||||||||||||||||||||||||||||||||||
| 171 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 172 | 0 | ▶ | if ($runtime_options->{'show_content'} ne 'Data only' && defined $my_data_obj->get_selected_tree) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$runtime_options->{"show_content"} ne "Data only" and defined $my_data_obj->get_selected_tree
MC/DC0%0/2
$runtime_options->{"show_content"} ne "Data only" and defined $my_data_obj->get_selected_tree
$runtime_options->{"show_content"} ne "Data only"
defined $my_data_obj->get_selected_tree
Truth table0%0/3
A and B
A= $runtime_options->{"show_content"} ne "Data only"B= defined $my_data_obj->get_selected_tree
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 173 | 0 | $nexusG->set_TreeWidth($runtime_options->{'tree_width'}*72); | |||||||||||||||||||||||||||||||||||||||||||||||
| 174 | 0 | &__set_node_coords($my_data_obj->get_selected_tree); | |||||||||||||||||||||||||||||||||||||||||||||||
| 175 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 176 | 0 | $nexusG->set_upperXbound; | |||||||||||||||||||||||||||||||||||||||||||||||
| 177 | 0 | $nexusG->set_upperYbound; | |||||||||||||||||||||||||||||||||||||||||||||||
| 178 | 0 | $nexusG->set_xsize; | |||||||||||||||||||||||||||||||||||||||||||||||
| 179 | 0 | $nexusG->set_ysize; | |||||||||||||||||||||||||||||||||||||||||||||||
| 180 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 181 | #print "<PRE>"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 182 | #print Dumper $nexusG; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 183 | #print "</PRE>"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 184 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 185 | ### 5. Open the image handlers for drawing | ||||||||||||||||||||||||||||||||||||||||||||||||
| 186 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 187 | ## 5.a load the specific module | ||||||||||||||||||||||||||||||||||||||||||||||||
| 188 | 0 | ▶ | if ($runtime_options->{'output_type'} eq "ps") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 189 | 0 | eval 'use PostScript::Simple'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 190 | } elsif ($runtime_options->{'output_type'} eq "pdf") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 191 | 0 | eval 'use PDF::API2::Lite'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 192 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 193 | 0 | eval 'use GD::Simple'; | |||||||||||||||||||||||||||||||||||||||||||||||
| 194 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 195 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 196 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 197 | ## 5.b Initialize graphics module | ||||||||||||||||||||||||||||||||||||||||||||||||
| 198 | 0 | ▶ | if ($runtime_options->{'output_type'} eq "ps" ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 199 | 0 | my $p = new PostScript::Simple( | |||||||||||||||||||||||||||||||||||||||||||||||
| 200 | xsize => $nexusG->get_xsize, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 201 | ysize => $nexusG->get_ysize, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 202 | colour => 1, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 203 | eps => 0, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 204 | units => "pt", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 205 | coordorigin => "LeftTop", | ||||||||||||||||||||||||||||||||||||||||||||||||
| 206 | direction => "RightDown"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 207 | 0 | $p->newpage; | |||||||||||||||||||||||||||||||||||||||||||||||
| 208 | 0 | $p->setfont("Courier",10); | |||||||||||||||||||||||||||||||||||||||||||||||
| 209 | 0 | $my_data_obj->set_image_handler($p); | |||||||||||||||||||||||||||||||||||||||||||||||
| 210 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 211 | elsif ( $runtime_options->{'output_type'} eq "pdf" ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 212 | 0 | my $p = new PDF::API2::Lite; | |||||||||||||||||||||||||||||||||||||||||||||||
| 213 | 0 | my $font = $p->corefont("Courier"); | |||||||||||||||||||||||||||||||||||||||||||||||
| 214 | 0 | $p->page($nexusG->get_xsize,$nexusG->get_ysize); | |||||||||||||||||||||||||||||||||||||||||||||||
| 215 | 0 | $my_data_obj->set_image_handler($p); | |||||||||||||||||||||||||||||||||||||||||||||||
| 216 | 0 | $my_data_obj->set_font($font); | |||||||||||||||||||||||||||||||||||||||||||||||
| 217 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 218 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 219 | 0 | my $im = new GD::Simple($nexusG->get_xsize,$nexusG->get_ysize); | |||||||||||||||||||||||||||||||||||||||||||||||
| 220 | # make the background transparent and interlaced | ||||||||||||||||||||||||||||||||||||||||||||||||
| 221 | #$im->transparent($white); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 222 | 0 | $im->interlaced('true'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 223 | 0 | $my_data_obj->set_image_handler($im); | |||||||||||||||||||||||||||||||||||||||||||||||
| 224 | 0 | $my_data_obj->allocate_colors; | |||||||||||||||||||||||||||||||||||||||||||||||
| 225 | 0 | $my_data_obj->set_font(gdSmallFont()); | |||||||||||||||||||||||||||||||||||||||||||||||
| 226 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 227 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 228 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 229 | ############################## | ||||||||||||||||||||||||||||||||||||||||||||||||
| 230 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 231 | # Assgn state to nodes by taxonomy | ||||||||||||||||||||||||||||||||||||||||||||||||
| 232 | # PRINT TREE AND OTHER ELEMENTS IF PRESENT | ||||||||||||||||||||||||||||||||||||||||||||||||
| 233 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 234 | 0 | my $tree = $my_data_obj->get_selected_tree; | |||||||||||||||||||||||||||||||||||||||||||||||
| 235 | # used taxlabels before from taxa block, now getting them from tree | ||||||||||||||||||||||||||||||||||||||||||||||||
| 236 | 0 | ▶ | $taxlabels = ($tree) ? $tree->get_node_names() : $nexusObject->get_block('taxa')->get_taxlabels(); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 237 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 238 | ##### 7. Coloring data and tree based on the NCBI Taxonomy option | ||||||||||||||||||||||||||||||||||||||||||||||||
| 239 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 240 | 0 | ▶ | if ($runtime_options->{'set_type'} eq 'Taxonomy') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 241 | 0 | &__assign_ncbi_taxonomy($my_data_obj,$taxlabels); | |||||||||||||||||||||||||||||||||||||||||||||||
| 242 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 243 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 244 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 245 | ##### 8. Custom set processing for taxa label colors ####### | ||||||||||||||||||||||||||||||||||||||||||||||||
| 246 | 0 | ▶ | if ($runtime_options->{'set_type'} eq 'Custom') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 247 | 0 | my $taxlabels = $nexusObject->get_block('taxa')->get_taxlabels(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 248 | 0 | for my $taxlabel (@$taxlabels) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 249 | 0 | $my_data_obj->set_node_color($taxlabel,'black'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 250 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 251 | 0 | ▶ | if ($nexusObject->get_block('sets')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 252 | # redundant to subsequent code | ||||||||||||||||||||||||||||||||||||||||||||||||
| 253 | # my $taxSets = $nexusObject->get_block('sets')->get_taxsets(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 254 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 255 | 0 | my $block = $nexusObject->get_block('sets'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 256 | 0 | ▶ | warn("Grabbing sets block from NEXUS file...\n") if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 257 | 0 | my $taxSets = $block->get_taxsets(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 258 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 259 | 0 | my %setsColors; | |||||||||||||||||||||||||||||||||||||||||||||||
| 260 | 0 | my $count = 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 261 | 0 | my @customset_params = @{ $runtime_options->{'customset'} }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 262 | 0 | foreach my $key (sort keys %{$taxSets}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 263 | 0 | $setsColors{$key} = $customset_params[$count-1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 264 | 0 | $count++; | |||||||||||||||||||||||||||||||||||||||||||||||
| 265 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 266 | 0 | for my $taxSetName (sort keys %{$taxSets}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 267 | 0 | for my $taxon (@{$taxSets->{$taxSetName}}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 268 | 0 | my $col_name = $setsColors{$taxSetName}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 269 | 0 | ▶ | $my_data_obj->set_node_color($taxon,$col_name) if $col_name =~/\S+/; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 270 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 271 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 272 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 273 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 274 | ##### 9. propagating coloring options on the tree | ||||||||||||||||||||||||||||||||||||||||||||||||
| 275 | 0 | my @colornode_params = @{ $runtime_options->{'color_sub_tree'} }; # Color a node and its children | |||||||||||||||||||||||||||||||||||||||||||||||
| 276 | 0 | ▶ | if (defined $tree) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 277 | 0 | my $root = $tree->get_rootnode(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 278 | 0 | ▶ | my $node = $tree->find($colornode_params[$#colornode_params]) if ($colornode_params[0] ne ''); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 279 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 280 | 0 | &AssignStateToNode( $my_data_obj->get_nodes_hash,$root,'black'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 281 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 282 | 0 | my @highlight_params = @{ $runtime_options->{'highlight_otus'} }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 283 | 0 | foreach my $highlight_param(@highlight_params) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 284 | 0 | my @nodes_list; | |||||||||||||||||||||||||||||||||||||||||||||||
| 285 | 0 | ▶ | &AssignStateToSuperNode($my_data_obj,$root,$highlight_param,\@nodes_list,'gold') if ($highlight_param); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 286 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 287 | 0 | ▶ | &AssignStateToSubNode($my_data_obj,$node,'highlighter') if ($colornode_params[0] ne '' && $node); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$colornode_params[0] ne "" and $node
MC/DC0%0/2
$colornode_params[0] ne "" and $node
$colornode_params[0] ne ""
$node
Truth table0%0/3
A and B
A= $colornode_params[0] ne ""B= $node
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 289 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 290 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 291 | ##### 10. Drawing the tree and character matrix data. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 292 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 293 | 0 | ▶ | if (($runtime_options->{'show_content'} eq 'Data only') || (not defined $tree)) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$runtime_options->{"show_content"} eq "Data only" or not defined $tree
MC/DC0%0/2
$runtime_options->{"show_content"} eq "Data only" or not defined $tree
$runtime_options->{"show_content"} eq "Data only"
not defined $tree
Truth table0%0/3
A or not(B)
A= $runtime_options->{"show_content"} eq "Data only"B= not defined $tree
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 294 | 0 | &__print_matrix($my_data_obj,$nexusG->get_lowerXbound, $nexusG->get_lowerYbound,$taxlabels,1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 295 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 296 | 0 | ▶ | &__print_tree($my_data_obj,$tree->get_rootnode, $nexusG->get_lowerXbound, $nexusG->get_lowerYbound) if defined $tree; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 297 | 0 | ▶ | &__print_matrix($my_data_obj,$nexusG->get_lowerXbound, $nexusG->get_lowerYbound,$taxlabels,0) if ($runtime_options->{'show_content'} eq 'Tree and Data'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 298 | 0 | ▶ | if (defined $nexusObject->get_block("history",'intron') && $ppp_param) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $nexusObject->get_block("history", "intron") and $ppp_param
MC/DC0%0/2
defined $nexusObject->get_block("history", "intron") and $ppp_param
defined $nexusObject->get_block("history", "intron")
$ppp_param
Truth table0%0/3
A and B
A= defined $nexusObject->get_block("history", "intron")B= $ppp_param
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 299 | 0 | my $otus = $nexusObject->get_block("history",'intron')->get_otuset->get_otus; | |||||||||||||||||||||||||||||||||||||||||||||||
| 300 | 0 | my $otu_seq_hash; | |||||||||||||||||||||||||||||||||||||||||||||||
| 301 | 0 | %{$otu_seq_hash} = map {$_->get_name => $_->get_seq} @{$otus}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 302 | 0 | &__print_piechart($my_data_obj,$tree->get_rootnode, $otu_seq_hash); | |||||||||||||||||||||||||||||||||||||||||||||||
| 303 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 304 | 0 | ▶ | &__print_inode_names($my_data_obj,$tree->get_nodes) if ($runtime_options->{'show_inode_label'} eq 'on') ; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 305 | 0 | ▶ | &__print_boot_strap($my_data_obj,$tree->get_nodes) if ($runtime_options->{'show_bootstrap_values'} eq 'on') ; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 306 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 307 | 0 | ▶ | if ($my_data_obj->get_selected_char_block && $runtime_options->{'show_content'} ne 'Tree only') { # Character labels, weights | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$my_data_obj->get_selected_char_block and $runtime_options->{"show_content"} ne "Tree only"
MC/DC0%0/2
$my_data_obj->get_selected_char_block and $runtime_options->{"show_content"} ne "Tree only"
$my_data_obj->get_selected_char_block
$runtime_options->{"show_content"} ne "Tree only"
Truth table0%0/3
A and B
A= $my_data_obj->get_selected_char_blockB= $runtime_options->{"show_content"} ne "Tree only"
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 308 | 0 | my $block = $my_data_obj->get_selected_char_block; | |||||||||||||||||||||||||||||||||||||||||||||||
| 309 | 0 | ▶ | if ($my_data_obj->get_char_column_labels) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 310 | 0 | &__print_char_labels($my_data_obj,$block); | |||||||||||||||||||||||||||||||||||||||||||||||
| 311 | 0 | &__highlight_char($my_data_obj,$block); | |||||||||||||||||||||||||||||||||||||||||||||||
| 312 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 313 | 0 | ▶ | &__plot_wts($my_data_obj,$my_data_obj->get_char_block_wts) if ( $my_data_obj->get_char_block_wts ) ; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 314 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 315 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 316 | 0 | &__plot_scale_border_title($my_data_obj); | |||||||||||||||||||||||||||||||||||||||||||||||
| 317 | #&__save_session($session); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 318 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 319 | #print "<pre>",Dumper($nexusObject),"</pre>"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 320 | # 11. Convert the image handler output to PNG, PS and PDF format based on the output option. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 321 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 322 | 0 | ▶ | if ($runtime_options->{'output_type'} eq "ps") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 323 | 0 | $my_data_obj->get_image_handler->output($runtime_options->{'output_file'}) | |||||||||||||||||||||||||||||||||||||||||||||||
| 324 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 325 | elsif ($runtime_options->{'output_type'} eq "pdf") { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 326 | 0 | $my_data_obj->get_image_handler->saveas($runtime_options->{'output_file'}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 327 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 328 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 329 | 0 | ▶ | open(PNG,">$runtime_options->{'output_file'}") || die "cannot open file\n"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 330 | 0 | binmode PNG; | |||||||||||||||||||||||||||||||||||||||||||||||
| 331 | 0 | ▶ | print PNG $my_data_obj->get_image_handler->png() || die "DIED"; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Condition0%0/2
$my_data_obj->get_image_handler->png || die('DIED')
MC/DC0%0/1
$my_data_obj->get_image_handler->png || die('DIED')
$my_data_obj->get_image_handler->png
Truth table0%0/2
A
A= $my_data_obj->get_image_handler->png
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 332 | 0 | close PNG; | |||||||||||||||||||||||||||||||||||||||||||||||
| 333 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 334 | 0 | $self->set_data($nexusObject,$my_data_obj,$nexusG); | |||||||||||||||||||||||||||||||||||||||||||||||
| 335 | 0 | return $self; | |||||||||||||||||||||||||||||||||||||||||||||||
| 336 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 337 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 338 | #################################################################### SUBROUTINES | ||||||||||||||||||||||||||||||||||||||||||||||||
| 339 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 340 | =head2 get_data | ||||||||||||||||||||||||||||||||||||||||||||||||
| 341 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 342 | Title : get_data | ||||||||||||||||||||||||||||||||||||||||||||||||
| 343 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 344 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 345 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 346 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 347 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 348 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 349 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 350 | 0 | ▶ | sub get_data { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
get_data: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 351 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 352 | 0 | return ($self->{'data'}->{'nexus_obj'},$self->{'data'}->{'my_data'},$self->{'data'}->{'gfx'} ) ; | |||||||||||||||||||||||||||||||||||||||||||||||
| 353 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 354 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 355 | =head2 set_data | ||||||||||||||||||||||||||||||||||||||||||||||||
| 356 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 357 | Title : set_data | ||||||||||||||||||||||||||||||||||||||||||||||||
| 358 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 359 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 360 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 361 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 362 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 363 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 364 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 365 | 0 | ▶ | sub set_data { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
set_data: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 366 | 0 | my $self = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 367 | 0 | my ($nexus_obj,$my_data,$gfx) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 368 | 0 | $self->{'data'}->{'nexus_obj'} = $nexus_obj; | |||||||||||||||||||||||||||||||||||||||||||||||
| 369 | 0 | $self->{'data'}->{'my_data'} = $my_data; | |||||||||||||||||||||||||||||||||||||||||||||||
| 370 | 0 | $self->{'data'}->{'gfx'} = $gfx; | |||||||||||||||||||||||||||||||||||||||||||||||
| 371 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 372 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 373 | =head2 rgb2hex | ||||||||||||||||||||||||||||||||||||||||||||||||
| 374 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 375 | Title : rgb2hex | ||||||||||||||||||||||||||||||||||||||||||||||||
| 376 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 377 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 378 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 379 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 380 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 381 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 382 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 383 | 0 | ▶ | sub rgb2hex { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
rgb2hex: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 384 | 0 | my $rgb_hash = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 385 | 0 | return "#". join "", map {sprintf "%2.2X",$_} @{$rgb_hash}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 387 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 388 | 0 | ▶ | sub __draw_piechart { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__draw_piechart: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 389 | 0 | my ($my_data,$x, $y, $radius, $prob) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 390 | 0 | my $im_h = $my_data->get_image_handler; | |||||||||||||||||||||||||||||||||||||||||||||||
| 391 | 0 | ▶ | if ($my_data->get_image_handler_type eq 'pdf') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 392 | 0 | $im_h->strokecolor($my_data->get_color('silver')); | |||||||||||||||||||||||||||||||||||||||||||||||
| 393 | 0 | $im_h->circle($x, $nexusG->get_ysize-$y, $radius/2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 394 | 0 | $im_h->strokecolor($my_data->get_color('black')); | |||||||||||||||||||||||||||||||||||||||||||||||
| 395 | 0 | $im_h->circle($x,$nexusG->get_ysize-$y,$radius/2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 396 | 0 | $im_h->stroke; | |||||||||||||||||||||||||||||||||||||||||||||||
| 397 | 0 | $im_h->fillcolor($my_data->get_color('red')); | |||||||||||||||||||||||||||||||||||||||||||||||
| 398 | 0 | $im_h->arc($x,$nexusG->get_ysize - $y,$radius/2,$radius/2,0,$prob*360 + 0.1,1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 399 | 0 | $im_h->fill; | |||||||||||||||||||||||||||||||||||||||||||||||
| 400 | }elsif ($my_data->get_image_handler_type eq 'ps') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 401 | 0 | $im_h->setlinewidth(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 402 | 0 | $im_h->setcolour(@{$my_data->get_color('silver')}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 403 | 0 | $im_h->circle({filled => 1},$x,$y,$radius/2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 404 | 0 | $im_h->setcolour(@{$my_data->get_color('black')}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 405 | 0 | $im_h->circle($x,$y,$radius/2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 406 | 0 | $im_h->setcolour(@{$my_data->get_color('red')}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 407 | 0 | my $start = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 408 | 0 | ▶ | if ($prob >= 0.5) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 409 | 0 | $start = 180; | |||||||||||||||||||||||||||||||||||||||||||||||
| 410 | 0 | $prob -= 0.5; | |||||||||||||||||||||||||||||||||||||||||||||||
| 411 | 0 | $im_h->arc({filled=>1}, $x, $y, $radius/2, 180, 0); | |||||||||||||||||||||||||||||||||||||||||||||||
| 412 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 413 | 0 | &__draw_pieslice($my_data,$x,$y,$radius,$prob,$start); | |||||||||||||||||||||||||||||||||||||||||||||||
| 414 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 415 | 0 | $im_h->moveTo($x,$y); | |||||||||||||||||||||||||||||||||||||||||||||||
| 416 | 0 | $im_h->penSize(1,1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 417 | #$im->bgcolor(undef); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 418 | 0 | $im_h->bgcolor($my_data->get_color('silver')); | |||||||||||||||||||||||||||||||||||||||||||||||
| 419 | 0 | $im_h->arc($radius,$radius,0,360,gdArc()); | |||||||||||||||||||||||||||||||||||||||||||||||
| 420 | 0 | $im_h->fgcolor($my_data->get_color('black')); | |||||||||||||||||||||||||||||||||||||||||||||||
| 421 | 0 | $im_h->bgcolor($my_data->get_color('red')); | |||||||||||||||||||||||||||||||||||||||||||||||
| 422 | 0 | $im_h->arc($radius,$radius,0,$prob*360,gdEdged()|gdArc()); | |||||||||||||||||||||||||||||||||||||||||||||||
| 423 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 424 | 0 | $im_h->moveTo($x,$y); | |||||||||||||||||||||||||||||||||||||||||||||||
| 425 | 0 | $im_h->bgcolor(undef); | |||||||||||||||||||||||||||||||||||||||||||||||
| 426 | 0 | $im_h->fgcolor('black'); | |||||||||||||||||||||||||||||||||||||||||||||||
| 427 | 0 | $im_h->ellipse($radius,$radius); | |||||||||||||||||||||||||||||||||||||||||||||||
| 428 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 430 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 431 | 0 | ▶ | sub __draw_pieslice { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__draw_pieslice: not called CC=1 SCAR=6.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 432 | 0 | my ($my_data,$x,$y,$radius,$prob,$start) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 433 | 0 | my $im_h = $my_data->get_image_handler; | |||||||||||||||||||||||||||||||||||||||||||||||
| 434 | 0 | my $pi = 3.14159265; | |||||||||||||||||||||||||||||||||||||||||||||||
| 435 | 0 | my $start_rad = $start/180 * $pi; | |||||||||||||||||||||||||||||||||||||||||||||||
| 436 | 0 | my $prob_rad = $prob * 2 * $pi; | |||||||||||||||||||||||||||||||||||||||||||||||
| 437 | 0 | $im_h->arc({filled=>1},$x,$y,$radius/2,360-($start+$prob*360),$start); | |||||||||||||||||||||||||||||||||||||||||||||||
| 438 | 0 | $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)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 440 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 441 | 0 | ▶ | sub __draw_line { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__draw_line: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 442 | 0 | my ($my_data,$x1, $y1, $x2, $y2, $color, $size) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 443 | 0 | my $im_h = $my_data->get_image_handler; | |||||||||||||||||||||||||||||||||||||||||||||||
| 444 | 0 | my $color_val = $my_data->get_color($color); | |||||||||||||||||||||||||||||||||||||||||||||||
| 445 | 0 | ▶ | if ($my_data->get_image_handler_type eq 'pdf') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 446 | 0 | $im_h->strokecolor($color_val); | |||||||||||||||||||||||||||||||||||||||||||||||
| 447 | #$im_h->linewidth(1); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 448 | 0 | $im_h->move($x1, $nexusG->get_ysize-$y1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 449 | 0 | $im_h->line($x2, $nexusG->get_ysize-$y2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 450 | 0 | $im_h->stroke; | |||||||||||||||||||||||||||||||||||||||||||||||
| 451 | }elsif ($my_data->get_image_handler_type eq 'ps') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 452 | 0 | ▶ | if ($size == 0.5) { $im_h->setlinewidth(0.5); } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 453 | 0 | else { $im_h->setlinewidth(1.5); } | |||||||||||||||||||||||||||||||||||||||||||||||
| 454 | 0 | $im_h->setcolour(@{$color_val}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 455 | 0 | $im_h->line($x1,$y1,$x2,$y2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 456 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 457 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 458 | 0 | $im_h->moveTo($x1,$y1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 459 | 0 | $im_h->penSize($size,1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 460 | 0 | $im_h->fgcolor($color_val); | |||||||||||||||||||||||||||||||||||||||||||||||
| 461 | 0 | $im_h->lineTo($x2,$y2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 462 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 463 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 464 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 465 | 0 | ▶ | sub __draw_text { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__draw_text: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 466 | 0 | my ($my_data, $x, $y, $string, $color) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 467 | 0 | my $font = $my_data->get_font; | |||||||||||||||||||||||||||||||||||||||||||||||
| 468 | 0 | my $im_h = $my_data->get_image_handler; | |||||||||||||||||||||||||||||||||||||||||||||||
| 469 | 0 | my $color_val = $my_data->get_color($color); | |||||||||||||||||||||||||||||||||||||||||||||||
| 470 | 0 | ▶ | if ($my_data->get_image_handler_type eq 'pdf') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 471 | 0 | $im_h->fillcolor($color_val); | |||||||||||||||||||||||||||||||||||||||||||||||
| 472 | 0 | $im_h->print($font,10,$x,$nexusG->get_ysize-$y,0,0,$string); | |||||||||||||||||||||||||||||||||||||||||||||||
| 473 | 0 | $im_h->fill; | |||||||||||||||||||||||||||||||||||||||||||||||
| 474 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 475 | }elsif ($my_data->get_image_handler_type eq 'ps') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 476 | 0 | $im_h->setcolour(@{$color_val}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 477 | 0 | $im_h->text($x, $y + ($nexusG->get_fontHeight/4),$string); | |||||||||||||||||||||||||||||||||||||||||||||||
| 478 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 479 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 480 | #$font="Courier"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 481 | 0 | $im_h->moveTo($x,$y+($nexusG->get_fontHeight)/2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 482 | 0 | $im_h->font($font); | |||||||||||||||||||||||||||||||||||||||||||||||
| 483 | 0 | ▶ | $im_h->fontsize(14) if ($font eq 'Times'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 484 | 0 | $im_h->fgcolor($color_val); | |||||||||||||||||||||||||||||||||||||||||||||||
| 485 | 0 | $im_h->string($string); | |||||||||||||||||||||||||||||||||||||||||||||||
| 486 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 487 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 488 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 489 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 490 | 0 | ▶ | sub __draw_circle { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__draw_circle: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 491 | 0 | my ($my_data,$x, $y, $radius, $color) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 492 | 0 | my $im_h = $my_data->get_image_handler; | |||||||||||||||||||||||||||||||||||||||||||||||
| 493 | 0 | my $color_val = $my_data->get_color($color); | |||||||||||||||||||||||||||||||||||||||||||||||
| 494 | 0 | ▶ | if ($my_data->get_image_handler_type eq 'pdf') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 495 | 0 | $im_h->strokecolor($color_val); | |||||||||||||||||||||||||||||||||||||||||||||||
| 496 | #$im_h->linewidth(1); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 497 | 0 | $im_h->circle($x,$nexusG->get_ysize - $y, $radius/2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 498 | 0 | $im_h->stroke; | |||||||||||||||||||||||||||||||||||||||||||||||
| 499 | }elsif ($my_data->get_image_handler_type eq 'ps') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 500 | 0 | $im_h->setlinewidth(1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 501 | 0 | $im_h->setcolour(@{$color_val}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 502 | 0 | $im_h->circle($x,$y,$radius/2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 503 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 504 | 0 | $im_h->moveTo($x,$y); | |||||||||||||||||||||||||||||||||||||||||||||||
| 505 | 0 | $im_h->fgcolor($color_val); | |||||||||||||||||||||||||||||||||||||||||||||||
| 506 | 0 | $im_h->bgcolor($color_val); | |||||||||||||||||||||||||||||||||||||||||||||||
| 507 | 0 | $im_h->arc($radius,$radius,0,360,gdEdged()|gdArc()); | |||||||||||||||||||||||||||||||||||||||||||||||
| 508 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 510 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 511 | 0 | ▶ | sub __draw_filledRect { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__draw_filledRect: not called CC=5 SCAR=34.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 512 | 0 | my ($my_data,$x1, $y1, $x2, $y2, $color,$transparency) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 513 | 0 | my $color_val = $my_data->get_color($color); | |||||||||||||||||||||||||||||||||||||||||||||||
| 514 | 0 | my $im_h = $my_data->get_image_handler; | |||||||||||||||||||||||||||||||||||||||||||||||
| 515 | 0 | ▶ | if ($my_data->get_image_handler_type eq 'pdf') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 2 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 516 | 0 | ▶ | if (ref $color_val) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 517 | 0 | $im_h->fillcolor(&rgb2hex($color_val)); | |||||||||||||||||||||||||||||||||||||||||||||||
| 518 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 519 | 0 | $im_h->fillcolor($color_val); | |||||||||||||||||||||||||||||||||||||||||||||||
| 520 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 521 | 0 | $im_h->rectxy($x1,$nexusG->get_ysize - $y1,$x2,$nexusG->get_ysize-$y2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 522 | 0 | $im_h->fill; | |||||||||||||||||||||||||||||||||||||||||||||||
| 523 | } elsif ($my_data->get_image_handler_type eq 'ps') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 524 | 0 | $im_h->setcolour(map {$_*1} @{$color_val}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 525 | 0 | $im_h->box({filled=>1},$x1,$y1,$x2,$y2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 526 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 527 | 0 | ▶ | if (ref $color_val) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 528 | 0 | $im_h->bgcolor(@{$color_val}); | |||||||||||||||||||||||||||||||||||||||||||||||
| 529 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 530 | 0 | $im_h->bgcolor($color_val); | |||||||||||||||||||||||||||||||||||||||||||||||
| 531 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 532 | 0 | $im_h->rectangle($x1,$y1,$x2,$y2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 533 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 534 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 535 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 536 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 537 | =head2 checkNumber | ||||||||||||||||||||||||||||||||||||||||||||||||
| 538 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 539 | Title : checkNumber | ||||||||||||||||||||||||||||||||||||||||||||||||
| 540 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 541 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 542 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 543 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 544 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 545 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 546 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 547 | 0 | ▶ | sub checkNumber { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
checkNumber: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 548 | 0 | my $arg=$_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 549 | 0 | ▶ | if ($arg =~ /(\d+\.?\d*|\.\d+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 550 | 0 | return $arg; | |||||||||||||||||||||||||||||||||||||||||||||||
| 551 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 552 | 0 | return undef; | |||||||||||||||||||||||||||||||||||||||||||||||
| 553 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 554 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 555 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 556 | =head2 isNumber | ||||||||||||||||||||||||||||||||||||||||||||||||
| 557 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 558 | Title : isNumber | ||||||||||||||||||||||||||||||||||||||||||||||||
| 559 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 560 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 561 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 562 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 563 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 564 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 565 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 566 | 0 | ▶ | sub isNumber { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
isNumber: not called CC=2 SCAR=17.9
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 567 | 0 | my $arg=$_[0]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 568 | 0 | my $var=$_[1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 569 | 0 | ▶ | if ($arg =~ /(\d+\.?\d*|\.\d+)/) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 570 | 0 | return 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 571 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 572 | 0 | return 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 574 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 575 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 576 | 0 | ▶ | sub __read_nexus { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__read_nexus: not called CC=22 SCAR=62.3
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 577 | 0 | my $mydata = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 578 | 0 | my $inputFile = $runtime_options->{'input_file'}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 579 | 0 | my $nexusObject; | |||||||||||||||||||||||||||||||||||||||||||||||
| 580 | 0 | ▶ | if($nexusG->get_isVerbose) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 581 | 0 | $DEBUG=1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 582 | 0 | $nexusObject = new Bio::NEXUS($inputFile,1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 583 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 584 | 0 | $nexusObject = new Bio::NEXUS($inputFile); | |||||||||||||||||||||||||||||||||||||||||||||||
| 585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 586 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 587 | 0 | ▶ | if ($runtime_options->{'species_tree'} eq 'on') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 588 | 0 | return $nexusObject; | |||||||||||||||||||||||||||||||||||||||||||||||
| 589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 590 | # Read in NEXUS blocks from NEXUS object | ||||||||||||||||||||||||||||||||||||||||||||||||
| 591 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 592 | 0 | my @selectsub_params = @{ $runtime_options->{'select_sub_tree'} }; # Select a subtree | |||||||||||||||||||||||||||||||||||||||||||||||
| 593 | 0 | my @reroot_params = @{ $runtime_options->{'reroot_node'} }; # Reroot a subtree | |||||||||||||||||||||||||||||||||||||||||||||||
| 594 | 0 | my @swap_params = @{ $runtime_options->{'swap_children'} }; # Swap the children of the node | |||||||||||||||||||||||||||||||||||||||||||||||
| 595 | 0 | my @excludesub_params = @{ $runtime_options->{'exclude_sub_tree'} }; # Exclude a subtree | |||||||||||||||||||||||||||||||||||||||||||||||
| 596 | 0 | my @setsbyinode_params = @{ $runtime_options->{'setsbyinode'} }; | |||||||||||||||||||||||||||||||||||||||||||||||
| 597 | 0 | my $tree; | |||||||||||||||||||||||||||||||||||||||||||||||
| 598 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 599 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 600 | 0 | ▶ | if ($nexusObject->get_block('trees')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 601 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 602 | 0 | ▶ | $nexusObject = $nexusObject->reroot($reroot_params[$#reroot_params]) if ($reroot_params[0] ne ''); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 603 | 0 | ▶ | $nexusObject = $nexusObject->select_subtree($selectsub_params[$#selectsub_params]) if ( $selectsub_params[0] ne '' ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 604 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 605 | 0 | foreach my $excludesub_param (@excludesub_params) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 606 | 0 | $nexusObject = $nexusObject->exclude_subtree($excludesub_param); | |||||||||||||||||||||||||||||||||||||||||||||||
| 607 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 608 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 609 | 0 | $tree = $nexusObject->get_block("trees")->get_tree(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 610 | 0 | foreach my $swapnode(@swap_params){ | |||||||||||||||||||||||||||||||||||||||||||||||
| 611 | 0 | ▶ | last if ($swapnode eq ''); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 612 | 0 | ▶ | &swap_children($tree,$swapnode) if ($tree->find($swapnode)); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 613 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 614 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 615 | 0 | $nexusObject = $nexusObject->exclude_otus(\@excludesub_params); | |||||||||||||||||||||||||||||||||||||||||||||||
| 616 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 617 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 618 | 0 | ▶ | if ($selectsub_params[0] ne '' || $excludesub_params[0] ne '') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$selectsub_params[0] ne "" or $excludesub_params[0] ne ""
MC/DC0%0/2
$selectsub_params[0] ne "" or $excludesub_params[0] ne ""
$selectsub_params[0] ne ""
$excludesub_params[0] ne ""
Truth table0%0/3
A or B
A= $selectsub_params[0] ne ""B= $excludesub_params[0] ne ""
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 619 | 0 | my @intron_present_cols=(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 620 | 0 | ▶ | my @taxa = @{$nexusObject->get_block("characters")->get_taxlabels()} if $nexusObject->get_block("characters"); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 621 | 0 | ▶ | my %intron_seqs = %{$nexusObject->get_block("characters","intron")->get_otuset->get_seq_string_hash} if $nexusObject->get_block("characters","intron"); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 622 | 0 | ▶ | for (my $c=0; $c < length($intron_seqs{$taxa[0]}); $c++) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 623 | 0 | foreach my $taxon (@taxa) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 624 | 0 | my $sequence = $intron_seqs{$taxon}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 625 | 0 | ▶ | if (substr($sequence,$c,1) ne '0') { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 626 | 0 | push @intron_present_cols, $c; | |||||||||||||||||||||||||||||||||||||||||||||||
| 627 | 0 | last; | |||||||||||||||||||||||||||||||||||||||||||||||
| 628 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 629 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 630 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 631 | 0 | ▶ | $nexusObject = $nexusObject->select_chars(\@intron_present_cols) if (lc($runtime_options->{'character_data_type'}) eq 'intron'); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 632 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 633 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 634 | #### Set by Inode ### | ||||||||||||||||||||||||||||||||||||||||||||||||
| 635 | 0 | ▶ | if (defined $nexusObject->get_block("Trees") && $nexusObject->get_block("trees")->get_tree) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $nexusObject->get_block("Trees") and $nexusObject->get_block("trees")->get_tree
MC/DC0%0/2
defined $nexusObject->get_block("Trees") and $nexusObject->get_block("trees")->get_tree
defined $nexusObject->get_block("Trees")
$nexusObject->get_block("trees")->get_tree
Truth table0%0/3
A and B
A= defined $nexusObject->get_block("Trees")B= $nexusObject->get_block("trees")->get_tree
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 636 | 0 | my $sets; | |||||||||||||||||||||||||||||||||||||||||||||||
| 637 | my $setsblock; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 638 | 0 | for my $inodename (@setsbyinode_params) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 639 | 0 | my $subtree = $nexusObject->select_subtree($inodename); | |||||||||||||||||||||||||||||||||||||||||||||||
| 640 | 0 | my $otus = $subtree->get_otus(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 641 | 0 | $$sets{$inodename} = $otus; | |||||||||||||||||||||||||||||||||||||||||||||||
| 642 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 643 | 0 | ▶ | if ($nexusObject->get_block('Sets')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 644 | 0 | $nexusObject->get_block('Sets')->add_taxsets($sets); | |||||||||||||||||||||||||||||||||||||||||||||||
| 645 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 646 | 0 | $setsblock = Bio::NEXUS::SetsBlock->new('Sets',[]); | |||||||||||||||||||||||||||||||||||||||||||||||
| 647 | 0 | $setsblock->set_taxsets($sets); | |||||||||||||||||||||||||||||||||||||||||||||||
| 648 | 0 | $nexusObject->add_block($setsblock); | |||||||||||||||||||||||||||||||||||||||||||||||
| 649 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 650 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 651 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 652 | ######### | ||||||||||||||||||||||||||||||||||||||||||||||||
| 653 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 654 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 655 | #my @trees = @{$block->get_trees()}; ##### Get names of all trees in the file | ||||||||||||||||||||||||||||||||||||||||||||||||
| 656 | #foreach my $myTree (@trees) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 657 | # $myTreeName = $myTree->{name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 658 | # print "Tree: $myTreeName<br>"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 659 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 660 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 661 | # EXTRACT TREE DATA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 662 | #die "No tree in file $inputFile\n" unless $tree; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 663 | 0 | return $nexusObject; | |||||||||||||||||||||||||||||||||||||||||||||||
| 664 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 665 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 666 | =head2 parse_number | ||||||||||||||||||||||||||||||||||||||||||||||||
| 667 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 668 | Title : parse_number | ||||||||||||||||||||||||||||||||||||||||||||||||
| 669 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 670 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 671 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 672 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 673 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 674 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 675 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 676 | # parse numbers in format "1-3, 4 6 8-10" | ||||||||||||||||||||||||||||||||||||||||||||||||
| 677 | #Taken from nextool.pl | ||||||||||||||||||||||||||||||||||||||||||||||||
| 678 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 679 | 0 | ▶ | sub parse_number { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
parse_number: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 680 | 0 | my $s = shift; | |||||||||||||||||||||||||||||||||||||||||||||||
| 681 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 682 | 0 | ▶ | if (! $s =~ /^\s*(\d+(-\d+)?)([,\s]\s*\d+(-\d+)?)*\s*$/ ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 683 | 0 | die "Invalid number format. Use 1 or 1-3 or 1, 3, 5-8 or 1 3 5 6-10.\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 684 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 685 | 0 | $s =~ s/^\s+|\s+$//g; | |||||||||||||||||||||||||||||||||||||||||||||||
| 686 | 0 | $s =~ s/,?\s+/,/g; # use ',' as separator | |||||||||||||||||||||||||||||||||||||||||||||||
| 687 | 0 | my @cols = split(/,/, $s); | |||||||||||||||||||||||||||||||||||||||||||||||
| 688 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 689 | 0 | my @arr; | |||||||||||||||||||||||||||||||||||||||||||||||
| 690 | 0 | foreach my $item (@cols) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 691 | 0 | ▶ | if ($item =~ /-/) { # eg 1-3 | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 3 branches
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 692 | 0 | $item =~ /([0-9]+)\s*-\s*([0-9]+)/; | |||||||||||||||||||||||||||||||||||||||||||||||
| 693 | 0 | ▶ | for (my $i = $1; $i <= $2; $i++) { push ( @arr, $i-1 ); } | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 694 | } elsif ($item =~ /^\d+$/) { # eg 4 | ||||||||||||||||||||||||||||||||||||||||||||||||
| 695 | 0 | push ( @arr, $item-1 ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 696 | } elsif ($item) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 697 | 0 | die "non-number was used for column number\n"; | |||||||||||||||||||||||||||||||||||||||||||||||
| 698 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 699 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 700 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 701 | 0 | @arr = sort {$a<=>$b} @arr; | |||||||||||||||||||||||||||||||||||||||||||||||
| 702 | 0 | return \@arr; | |||||||||||||||||||||||||||||||||||||||||||||||
| 703 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 704 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 705 | =head2 AssignStateToNode | ||||||||||||||||||||||||||||||||||||||||||||||||
| 706 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 707 | Title : AssignStateToNode | ||||||||||||||||||||||||||||||||||||||||||||||||
| 708 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 709 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 710 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 711 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 712 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 713 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 714 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 715 | 0 | ▶ | sub AssignStateToNode { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssignStateToNode: not called CC=8 SCAR=42.8
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 716 | # AssignStateToNode -- propagate colors or other states up a tree | ||||||||||||||||||||||||||||||||||||||||||||||||
| 717 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 718 | # Technically, what we are doing here is reconstructing ancestral states | ||||||||||||||||||||||||||||||||||||||||||||||||
| 719 | # based on a transition model of infinite cost (zero rate), so that no | ||||||||||||||||||||||||||||||||||||||||||||||||
| 720 | # transitions are allowed. Thus, an ancestor is assigned to a state | ||||||||||||||||||||||||||||||||||||||||||||||||
| 721 | # _i_ if and only if all of its descendants are assigned to state _i_. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 722 | # | ||||||||||||||||||||||||||||||||||||||||||||||||
| 723 | # this function | ||||||||||||||||||||||||||||||||||||||||||||||||
| 724 | # * probably should be put in a library and named something like | ||||||||||||||||||||||||||||||||||||||||||||||||
| 725 | # "AssignAncestralStatesByConsensus"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 726 | # * maps states to the *names* of nodes, not to their object refs; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 727 | # * allows for polytomies; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 728 | # * does not assume all OTUs have defined states, but note that | ||||||||||||||||||||||||||||||||||||||||||||||||
| 729 | # any undefined states of OTUs *will remain undefined* | ||||||||||||||||||||||||||||||||||||||||||||||||
| 730 | #$node # node object | ||||||||||||||||||||||||||||||||||||||||||||||||
| 731 | #$unknownState # state to assign when no other assignment can be made | ||||||||||||||||||||||||||||||||||||||||||||||||
| 732 | #$map # hash with any available states | ||||||||||||||||||||||||||||||||||||||||||||||||
| 733 | 0 | my ($map, $node, $unknownState) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 734 | 0 | my $name = $node->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 735 | 0 | my $lastState = undef; | |||||||||||||||||||||||||||||||||||||||||||||||
| 736 | 0 | my $assignable = 1; | |||||||||||||||||||||||||||||||||||||||||||||||
| 737 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 738 | # return if state already exists OR if the node is an OTU | ||||||||||||||||||||||||||||||||||||||||||||||||
| 739 | 0 | ▶ | return if (defined($map->{$name}) || $node->is_otu() ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $map->{$name} or $node->is_otu
MC/DC0%0/2
defined $map->{$name} or $node->is_otu
defined $map->{$name}
$node->is_otu
Truth table0%0/3
A or B
A= defined $map->{$name}B= $node->is_otu
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 740 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 741 | # Go through children and make sure all children are the same state | ||||||||||||||||||||||||||||||||||||||||||||||||
| 742 | 0 | foreach my $child (@{$node->get_children()}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 743 | 0 | my $childname = $child->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 744 | 0 | ▶ | &AssignStateToNode($map, $child, $unknownState) unless $map->{$childname}; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 745 | 0 | ▶ | if ( defined($lastState) && $$map{$childname} ne $lastState ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
defined $lastState and $map->{$childname} ne $lastState
MC/DC0%0/2
defined $lastState and $map->{$childname} ne $lastState
defined $lastState
$map->{$childname} ne $lastState
Truth table0%0/3
A and B
A= defined $lastStateB= $map->{$childname} ne $lastState
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 746 | 0 | $assignable = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 747 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 748 | 0 | $lastState = $map->{$childname}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 749 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 750 | 0 | ▶ | return( $map->{ $name } = ( $assignable ? $lastState : $unknownState ) ); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 751 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 752 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 753 | =head2 AssignStateToSuperNode | ||||||||||||||||||||||||||||||||||||||||||||||||
| 754 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 755 | Title : AssignStateToSuperNode | ||||||||||||||||||||||||||||||||||||||||||||||||
| 756 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 757 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 758 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 759 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 760 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 761 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 762 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 763 | 0 | ▶ | sub AssignStateToSuperNode { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssignStateToSuperNode: not called CC=7 SCAR=40.3
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 764 | # AssignStateToSuperNode -- propogate color up a tree to highlight a sequence's branch path | ||||||||||||||||||||||||||||||||||||||||||||||||
| 765 | 0 | my ($my_data, $node, $OTU, $nodesListRef, $color) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 766 | 0 | my @nodesList = @$nodesListRef; | |||||||||||||||||||||||||||||||||||||||||||||||
| 767 | 0 | my $name = $node->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 768 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 769 | 0 | ▶ | return if ($node && $node->is_otu() && ($name ne $OTU)); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/6
$node and $node->is_otu and $name ne $OTU
$node and $node->is_otu
MC/DC0%0/3
$node and $node->is_otu and $name ne $OTU
$node
$node->is_otu
$name ne $OTU
Truth table0%0/4
A and B and C
A= $nodeB= $node->is_otuC= $name ne $OTU
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 770 | 0 | ▶ | if ($nodesList[$#nodesList] eq $OTU) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 771 | 0 | foreach my $node_name (@nodesList) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 772 | 0 | $my_data->set_node_color($node_name, $color); | |||||||||||||||||||||||||||||||||||||||||||||||
| 773 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 774 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 775 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 776 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 777 | 0 | foreach my $child (@{$node->get_children()}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 778 | 0 | my @newNodesList = @nodesList; | |||||||||||||||||||||||||||||||||||||||||||||||
| 779 | 0 | push @newNodesList,$child->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 780 | 0 | &AssignStateToSuperNode($my_data,$child,$OTU,\@newNodesList,$color); | |||||||||||||||||||||||||||||||||||||||||||||||
| 781 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 782 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 783 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 784 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 785 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 786 | =head2 AssignStateToSubNode | ||||||||||||||||||||||||||||||||||||||||||||||||
| 787 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 788 | Title : AssignStateToSubNode | ||||||||||||||||||||||||||||||||||||||||||||||||
| 789 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 790 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 791 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 792 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 793 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 794 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 795 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 796 | 0 | ▶ | sub AssignStateToSubNode { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
AssignStateToSubNode: not called CC=4 SCAR=30.0
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 797 | # AssignStateToNode -- propagate colors or other states down a tree once a node is selected | ||||||||||||||||||||||||||||||||||||||||||||||||
| 798 | 0 | my ($my_data, $node, $color) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 799 | 0 | my $name = $node->get_name; | |||||||||||||||||||||||||||||||||||||||||||||||
| 800 | 0 | ▶ | return if (!$node || $node->is_otu()); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
not $node or $node->is_otu
MC/DC0%0/2
not $node or $node->is_otu
not $node
$node->is_otu
Truth table0%0/3
not(A) or B
A= not $nodeB= $node->is_otu
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 801 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 802 | 0 | foreach my $child (@{$node->get_children()}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 803 | 0 | $my_data->set_node_color($child->get_name,$color); | |||||||||||||||||||||||||||||||||||||||||||||||
| 804 | 0 | &AssignStateToSubNode($my_data, $child, $color); | |||||||||||||||||||||||||||||||||||||||||||||||
| 805 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 806 | 0 | return; | |||||||||||||||||||||||||||||||||||||||||||||||
| 807 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 808 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 809 | 0 | ▶ | sub __print_piechart { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__print_piechart: not called CC=3 SCAR=24.8
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 810 | 0 | my ($my_data, $node, $otu_seq_hash) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 811 | 0 | my $name = $node->get_name(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 812 | 0 | my $x = $node->_get_xcoord; | |||||||||||||||||||||||||||||||||||||||||||||||
| 813 | 0 | my $y = $node->_get_ycoord; | |||||||||||||||||||||||||||||||||||||||||||||||
| 814 | 0 | my $seq = $otu_seq_hash->{$name}->[$ppp_param-1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 815 | 0 | my $prob = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 816 | 0 | ▶ | $prob = ((ref $seq) eq 'ARRAY') ? $seq->[1] : $seq; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 817 | 0 | &__draw_piechart($my_data,$x, $y, $nexusG->get_pieChartRadius, $prob); | |||||||||||||||||||||||||||||||||||||||||||||||
| 818 | 0 | foreach my $child (@{$node->get_children()}) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 819 | 0 | &__print_piechart($my_data,$child,$otu_seq_hash); | |||||||||||||||||||||||||||||||||||||||||||||||
| 820 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 821 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 822 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 823 | 0 | ▶ | sub __print_tree { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Subroutine
__print_tree: not called CC=19 SCAR=59.4
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 824 | 0 | my ($my_data,$node, $x0, $y0,$otuseqs) = @_; | |||||||||||||||||||||||||||||||||||||||||||||||
| 825 | 0 | my $name = $node->get_name(); | |||||||||||||||||||||||||||||||||||||||||||||||
| 826 | 0 | my $x1 = int($node->_get_xcoord); | |||||||||||||||||||||||||||||||||||||||||||||||
| 827 | 0 | my $y1 = 0; | |||||||||||||||||||||||||||||||||||||||||||||||
| 828 | 0 | my $color; | |||||||||||||||||||||||||||||||||||||||||||||||
| 829 | 0 | my $prob_val = ''; | |||||||||||||||||||||||||||||||||||||||||||||||
| 830 | 0 | my $treeNodeRadius = $nexusG->get_treeNodeRadius; | |||||||||||||||||||||||||||||||||||||||||||||||
| 831 | 0 | my $pieChartRadius = $nexusG->get_pieChartRadius; | |||||||||||||||||||||||||||||||||||||||||||||||
| 832 | 0 | ▶ | $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'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/7
not $runtime_options->{"set_type"} or $runtime_options->{"set_type"} eq "None"
$my_data->get_node_color($name) or "black"
$my_data->get_node_color($name) or "gray"
MC/DC0%0/2
not $runtime_options->{"set_type"} or $runtime_options->{"set_type"} eq "None"
not $runtime_options->{"set_type"}
$runtime_options->{"set_type"} eq "None"
MC/DC0%0/1
$my_data->get_node_color($name) or "black"
$my_data->get_node_color($name)
MC/DC0%0/1
$my_data->get_node_color($name) or "gray"
$my_data->get_node_color($name)
Truth table0%0/3
not(A) or B
A= not $runtime_options->{"set_type"}B= $runtime_options->{"set_type"} eq "None"
Truth table0%0/2
A
A= $my_data->get_node_color($name)
Truth table0%0/2
A
A= $my_data->get_node_color($name)
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 833 | #$y1 += $nexusG->get_fontHeight; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 834 | 0 | ▶ | if ($ppp_param && $nexusObject->get_block('history','intron')) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
Condition0%0/3
$ppp_param and $nexusObject->get_block("history", "intron")
MC/DC0%0/2
$ppp_param and $nexusObject->get_block("history", "intron")
$ppp_param
$nexusObject->get_block("history", "intron")
Truth table0%0/3
A and B
A= $ppp_paramB= $nexusObject->get_block("history", "intron")
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 835 | 0 | my $seq = $otuseqs->{$name}->[$ppp_param-1]; | |||||||||||||||||||||||||||||||||||||||||||||||
| 836 | 0 | ▶ | $prob_val = (ref $seq) ? $seq->[1] : $seq; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 837 | 0 | $prob_val = ":p(1) = ". $prob_val; | |||||||||||||||||||||||||||||||||||||||||||||||
| 838 | 0 | $y1 = int($node->_get_ycoord); | |||||||||||||||||||||||||||||||||||||||||||||||
| 839 | 0 | &__draw_line($my_data,$x0, $y1, $x1, $y1, $color, 2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 840 | 0 | ▶ | if ($y1 > $y0) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 841 | 0 | ▶ | &__draw_line($my_data,$x0, $y1, $x0, $y0 + $pieChartRadius/2, $color, 2) unless $node->get_name eq 'root' ; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 842 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 843 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 844 | 0 | ▶ | &__draw_line($my_data,$x0, $y1, $x0, $y0 - $pieChartRadius / 2, $color, 2) unless $node->get_name eq 'root' ; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 845 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 846 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 847 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 848 | 0 | $y1 = int($node->_get_ycoord); | |||||||||||||||||||||||||||||||||||||||||||||||
| 849 | 0 | &__draw_line($my_data,$x0, $y1, $x1, $y1, $color, 2); | |||||||||||||||||||||||||||||||||||||||||||||||
| 850 | 0 | ▶ | &__draw_line($my_data,$x0, $y0, $x0, $y1, $color, 2) unless $node->get_name eq 'root' ; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 851 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 852 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 853 | 0 | ▶ | if ($node->is_otu()) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 854 | 0 | &__print_label($my_data, $x1+$pieChartRadius*.75, $y1,$node->get_name,$color) ; | |||||||||||||||||||||||||||||||||||||||||||||||
| 855 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 856 | 0 | my $x2 = int( $x1 + $treeNodeRadius ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 857 | 0 | my $y2 = int( $y1 + $treeNodeRadius ); | |||||||||||||||||||||||||||||||||||||||||||||||
| 858 | 0 | ▶ | if ( not $ppp_param ) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 859 | 0 | ▶ | &__draw_circle($my_data,$x1, $y1,$treeNodeRadius,$color) if (!$node->is_otu); | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 860 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 861 | 0 | ▶ | $my_data->set_tree_map_coord( $node->get_name, [$x1,$y1,$x2,$y2] ) if $runtime_options->{'output_type'} eq 'png'; | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 862 | 0 | ▶ | if ($node->{name} ne "root") { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 863 | #$query->delete("session") if ($runtime_options->{'session'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 864 | 0 | $node->_set_xcoord($x1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 865 | 0 | $node->_set_ycoord($y1); | |||||||||||||||||||||||||||||||||||||||||||||||
| 866 | #$areaMap .= qq(<area shape=rect onMouseOver="showtip(this,event,'$node->{name} options $prob_val')" onMouseOut="PopUpMenu2_Hide();" coords=$x1,$y1,$x2,$y2 href="javascript:PopUpMenu2_Set(getParam(\'$qs\',\'$node->{name}\',\'$file_param\',\'$colornode_params[$#colornode_params]\'),'','','','','');">\n); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 867 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 868 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 869 | #$areaMap .= qq(<area shape=rect onMouseOver="showtip(this,event,'Root node options $prob_val')" onMouseOut="PopUpMenu2_Hide();" coords=$x1,$y1,$x2,$y2 href="javascript:PopUpMenu2_Set(getParamRoot(\'$qs\',\'$node->{name}\',\'$file_param\',\'$colornode_params[$#colornode_params]\'),'','','','','');">\n); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 870 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 871 | 0 | ▶ | if (not $node->is_otu) { | ||||||||||||||||||||||||||||||||||||||||||||||
|
Branch: 1 branch
| |||||||||||||||||||||||||||||||||||||||||||||||||
| 872 | 0 | my @nodes = @{$node->get_children()}; | |||||||||||||||||||||||||||||||||||||||||||||||
| 873 | 0 | foreach my $child (@nodes) { | |||||||||||||||||||||||||||||||||||||||||||||||
| 874 | 0 | &__print_tree($my_data,$child, $x1, $y1,$otuseqs); | |||||||||||||||||||||||||||||||||||||||||||||||
| 875 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 876 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 877 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 878 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 879 | sub __print_matrix { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 880 | my ($my_data, $x0, $y0,$taxlabels,$is_print_labels) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 881 | my $seqs = $my_data->get_char_block_seq; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 882 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 883 | foreach my $taxa (@{$taxlabels}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 884 | my $color = $my_data->get_node_color($taxa); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 885 | &__print_label($my_data,$x0,$y0,$taxa,$color) if $is_print_labels; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 886 | my $xPos = $nexusG->get_characterStartXpos; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 887 | $color = 'gray' if ( (defined @{ $runtime_options->{'highlight_otus'} }) and ($color eq 'black') ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 888 | &__print_sequence($my_data, $xPos,$y0,$seqs->{$taxa},$taxa, $color) if defined $seqs; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 889 | $y0 += $nexusG->get_verticalOtuSpacing; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 890 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 891 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 892 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 893 | sub __print_label { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 894 | my ($my_data, $x, $y,$taxon_name, $color) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 895 | my ($x1,$x2,$y1,$y2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 896 | $color = ( defined($color) ? $color : 'black' ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 897 | my $tip = ($color ne 'gray') ? 'OTU options' : 'Taxonomy not identified for this sequence'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 898 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 899 | # Print either left justified or right justified names | ||||||||||||||||||||||||||||||||||||||||||||||||
| 900 | if ($runtime_options->{'right_justify_labels'} eq 'on') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 901 | $x1 = $x; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 902 | $y1 = $y; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 903 | $x2 = $nexusG->get_characterStartXpos - (length($taxon_name) * $nexusG->get_fontWidth) - $nexusG->get_labelMatrixGapWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 904 | $y2 = $y; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 905 | &__draw_text($my_data,$x2,$y2,$taxon_name,$color); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 906 | $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'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 907 | $x1 += $nexusG->get_fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 908 | $x2 -= $nexusG->get_fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 909 | &__draw_line($my_data,$x1,$y1,$x2,$y1,'gray',1) if (($x1 < $x2) && ($runtime_options->{'show_content'} ne 'Data only')); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 910 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 911 | $x1 = $x; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 912 | $x2 = $nexusG->get_characterStartXpos - $nexusG->get_labelMatrixGapWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 913 | $y1 = $y; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 914 | #$y2 = $y-( $nexusG->get_fontHeight/2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 915 | $y2 = $y; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 916 | &__draw_text($my_data,$x1,$y2,$taxon_name,$color); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 917 | $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'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 918 | #$areaMap.= sprintf "<area shape=rect onMouseOver=\"showtip(this,event,\'$tip\')\" onMouseOut=\"PopUpMenu2_Hide();\" coords=%d,%d,%d,%d href=\"javascript:PopUpMenu2_Set(getParam2(\'$qs\',\'%s\',\'$file_param\',\'$dir_param\',\'$highlight_params[$#highlight_params]\'),'','','','','');\">\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"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 919 | $x1 += length($taxon_name) * $nexusG->get_fontWidth + $nexusG->get_fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 920 | &__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); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 921 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 922 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 923 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 924 | sub __print_sequence() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 925 | my ($my_data, $x, $y, $sequence, $taxName, $color) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 926 | my $block = $my_data->get_selected_char_block; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 927 | $color = ( defined($color) ? $color : 'black' ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 928 | my $data_type = $block->get_format()->{'datatype'} if ($block->get_format()); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 929 | my $gap_val = $block->get_format()->{'gap'} if ($block->get_format()->{'gap'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 930 | my $missing_val = $block->get_format()->{'missing'} if ($block->get_format()->{'missing'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 931 | my $max_val = $block->get_format()->{'max'} if ($block->get_format()->{'max'}); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 932 | $sequence = uc (&__processSeqForDisplay($sequence)) if ($data_type ne 'continuous'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 933 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 934 | my $fontWidth = $nexusG->get_fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 935 | my $fontHeight = $nexusG->get_fontHeight; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 936 | my $blockWidth = $nexusG->get_charLabelBlockWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 937 | my $xnew = $x; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 938 | if ($data_type eq 'continuous') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 939 | my $continuousMax; # Largest value in a continuous data matrix | ||||||||||||||||||||||||||||||||||||||||||||||||
| 940 | if (not $max_val) { ##Find largest value in continuous data | ||||||||||||||||||||||||||||||||||||||||||||||||
| 941 | my @array = sort { $a <=>$b } split(' ',$my_data->get_char_block_seq->{$taxName}); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 942 | $continuousMax = pop @array; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 943 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 944 | my $max = $max_val || $continuousMax; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 945 | my $xpos = $x; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 946 | my $columnCount = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 947 | my $colorscale; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 948 | my $color; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 949 | my @states = split(' ',$sequence); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 950 | my $im_h = $my_data->get_image_handler; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 951 | for (1 .. scalar(@states)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 952 | my $val = $states[$_-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 953 | $my_data->add_contin_data_map_coord($taxName,[$xpos,$y,$xpos+$fontWidth,$y+$fontHeight]) if $runtime_options->{'output_type'} eq 'png'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 954 | if ($gap_val eq $val) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 955 | #$floatMap .=sprintf "<area shape=\"rect\" coords=%d,%d,%d,%d onMouseOver=\"showtip(this,event,'Gap')\">\n",$xpos,$y,$xpos+$fontWidth,$y+$fontHeight; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 956 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 957 | elsif ($missing_val eq $val) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 958 | &__draw_text($my_data,$xpos,$y,'?','black'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 959 | #$floatMap .=sprintf "<area shape=\"rect\" coords=%d,%d,%d,%d onMouseOver=\"showtip(this,event,'Missing')\">\n",$xpos,$y,$xpos+$fontWidth,$y+$fontHeight; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 960 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 961 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 962 | $colorscale = ($max == 0) ? 0 : $val/$max; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 963 | if ($colorscale > 0.75) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 964 | $color = [255,(1-($colorscale-0.75)/0.25)*255,0]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 965 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 966 | elsif ($colorscale > 0.5) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 967 | $color = [($colorscale-0.5)/0.25*255,255,0]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 968 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 969 | elsif ($colorscale > 0.25) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 970 | $color = [0,255,(1-($colorscale-0.25)/0.25)*255]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 971 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 972 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 973 | $color = [0,$colorscale/.25*255,255]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 974 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 975 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 976 | &__draw_filledRect($my_data,$xpos,$y+$fontHeight-($fontHeight*$colorscale),$xpos+$fontWidth,$y+$fontHeight,$color); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 977 | &__draw_line($my_data,$xpos,$y+$fontHeight-($fontHeight*$colorscale),$xpos,$y+$fontHeight,'black',0.5); # Left border | ||||||||||||||||||||||||||||||||||||||||||||||||
| 978 | &__draw_line($my_data,$xpos+$fontWidth,$y+$fontHeight-($fontHeight*$colorscale),$xpos+$fontWidth,$y+$fontHeight,'black',0.5); # Right border | ||||||||||||||||||||||||||||||||||||||||||||||||
| 979 | &__draw_line($my_data,$xpos,$y+$fontHeight-($fontHeight*$colorscale),$xpos+$fontWidth,$y+$fontHeight-($fontHeight*$colorscale),'black',0.5); # Top border | ||||||||||||||||||||||||||||||||||||||||||||||||
| 980 | &__draw_line($my_data,$xpos,$y+$fontHeight,$xpos+$fontWidth,$y+$fontHeight,'black',0.5); # Bottom border | ||||||||||||||||||||||||||||||||||||||||||||||||
| 981 | #$floatMap .=sprintf "<area shape=\"rect\" coords=%d,%d,%d,%d onMouseOver=\"showtip(this,event,'$val')\">\n",$xpos,$y,$xpos+$fontWidth,$y+$fontHeight; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 982 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 983 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 984 | $xpos += $fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 985 | $columnCount++; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 986 | $xpos += $fontWidth if ($columnCount% ($blockWidth) == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 987 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 988 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 989 | elsif (($runtime_options->{'colorintron'}) ne '' && (lc($runtime_options->{'character_data_type'}) ne 'intron')) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 990 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 991 | my %intronSequences = %{$nexusObject->get_block("characters","intron")->get_otuset->get_seq_string_hash}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 992 | my $intronSeq = $intronSequences{$taxName}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 993 | my @intronLabels = @{$nexusObject->get_block("characters","intron")->get_charlabels}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 994 | my @intron_present_pos = (); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 995 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 996 | for (my $c = 0,my $index = 0; $c < length($intronSeq); $c++, $index++) { # Get positions only where introns are present | ||||||||||||||||||||||||||||||||||||||||||||||||
| 997 | $index = index($intronSeq,'1',$index); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 998 | last if ($index == -1); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 999 | push @intron_present_pos, $intronLabels[$index]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1000 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1001 | #print "<PRE> $taxName ";print Dumper \@intron_present_pos;print"</PRE>"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1002 | my $frontPos = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1003 | my $aaNum = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1004 | my @phaseColor = ('red','blue','darkgreen'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1005 | if (lc($runtime_options->{'character_data_type'}) eq 'protein') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1006 | $frontPos = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1007 | $aaNum = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1008 | my $numBlanks; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1009 | foreach my $intron_pos (@intron_present_pos) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1010 | ($aaNum = $intron_pos) =~ s/(-.)//; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1011 | $aaNum -= $runtime_options->{'select_char_range'}->[0] if defined @{$runtime_options->{'select_char_range'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1012 | (my $phaseNum = $intron_pos) =~ s/(.*-)//; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1013 | my $phaseColor = $phaseColor[$phaseNum]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1014 | $numBlanks = int($aaNum/$blockWidth)-int($frontPos/$blockWidth); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1015 | my $frontPx = ($frontPos+int($frontPos/$blockWidth))*$fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1016 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1017 | next if $aaNum < 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1018 | if ($aaNum <= length($sequence)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1019 | &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$frontPos+int($frontPos/$blockWidth),$aaNum-1-$frontPos+$numBlanks)),$color); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1020 | $frontPx += ($aaNum-1-$frontPos+$numBlanks)*$fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1021 | $frontPx -= $fontWidth if ($aaNum%$blockWidth == 0); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1022 | &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$aaNum-1+int(($aaNum-1)/$blockWidth),1)),$phaseColor); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1023 | $frontPos = $aaNum; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1024 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1025 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1026 | $numBlanks = $aaNum < 0 ? 0 : int($aaNum/$blockWidth)-int($frontPos/$blockWidth); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1027 | my $frontPx = ($frontPos + int($frontPos/$blockWidth)) * $fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1028 | &__draw_text( $my_data,$xnew + $frontPx, $y, uc( substr( $sequence,$frontPos + int ( $frontPos/$blockWidth), length($sequence) - $frontPos + $numBlanks) ), $color); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1029 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1030 | elsif (lc ($runtime_options->{'character_data_type'}) eq 'dna') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1031 | $frontPos = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1032 | $aaNum = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1033 | foreach my $intron_pos (@intron_present_pos) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1034 | ($aaNum = $intron_pos) =~ s/(-.)//; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1035 | $aaNum -= 3 * $runtime_options->{'select_char_range'}->[0] if defined @{$runtime_options->{'select_char_range'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1036 | (my $phaseNum = $intron_pos) =~ s/(.*-)//; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1037 | my $dnaNum = ($aaNum-1)*3; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1038 | next if $dnaNum < 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1039 | my $phaseColor = $phaseColor[$phaseNum]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1040 | my $numBlanks = int(($dnaNum-1)/$blockWidth)-int(($frontPos-1)/$blockWidth); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1041 | my $frontPx = ($frontPos+int(($frontPos-1)/$blockWidth))*$fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1042 | if ($dnaNum+$phaseNum < length($sequence)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1043 | &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$frontPos+int(($frontPos-1)/$blockWidth),$dnaNum-$frontPos+$numBlanks)),$color); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1044 | $frontPx += ($dnaNum-$frontPos+$numBlanks)*$fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1045 | my $length = 1 if (int($dnaNum+1)/$blockWidth > int($dnaNum-1)/$blockWidth); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1046 | &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$dnaNum+int(($dnaNum-1)/$blockWidth),3+$length)),$phaseColor); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1047 | $frontPos = $dnaNum+3; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1048 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1049 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1050 | my $frontPx = ($frontPos+int($frontPos/$blockWidth))*$fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1051 | &__draw_text($my_data,$xnew+$frontPx,$y,uc(substr($sequence,$frontPos+int($frontPos/$blockWidth),length($sequence)-$frontPos+int($aaNum/$blockWidth)-int($frontPos/$blockWidth))),$color); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1052 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1053 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1054 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1055 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1056 | &__draw_text($my_data,$xnew,$y,uc($sequence),$color); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1057 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1058 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1059 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1060 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1061 | sub __processSeqForDisplay() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1062 | my $string = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1063 | $string =~ tr/01/.+/; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1064 | my @tmp = split (//, $string); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1065 | my $tmp_string = ""; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1066 | my $char_block_width = $nexusG->get_charLabelBlockWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1067 | $string =~ s/(.{$char_block_width})/$1 /g; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1068 | return $string; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1069 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1070 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1071 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1072 | sub __print_char_labels { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1073 | my ($my_data, $block) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1074 | warn("Grabbing characters block from NEXUS file...\n") if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1075 | my @columnLabels = $my_data->get_char_column_labels; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1076 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1077 | my @columnLabelsAll = @{$nexusObject->get_block("characters","intron")->get_charlabels} if $nexusObject->get_block("characters","intron"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1078 | warn "WARNING: No labels\n" unless @columnLabels; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1079 | my $blank = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1080 | my $longestLabel = $nexusG->get_longestCharLabelLength(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1081 | my $yPosition = $nexusG->get_lowerYMargin ; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1082 | my $highlightcol = $columnLabelsAll[$ppp_param-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1083 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1084 | for (my $i = 0; $i <= $#columnLabels; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1085 | if ( $i && ($i % ($nexusG->get_charLabelBlockWidth) == 0) ) { # char #11, #21, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1086 | $blank += $nexusG ->get_fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1087 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1088 | my $label=$columnLabels[$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1089 | my $x = $nexusG->get_characterStartXpos + $blank + $i * $nexusG->get_fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1090 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1091 | my $colpos = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1092 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1093 | for (1 .. scalar(@columnLabelsAll)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1094 | #print "$highlightcol , $columnLabelsAll[$_-1]<br>"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1095 | #print "@columnLabels<br>"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1096 | if ($highlightcol eq $columnLabels[$_-1]) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1097 | $colpos = $_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1098 | last; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1099 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1100 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1101 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1102 | my $color = ($ppp_param && ($colpos==($i+1))) ? 'darkgreen': 'darkred'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1103 | $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'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1104 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1105 | $label =~ s/-|_/\|/; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1106 | substr($label,0,0) = ' ' x (($longestLabel/$nexusG->get_fontHeight)-length($label)); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1107 | &__print_vertical_label($my_data, $x, $yPosition, $label, $color, @columnLabelsAll); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1108 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1109 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1110 | sub __highlight_char{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1111 | my ($my_data, $block) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1112 | warn("Grabbing characters block from NEXUS file...\n") if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1113 | my @columnLabels = $my_data->get_char_column_labels; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1114 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1115 | warn "WARNING: No labels\n" unless @columnLabels; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1116 | my $blank = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1117 | for (my $i = 0; $i <= $#columnLabels; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1118 | if ( $i && ($i % ($nexusG->get_charLabelBlockWidth) == 0) ) { # char #11, #21, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1119 | $blank += $nexusG ->get_fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1120 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1121 | my $label=$columnLabels[$i]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1122 | my $x = $nexusG->get_characterStartXpos + $blank + $i * $nexusG->get_fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1123 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1124 | if (my $char_highlight_pos = grep /^$columnLabels[$i]$/ , @{$runtime_options->{'highlight_chars'} } ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1125 | &__draw_filledRect($my_data,$x,1,$x+$nexusG->get_fontWidth,$nexusG->get_lowerYMargin,'pink'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1126 | &__draw_filledRect($my_data,$x,$nexusG->get_upperYbound,$x+$nexusG->get_fontWidth,$nexusG->get_ysize-1,'pink'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1127 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1128 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1129 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1130 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1131 | sub __print_vertical_label { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1132 | my ($my_data, $x, $y, $label, $color,@columnLabelsAll) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1133 | foreach my $letter (split(//,$label)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1134 | &__draw_text($my_data,$x,$y,$letter,$color); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1135 | $y += $nexusG->get_fontHeight; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1136 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1137 | $label =~ s/\|/-/; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1138 | $label =~ s/\s//g; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1139 | &__print_intron_history($my_data,$x,$y,$label,$color,@columnLabelsAll) if ( (lc $runtime_options->{'character_data_type'}) eq 'intron') && ($nexusObject->get_block('history','intron')); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1140 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1141 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1142 | sub __print_intron_history { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1143 | my ($my_data, $x, $y, $label,$color,@columnLabelsAll) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1144 | &__draw_text($my_data,$x,$y,'H','blue'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1145 | $my_data->set_intron_map_coord($label,[$x,$y,$x+$nexusG->get_fontWidth,$y+$nexusG->get_fontHeight]) if $runtime_options->{'output_type'} eq 'png'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1146 | #$labelAreaMap .=sprintf "<area shape=\"rect\" onMouseOver=\"showtip(this,event,'Intron history options for $label')\" onMouseOut=\"PopUpMenu2_Hide();\" coords=%d,%d,%d,%d href=\"javascript:PopUpMenu2_Set(getParam3(\'$qs\',\'$charnum\'),'','','','','');\">\n",$x, $y, $x + $nexusG->get_fontWidth, $y + $nexusG->get_fontHeight if ($runtime_options->{'output_type'} ne "ps" && $runtime_options->{'output_type'} ne "pdf"); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1147 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1148 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1149 | sub __plot_wts { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1150 | my ($my_data, @weights) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1151 | my $blank = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1152 | my $is_weights; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1153 | for (my $i = 0; $i <= $#weights; $i++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1154 | my $height = $weights[$i] * $nexusG->get_histogramHeight ; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1155 | if ( $i && ($i % ($nexusG->get_charLabelBlockWidth)) == 0 ) { # char #11, #21, etc. | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1156 | $blank += $nexusG->get_fontWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1157 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1158 | my $x1 = $nexusG->get_characterStartXpos + $blank + $i * $nexusG->get_fontWidth + (0.25 * $nexusG->get_fontWidth); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1159 | my $x2 = $x1 + ($nexusG->get_fontWidth/2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1160 | my $y1 = $nexusG->get_lowerYbound - $height - $nexusG->get_charLabelMatrixGapWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1161 | my $y2 = $nexusG->get_lowerYbound - $nexusG->get_charLabelMatrixGapWidth; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1162 | &__draw_filledRect($my_data,$x1,$y1,$x2,$y2,'darkgreen'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1163 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1164 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1165 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1166 | sub __set_node_coords { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1167 | my $tree = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1168 | my $treeName = $tree->get_name() || "unnamed"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1169 | my $cladogram_type = $runtime_options->{'cladogram_mode'} if $runtime_options->{'show_cladogram'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1170 | $tree->_set_xcoord($nexusG->get_TreeWidth,$cladogram_type); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1171 | $tree->_set_ycoord(0,$nexusG->get_verticalOtuSpacing); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1172 | my @nodes = @{$tree->get_nodes()}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1173 | my $root = $tree->get_rootnode(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1174 | warn("Getting names of OTUs in tree...\n") if ( $DEBUG ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1175 | my @sorted; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1176 | for my $node (@nodes) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1177 | push @sorted, $node->_get_xcoord(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1178 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1179 | @sorted = sort { $a <=> $b } @sorted; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1180 | my $sortedNum = pop @sorted; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1181 | my $amp = $nexusG->get_TreeWidth / $sortedNum if ($sortedNum != 0); # unit of branch length | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1182 | foreach my $node (@nodes) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1183 | $node->_set_xcoord(($node->_get_xcoord* $amp) + $nexusG->get_lowerXbound); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1184 | $node->_set_ycoord($node->_get_ycoord + $nexusG->get_lowerYbound); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1185 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1186 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1187 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1188 | sub __print_inode_names() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1189 | my ($my_data, $nodes) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1190 | my ($xnew,$x1, $y1); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1191 | foreach my $node (@{$nodes}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1192 | next if $node->is_otu; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1193 | $x1 = int($node->_get_xcoord); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1194 | $y1 = int($node->_get_ycoord); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1195 | $xnew = $x1 + $nexusG->get_fontWidth/2; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1196 | $xnew += $nexusG->get_pieChartRadius* 0.5 if ($ppp_param); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1197 | &__draw_text($my_data,$xnew, $y1,$node->get_name, 'darkgray'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1198 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1199 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1200 | sub __print_boot_strap() { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1201 | my ($my_data, $nodes) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1202 | foreach my $node (@{$nodes}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1203 | my $name = $node->get_name(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1204 | next unless $node->get_support_value; # print only non-zero values and only if defined in the tree | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1205 | &__draw_text($my_data,$node->_get_xcoord - ($nexusG->get_fontWidth * 4),$node->_get_ycoord + ($nexusG->get_fontHeight)/2,$node->get_support_value,'red'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1206 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1207 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1208 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1209 | sub __plot_scale_border_title { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1210 | my ($my_data) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1211 | # PRINT SCALE | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1212 | my $cladogram_type = $runtime_options->{'cladogram_mode'} if $runtime_options->{'show_cladogram'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1213 | if ( ($runtime_options->{'show_content'} ne 'Data only') && $nexusObject->get_block('trees') && (not $cladogram_type)) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1214 | #$lowerYbound -= $nexusG->get_histogramHeight/2 if (!($runtimeOptions{t}) && &__get_column_labels); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1215 | #$lowerYbound -= $nexusGi->get_fontHeight if ($runtimeOptions{t}); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1216 | #&__print_line($lowerXbound, $lowerYbound, $lowerXbound + $amp / 10, $lowerYbound, 2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1217 | #&__print_line($lowerXbound, $lowerYbound+5, $lowerXbound, $lowerYbound, 2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1218 | #&__print_line($lowerXbound + $amp / 10, $lowerYbound+5, $lowerXbound + $amp / 10, $lowerYbound, 2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1219 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1220 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1221 | # PRINT TITLE | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1222 | #my $file_param = $my_data->get_title; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1223 | my $file_param = 'Test'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1224 | &__draw_text($my_data,$nexusG->get_lowerXbound, $nexusG->get_fontHeight+5, uc($file_param), 'black'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1225 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1226 | # PRINT BORDER | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1227 | if ($runtime_options->{'show_border'} eq 'on' ){ # draw a box around what Postscript has determined is the plot | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1228 | my $lowerXBorder = $nexusG->get_lowerXMargin/2; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1229 | my $lowerYBorder = $nexusG->get_lowerYMargin/2; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1230 | my $upperXBorder = $nexusG->get_xsize - ($nexusG->get_upperXMargin/2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1231 | my $upperYBorder = $nexusG->get_ysize - ($nexusG->get_upperYMargin/2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1232 | &__draw_line($my_data,$lowerXBorder,$lowerYBorder,$upperXBorder,$lowerYBorder,'black',2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1233 | &__draw_line($my_data,$upperXBorder,$lowerYBorder,$upperXBorder,$upperYBorder,'black',2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1234 | &__draw_line($my_data,$upperXBorder,$upperYBorder,$lowerXBorder,$upperYBorder,'black',2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1235 | &__draw_line($my_data,$lowerXBorder,$upperYBorder,$lowerXBorder,$lowerYBorder,'black',2); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1236 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1237 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1238 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1239 | sub __assign_ncbi_taxonomy { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1240 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1241 | use DBI; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1242 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1243 | my ($my_data , $taxlabels) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1244 | my $dbh = DBI->connect("dbi:mysql:taxonomy", "root", "") || die "Can't connect to taxonomy: $DBI::errstr"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1245 | my $dir_param = $runtime_options->{'directory_param'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1246 | my $table_name = ($dir_param eq 'pandit') ? 'sptr_taxa' : 'cds'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1247 | my $field_name = ($dir_param eq 'pandit') ? 'sptr_id' : 'prot_id'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1248 | my $search_cond=($dir_param eq 'pandit') ? "= ?" : "like ?"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1249 | my $sql_statement; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1250 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1251 | if($dir_param eq 'uploads') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1252 | $sql_statement=qq{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1253 | SELECT kingdom,name | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1254 | from taxon_name | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1255 | where name_class='scientific name' and | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1256 | taxon_id= ? limit 10}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1257 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1258 | $sql_statement=qq{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1259 | SELECT kingdom,name | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1260 | from $table_name,taxon_name | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1261 | where $table_name.taxon_id=taxon_name.taxon_id and | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1262 | name_class='scientific name' and | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1263 | $table_name.$field_name $search_cond limit 10}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1264 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1265 | my $kingdom = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1266 | vertebrata => lc $runtime_options->{'kingdom'}->{'vertebrate'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1267 | invertebrata => lc $runtime_options->{'kingdom'}->{'invertebrate'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1268 | plants => lc $runtime_options->{'kingdom'}->{'plant'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1269 | fungi => lc $runtime_options->{'kingdom'}->{'fungi'}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1270 | protist => lc $runtime_options->{'kingdom'}->{'protist'} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1271 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1272 | for my $taxlabel (@$taxlabels) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1273 | my $taxlabel_tmp=(split(/\//,$taxlabel))[0]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1274 | (my $id=$taxlabel_tmp)=~s/^.*_//g; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1275 | if ($dir_param eq 'uploads') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1276 | ## some conditions | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1277 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1278 | chop($id) if ($dir_param eq 'NEXUS' or $dir_param eq 'uploads'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1279 | chop($id) if ($dir_param eq 'NEXUS' or $dir_param eq 'uploads'); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1280 | $id = ($dir_param eq 'pandit') ? $id : "$id%"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1281 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1282 | my $sth = $dbh->prepare($sql_statement) || die "Can't prepare statement: $DBI::errstr"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1283 | my $rc = $sth->execute($id) || die "Can't execute statement: $DBI::errstr"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1284 | my $num_of_rows = $sth->rows; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1285 | my $matrix_ref = $sth->fetchall_arrayref; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1286 | for (my $rowNo = 0;$rowNo < $num_of_rows;$rowNo++) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1287 | $my_data->set_node_color($taxlabel,$kingdom->{$$matrix_ref[0][$rowNo]}); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1288 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1289 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1290 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1291 | $dbh->disconnect; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1292 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1293 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1294 | =head2 swap_children | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1295 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1296 | Title : swap_children | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1297 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1298 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1299 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1300 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1301 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1302 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1303 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1304 | sub swap_children { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1305 | my ($self,$nodename) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1306 | my $treename = $self->get_name(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1307 | my $tree = $self->clone(); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1308 | my $swapnode = $tree->find($nodename); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1309 | $swapnode or die "ERROR: Node $nodename not found in $treename\n"; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1310 | my $childcount = scalar(@{$swapnode->get_children()}); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1311 | my $tempnode = $swapnode->get_children()->[$childcount-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1312 | for (my $index = $childcount-1; $index > 0; $index--) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1313 | print $index, " "; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1314 | $swapnode->get_children()->[$index] = $swapnode->get_children()->[$index-1]; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1315 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1316 | $swapnode->get_children()->[0] = $tempnode; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1317 | $self = $tree->clone; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1318 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1319 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1320 | package MyData; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1321 | use Data::Dumper; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1322 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1323 | =head2 new | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1324 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1325 | Title : new | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1326 | Usage : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1327 | Function: NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1328 | Returns : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1329 | Args : NA | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1330 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1331 | =cut | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1332 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1333 | sub new () { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1334 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1335 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1336 | my $RGBcolorHash = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1337 | white => [250,250,250], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1338 | red => [250,0,0], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1339 | green => [0,150,0], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1340 | blue => [0,0,250], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1341 | forest => [34,139,34], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1342 | aqua => [152,245,255], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1343 | gold => [255,185,15], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1344 | gray => [130,130,130], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1345 | pink => [255,34,179], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1346 | brown => [139,69,19], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1347 | black => [0,0,0], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1348 | purple => [111,0,111], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1349 | orange => [255,120,0], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1350 | darkgray => [110,110,110], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1351 | darkpurple => [111,0,111], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1352 | darkred => [170,0,0], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1353 | darkgreen => [0,140,0], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1354 | silver => [230,232,250], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1355 | yellow => [255,255,0], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1356 | highlighter => [51,184,215], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1357 | tranparent_pink => [255,34,179] | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1358 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1359 | my $data = { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1360 | 'selected_character_block' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1361 | 'title' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1362 | 'selected_tree' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1363 | 'species_tree' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1364 | 'char_block_seq' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1365 | 'char_block_wts' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1366 | 'char_column_labels' => [], | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1367 | 'nodes_color_hash' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1368 | 'ps_color_hash' => $RGBcolorHash, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1369 | 'gd_color_hash' => {}, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1370 | 'gd_tree_map_coord' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1371 | 'gd_label_map_coord' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1372 | 'gd_intron_map_coord' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1373 | 'gd_contin_data_map_coord' => undef, | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1374 | }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1375 | bless ($data,$self); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1376 | return $data; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1377 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1378 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1379 | sub set_title { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1380 | my ($self,$title) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1381 | $self->{'title'} = $title; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1382 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1383 | sub get_title { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1384 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1385 | return $self->{'title'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1386 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1387 | sub set_tree_map_coord { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1388 | my ($self,$node_name,$coord) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1389 | $self->{'gd_tree_map_coord'}->{$node_name} = $coord; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1390 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1391 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1392 | sub get_tree_map_coord { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1393 | my ($self, $node_name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1394 | return $self->{'gd_tree_map_coord'}->{$node_name}; ## black | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1395 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1396 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1397 | sub set_contin_data_map_coord { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1398 | my ($self,$node_name,$coord) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1399 | $self->{'gd_contin_data_map_coord'}->{$node_name} = $coord; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1400 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1401 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1402 | sub get_contin_data_map_coord { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1403 | my ($self, $node_name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1404 | return $self->{'gd_contin_data_map_coord'}->{$node_name}; ## black | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1405 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1406 | sub add_contin_data_map_coord { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1407 | my ($self, $node_name,$coord) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1408 | push (@{ $self->{'gd_contin_data_map_coord'}->{$node_name} }, $coord); ## black | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1409 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1410 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1411 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1412 | sub set_label_map_coord { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1413 | my ($self,$col_label,$coord) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1414 | $self->{'gd_label_map_coord'}->{$col_label} = $coord; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1415 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1416 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1417 | sub get_label_map_coord { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1418 | my ($self, $col_label) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1419 | return $self->{'gd_label_map_coord'}->{$col_label}; ## black | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1420 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1421 | sub set_intron_map_coord { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1422 | my ($self,$col_label,$coord) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1423 | $self->{'gd_intron_map_coord'}->{$col_label} = $coord; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1424 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1425 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1426 | sub get_intron_map_coord { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1427 | my ($self, $col_label) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1428 | return $self->{'gd_intron_map_coord'}->{$col_label}; ## black | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1429 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1430 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1431 | sub set_selected_char_block { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1432 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1433 | $self->{'selected_character_block'} = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1434 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1435 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1436 | sub get_selected_char_block { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1437 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1438 | return $self->{'selected_character_block'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1439 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1440 | sub set_image_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1441 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1442 | $self->{'image_handle'} = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1443 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1444 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1445 | sub get_image_handler { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1446 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1447 | return $self->{'image_handle'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1448 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1449 | sub set_font { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1450 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1451 | $self->{'font'} = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1452 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1453 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1454 | sub get_font { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1455 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1456 | return $self->{'font'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1457 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1458 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1459 | sub get_image_handler_type { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1460 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1461 | return if not defined $self->{'image_handle'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1462 | if ((ref $self->{'image_handle'}) =~/GD/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1463 | return 'gd'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1464 | } elsif ((ref $self->{'image_handle'}) =~/Post/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1465 | return 'ps'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1466 | } else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1467 | return 'pdf'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1468 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1469 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1470 | sub allocate_colors { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1471 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1472 | my $img_h = $self->{'image_handle'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1473 | foreach my $color_val (keys %{ $self->{'ps_color_hash'} }) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1474 | if ((ref $img_h) =~/GD/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1475 | if ($color_val eq 'tranparent_pink'){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1476 | $self->{'gd_color_hash'}->{$color_val} = $img_h->colorAllocateAlpha( @{ $self->{'ps_color_hash'}->{$color_val} },120); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1477 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1478 | $self->{'gd_color_hash'}->{$color_val} = $img_h->colorAllocate( @{ $self->{'ps_color_hash'}->{$color_val} } ); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1479 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1480 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1481 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1482 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1483 | sub get_color { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1484 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1485 | my $name = shift || 'black'; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1486 | my $img_h = $self->{'image_handle'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1487 | my $color; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1488 | if ((ref $img_h) =~ /GD/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1489 | $color = $self->{'gd_color_hash'}->{lc $name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1490 | }elsif ((ref $img_h) =~/Postscript/i) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1491 | $color = $self->{'ps_color_hash'}->{lc $name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1492 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1493 | $color = "#". join "", map {sprintf "%2.2X",$_} @{ $self->{'ps_color_hash'}->{lc $name} } if $self->{'ps_color_hash'}->{lc $name}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1494 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1495 | return $color || $name; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1496 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1497 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1498 | sub get_char_block_seq { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1499 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1500 | my $taxon_name = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1501 | my $block = $self->{'selected_character_block'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1502 | my $data_type; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1503 | if ( not defined $self->{'char_block_seq'} and defined $block) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1504 | if ($block->get_format()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1505 | $data_type = $block->get_format()->{'datatype'} ; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1506 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1507 | if ($data_type eq 'continuous') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1508 | $self->{'char_block_seq'} = $block->get_otuset->get_seq_string_hash(' '); | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1509 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1510 | else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1511 | $self->{'char_block_seq'} = $block->get_otuset->get_seq_string_hash; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1512 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1513 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1514 | return $self->{'char_block_seq'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1515 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1516 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1517 | sub get_char_column_labels { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1518 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1519 | my $block = $self->{'selected_character_block'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1520 | my @columnLabels; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1521 | if (defined $block && (not @{$self->{'char_column_labels'}})){ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1522 | my $characterLabels = $block->get_charlabels; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1523 | my $seqLength = $block->get_nchar; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1524 | if ($characterLabels && @$characterLabels) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1525 | @columnLabels = @$characterLabels; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1526 | } elsif ($seqLength) { # not labeled, e.g., typical dna or aa seq alignment | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1527 | for (1 .. $seqLength) {push @columnLabels, $_;} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1528 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1529 | $self->{'char_column_labels'} = \@columnLabels; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1530 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1531 | return @{$self->{'char_column_labels'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1532 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1533 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1534 | sub set_node_color { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1535 | my ($self,$node_name,$color) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1536 | $self->{'nodes_color_hash'}->{$node_name} = $color; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1537 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1538 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1539 | sub get_node_color { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1540 | my ($self, $node_name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1541 | return $self->{'nodes_color_hash'}->{$node_name} || 'black'; ## black | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1542 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1543 | sub get_nodes_hash { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1544 | my ($self,$name,$color) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1545 | return $self->{'nodes_color_hash'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1546 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1547 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1548 | sub get_char_block_wts { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1549 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1550 | my $block = $self->{'selected_character_block'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1551 | my $is_weights = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1552 | my @assumptions_blocks = @{ $nexusObject->get_blocks('assumptions') }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1553 | if (not @{$self->{'char_block_wts'}}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1554 | my @weights; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1555 | for my $asmpt_block (@assumptions_blocks) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1556 | if ($asmpt_block->get_link( 'characters' ) eq $block->get_title()) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1557 | warn("Grabbing assumptions block from NEXUS file...\n") if $DEBUG; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1558 | foreach my $assumption(@{$asmpt_block->get_assumptions()}) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1559 | if( $assumption->is_wt() ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1560 | @weights = @{ $assumption->get_weights() }; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1561 | my $max_wt; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1562 | $max_wt = $nexusG->get_maximumWtvalue; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1563 | #foreach my $weight(@weights) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1564 | # $max_wt = $weight if ($weight > $max_wt) | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1565 | #} | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1566 | foreach my $weight(@weights) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1567 | if ($weight eq '-') { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1568 | $weight = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1569 | }else { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1570 | $weight = ($max_wt != 0 ) ? ($weight/$max_wt) : 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1571 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1572 | $is_weights = 0; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1573 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1574 | if ( $DEBUG ) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1575 | warn("No weights found in this file\n") unless $is_weights; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1576 | warn("Weights have been found in this file\n") if $is_weights; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1577 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1578 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1579 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1580 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1581 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1582 | $self->{'char_block_wts'} = \@weights; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1583 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1584 | return @{$self->{'char_block_wts'}}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1585 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1586 | sub set_selected_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1587 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1588 | $self->{'selected_tree'} = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1589 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1590 | sub set_species_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1591 | my ($self,$tree) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1592 | $self->{'species_tree'} = $tree; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1593 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1594 | sub set_gene_tree{ | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1595 | my ($self,$tree) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1596 | $self->{'gene_tree'} = $tree; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1597 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1598 | sub get_species_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1599 | my ($self,$tree) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1600 | return $self->{'species_tree'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1601 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1602 | sub get_gene_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1603 | my ($self) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1604 | return $self->{'gene_tree'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1605 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1606 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1607 | sub get_nodename_from_gene_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1608 | my ($self,$species_node_name) = @_; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1609 | my $gene_tree = $self->get_gene_tree; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1610 | my $species_tree = $self->get_species_tree; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1611 | my @gene_nodelist = @{ $gene_tree->get_nodes}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1612 | my $comment; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1613 | my $species_name; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1614 | for my $gene_node (@gene_nodelist) { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1615 | $comment = $gene_node->get_support_value; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1616 | my ($species_name) = $comment =~ /:?S=([^:]*)/g; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1617 | return $gene_node->get_name if $species_name eq $species_node_name; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1618 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1619 | return undef; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1620 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1621 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1622 | sub get_selected_tree { | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1623 | my $self = shift; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1624 | return $self->{'selected_tree'}; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1625 | } | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1626 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1627 | 1; | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1628 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1629 | ################# POD Documentation ################## | ||||||||||||||||||||||||||||||||||||||||||||||||
| 1630 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1631 | |||||||||||||||||||||||||||||||||||||||||||||||||
| 1632 | __END__ | ||||||||||||||||||||||||||||||||||||||||||||||||