moving stuff around
[cview.git] / lib / CXGN / MapFactory / CviewAndCmap.pm
blob3b65f585be40d18c3ddb2384481b09de11933c96
3 =head1 NAME
5 CXGN::Cview::MapFactory::CviewAndCmap - a class to access maps in both cview and cmap databases.
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::CviewAndCmap;
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 $self->{cview} = CXGN::Cview::MapFactory::SGN->new($dbh);
53 $self->{cmap} = CXGN::Cview::MapFactory::Cmap->new($dbh);
56 return $self;
59 =head2 function create()
61 Description: creates a map based on the hashref given, which
62 should either contain the key map_id or map_version_id
63 and an appropriate identifier. The function returns undef
64 if a map of the given id cannot be found/created.
65 Example:
67 =cut
69 sub create {
70 my $self = shift;
71 my $args = shift;
73 my $id = 0;
74 if (exists($args->{map_version_id})) {
75 $id=$args->{map_version_id};
78 elsif (exists($args->{map_id})) {
79 $id=$args->{map_id};
81 else {
82 die "Need a map_id or map_version_id key in hashref\n";
85 my $map;
87 if ($id =~ /cmap/) {
88 $map = $self->{cmap}->create($args);
90 else {
91 $map = $self->{cview}->create($args);
94 return $map;
100 =head2 function get_all_maps()
102 Synopsis: my @maps = $map_factory->get_all_maps();
103 Arguments: none
104 Returns: a list of all maps currently defined, as
105 CXGN::Cview::Map objects (and subclasses)
106 Side effects: Queries the database for certain maps
107 Description:
109 =cut
111 sub get_all_maps {
112 my $self = shift;
114 my @maps = ();
116 @maps = ($self->{cview}->get_all_maps(), $self->{cmap}->get_all_maps());
118 return @maps;
121 sub get_system_maps {
122 my $self = shift;
123 return $self->get_all_maps();
126 sub get_user_maps {
127 my $self = shift;
128 my @maps = ();
129 @maps = $self->{cview}->get_user_maps();
130 return @maps;
133 return 1;