Get rid of some warnings in CXGN::Cview::Chromosome::Vector
[cview.git] / lib / CXGN / Cview / MapFactory / Custom.pm
blob3600305d4045b125fb1bb1ab4929b4c41fbf8d6c
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::Custom;
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);
50 my $mysql = DBI->connect("DBI:mysql:database=CMAP;host=localhost", "web_usr", "tomato");
51 $self->set_dbh($mysql);
53 return $self;
56 =head2 function create()
58 Description: creates a map based on the hashref given, which
59 should either contain the key map_id or map_version_id
60 and an appropriate identifier. The function returns undef
61 if a map of the given id cannot be found/created.
62 Example:
64 =cut
66 sub create {
67 my $self = shift;
68 my $args = shift;
70 my $id = 0;
71 if (exists($args->{map_version_id})) {
72 $id=$args->{map_version_id};
75 elsif (exists($args->{map_id})) {
76 $id=$args->{map_id};
78 else {
79 die "Need a map_id or map_version_id key in hashref\n";
82 print STDERR "Create: Using id = $id\n";
84 my $map = CXGN::Cview::Map::GMOD::Cmap->new($self->get_dbh(), $id);
86 return $map;
92 =head2 function get_all_maps()
94 Synopsis: my @maps = $map_factory->get_all_maps();
95 Arguments: none
96 Returns: a list of all maps currently defined, as
97 CXGN::Cview::Map objects (and subclasses)
98 Side effects: Queries the database for certain maps
99 Description:
101 =cut
103 sub get_all_maps {
104 my $self = shift;
105 my $query = "SELECT map_set_id FROM cmap_map_set";
106 my $sth = $self->get_dbh()->prepare($query);
107 $sth->execute();
108 my @maps = ();
109 while (my ($map_id) = $sth->fetchrow_array()) {
110 push @maps, $self->create({ map_id=>$map_id} );
112 return @maps;
115 sub get_system_maps {
116 my $self = shift;
117 return $self->get_all_maps();
120 sub get_user_maps {
123 return 1;