From 925d6dfe382c851dae80c2fe5001da44f70956a6 Mon Sep 17 00:00:00 2001 From: Robert Buels Date: Fri, 24 Sep 2010 13:18:36 -0700 Subject: [PATCH] perltidy on marker location printing code --- mason/markers/locations.mas | 462 ++++++++++++++++++++++++-------------------- 1 file changed, 250 insertions(+), 212 deletions(-) rewrite mason/markers/locations.mas (87%) diff --git a/mason/markers/locations.mas b/mason/markers/locations.mas dissimilarity index 87% index 81c9a33d3..dd9a0ba7e 100644 --- a/mason/markers/locations.mas +++ b/mason/markers/locations.mas @@ -1,212 +1,250 @@ - -<%doc> - -=head1 NAME - -/markers/locations.mas - a Mason component displaying information about map locations of markers - -=head1 DESCRIPTION - -parameters - -=over 5 - -=item * - -$marker - a CXGN::Marker object. - - -=back - -=head1 AUTHOR - -Lukas Mueller - -=cut - - - -<%args> -$marker - - -<& /util/import_javascript.mas, classes => [ "CXGN.Effects" ] &> - -<%perl> - - use CXGN::Cview::MapFactory; -use CXGN::Cview::ChrMarkerImage; - -my $locations_html=''; -my $marker_name = $marker->get_name(); -my @displayed_locs=(); -my @displayed_pcr=(); -#if we have some experiments, and they are an arrayref, and there is at least one location in them -my $experiments=$marker->current_mapping_experiments(); -if($experiments and @{$experiments} and grep {$_->{location}} @{$experiments}) { - my $count = 1; - for my $experiment(@{$experiments}) { - - #make sure we have a location before we go about showing location data--some experiments do not have locations - if(my $loc=$experiment->{location}) { - #make sure we haven't displayed a location entry with the same location ID already - unless(grep {$_==$loc->location_id()} @displayed_locs) { - push(@displayed_locs,$loc->location_id()); - if ($count > 1) { - $locations_html .= '


'; - } - $locations_html.=''; - #make a section detailing the location - my $protocol=''; - my $pcr=$experiment->{pcr_experiment}; - my $rflp=$experiment->{rflp_experiment}; - $protocol=$experiment->{protocol}; - unless($protocol) { - if($pcr) { - $protocol='PCR'; - } - elsif($rflp) { - $protocol='RFLP'; - } - else { - $protocol='Unknown'; - } - } - - #make a link to the map this marker can be found on - my $map_version_id=$loc->map_version_id(); - my $lg_name=$loc->lg_name(); - my $position=$loc->position(); - my $subscript=$loc->subscript(); - $subscript||=''; - my $map_url=''; - my $map_id=''; - - my $dbh = $marker->{dbh}; - my $map_factory = CXGN::Cview::MapFactory->new($dbh); - my $map = $map_factory->create({map_version_id=>$map_version_id}); - my $map_name=$map->get_short_name(); - if($map_version_id) { - $map_id=$map->get_id(); - - if($map_id and $map_name and defined($lg_name) and defined($position)) { - $map_url="$map_name v$map_version_id"; - } - } - else { - $map_url='Map data not available'; - } - my $multicol=1; - my $width="200px"; - if($subscript and $multicol>1){$multicol++;} - my @locations= - ( - '__title' =>"Map: $map_url   Loc. ID ".$loc->location_id()."", - '__tableattrs'=>"width=\"$width\"", - '__multicol'=>$multicol, - 'Chromosome'=>$loc->lg_name(), - 'Position '=>sprintf('%.2f cM',$loc->position()), - 'Confidence'=>$loc->confidence(), - 'Protocol'=>$protocol - ); - if($subscript) { - push(@locations,('Subscript'=>$subscript)); - } - $locations_html.=''; - $locations_html.='
'; - $locations_html.=CXGN::Page::FormattingHelpers::info_table_html(@locations); - $locations_html.=''; - ####$map_factory = CXGN::Cview::MapFactory->new($dbh); -####### my $map=$map_factory->create({map_version_id=>$map_version_id}); -####### my $map_version_id=$map->get_id(); - - my $hilite_name = $marker_name; - if ($subscript) { - $hilite_name.=$subscript; - } - my $chromosome= CXGN::Cview::ChrMarkerImage->new("", 150,150,$dbh, $lg_name, $map, $hilite_name); - my ($image_path, $image_url)=$chromosome->get_image_filename(); - my $chr_link= qq||; - $chr_link .= $chromosome->get_image_map("map$count"); - $chr_link .= '
' . $map_name; - $count++; - $locations_html .= '
'; - $locations_html .= $chr_link; - $locations_html.='
'; - - #if we have a pcr experiment that was used to map this marker to this location, make a section for this experiment's data - if($pcr and !grep {$_==$pcr->pcr_experiment_id()} @displayed_pcr) { - $locations_html .= ''; - my $pcr_bands=$pcr->pcr_bands_hash_of_strings(); - my $digest_bands=$pcr->pcr_digest_bands_hash_of_strings(); - my $pcr_bands_html = CXGN::Page::FormattingHelpers::info_table_html - ( __border => 0, __sub => 1, - map { - my $accession_name = CXGN::Accession->new($dbh,$_)->verbose_name; - $accession_name => $pcr_bands->{$_} - } keys %$pcr_bands, - ); - my $digest_bands_html = CXGN::Page::FormattingHelpers::info_table_html - ( __border => 0, __sub => 1, - map { - my $accession_name=CXGN::Accession->new($dbh,$_)->verbose_name(); - $accession_name => $digest_bands->{$_}; - } keys %$digest_bands, - ); - my $mg=''; - if($pcr->mg_conc()) { - $mg=$pcr->mg_conc().'mM'; - } - my $temp=''; - if($pcr->temp()) { - $temp=$pcr->temp().'°C'; - } - $locations_html.='
'; - my $fwd=$pcr->fwd_primer()||'Unknown'; - my $rev=$pcr->rev_primer()||'Unknown'; - my $enz=$pcr->enzyme()||'unknown enzyme'; - my $dcaps=$pcr->dcaps_primer(); - $temp||='Unknown'; - $mg||='Unknown'; - my $digest_title="Digested band sizes (using $enz)"; - unless($digest_bands_html) { - $digest_title=' '; - $digest_bands_html=' '; - } - - ### TODO ### - my ($dcaps_left,$dcaps_right); - - - if ($dcaps) { - $dcaps_left = "dCAPS primer (5'-3')"; - $dcaps_right = "$dcaps"; - } - - $locations_html.=CXGN::Page::FormattingHelpers::info_table_html - ( - '__title'=>"PCR data   Exp. ID ".$pcr->pcr_experiment_id()."", - "Forward primer (5'-3')"=>"$fwd", - "Reverse primer (5'-3')"=>"$rev", - $dcaps_left => $dcaps_right, - 'Accessions and product sizes'=>$pcr_bands_html, - $digest_title=>$digest_bands_html, - 'Approximate temperature'=>$temp, - 'Mg+2 concentration'=>$mg, - '__multicol'=>3, - '__tableattrs'=>"width=\"100%\"", - ); - $locations_html.='
'; - push(@displayed_pcr,$pcr->pcr_experiment_id()); - } - } - } - } -} - -###print blue_section_html('Mapped locations',$locations_html); - - -<&| /page/info_section.mas, title=>'Mapped locations', collapsible=>1, collapsed=>0 &> - <% $locations_html %> - + +<%doc> + +=head1 NAME + +/markers/locations.mas - a Mason component displaying information about map locations of markers + +=head1 DESCRIPTION + +parameters + +=over 5 + +=item * + +$marker - a CXGN::Marker object. + + +=back + +=head1 AUTHOR + +Lukas Mueller + +=cut + + + +<%args> +$marker + + +<& /util/import_javascript.mas, classes => [ "CXGN.Effects" ] &> + +<%perl> +use CXGN::Cview::MapFactory; +use CXGN::Cview::ChrMarkerImage; + +my $locations_html = ''; +my $marker_name = $marker->get_name(); +my @displayed_locs; +my @displayed_pcr; + +#if we have some experiments, and they are an arrayref, and there is at least one location in them +my $experiments = $marker->current_mapping_experiments() || []; + +if ( $experiments + and @{$experiments} + and grep { $_->{location} } @{$experiments} ) +{ + my $count = 1; + for my $experiment ( @{$experiments} ) { + +#make sure we have a location before we go about showing location data--some experiments do not have locations + if ( my $loc = $experiment->{location} ) { + +#make sure we haven't displayed a location entry with the same location ID already + unless ( grep { $_ == $loc->location_id() } @displayed_locs ) { + push( @displayed_locs, $loc->location_id() ); + if ( $count > 1 ) { + $locations_html .= '


'; + } + $locations_html .= +''; + + #make a section detailing the location + my $protocol = ''; + my $pcr = $experiment->{pcr_experiment}; + my $rflp = $experiment->{rflp_experiment}; + $protocol = $experiment->{protocol}; + unless ($protocol) { + if ($pcr) { + $protocol = 'PCR'; + } + elsif ($rflp) { + $protocol = 'RFLP'; + } + else { + $protocol = 'Unknown'; + } + } + + #make a link to the map this marker can be found on + my $map_version_id = $loc->map_version_id(); + my $lg_name = $loc->lg_name(); + my $position = $loc->position(); + my $subscript = $loc->subscript(); + $subscript ||= ''; + my $map_url = ''; + my $map_id = ''; + + my $dbh = $marker->{dbh}; + my $map_factory = CXGN::Cview::MapFactory->new($dbh); + my $map = + $map_factory->create( { map_version_id => $map_version_id } ); + my $map_name = $map->get_short_name(); + if ($map_version_id) { + $map_id = $map->get_id(); + + if ( $map_id + and $map_name + and defined($lg_name) + and defined($position) ) + { + $map_url = +"$map_name v$map_version_id"; + } + } + else { + $map_url = + 'Map data not available'; + } + my $multicol = 1; + my $width = "200px"; + if ( $subscript and $multicol > 1 ) { $multicol++; } + my @locations = ( + '__title' => +"Map: $map_url   Loc. ID " + . $loc->location_id() + . "", + '__tableattrs' => "width=\"$width\"", + '__multicol' => $multicol, + 'Chromosome' => $loc->lg_name(), + 'Position ' => sprintf( '%.2f cM', $loc->position() ), + 'Confidence' => $loc->confidence(), + 'Protocol' => $protocol + ); + if ($subscript) { + push( @locations, ( 'Subscript' => $subscript ) ); + } + $locations_html .= ''; + $locations_html .= '
'; + $locations_html .= + CXGN::Page::FormattingHelpers::info_table_html(@locations); + $locations_html .= ''; + ####$map_factory = CXGN::Cview::MapFactory->new($dbh); +####### my $map=$map_factory->create({map_version_id=>$map_version_id}); +####### my $map_version_id=$map->get_id(); + + my $hilite_name = $marker_name; + if ($subscript) { + $hilite_name .= $subscript; + } + my $chromosome = + CXGN::Cview::ChrMarkerImage->new( "", 150, 150, $dbh, + $lg_name, $map, $hilite_name ); + my ( $image_path, $image_url ) = + $chromosome->get_image_filename(); + my $chr_link = +qq||; + $chr_link .= $chromosome->get_image_map("map$count"); + $chr_link .= '
' . $map_name; + $count++; + $locations_html .= '
'; + $locations_html .= $chr_link; + $locations_html .= '
'; + +#if we have a pcr experiment that was used to map this marker to this location, make a section for this experiment's data + if ( $pcr + and !grep { $_ == $pcr->pcr_experiment_id() } + @displayed_pcr ) + { + $locations_html .= +''; + my $pcr_bands = $pcr->pcr_bands_hash_of_strings(); + my $digest_bands = $pcr->pcr_digest_bands_hash_of_strings(); + my $pcr_bands_html = + CXGN::Page::FormattingHelpers::info_table_html( + __border => 0, + __sub => 1, + map { + my $accession_name = + CXGN::Accession->new( $dbh, $_ )->verbose_name; + $accession_name => $pcr_bands->{$_} + } keys %$pcr_bands, + ); + my $digest_bands_html = + CXGN::Page::FormattingHelpers::info_table_html( + __border => 0, + __sub => 1, + map { + my $accession_name = + CXGN::Accession->new( $dbh, $_ )->verbose_name(); + $accession_name => $digest_bands->{$_}; + } keys %$digest_bands, + ); + my $mg = ''; + if ( $pcr->mg_conc() ) { + $mg = $pcr->mg_conc() . 'mM'; + } + my $temp = ''; + if ( $pcr->temp() ) { + $temp = $pcr->temp() . '°C'; + } + $locations_html .= '
'; + my $fwd = $pcr->fwd_primer() + || 'Unknown'; + my $rev = $pcr->rev_primer() + || 'Unknown'; + my $enz = $pcr->enzyme() || 'unknown enzyme'; + my $dcaps = $pcr->dcaps_primer(); + $temp ||= 'Unknown'; + $mg ||= 'Unknown'; + my $digest_title = "Digested band sizes (using $enz)"; + + unless ($digest_bands_html) { + $digest_title = ' '; + $digest_bands_html = ' '; + } + + ### TODO ### + my ( $dcaps_left, $dcaps_right ); + + if ($dcaps) { + $dcaps_left = "dCAPS primer (5'-3')"; + $dcaps_right = "$dcaps"; + } + + $locations_html .= + CXGN::Page::FormattingHelpers::info_table_html( + '__title' => +"PCR data   Exp. ID " + . $pcr->pcr_experiment_id() + . "", + "Forward primer (5'-3')" => + "$fwd", + "Reverse primer (5'-3')" => + "$rev", + $dcaps_left => $dcaps_right, + 'Accessions and product sizes' => $pcr_bands_html, + $digest_title => $digest_bands_html, + 'Approximate temperature' => $temp, + 'Mg+2 concentration' => $mg, + '__multicol' => 3, + '__tableattrs' => "width=\"100%\"", + ); + $locations_html .= '
'; + push( @displayed_pcr, $pcr->pcr_experiment_id() ); + } + } + } + } +} + +###print blue_section_html('Mapped locations',$locations_html); + + +<&| /page/info_section.mas, title=>'Mapped locations', collapsible=>1, collapsed=>0 &> + <% $locations_html %> + -- 2.11.4.GIT