4 chr_sbfinder.pl - a script that finds the seed bacs on a given chromosome with some options
8 chr_sbfinder.pl will display and input form if no arguments are given, or query the database for seedbacs on a given chromosome if there are arguments.
10 overgo associations are generated using the scripts in /sgn-tools/stable/physical_tools/bin/
12 computational associations are generated using parsed BLAST reports and are loaded into the database using the script in /sgn-tools/stable/physical_tools/bin/load_computational_associations.pl
14 manual associations are currently entered using SQL commands.
16 This script relies on a materialized view of the information in the tables cited above. The view is generated using the script /sgn-tools/stable/physical_tools/bin/add_bac_marker_view.pl .
20 Lukas Mueller (lam87@cornell.edu),
21 Beth Skwarecki (eas68@cornell.edu)
29 use CXGN
::DB
::Connection
;
30 use CXGN
::Genomic
::Clone
;
32 my $sbf = chr_seedbac_finder
-> new
();
35 if (!$sbf -> has_data
()) {
36 #print STDERR "No data supplied...\n";
40 if ($sbf->get_query("overgo")) {
41 $sbf -> get_overgo_associations
();
43 if ($sbf->get_query("computational")) {
44 $sbf -> get_computational_associations
();
46 if ($sbf->get_query("manual")) {
47 $sbf-> get_manual_associations
();
49 $sbf -> display_results
();
52 package chr_seedbac_finder
;
59 my $self = bless $args, $class;
60 our $page = CXGN
::Page
->new();
62 $self->{page
} = $page;
63 $self->set_dbh( CXGN
::DB
::Connection
->new() );
79 #$self->{page}->header();
83 $self->{page
}->footer();
91 <h3>Seedbac finder</h3>
92 This tool lists all anchored bacs for a given chromosome on the tomato F2-2000 map to help identify seed bacs.<br /><br />
94 Chromosome: <select name="chr">
97 for(my $i=1; $i<=12; $i++){
98 print "<option value=\"$i\">$i</option>";
104 Marker minimal confidence: <select name="confidence">
105 <option value=\"0\">I</option>
106 <option value=\"1\">ILOD(2)</option>
107 <option value=\"2\">CLOD(3)</option>
108 <option value=\"3\">FLOD(3)</option>
111 <!-- Return <input type="text" name="nr_bacs" value="all" size="3" /> BACs per anchor point. -->
113 <input type="checkbox" name="show_overgo" checked="checked" /> Retrieve experimental (overgo) associations<br />
114 <input type="checkbox" name="show_computational" /> Retrieve computational associations<br />
115 <input type="checkbox" name="show_manual" /> Retrieve manual associations<br />
118 <input type="checkbox" name="text_output" /> Output as text<br />
120 <input type="submit" value="Submit" />
129 my $nr_bacs_input = 0;
130 my $chr = 0; my $confidence = -1;
131 my ($show_overgo, $show_computational, $show_manual);
132 ($chr, $confidence, $nr_bacs_input, $self->{text_output
}, $show_overgo, $show_computational, $show_manual) = $self->{page
}->get_arguments("chr", "confidence", "nr_bacs", "text_output", "show_overgo", "show_computational", "show_manual");
133 chomp($nr_bacs_input);
134 $self->set_chr($chr);
135 $self->set_confidence($confidence);
136 $self->{nr_bacs
} = int($nr_bacs_input);
137 if ($self->{nr_bacs
} != $nr_bacs_input && (!($nr_bacs_input eq "all" || $nr_bacs_input eq ""))) { $self->{page
}->error_page("Number of BACs returned has to be numeric."); }
138 if ($show_overgo) { $self->add_query("overgo"); }
139 if ($show_computational) { $self->add_query("computational"); }
140 if ($show_manual) { $self->add_query("manual"); }
144 sub display_results
{
146 if ($self->{text_output
}) {
147 $self->display_results_text();
149 else { $self->display_results_html(); }
152 sub display_results_text
{
154 #print "Pragma: \"no-cache\"\nContent-Disposition: filename=sequences.fasta\nContent-type: application/data\n\n";
155 #$self->{page}->{request}->send_http_header("text/plain");
162 sub display_results_html
{
165 #$self->{page}->header();
169 print "<br /><h3>Seedbacs for chromosome ".$self->get_chr()."</h3>";
171 print "Only unambiguous matches are shown. ";
172 if ($self->{nr_bacs
}) { print "$self->{nr_bacs} shown per anchor point."; }
173 else { print "All BACs listed for each marker."; }
175 #if (! @bacs) { print "No bacs found or marker does not exist.\n"; }
177 print qq { <table cellspacing
="5" cellpadding
="0" border
="0"> };
178 print qq { <tr
><td
>Marker
</td><td>confidence</td
><td
>offset
(cM
)</td><td>BAC name</td
><td
>estimated
length</td><td>contig name</td
><td
>contig size
</td><td>top pick</td
><td
>type
</td></tr
> };
183 $self->{page
}->footer();
189 my ($marker_id, $marker_name, $confidence, $offset, $bac, $len, $name, $contigs, $type) = @_;
193 my @confidence = ( "I", "ILOD2", "CFLOD3", "F");
195 if (!$self->{bgcolor
}) { $self->{bgcolor
}="#ffffff"; }
196 my $toppick=" ";
197 if ($count ==1) { $toppick=qq{<img src
="/img/checkmark.jpg" alt
="" />}; }
198 $s .= qq { <tr bgcolor
="$self->{bgcolor}"><td
><a href
="/search/markers/markerinfo.pl?marker_id=$marker_id">$marker_name</a
> [<a href
="/tools/seedbac/sbfinder.pl?marker=$marker_name">all
</a
>][<a href
="/cview/view_chromosome.pl?chr_nr=$self->{chr}&hilite=$marker_name">View
</a>]</td
><td align
="center">$confidence[$confidence]</td><td align="center">$offset</td
><td
><b
><a href
="/maps/physical/clone_info.pl?cu_name=$bac">$bac</a
></b></td
><td align
="center">$len</td><td align="center">$name</td
><td align
="center">$contigs</td><td bgcolor="#FFFFFF">$toppick</td
><td
>$type</td></tr
> };
205 my $marker_name = shift;
206 my $confidence = shift;
208 my @confidence = ( "I", "ILOD2", "CFLOD3", "F");
211 foreach my $b (@bacs) {
212 my ($bac, $len, $name, $contigs) = split /\t/, $b;
213 if (!$contigs) { $contigs = ""; } # avoid undefined blabla errors
214 if (!$name) { $name = ""; }
215 $s.= "$marker_name\t$confidence[$confidence]\t$offset\t$bac\t$len\t$name\t$contigs\n";
222 my $color1 = "#FFFFFF";
223 my $color2 = "#DDDDDD";
224 my $color3 = "#FF0000";
225 if (!$self->{bgcolor
}) { $self->{bgcolor
}=$color3; }
226 if ($self->{bgcolor
} eq $color1) { $self->{bgcolor
} = $color2; }
227 else { $self->{bgcolor
} = $color1; }
231 sub get_overgo_associations
{
234 $self ->{html
}.= qq { <tr
><td colspan
="10"><h3
>Experimental
(overgo
) Associations
</h3></td
></tr
> };
236 my $results = $self->get_associations("overgo");
238 foreach my $row (@
$results){
239 $self->{html
}.=$self->format_html(@
$row,"overgo");
240 $self->{text
}.=$self->format_text(@
$row, "overgo");
245 sub get_computational_associations
{
247 my $physical = $self->get_dbh()->qualify_schema("physical");
248 my $genomic = $self->get_dbh()->qualify_schema("genomic");
249 my $current_tomato_map_id = CXGN
::Map
::Tools
::current_tomato_map_id
;
250 $self ->{html
}.= qq { <tr
><td colspan
="10"><h3
>Computational Associations
</h3></td
></tr
> };
251 # my $sth = $self->get_dbh()->prepare("
252 # SELECT distinct(marker_alias.marker_id), max(marker_alias.alias), max(confidence_id), max(position), max(library.shortname||platenum||clone.wellrow||clone.wellcol), max(estimated_length), max('?'), 0, linkage_group.lg_order
253 # FROM $physical.computational_associations JOIN $genomic.clone using (clone_id)
254 # JOIN $genomic.library using (library_id)
255 # JOIN marker_alias USING (marker_id)
256 # JOIN marker_experiment ON ($physical.computational_associations.marker_id=marker_experiment.marker_id)
257 # JOIN marker_location using (location_id)
258 # JOIN map_version using (map_version_id)
259 # JOIN linkage_group ON (linkage_group.map_version_id=map_version.map_version_id)
260 # WHERE linkage_group.lg_name=?
261 # AND marker_location.confidence_id>=?
262 # AND map_version.map_id=$current_tomato_map_id
263 # AND map_version.current_version='t'
264 # AND marker_alias.preferred='t'
265 # GROUP BY marker_alias.marker_id, linkage_group.lg_order
266 # -- ,marker_alias.alias, confidence_id, position, clone_id, estimated_length, linkage_group.lg_order, library.shortname, clone.wellrow, clone.wellcol
267 # ORDER BY linkage_group.lg_order"
270 # $sth->execute($self->get_chr(), $self->get_confidence());
272 my $results = $self->get_associations("computational");
274 foreach my $result (@
$results) {
275 # $self->{html}.="*";
276 $self->{html
}.=$self->format_html(@
$result,"computational");
277 $self->{text
}.=$self->format_text(@
$result,"computational");
282 =head2 get_manual_associations
293 sub get_manual_associations
{
296 $self ->{html
}.= qq { <tr
><td colspan
="10"><h3
>Manual Associations
</h3></td
></tr
> };
298 my $results = $self->get_associations("manual");
300 foreach my $row (@
$results){
301 $self->{html
}.=$self->format_html(@
$row,"overgo");
302 $self->{text
}.=$self->format_text(@
$row, "overgo");
306 =head2 function get_associations
316 sub get_associations
{
318 my $association_type = shift;
320 my $physical = $self->get_dbh()->qualify_schema('physical');
322 my $MAP_ID = CXGN
::Map
::Tools
::current_tomato_map_id
();
323 print STDERR
"map_id=$MAP_ID\n";
325 my $limit_string = "";
326 if ($self->{nr_bacs
}) { $limit_string = "limit $self->{nr_bacs}"; }
328 my $query = "SELECT distinct marker_id, alias, confidence_id, bmm.position, arizona_clone_name, estimated_length, contig_name, number_of_bacs as mc, lg.lg_order FROM physical.bac_marker_matches AS bmm join linkage_group as lg using(lg_id) WHERE confidence_id >= ? AND lg.lg_name = ? AND association_type=? ORDER BY lg.lg_order, bmm.position, alias, estimated_length desc, number_of_bacs desc, contig_name";
330 print STDERR
"Now working on QUERY: $query\n";
331 my $sth = $self->get_dbh()->prepare($query);
333 $sth->execute($self->get_confidence(), $self->get_chr(), $association_type);
335 my $results = $sth->fetchall_arrayref();
339 =head2 function get_confidence
351 return $self->{confidence
};
354 =head2 function set_confidence
366 $self->{confidence
}=shift;
369 =head2 function get_chr
384 =head2 function set_chr
399 =head2 function get_dbh
414 =head2 function set_dbh
442 my $query_type = shift;
443 $self->{queries
}->{$query_type}=1;
459 return keys (%{$self->{queries
}});
476 my $query_type = shift;
477 if (exists($self->{queries
}->{$query_type}) ) {
478 return $self->{queries
}->{$query_type};
480 else { return undef; }