moving stuff around
[cview.git] / lib / CXGN / MapFactory / Cmap.pm
blob965449b1cfbbd5e060081dfd73f85774cbb623a9
3 =head1 NAME
5 CXGN::Cview::MapFactory::Custom - a class to provide custom behaviour for the comparative viewer
7 =head1 DESCRIPTION
9 For the interface to be implemented, see L<CXGN::Cview::MapFactory>, and for an example, see L<CXGN::Cview::MapFactory::SGN>.
11 =head1 AUTHOR
13 Lukas Mueller <lam87@cornell.edu>
15 =cut
17 use strict;
19 package CXGN::Cview::MapFactory::Cmap;
21 use base qw| CXGN::DB::Object |;
23 use CXGN::Cview::Map::SGN::Genetic;
24 use CXGN::Cview::Map::SGN::User;
25 use CXGN::Cview::Map::SGN::Fish;
26 use CXGN::Cview::Map::SGN::Sequence;
27 use CXGN::Cview::Map::SGN::IL;
28 use CXGN::Cview::Map::SGN::Physical;
29 use CXGN::Cview::Map::SGN::ProjectStats;
30 use CXGN::Cview::Map::SGN::AGP;
31 use CXGN::Cview::Map::SGN::Contig;
32 use CXGN::Cview::Map::GMOD::Cmap;
34 =head2 function new()
36 Synopsis: constructor
37 Arguments: none
38 Returns: a CXGN::Cview::MapFactory object
39 Side effects: none
40 Description: none
42 =cut
44 sub new {
45 my $class = shift;
46 my $dbh = shift;
48 my $self = $class->SUPER::new($dbh);
49 # at this point throw away the database handle which will be to a SGN postgresql database.
51 my $mysql = DBI->connect("DBI:mysql:database=CMAP;host=localhost", "web_usr", "tomato");
52 $self->set_dbh($mysql);
54 return $self;
57 =head2 function create()
59 Description: creates a map based on the hashref given, which
60 should either contain the key map_id or map_version_id
61 and an appropriate identifier. The function returns undef
62 if a map of the given id cannot be found/created.
63 Example:
65 =cut
67 sub create {
68 my $self = shift;
69 my $args = shift;
71 my $id = 0;
72 if (exists($args->{map_version_id})) {
73 $id=$args->{map_version_id};
76 elsif (exists($args->{map_id})) {
77 $id=$args->{map_id};
79 else {
80 die "Need a map_id or map_version_id key in hashref\n";
83 print STDERR "Create: Using id = $id\n";
85 my $map = CXGN::Cview::Map::GMOD::Cmap->new($self->get_dbh(), $id);
87 return $map;
93 =head2 function get_all_maps()
95 Synopsis: my @maps = $map_factory->get_all_maps();
96 Arguments: none
97 Returns: a list of all maps currently defined, as
98 CXGN::Cview::Map objects (and subclasses)
99 Side effects: Queries the database for certain maps
100 Description:
102 =cut
104 sub get_all_maps {
105 my $self = shift;
106 my $query = "SELECT map_set_id FROM cmap_map_set";
107 my $sth = $self->get_dbh()->prepare($query);
108 $sth->execute();
109 my @maps = ();
110 while (my ($map_id) = $sth->fetchrow_array()) {
111 push @maps, $self->create({ map_version_id=>"cmap".$map_id} );
113 return @maps;
116 sub get_system_maps {
117 my $self = shift;
118 return $self->get_all_maps();
121 sub get_user_maps {
124 return 1;