6 CXGN::Cview::MapFactory - a factory object for CXGN::Cview::Map objects
10 my $map_factory = CXGN::Cview::MapFactory->new($dbh);
11 $map = $map_factory->create({map_version_id=>"u1"});
15 The MapFactory object is part of a compatibility layer that defines the data sources of the comparative mapviewer. If there are different types of maps that can be distinguished by their ids, the MapFactory should be implemented to return the right map object for the given id. Of course, the corresponding map object also needs to be implemented, using the interface defined in CXGN::Cview::Map .
17 The MapFactory constructor takes a database handle (preferably constructed using CXGN::DB::Connection object). The map objects can then be constructed using the create function, which takes a hashref as a parameter, containing either map_id or map_version_id as a key (but not both). map_ids will be converted to map_version_ids immediately. Map_version_ids are then analyzed and depending on its format, CXGN::Cview::Map object of the proper type is returned.
19 The function get_all_maps returns all maps as list of appropriate CXGN::Cview::Map::* objects.
21 For the current SGN implementation, the following identifier formats are defined and yield following corresponding map objects
23 \d+ refers to a map id in the database and yields either a
24 CXGN::Cview::Map::SGN::Genetic (type genetic)
25 CXGN::Cview::Map::SGN::FISH (type fish)
26 CXGN::Cview::Map::SGN::Sequence (type sequence)
27 u\d+ refers to a user defined map and returns:
28 CXGN::Cview::Map::SGN::User object
29 filepath refers to a map defined in a file and returns a
30 CXGN::Cview::Map::SGN::File object
31 il\d+ refers to a population id in the phenome.population table
32 (which must be of type IL) and returns a
33 CXGN::Cview::Map::SGN::IL object
34 p\d+ CXGN::Cview::Map::SGN::Physical
35 c\d+ CXGN::Cview::Map::SGN::Contig
36 o CXGN::Cview::Map::SGN::ProjectStats map object
38 The actual map objects returned are defined in the CXGN::Cview::Maps namespace. Because this is really a compatibility layer, an additional namespace of the resource is appended, such that a genetic map at SGN could be defined as CXGN::Cview::Maps::SGN::Genetic . If no corresponding map is found, undef is returned.
42 Lukas Mueller (lam87@cornell.edu)
46 Refer to the L<CXGN::LICENSE> file.
50 This class implements the following functions:
52 (See the superclass, CXGN::Cview::Maps, for a definition of the class interface)
56 package CXGN
::Cview
::MapFactory
;
61 use base qw
| CXGN
::DB
::Object
|;
64 our $VERSION = '2.00';
65 $VERSION = eval $VERSION;
70 Arguments: database handle, configuration variable hashref
71 the configuration hashref supports the following
75 with the following values:
80 Returns: a CXGN::Cview::MapFactory object
88 my ($dbh, $conf_hash_ref) = @_;
90 my $db_backend = $conf_hash_ref->{cview_db_backend
};
92 # figure out what map factory class we need. if cview_db_backend
93 # conf var is set, use that, otherwise try to use the project_name
94 # conf var, and if that's not set then fall back to SGN
96 my $mf_name = $db_backend ?
$db_backend eq 'cxgn_and_cmap' ?
'CviewAndCmap'
97 : $db_backend eq 'cmap' ?
'Cmap'
98 : $db_backend eq 'cxgn' ?
'SGN'
99 : $db_backend eq 'Cassava' ?
'Cassava'
100 : $db_backend eq 'Cacao' ?
'Cacao'
101 : $db_backend eq 'Ricebase' ?
'Ricebase'
102 : croak
"invalid cview backend $db_backend"
105 # print STDERR "Using cview backend $mf_name (conf has is $conf_hash_ref->{cview_db_backend}\n";
107 # try to load the mapfactory class
108 my $mf_class = __PACKAGE__
."::$mf_name";
109 eval "require $mf_class";
110 $@
and die "error loading $mf_class:\n$@";
112 # now instantiate it, passing along the same dbh and config we got
113 return $mf_class->new( @_ );