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)
50 Refer to the L<CXGN::LICENSE> file.
54 This class implements the following functions:
60 package CXGN
::Cview
::MapFactory
::SGN
;
62 use base qw
| CXGN
::DB
::Object
|;
65 use CXGN
::Cview
::Map
::SGN
::Genetic
;
66 #use CXGN::Cview::Map::SGN::User;
67 use CXGN
::Cview
::Map
::SGN
::Fish
;
68 use CXGN
::Cview
::Map
::SGN
::Sequence
;
69 use CXGN
::Cview
::Map
::SGN
::IL
;
70 use CXGN
::Cview
::Map
::SGN
::Physical
;
71 use CXGN
::Cview
::Map
::SGN
::ProjectStats
;
72 use CXGN
::Cview
::Map
::SGN
::AGP
;
73 use CXGN
::Cview
::Map
::SGN
::ITAG
;
74 use CXGN
::Cview
::Map
::SGN
::Contig
;
79 Arguments: a database handle
80 Returns: a CXGN::Cview::MapFactory::SGN object
90 my $self = $class->SUPER::new
($dbh);
95 =head2 function create()
97 Description: creates a map based on the hashref given, which
98 should either contain the key map_id or map_version_id
99 and an appropriate identifier. The function returns undef
100 if a map of the given id cannot be found/created.
109 my $c = SGN
::Context
->new();
110 #print STDERR "Hashref = map_id => $hashref->{map_id}, map_version_id => $hashref->{map_version_id}\n";
112 my $temp_dir = File
::Spec
->catfile($c->get_conf('basepath'), $c->get_conf('tempfiles_subdir'), 'cview');
114 if (!exists($hashref->{map_id
}) && !exists($hashref->{map_version_id
})) {
115 die "[CXGN::Cview::MapFactory] Need either a map_id or map_version_id.\n";
117 if ($hashref->{map_id
} && $hashref->{map_version_id
}) {
118 die "[CXGN::Cview::MapFactory] Need either a map_id or map_version_id - not both.\n";
120 if ($hashref->{map_id
}) {
121 $hashref->{map_version_id
}=CXGN
::Cview
::Map
::Tools
::find_current_version
($self->get_dbh(), $hashref->{map_id
});
124 # now, we only deal with map_versions...
126 my $id = $hashref->{map_version_id
};
128 #print STDERR "MapFactory: dealing with id = $id\n";
130 # if the map_version_id is purely numeric,
131 # check if the map is in the maps table and generate the
135 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=?";
136 my $sth = $self->get_dbh()->prepare($query);
138 my ($id, $map_type) = $sth->fetchrow_array();
139 if ($map_type =~ /genetic/i) {
140 return CXGN
::Cview
::Map
::SGN
::Genetic
->new($self->get_dbh(), $id);
142 elsif ($map_type =~ /fish/) {
143 #print STDERR "Creating a fish map...\n";
144 return CXGN
::Cview
::Map
::SGN
::Fish
->new($self->get_dbh(), $id);
146 elsif ($map_type =~ /seq/) {
147 #print STDERR "Creating a seq map...\n";
148 return CXGN
::Cview
::Map
::SGN
::Sequence
->new($self->get_dbh(), $id);
151 elsif ($id =~ /^u/i) {
152 return CXGN
::Cview
::Map
::SGN
::User
->new($self->get_dbh(), $id);
154 elsif ($id =~ /^il/i) {
156 "The tomato Introgression lines (ILs) are a set of nearly isogenic lines (NILs) developed by Dani Zamir through a succession of backcrosses, where each line carries a single genetically defined chromosome segment from a divergent genome. The ILs, representing whole-genome coverage of S. pennellii in overlapping segments in the genetic background of S. lycopersicum cv. M82, were first phenotyped in 1993, and presently this library consists of 76 genotypes. ";
158 my ($population_id, $map_id) = $self->get_db_ids($id);
160 $abstract .= " This IL map is based on markers of the F2-2000 map. ILs have also been mapped <a href=\"map.pl?map_id=il6.5&show_ruler=1&show_offsets=1\" >with the ExPEN1992 map as a reference</a>.";
162 elsif ($map_id ==5) {
163 $abstract .= " The IL lines on this map have been characterized based on the markers on the 1992 tomato map. ILs have also been mapped <a href=\"map.pl?map_id=il6.9&show_ruler=1&show_offsets=1\" >with the ExPEN2000 map as a reference</a>. ";
166 my $ref_map = "ExPEN2000";
167 if ($id==5) { $ref_map = "ExPEN1992";}
168 my $long_name =qq | <i
>Solanum lycopersicum
</i
> Zamir Introgression Lines
(IL
) based on
$ref_map |;
170 return CXGN
::Cview
::Map
::SGN
::IL
->new($self->get_dbh(), $id,
171 { short_name
=> "Tomato IL map",
172 long_name
=> $long_name,
173 abstract
=> $abstract
176 elsif ($id =~ /^\//) {
177 #return CXGN::Cview::Map::SGN::File->new($dbh, $id);
179 elsif ($id =~ /^p\d+/) {
180 return CXGN
::Cview
::Map
::SGN
::Physical
->new($self->get_dbh(), $id);
182 elsif ($id =~ /^o$/i) {
184 return CXGN
::Cview
::Map
::SGN
::ProjectStats
->new($self->get_dbh(), {
185 short_name
=>"Tomato Sequencing Progress",
186 long_name
=>"Tomato Sequencing Statistics by Chromosome",
187 abstract
=> $self->get_abstract(),
192 elsif ($id =~ /^agp$/i) {
193 return CXGN
::Cview
::Map
::SGN
::AGP
->new($self->get_dbh(), $id, {
194 short_name
=> "Tomato AGP map",
195 long_name
=> "Tomato (Solanum lycopersicum) Accessioned Golden Path map",
196 abstract
=> "<p>The AGP map shows the sequencing progress of the international tomato genome sequencing project by listing all finished clones by estimated physical map position . Each sequencing center generates one or more AGP (Accessioned Golden Path) files and uploads them to SGN. These files contain all the sequenced BACs, their position on the chromosome, the overlaps with other BACs and other information. For a complete specification, please refer to the <a href=\"http://www.sanger.ac.uk/Projects/C_elegans/DOCS/agp_files.shtml\">Sanger AGP specification</a>. The AGP files can also be downloaded from the SGN FTP site, at <a href=\"ftp://ftp.sgn.cornell.edu/tomato_genome/agp/\">ftp://ftp.sgn.cornell.edu/tomato_genome/agp/</a>.</p> <p>Note that this map is in testing (beta), and not all features may be functional.</p>" ,
197 temp_dir
=> $temp_dir } );
199 elsif ($id =~ /^itag$/i) {
200 return CXGN
::Cview
::Map
::SGN
::ITAG
->new($self->get_dbh(), $id, {
201 short_name
=> "Tomato ITAG map",
202 long_name
=>"Tomato (Solanum lycopersicum) ITAG map",
203 abstract
=>"<p>The ITAG map shows the contig assembly and the corresponding BACs as used by the most recent annotation from the International Tomato Annotation Group (ITAG, see <a href=\"http://www.ab.wur.nl/TomatoWiki\">ITAG Wiki</a>). Clicking on the contigs will show the ITAG annotation in the genome browser.",
204 temp_dir
=> $temp_dir }
207 # elsif ($id =~ /^u\d+$/i) {
208 # return CXGN::Cview::Map::SGN::User->new($self->get_dbh(), $id);
210 elsif ($id =~ /^c\d+$/i) {
211 return CXGN
::Cview
::Map
::SGN
::Contig
->new($self->get_dbh(), $id, {
212 berkeley_db_path
=>'/data/prod/public/tomato_genome/physical_mapping/fpc/SGN_2009/gbrowse/curr/',
213 short_name
=> "Tomato FPC map SGN2009",
214 long_name
=> "Solanum lycopersicum Contig Map SGN2009",
215 temp_dir
=> $temp_dir,
216 marker_link
=> "/gbrowse/gbrowse/fpc_tomato_sgn_2009/?name=",
220 <p
>This
map shows the contig positions of the SGN2009 physical
map constructed at the Arizona Genome Institute
in late
2009. The marker positions shown are from the latest
<a href
="/cview/map.pl?map_id=9">EXPEN2000
map</a>.</p>
222 <p
>This physical
map contains clones from the HindIII
, EcoRI
, MboI
and sheared BAC library
.</p
>
224 <p
>This overview shows the counts of contigs along the chromosome
. Click on any chromosome to view the individual contigs
. More information on
each contig can be obtained by by clicking on a specific contig
.
226 <p
>Specific contig IDs
, including contigs that are
not mapped
, can be searched on the
<a href
="/gbrowse/gbrowse/fpc_tomato_sgn_2009/">FPC viewer page
</a>.</p>
236 print STDERR
"Map NOT FOUND!!!!!!!!!!!!!!!!!!\n\n";
241 =head2 function get_all_maps()
245 Returns: a list of all maps currently defined, as
246 CXGN::Cview::Map objects (and subclasses)
247 Side effects: Queries the database for certain maps
255 my @system_maps = $self->get_system_maps();
256 my @user_maps = $self->get_user_maps();
257 my @maps = (@system_maps, @user_maps);
263 =head2 get_system_maps
265 Usage: my @system_maps = $map_factory->get_system_maps();
266 Desc: retrieves a list of system maps (from the sgn
267 database) as a list of CXGN::Cview::Map objects
275 sub get_system_maps
{
280 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";
281 my $sth = $self->get_dbh()->prepare($query);
284 while (my ($map_id) = $sth->fetchrow_array()) {
285 my $map = $self->create({ map_id
=> $map_id });
286 if ($map) { push @maps, $map; }
289 # push il, physical, contig, and agp map
291 foreach my $id ("il6.5", "il6.9", "p9", "c9", "agp", "itag") {
292 my $map = $self->create( {map_id
=>$id} );
293 if ($map) { push @maps, $map; }
303 Status: DEPRECATED. Does nothing now, as user maps have been disabled.
305 Desc: retrieves the current user maps of the logged in user.
306 Ret: a list of CXGN::Cview::Map objects
315 # push the maps that are specific to that user and not public, if somebody is logged in...
318 # my $login = CXGN::Login->new($self->get_dbh());
319 # my $user_id = $login->has_session();
321 # my $q3 = "SELECT user_map_id FROM sgn_people.user_map WHERE obsolete='f' AND sp_person_id=?";
322 # my $h3 = $self->get_dbh()->prepare($q3);
323 # $h3->execute($user_id);
324 # while (my ($user_map_id) = $h3->fetchrow_array()) {
325 # my $map = $self->create( {map_id=>"u".$user_map_id} );
327 # if ($map) { push @maps, $map; }
338 my $population_id = 6;
339 my $reference_map_id=5;
341 if ($id=~/il(\d+)\.?(\d*)?/) {
343 $reference_map_id=$2;
345 if (!$reference_map_id) { $reference_map_id=5; }
346 if (!$population_id) { $population_id=6; }
347 print STDERR
"Population ID: $population_id, reference_map_id = $reference_map_id\n";
349 return ($population_id, $reference_map_id);