use Bio::DB::GFF;
# Open the sequence database
my $db = Bio::DB::GFF->new( -adaptor => 'dbi:mysql',
-dsn => 'dbi:mysql:elegans42',
-aggregator => ['alignment'],
);
-----------------------------
Aggregator method: alignment
Main method: (none)
Sub methods: similarity, HSP
-----------------------------
sub aggregate
{ my $self = shift;
my $features = shift;
my $factory = shift;
my $matchsub = $self->match_sub($factory) or return;
my $passthru = $self->passthru_sub($factory);
my $method = $self->get_method;
my (%alignments,%targets,@result);
warn "running alignment aggregator" if $factory->debug;
for my $feature (@$features) {
if ($matchsub->($feature)) {
my $group = $feature->{group};
my $source = $feature->source;
unless (exists $alignments{$group,$source}) {
my $type = Bio::DB::GFF::Typename->new($method,$source);
my $f = $feature->clone;
@{$f}{qw(type score phase)} = ($type,undef,undef);
$alignments{$group,$source} = $f or next;
}
my $main = $alignments{$group,$source};
$main->add_subfeature($feature);
push @result,$feature if $passthru && $passthru->($feature);
} else {
push @result,$feature;
}
}
warn "running aligner adjuster" if $factory->debug;
for my $alignment (values %alignments) {
$alignment->adjust_bounds;
$alignment->compound(1);
push @result,$alignment;
}
warn "aligner done" if $factory->debug;
@$features = @result; } |