my $db = shift;
my $type = shift;
my $csa = $db->get_CoordSystemAdaptor();
my $mcc = $db->get_MetaCoordContainer();
# determine what coordinate systems have top-level seq_regions
my $sth = $db->dbc->prepare
(qq{SELECT distinct(sr.coord_system_id)
FROM seq_region sr, seq_region_attrib sra, attrib_type at
WHERE sr.seq_region_id = sra.seq_region_id
AND sra.attrib_type_id = at.attrib_type_id
AND at.code = 'toplevel'});
$sth->execute();
my @top_css =
map {$csa->fetch_by_dbID($_->[0])}
@{$sth->fetchall_arrayref()};
$sth->finish();
# determine what coord systems features are stored in
my @feat_css = @{$mcc->fetch_all_CoordSystems_by_feature_type($type)};
my @css;
foreach my $feat_cs (@feat_css) {
foreach my $top_cs (@top_css) {
if(!$feat_cs->equals($top_cs)) {
if($feat_cs->rank() > $top_cs->rank()) {
my @mp = @{$csa->get_mapping_path($top_cs, $feat_cs)};
if(@mp == 2) {
if($mp[0]->equals($top_cs)) {
push @css, \@mp;
} else {
die("Unexpected: ". $top_cs->name() .
" coord system should not be component of " .
$feat_cs->name(), " coord system.");
}
}
} else {
die("There is no 1 step mapping path between coord systems " .
$feat_cs->name()." and ".$top_cs->name().". This script " .
"requires one step mapping paths.");
}
}
}
}
if(!@css) {
die("Nothing to do for ${type}s (or missing meta/assembly info)\n");
}
return @css;
}