Bio::DB::GFF::Aggregator::match_gap - GFF3 match aggregator


GBrowse documentation Contained in the GBrowse distribution.

Index


Code Index:

NAME

Top

Bio::DB::GFF::Aggregator::match_gap -- GFF3 match aggregator

SYNOPSIS

Top

 -------------------------------------------------
 Aggregator method: match_gap
 Main method:       match
 Sub methods:       match
 -------------------------------------------------

DESCRIPTION

Top

This aggregator is used for GFF3 style gapped alignments, in which there is a single feature of method 'match' with a 'Gap' attribute.

The 'Gap' attribute's format consists of a series of (operartion,length) pairs separated by space characters, for example: 'M8 D3 M6'. (see GFF reference for complete explanation)

This module only recognizes the M and D operators, which should be sufficient for simple nucleotide to nucleotide alignments.

################################################################################

BUGS

Top

None reported.

SEE ALSO

Top

Bio::DB::GFF, Bio::DB::GFF::Aggregator

AUTHOR

Top

Dmitri Bichko

This library is free software; you can redistribute it and/or modify it under the same terms as Perl itself.


GBrowse documentation Contained in the GBrowse distribution.
package Bio::DB::GFF::Aggregator::match_gap;
use strict;

################################################################################

use base 'Bio::DB::GFF::Aggregator';

################################################################################

sub method {
	return 'match_gap';
}

sub part_names {
	return 'match';
}

sub main_name {
	return 'match';
}

sub require_whole_object {
	return 0;
}

sub aggregate {
	my $class = shift;
	my $features = shift;
	my @compound;
	foreach my $feature (@$features){
		if($feature->method eq 'match'){
			my $nf = $feature->clone;
			$nf->method('match_gap');
			my($offset, $start, $stop) = (0, $feature->start, $feature->stop);
			push @compound, $nf;		
			foreach my $code (split /\s+/, uc $feature->attributes('Gap')){
				my($op,$len) = split //, $code, 2;
				if($op eq 'M'){
					my $subf = $feature->clone;
					$subf->absolute(1);
					$subf->{start} = $start + $offset;
					$subf->{stop} = $start + $offset + $len - 1;
					$subf->method('HSP');
					$nf->add_subfeature($subf);
					$offset += $len;
				}
				elsif($op eq 'D'){
					$offset += $len;
				}
			}
		    $nf->adjust_bounds;
		}
	}
	push @$features, @compound;
	return $features;
}

################################################################################
1;

__END__