| 1 | package Bio::DB::GFF::Aggregator::match_gap; | ||
| 2 | use strict; | ||
| 3 | |||
| 4 | ################################################################################ | ||
| 5 | |||
| 6 | use base 'Bio::DB::GFF::Aggregator'; | ||
| 7 | |||
| 8 | ################################################################################ | ||
| 9 | |||
| 10 | =head1 NAME | ||
| 11 | |||
| 12 | Bio::DB::GFF::Aggregator::match_gap -- GFF3 match aggregator | ||
| 13 | |||
| 14 | =head1 SYNOPSIS | ||
| 15 | |||
| 16 | ------------------------------------------------- | ||
| 17 | Aggregator method: match_gap | ||
| 18 | Main method: match | ||
| 19 | Sub methods: match | ||
| 20 | ------------------------------------------------- | ||
| 21 | |||
| 22 | =head1 DESCRIPTION | ||
| 23 | |||
| 24 | This aggregator is used for GFF3 style gapped alignments, | ||
| 25 | in which there is a single feature of method 'match' with | ||
| 26 | a 'Gap' attribute. | ||
| 27 | |||
| 28 | The 'Gap' attribute's format consists of a series of | ||
| 29 | (operartion,length) pairs separated by space characters, | ||
| 30 | for example: 'M8 D3 M6'. | ||
| 31 | (see GFF reference for complete explanation) | ||
| 32 | |||
| 33 | This module only recognizes the M and D operators, which | ||
| 34 | should be sufficient for simple nucleotide to nucleotide | ||
| 35 | alignments. | ||
| 36 | |||
| 37 | ################################################################################ | ||
| 38 | |||
| 39 | =cut | ||
| 40 | |||
| 41 | sub method { | ||
| 42 | return 'match_gap'; | ||
| 43 | } | ||
| 44 | |||
| 45 | sub part_names { | ||
| 46 | return 'match'; | ||
| 47 | } | ||
| 48 | |||
| 49 | sub main_name { | ||
| 50 | return 'match'; | ||
| 51 | } | ||
| 52 | |||
| 53 | sub require_whole_object { | ||
| 54 | return 0; | ||
| 55 | } | ||
| 56 | |||
| 57 | sub aggregate { | ||
| 58 | my $class = shift; | ||
| 59 | my $features = shift; | ||
| 60 | my @compound; | ||
| 61 | foreach my $feature (@$features){ | ||
| 62 | if($feature->method eq 'match'){ | ||
| 63 | my $nf = $feature->clone; | ||
| 64 | $nf->method('match_gap'); | ||
| 65 | my($offset, $start, $stop) = (0, $feature->start, $feature->stop); | ||
| 66 | push @compound, $nf; | ||
| 67 | foreach my $code (split /\s+/, uc $feature->attributes('Gap')){ | ||
| 68 | my($op,$len) = split //, $code, 2; | ||
| 69 | if($op eq 'M'){ | ||
| 70 | my $subf = $feature->clone; | ||
| 71 | $subf->absolute(1); | ||
| 72 | $subf->{start} = $start + $offset; | ||
| 73 | $subf->{stop} = $start + $offset + $len - 1; | ||
| 74 | $subf->method('HSP'); | ||
| 75 | $nf->add_subfeature($subf); | ||
| 76 | $offset += $len; | ||
| 77 | } | ||
| 78 | elsif($op eq 'D'){ | ||
| 79 | $offset += $len; | ||
| 80 | } | ||
| 81 | } | ||
| 82 | $nf->adjust_bounds; | ||
| 83 | } | ||
| 84 | } | ||
| 85 | push @$features, @compound; | ||
| 86 | return $features; | ||
| 87 | } | ||
| 88 | |||
| 89 | ################################################################################ | ||
| 90 | 1; | ||
| 91 | |||
| 92 | __END__ |