moving more stuff
[cview.git] / lib / CXGN / Cview / Map / Tools.pm
blob1b6267c576b5efa9f6af66e513f67babb630418e
2 =head1 NAME
4 CXGN::Cview::Map::Tools
6 =head1 AUTHOR
8 John Binns <zombieite@gmail.com>
10 =head1 DESCRIPTION
12 Non-object-oriented quick functions for getting random bits of data about maps.
14 =head2 is_current_version
16 #example: make a new map object but only if we have the current version
17 if(CXGN::Map::Tools::is_current_version($dbh,$map_version_id))
19 my $map=CXGN::Map->new({map_version_id=>$map_version_id});
22 =head2 find_current_version
24 #example: find the current map_version_id for a map_id
25 my $map_version_id=CXGN::Map::Tools::find_current_version($dbh, $map_id);
27 =head2 current_tomato_map_id
29 returns 9. whatever.
31 =cut
33 use strict;
35 package CXGN::Cview::Map::Tools;
37 sub is_current_version
39 my ($dbh,$map_version_id)=@_;
40 my $q=$dbh->prepare('select current_version from sgn.map_version where map_version_id=?');
41 $q->execute($map_version_id);
42 my ($current)=$q->fetchrow_array();
43 return $current;
46 sub find_current_version
48 my ($dbh,$map_id)=@_;
50 # if it is not a database-based map, the map_id and map_version_id
51 # are identical and contain the char prefix
53 if (!is_db_map($map_id)) {
54 return $map_id;
57 # otherwise we look in the database to find out.
59 my $q=$dbh->prepare("select map_version_id from sgn.map_version where current_version='t' and map_id=?");
60 $q->execute($map_id);
61 my ($current)=$q->fetchrow_array();
62 return $current;
65 sub current_tomato_map_id {
66 # returns the current Tomato EXPEN-2000 map, which I keep changing.
67 return 9;
70 sub find_map_id_with_version {
71 my $dbh = shift;
72 my $map_version_id = shift;
74 # the map_id's for the maps that are not in the database are
75 # identical to their map_version_ids
77 if (!is_db_map($map_version_id)) {
78 return $map_version_id;
81 # all other map_versions need to be retrieved from the database
83 my $q =$dbh->prepare("select map_id from sgn.map_version where map_version_id=?");
84 $q->execute($map_version_id);
85 my ($map_id) = $q->fetchrow_array();
86 # warn "[CXGN::Cview::Map::Tools] find_map_id_with_version: $map_version_id corresponds to $map_id.\n";
87 return $map_id;
90 sub is_db_map {
91 my $id = shift;
92 if ($id =~ /^\d+$/) {
93 return 1;
95 return 0;
98 =head2 function get_physical_marker_color
100 Synopsis:
101 Arguments: the physical marker association type, currently
102 one of "overgo", "computational", "manual".
103 Returns: the associated color, as a list of three ints.
104 Side effects: will be used by the comparative viewer to render
105 the marker.
106 Description:
108 =cut
110 sub get_physical_marker_color {
111 my $type = shift;
112 my $status = shift;
113 if (!defined($status)) { $status = ""; }
115 if ($status eq "complete") { return (20, 250, 20); }
116 if ($status eq "in_progress") { return (20, 20, 250); }
117 if (!$type) { return (0, 0, 0); }
119 if ($type eq "overgo") {
120 return (100, 100, 100);
122 if ($type eq "computational") {
123 return (200, 100, 100, );
125 if ($type eq "manual") {
126 return (200, 200, 100);
128 if ($type eq "Lpen_manual") {
129 return (50, 200, 200);
131 return (0, 0, 0);