4 CXGN::Map - classes to get information on SGN mapping information.
8 This class was originally written to retrieve data on genetic maps in the SGN database. However, map types multiplied and this class was re-written as a factory object producing a map object of the appropriate type - genetic, fish, individual, user, etc. These map objects are defined in the CXGN::Map:: namespace. Previous documentation mentioned the existence of a CXGN::Map::Storable class, however, this never seemed to exist and the new map interface and subclasses have been written as read/write objects.
10 The "new" function has been re-cast to act as a factory object and will produce the right type of Map object given the appropriate parameters, which are defined as follows:
14 map_id genetic or fish
15 map_version_id genetic or fish
18 individual_id indivdual_map
20 Note that much of the functionality of this class has been factored out into a CXGN::LinkageGroup object, which also exists in different incarnations for the different map types.
24 John Binns <zombieite@gmail.com> and Lukas Mueller (lam87@cornell.edu)
30 This class defines the following functions to be implemented by the subclasses, and keeps the old functions for compatibility (see deprecated functions below).
35 use CXGN
::DB
::Connection
;
41 Usage: my $map = CXGN::Map->new($dbh, {map_version_id=>30})
42 Desc: creates a new CXGN::Map object
44 Args: - a database handle, if possible using
45 CXGN::DB::Connection object
46 - a hashref, containing either a key map_id or a key
47 map_version_id, but not both!
55 my($dbh,$map_info)=@_;
56 my $self=bless({},$class);
57 unless(CXGN
::DB
::Connection
::is_valid_dbh
($dbh)){die"Invalid DBH";}
58 ref($map_info) eq 'HASH' or die"Must send in a dbh and hash ref with a map_id key or a map_version_id key";
59 $self->{map_version_id
}=$map_info->{map_version_id
};
60 $self->{map_id
}=$map_info->{map_id
};
63 if($self->{map_version_id
})
65 die"You must only send in a map_id or a map_version_id, not both";
67 my $map_version_id_q=$dbh->prepare("select map_version_id from map_version where map_id=? and current_version='t'");
68 $map_version_id_q->execute($self->{map_id
});
69 ($self->{map_version_id
})=$map_version_id_q->fetchrow_array();
71 $self->{map_version_id
} or return undef;
72 my $general_info_q=$dbh->prepare
87 inner join map using (map_id)
91 $general_info_q->execute($self->{map_version_id
});
94 $self->{map_version_id
},
96 $self->{current_version
},
102 $self->{has_physical
}
103 )=$general_info_q->fetchrow_array();
104 if(!$self->{map_version_id
}){return undef;}
105 my $linkage_q=$dbh->prepare('select linkage_group.lg_id as lg_id,linkage_group.map_version_id as map_version_id,lg_order,lg_name, min(position) as north_centromere, max(position) as south_centromere from linkage_group left join marker_location on (north_location_id=location_id or south_location_id=location_id) where linkage_group.map_version_id=? group by linkage_group.lg_id, linkage_group.map_version_id, lg_order, lg_name order by lg_order');
106 $linkage_q->execute($self->{map_version_id
});
107 while(my $linkage_group=$linkage_q->fetchrow_hashref())
109 push(@
{$self->{linkage_groups
}},$linkage_group);
115 =head2 accessors set_short_name, get_short_name
128 return $self->{short_name
};
133 $self->{short_name
}=shift;
136 =head2 accessors set_long_name, get_long_name
149 return $self->{long_name
};
154 $self->{long_name
}=shift;
157 =head2 accessors set_abstract, get_abstract
170 return $self->{abstract
};
175 $self->{abstract
}=shift;
178 =head2 accessors set_linkage_groups, get_linkage_groups
189 sub get_linkage_groups
{
191 return @
{$self->{linkage_groups
}};
194 sub set_linkage_groups
{
196 @
{$self->{linkage_groups
}}=@_;
199 =head2 function add_linkage_group
209 sub add_linkage_group
{
212 push @
{$self->{linkage_groups
}}, $lg;
216 =head2 accessors set_map_type, get_map_type
229 return $self->{map_type
};
234 $self->{map_type
}=shift;
238 =head2 function get_units
250 if ($self->get_map_type() eq "genetic") {
253 elsif ($self->get_map_type() eq "fish") {
256 elsif ($self->get_map_type() =~ /sequenc/) {
269 =head1 DEPRECATED FUNCTIONS
271 These functions are still working but should not be used in new code.
273 Note that these functions only work as getters and not as setters.
277 =head2 function map_id
290 return $self->{map_id
};
293 =head2 function map_version_id
305 return $self->{map_version_id
};
308 =head2 function short_name
320 return $self->{short_name
};
323 =head2 function long_name
335 return $self->{long_name
};
338 =head2 function abstract
350 return $self->{abstract
};
353 =head2 linkage_groups
357 Ret: a reference to an array of hashrefs with linkage group info.
358 hash keys include lg_name and lg_order
367 if($self->{linkage_groups
})
369 return $self->{linkage_groups
};
381 Ret: the type of the map, either 'fish' for a fish map
382 or 'genetic' for a genetic map.
391 return $self->{map_type
};
407 return $self->{has_IL
};
423 return $self->{has_physical
};
432 Desc: a shortcut function to get at the chromosome names,
434 Ret: a list of chromosome names.
443 my $linkage_groups_ref = $self->linkage_groups();
444 my @names = map $_->{lg_name
}, @
{$linkage_groups_ref};
448 =head2 has_linkage_group
452 Ret: 1 if the string or number represents a linkage group
455 Args: a string or number describing a possible linkage
462 sub has_linkage_group
{
464 my $candidate = shift;
466 $candidate=~ s/\s*(.*)\s*/$1/;
467 foreach my $n (map $_->{lg_name
} , @
{$self->linkage_groups()}) {
468 #print STDERR "comparing $n with $candidate...\n";
469 if ($candidate =~ /^$n$/i) {
470 #print STDERR "Yip!\n";
477 =head2 function get_centromere
479 Synopsis: my ($north, $south, $center) = $map->get_centromere($lg_name)
480 Arguments: a valid linkage group name
481 Returns: a three member list, the first element corresponds
482 to the north boundary of the centromere in cM
483 the second corresponds to the south boundary of
484 the centromere in cM, the third is the arithmetic mean
485 of the two first values.
495 if (! $self->has_linkage_group($lg)) {
496 die "Not a valid linkage group for this map!\n";
499 my $lg_hash = $self->get_linkage_group_hash($lg);
500 # foreach my $k (keys %$lg_hash) {
501 # print " $k, $lg_hash->{$k}\n";
503 my $north = $lg_hash->{north_centromere
};
504 my $south = $lg_hash->{south_centromere
};
505 return ($north, $south, int(($north+$south)/2));
508 sub get_linkage_group_hash
{
511 foreach my $lg_hash (@
{$self->linkage_groups()}) {
512 if ($lg_hash->{lg_name
} eq $lg_name) {