These documents are For the HEAD of the CVS repository on July 19, 2007 Api docs for previous releases

Modware::Feature

MATCH

Summary Included libraries Package variables Synopsis Description General documentation Methods

Summary
   Modware::Feature::MATCH - default Modware representation of an MATCH
Package variables top
No package variables defined.
Included modulestop
Bio::Search::HSP::GenericHSP
Bio::Search::Hit::GenericHit
Inherit top
Modware::Feature
Synopsistop
  NEVER INSTANTIATE THIS OBJECT DIRECTLY, USE Modware::Feature like this:

my $match = new Modware::Feature(
-type => 'match',
-source => 'blastn.10.19.2007',
-bioperl => $some_bio_search_hit_generichit_object
);

USE CASE: Print the start and end relative to a reference feature for
each hsp in a given match.

foreach my $hsp ( $self->bioperl->hsps() ) {
my $hit = $hsp->hit();

print "HSP START:".$hit->start()."\n";
print "HSP END:". $hit->end()."\n";
}
Descriptiontop
  
A match is synonomous with a 'Hit' in blast. In a blast report the hit
contains all of the hsps that align to an item in a blast database. For instance,
if you blast an EST against a chromosome database and you get hits to chromosome 3 and 4,
you would have two match features, one to hold all the HSPs for chromosome 3 and one
for chromosome 4.

Match features are currently modeled with Bio::Search::Hit::GenericHit features. HSPs
can be accessed through the hsps method on the bioperl object (see use case in synopsis)

The HSPs are modeled with Bio::Search::HSP::GenericHSP objects

Please consult the bioperl documentation for Bio::Search::Hit::GenericHit and
Bio::Search::HSP::GenericHSP documentation.

You cannot update a MATCH object.
Methodstop
_get_bioperlDescriptionCode
_get_reference_featureDescriptionCode
_initDescriptionCode
_insert_hspsDescriptionCode
endDescriptionCode
insertDescriptionCode
newDescriptionCode
queryNo descriptionCode
startDescriptionCode
strandDescriptionCode
updateDescriptionCode

Methods description

_get_bioperl(2)codetopprevnext
 Title    : _get_bioperl
Note : creates a bioperl object representing this Match
: Match is represented as a Bio::Search::Hit::GenericHit
: with a collection of Bio::Search::HSP::GenericHSPs
Usage : called internally by lazy evaluated 'bioperl' method
Function : sets bioperl attribute to correct Bio::Search::Hit::GenericHit
Returns : nothing
Args : none
_get_reference_featurecodetopprevnext
 Title    : _get_reference_feature
Usage : $feature->_get_reference_feature();
Function : gets the reference_feature object for this feature (called from reference_feature)
Returns : nothing
Args : none
_initcodetopprevnext
 Title    : _init
Usage : called internally by constructor
: (hook to do any post-instantiation initialization)
Function : does nothing in Modware::Feature::MATCH
Returns : nothing
Args : none
_insert_hspscodetopprevnext
 Title    : _insert_hsps
Function : Inserts all of the HSPs ( SO term: match_part) into the database and links them
: through featurerelationship to the Hit (SO term: match)
Returns : nothing
Args : none
endcodetopprevnext
 Title    : end
Function : returns the end of the feature relatvie to a genomic
: reference feature (chromosome, contig, etc.)
Returns : integer base position
Args : none
insertcodetopprevnext
 Title    : insert
Function : Inserts Match feature and all of the HSPs into the database
: according to Chado recommendations
Returns : nothing
Args : none
newcodetopprevnext
 Title    : new
Note : never call this directly. Use new Modware::Feature with 'type' set to 'match'
Usage : my $match = new Modware::Feature(
-type => 'match',
-source => 'blastn.10.19.2007',
-bioperl => $some_bio_search_hit_generichit_object
);
Function : called by Modware::Feature->new when type = 'match'
Returns : feature_id string
Args : named arguments: -source, -type, -bioperl (Bio::Search::Hit::GenericHit), -description
startcodetopprevnext
 Title    : start
Function : returns the start of the match to a genomic
: reference feature (chromosome, contig, etc.)
Returns : integer base position
Args : none
strandcodetopprevnext
 Title    : strand
Function : Match features don't have strandedness, returns undef
Returns : undef
Args : none
updatecodetopprevnext
 Title    : update
Function : cannot update a match feature. Once its in, its in
:
Returns : nothing
Args : none

Methods code

_get_bioperldescriptiontopprevnext
sub _get_bioperl {
	my ($self) = @_;
	 
    my @subfeatures = grep{ $_->type_id->name eq 'match_part' } $self->subfeatures();

	#
# This whole mess is called a 'schwartzian transform' and is a useful
# sorting algorithm for calculated values using map and sort.
# for more info do a google search
#
my @hsps = map { $_->[0] } sort { $a->[1] <=> $b->[1] } map { [$_, ([$_->featureloc_feature_id()]->[0]->strand()||1)*[$_->featureloc_feature_id()]->[0]->fmin() ] } @subfeatures; my @bphsps; foreach my $hsp ( @hsps ) { my @locs = $hsp->featureloc_feature_id(); # the hit location is sotred in featureloc with the rank 0
# (hit location describes location on chromosome or other reference feature)
my ($hit_location) = grep{ $_->rank == 0 } @locs;; my $hit_primary_id = $hit_location->srcfeature_id(); my $hit_length = $hit_location->srcfeature_id(); # the hit strand can vary
my $hit_strand = $hit_location->strand(); my $hit_start = $hit_location->strand() eq 1? $hit_location->fmin() + 1 : $hit_location->fmax(); my $hit_end = $hit_location->strand() eq 1? $hit_location->fmax() : $hit_location->fmin() + 1; # the query location is sotred in featureloc with the rank 1
# (query location describes location on query feature (an EST for example))
my ($query_location) = grep{ $_->rank == 1 } @locs;; my $query_primary_id = $query_location->srcfeature_id(); my $query_length = $query_location->srcfeature_id(); # the query strand is assumed to be 1
# gmod loader loads it as null
my $query_strand = $query_location->strand(); my $query_start = $query_location->fmin() + 1; my $query_end = $query_location->fmax(); # for now, this is the best way to represent this
# a decorated SimilarityPair object that can
# be associated with a Bio::Search::Hit::GenericHit
my $bphsp = new Bio::Search::HSP::GenericHSP( -hit_strand => $hit_strand, -hit_start => $hit_start, -hit_end => $hit_end, -hit_name => $hit_primary_id, -hit_length => $hit_length, -query_strand => $query_strand, -query_start => $query_start, -query_end => $query_end, -query_name => $query_primary_id, -query_length => $query_length, -algorithm =>'BLASTN' ); push @bphsps, $bphsp; } my $bioperl_alignment = new Bio::Search::Hit::GenericHit(-algorithm => 'blastn', -name => 'test', -hsps =>\@ bphsps); $self->bioperl( $bioperl_alignment );
}
_get_reference_featuredescriptiontopprevnext
sub _get_reference_feature {
   my ($self) = @_;

   my $ref_object;

   my $location = $self->_featureloc();

   if ( $location && $location->srcfeature() ) {
      $ref_object = new Modware::Feature( -feature_id => $location->srcfeature->feature_id );
   }
  else {
     $ref_object = new Modware::Feature( -primary_id => [$self->bioperl()->hsps()]->[0]->hit() );
  }


   $self->reference_feature( $ref_object );
}
_initdescriptiontopprevnext
sub _init {
   my ($self, @args) = @_;
}
_insert_hspsdescriptiontopprevnext
sub _insert_hsps {
   my ($self,  @args) = @_;


   # The standard for storing an HSP is to store two featureloc records
# the first is relative to the genome reference feature and has rank = 0
# the second is relative to the query sequence and has rank = 1
foreach my $hsp ( $self->bioperl() ) { my $hit_subfeat = $hsp->hit(); my $query_subfeat = $hsp->query(); # uses standard _insert_subfeature method and inserts
# record in featureloc relative to genome referene feature with rank of 0
$subfeat_id = $self->_insert_subfeature($hit_subfeat, 'match_part'); # Now, insert another featureloc, relative to query feature
# with a rank of 1
Chado::Featureloc->create({ feature_id => $subfeat_id, srcfeature_id => $self->query->feature_id, strand => $query_subfeat->strand(), fmin => $query_subfeat->start() -1, fmax => $query_subfeat->end(), rank => 1 }); }
}
enddescriptiontopprevnext
sub end {
   my ($self, @args) = @_;

   return ( $self->bioperl('hit') < $self->bioperl('hit') ) ?
   $self->bioperl('hit') : $self->bioperl('hit');
}
insertdescriptiontopprevnext
sub insert {
   my ($self,  @args) = @_;

   $self->SUPER::insert();
   $self->_insert_featureloc();
   $self->_insert_hsps();


   $self->_update_qualifiers();  # need to update tags here, because calculating sequence can add a tags
}
newdescriptiontopprevnext
sub new {
   my ($type, @args) = @_;

  #
# do not bless it here, assume subclass will bless as a subclass type
#
my $self = {}; bless $self,$type; # You can pass in a chromosome_name or a reference _feature
# chromosome_name will probably be deprecated
my @arglist = qw( SOURCE DESCRIPTION BIOPERL ); my ( $source, $description, $bioperl ) = $self->_rearrange( [@arglist], @args ); $self->source ( $source ) if defined $source; $self->bioperl ( $bioperl ) if defined $bioperl; $self->description ( $description ) if defined $description; $self->qualifiers( [] ); $self->_init(); return $self;
}
querydescriptiontopprevnext
sub query {
   my ($self) = @_;
   my @feature_rows =  $self->_relationship_subjects( 'part_of' );
   my $first_hsp = [$self->bioperl()]->[0];
   my $query_name = $first_hsp->query();

   my $query = new Modware::Feature( -primary_id => $query_name );
   return $query;
}
startdescriptiontopprevnext
sub start {
   my ($self, @args) = @_;

   return ( $self->bioperl('hit') < $self->bioperl('hit') ) ?
   $self->bioperl('hit') : $self->bioperl('hit');
}
stranddescriptiontopprevnext
sub strand {
   my ($self, @args) = @_;

   return undef;
}
updatedescriptiontopprevnext
sub update {
   my ($self,  @args) = @_;

   warn "Cannot update a match feature nothing being done";
}

General documentation

AUTHOR - Eric Just top
   Eric Just e-just@northwestern.edu
APPENDIX top
   The rest of the documentation details each of the object
methods. Internal methods are usually preceded with a _