5 /markers/locations.mas - a Mason component displaying information about map locations of markers
15 $marker - a CXGN::Marker object.
22 Lukas Mueller <lam87@cornell.edu>
33 use CXGN::Cview::MapFactory;
34 use CXGN::Cview::ChrMarkerImage;
36 my $locations_html = '';
37 my $marker_name = $marker->get_name();
41 #if we have some experiments, and they are an arrayref, and there is at least one location in them
42 my $experiments = $marker->current_mapping_experiments() || [];
46 and grep { $_->{location} } @{$experiments} )
49 for my $experiment ( @{$experiments} ) {
51 #make sure we have a location before we go about showing location data--some experiments do not have locations
52 if ( my $loc = $experiment->{location} ) {
54 #make sure we haven't displayed a location entry with the same location ID already
55 unless ( grep { $_ == $loc->location_id() } @displayed_locs ) {
56 push( @displayed_locs, $loc->location_id() );
58 $locations_html .= '<br />';
61 '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr>';
63 #make a section detailing the location
65 my $pcr = $experiment->{pcr_experiment};
66 my $rflp = $experiment->{rflp_experiment};
67 $protocol = $experiment->{protocol};
76 $protocol = '<span class="ghosted">Unknown</span>';
80 #make a link to the map this marker can be found on
81 my $map_version_id = $loc->map_version_id();
82 my $lg_name = $loc->lg_name();
83 my $position = $loc->position();
84 my $subscript = $loc->subscript();
89 my $dbh = $marker->{dbh};
90 my $map_factory = CXGN::Cview::MapFactory->new($dbh);
92 $map_factory->create( { map_version_id => $map_version_id } );
94 print "map_version_id = $map_version_id could not be instantiated\n";
97 my $map_name = $map->get_short_name();
98 if ($map_version_id) {
99 $map_id = $map->get_id();
103 and defined($lg_name)
104 and defined($position) )
107 "<a href=\"/cview/view_chromosome.pl?map_version_id=$map_version_id&chr_nr=$lg_name&cM=$position&hilite=$marker_name$subscript&zoom=1\">$map_name</a>";
112 '<span class="ghosted">Map data not available</span>';
116 if ( $subscript and $multicol > 1 ) { $multicol++; }
119 "<b>Map:</b> $map_url ",
120 '__tableattrs' => "width=\"$width\"",
121 '__multicol' => $multicol,
122 'Map version' => $map_version_id." (location: ".$loc->location_id().")",
123 'Chromosome' => $loc->lg_name(),
124 'Position ' => sprintf( '%.2f', $loc->position() )." ".$map->get_units(),
125 'Confidence' => $loc->confidence(),
126 'Protocol' => $protocol
129 push( @locations, ( 'Subscript' => $subscript ) );
131 $locations_html .= '<td width = "25%">';
133 CXGN::Page::FormattingHelpers::info_table_html(@locations);
134 $locations_html .= '</td>';
135 $locations_html .= '<td align="center">';
136 ####$map_factory = CXGN::Cview::MapFactory->new($dbh);
137 ####### my $map=$map_factory->create({map_version_id=>$map_version_id});
138 ####### my $map_version_id=$map->get_id();
140 my $hilite_name = $marker_name;
142 $hilite_name .= $subscript;
144 my $chromosome = CXGN::Cview::ChrMarkerImage->new(
145 "", 240, 150, $dbh, $lg_name, $map, $hilite_name,
146 $c->get_conf("basepath"), $c->get_conf('tempfiles_subdir')."/cview",
148 my ( $image_path, $image_url ) =
149 $chromosome->get_image_filename();
151 qq|<img src="$image_url" usemap="#map$count" border="0" alt="" />|;
152 $chr_link .= $chromosome->get_image_map("map$count");
153 $chr_link .= '<br />' . $map_name;
155 $locations_html .= '<br />';
156 $locations_html .= $chr_link;
157 $locations_html .= '</td></tr></table>';
160 #if we have a pcr experiment that was used to map this marker to this location, make a section for this experiment's data
162 and !grep { $_ == $pcr->pcr_experiment_id() }
166 '<table width="100%" cellspacing="0" cellpadding="0" border="0"><tr>';
167 my $pcr_bands = $pcr->pcr_bands_hash_of_strings();
169 my %pcr_bands_by_name = ();
170 my $sth = $dbh->prepare("SELECT organism.species || ' ' || stock.name FROM public.stock JOIN public.organism USING(organism_id) WHERE stock_id=?");
172 foreach my $p (keys %$pcr_bands) {
175 $pcr_bands_by_name{($sth->fetchrow_array)} = $pcr_bands->{$p};
179 my $digest_bands = $pcr->pcr_digest_bands_hash_of_strings();
181 my %pcr_digest_bands_by_name = ();
182 foreach my $p (keys %$digest_bands) {
184 $pcr_digest_bands_by_name{($sth->fetchrow_array)} = $digest_bands->{$p};
189 CXGN::Page::FormattingHelpers::info_table_html(
195 my $digest_bands_html =
196 CXGN::Page::FormattingHelpers::info_table_html(
199 %pcr_digest_bands_by_name,
202 if ( $pcr->mg_conc() ) {
203 $mg = $pcr->mg_conc() . 'mM';
206 if ( $pcr->temp() ) {
207 $temp = $pcr->temp() . '°C';
209 $locations_html .= '<td>';
210 my $fwd = $pcr->fwd_primer()
211 || '<span class="ghosted">Unknown</span>';
212 my $rev = $pcr->rev_primer()
213 || '<span class="ghosted">Unknown</span>';
214 my $enz = $pcr->enzyme() || 'unknown enzyme' ;
215 my $additional_enzymes = $pcr->additional_enzymes();
216 my $dcaps = $pcr->dcaps_primer();
217 $temp ||= '<span class="ghosted">Unknown</span>';
218 $mg ||= '<span class="ghosted">Unknown</span>';
219 my $digest_title = "Digested band sizes (using $enz)";
221 unless ($digest_bands_html) {
222 $digest_title = ' ';
223 $digest_bands_html = ' ';
227 my ( $dcaps_left, $dcaps_right );
230 $dcaps_left = "dCAPS primer (5'-3')";
231 $dcaps_right = "<span class=\"sequence\">$dcaps</span>";
234 my $pcr_seq = $pcr->get_sequences;
236 my ($aspe, $aspe_primers);
237 $aspe_primers = join ('<BR>' , @{ $pcr_seq->{ASPE_primer} } ) if $pcr_seq->{ASPE_primer} ;
239 $aspe = "ASPE primers (5'-3')";
240 $aspe_primers = "<span class=\"snp\">$aspe_primers</span>"
243 $snp_nuc = join ('<BR>' , @{ $pcr_seq->{SNP} } ) if $pcr_seq->{SNP} ;
245 $snp = "SNP nucleotide";
246 $snp_nuc = "<span class=\"snp\">$snp_nuc</span>"
248 my ($three_prime, $seq3);
249 $seq3 = join ('<BR>' , @{ $pcr_seq->{three_prime_flanking_region} } ) if $pcr_seq->{three_prime_flanking_region} ;
251 $three_prime = "3' flanking region";
252 $seq3 = "<span class=\"assay\">$seq3</span>"
254 my ($five_prime, $seq5);
255 $seq5 = join ('<BR>' , @{ $pcr_seq->{five_prime_flanking_region} } ) if $pcr_seq->{five_prime_flanking_region} ;
257 $five_prime = "5' flanking region";
258 $seq5 = "<span class=\"assay\">$seq5</span>"
260 my ($indel, $indel_seq);
261 $indel_seq = join ('<BR>' , @{ $pcr_seq->{indel} } ) if $pcr_seq->{indel} ;
264 $indel_seq = "<span class=\"indel\">$indel_seq</span>"
266 $locations_html .= '<br />';
268 CXGN::Page::FormattingHelpers::info_table_html(
270 "PCR data <span class=\"tinytype\">Exp. ID "
271 . $pcr->pcr_experiment_id()
273 "Forward primer (5'-3')" =>
274 "<span class=\"sequence\">$fwd</span>",
275 "Reverse primer (5'-3')" =>
276 "<span class=\"sequence\">$rev</span>",
277 $dcaps_left => $dcaps_right,
278 'Accessions and product sizes' => $pcr_bands_html,
279 $digest_title => $digest_bands_html,
280 'Enzymes' => $additional_enzymes,
281 'Approximate temperature' => $temp,
282 'Mg<sup>+2</sup> concentration' => $mg,
284 '__tableattrs' => "width=\"100%\"",
285 ) if ($protocol ne 'SNP');
286 my ($snpdb_format, $snpdb);
288 $snpdb = "SNPdb format";
289 my @fives = @{ $pcr_seq->{five_prime_flanking_region} } ;
290 my @threes = @{ $pcr_seq->{three_prime_flanking_region} } ;
291 my @snps = @{ $pcr_seq->{SNP} };
292 for my $i ( 0 .. (scalar( @snps ) -1 ) ) {
293 my $snp_string = $snps[$i] ;
294 my $formatted = "[" . substr($snp_string, 0, 1) . "/" . substr($snp_string, -1) ."]";
295 my $five_p = $fives[$i];
296 my $three_p = $threes[$i];
297 $snpdb_format .= $five_p . $formatted ."<BR />" . $three_p . "<BR />";
301 CXGN::Page::FormattingHelpers::info_table_html(
303 "Assay data <span class=\"tinytype\"></span>",
304 $five_prime => $seq5,
305 $three_prime => $seq3,
306 $snpdb => $snpdb_format,
307 $aspe => $aspe_primers,
309 $indel => $indel_seq,
311 '__tableattrs' => "width=\"100%\"",
312 ) if $aspe || $indel || ($protocol eq "SNP");
313 $locations_html .= '</td></tr></table>';
314 push( @displayed_pcr, $pcr->pcr_experiment_id() )
323 <&| /page/info_section.mas, title=>'Mapped locations', collapsible=>1, collapsed=>0 &>
324 <% $locations_html %>