4 package CXGN
::Cview
::MapFactory
::ChlamyBase
;
6 use base qw
| CXGN
::DB
::Object
| ;
8 use CXGN
::Cview
::Map
::SGN
::Genetic
;
13 my $self = $class->SUPER::new
($dbh);
23 #print STDERR "Hashref = map_id => $hashref->{map_id}, map_version_id => $hashref->{map_version_id}\n";
25 if (!exists($hashref->{map_id
}) && !exists($hashref->{map_version_id
})) {
26 die "[CXGN::Cview::MapFactory] Need either a map_id or map_version_id.\n";
28 if ($hashref->{map_id
} && $hashref->{map_version_id
}) {
29 die "[CXGN::Cview::MapFactory] Need either a map_id or map_version_id - not both.\n";
31 if ($hashref->{map_id
}) {
32 $hashref->{map_version_id
}=CXGN
::Cview
::Map
::Tools
::find_current_version
($self->get_dbh(), $hashref->{map_id
});
35 # now, we only deal with map_versions...
37 my $id = $hashref->{map_version_id
};
39 #print STDERR "MapFactory: dealing with id = $id\n";
41 # if the map_version_id is purely numeric,
42 # check if the map is in the maps table and generate the
46 my $query = "SELECT map_version_id, map_type, map_id, short_name FROM sgn.map join sgn.map_version using(map_id) WHERE map_version_id=?";
47 my $sth = $self->get_dbh()->prepare($query);
49 my ($id, $map_type) = $sth->fetchrow_array();
50 if ($map_type =~ /genetic/i) {
51 return CXGN
::Cview
::Map
::SGN
::Genetic
->new($self->get_dbh(), $id);
54 print STDERR
"Map NOT FOUND!!!!!!!!!!!!!!!!!!\n\n";
59 =head2 function get_all_maps()
63 Returns: a list of all maps currently defined, as
64 CXGN::Cview::Map objects (and subclasses)
65 Side effects: Queries the database for certain maps
73 my @system_maps = $self->get_system_maps();
74 my @user_maps = $self->get_user_maps();
75 my @maps = (@system_maps, @user_maps);
81 =head2 get_system_maps
83 Usage: my @system_maps = $map_factory->get_system_maps();
84 Desc: retrieves a list of system maps (from the sgn
85 database) as a list of CXGN::Cview::Map objects
98 my $query = "SELECT map.map_id FROM sgn.map LEFT JOIN sgn.map_version USING(map_id) LEFT JOIN sgn.accession on(parent_1=accession.accession_id) LEFT JOIN sgn.organism USING(organism_id) LEFT JOIN common_name USING(common_name_id) WHERE current_version='t' ORDER by common_name.common_name";
99 my $sth = $self->get_dbh()->prepare($query);
102 while (my ($map_id) = $sth->fetchrow_array()) {
103 my $map = $self->create({ map_id
=> $map_id });
104 if ($map) { push @maps, $map; }
107 # push il, physical, contig, and agp map
109 foreach my $id ("il6.5", "il6.9", "p9", "c9", "agp") {
110 my $map = $self->create( {map_id
=>$id} );
111 if ($map) { push @maps, $map; }
122 Desc: retrieves the current user maps of the logged in user.
123 Ret: a list of CXGN::Cview::Map objects
132 # push the maps that are specific to that user and not public, if somebody is logged in...
135 my $login = CXGN
::Login
->new($self->get_dbh());
136 my $user_id = $login->has_session();
138 my $q3 = "SELECT user_map_id FROM sgn_people.user_map WHERE obsolete='f' AND sp_person_id=?";
139 my $h3 = $self->get_dbh()->prepare($q3);
140 $h3->execute($user_id);
141 while (my ($user_map_id) = $h3->fetchrow_array()) {
142 my $map = $self->create( {map_id
=>"u".$user_map_id} );
144 if ($map) { push @maps, $map; }