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

Modware::Feature

Aligned

Summary Included libraries Package variables Synopsis Description General documentation Methods

Summary
   Modware::Feature::Aligned - Parent Class of all Modware::Feature::* classes derived from BLAST alignments.
Package variables top
No package variables defined.
Included modulestop
Bio::Location::Split
Bio::Seq
Bio::SeqFeature::Generic(1)
Bio::SeqFeature::Generic(2)
Modware::Feature
Inherit top
Modware::Feature
Synopsistop
  do not create a Modware::Feature::Aligned object directly, it is for use by the Modware::Feature object
Descriptiontop
   THis is an abstract subclass of Modware::Feature and should not be called directly.  It contains
methods specific to features which are blasted against the genome (ests, mRNAs, Genbank records).

The main distinction here is that these objects will have TWO bioperl objects associated with them

1. bioperl - this represents the entitiy in question. i.e. and EST is represented by a
Bio::Seq object
2. bioperl_alignment - this represents the blast hit that maps this feature to the genome. it is
represented by a Bio::SeqFeature::Generic object and its locations on the reference
sequence map to hsps.

The bioperl object should be used when you want to work with the object itself ( for example, looking
at the sequence) whereas the alignment object should be used
when inspecting the objects location on the genome ( for example to find features that touch it ).
Methodstop
_blastDescriptionCode
_get_bioperlDescriptionCode
_get_bioperl_alignmentDescriptionCode
_get_chromosomeDescriptionCode
_initDescriptionCode
alignment_typeDescriptionCode
bioperl_alignmentDescriptionCode
blastDescriptionCode
endDescriptionCode
insertDescriptionCode
lengthNo descriptionCode
match_typeDescriptionCode
newNo descriptionCode
startDescriptionCode
updateDescriptionCode
update_alignmentDescriptionCode

Methods description

_blastcodetopprevnext
 Title    : _blast
Function : runs a blast, sets new bioperl_alignment
Returns : boolean ( true if valid lis is parsed and bioperl_alignment set )
Args : -type ( type of seq to blast ie 'DNA Coding Sequence', 'mRNA Sequence' etc. )
_get_bioperlcodetopprevnext
 Title    : _get_bioperl
Note : creates a bioperl object representing this EST (Bio::Seq)
Usage : called internally by lazy evaluated 'bioperl' method
Function : creates a bioperl object with a location on the chromosome's bioperl object.
Returns : nothing
Args : none
_get_bioperl_alignmentcodetopprevnext
 Title    : _get_bioperl_alignment
Note : creates a bioperl_alignment object from the database
: for alignment features such as EST's and mRNA's,
: this feature is created from where the feature aligns
: to the chromosome after BLASTING and filtering the hsp's
: with the LIS algorithm.
:
: Bio::SeqFeature::Generic object
: tag: hit_id ( ID of chromosome that alignment maps to )
Usage : called internally by lazy evaluated 'bioperl_alignment' method
Function : creates a bioperl_alignment object ( with location where applicable )
Returns : nothing
Args : none
_get_chromosomecodetopprevnext
 Title    : _get_chromosome
Usage : $feature->_get_chromosome();
Function : gets the chromosome object for this feature (called from chromosome)
Returns : nothing
Args : none
_initcodetopprevnext
 Title    : _init
Note : sets attributes specific to Aligned features
Usage : called internally by new
Function :
Returns : nothing
Args : none
alignment_typecodetopprevnext
 Title    : alignment_type
Function : returns type of alignment for SUBfeature table
Returns : nothing
Args : none
bioperl_alignmentcodetopprevnext
 Title    : bioperl_alignment
Note : Fetches the bioperl_alignment object associated with this feature ( Bio::SeqFeature::Generic )
: which has the location of the blast hits on the chromosome
: This is lazy evaluated
: each feature type will have its own _get_bioperl_alignment method
: An non-alignment is represented as an empty Bio::SeqFeature::Generic object
Usage : To print the bioperl_alignment name of the bioperl_alignment that this feature belongs to
: print $self->bioperl_alignment->bioperl_alignment_name();
Function : gets/sets the bioperl_alignment attribute of the feature
Returns : a Bio::SeqFeatureI implementing object
Args : optional: bioperl_alignment object
blastcodetopprevnext
 Title    : blast
Function : runs a blast, sets new bioperl_alignment
Returns : boolean ( true if valid lis is parsed and bioperl_alignment set )
Args : -type ( type of seq to blast ie 'DNA Coding Sequence', 'mRNA Sequence' etc. )
endcodetopprevnext
 Title    : end
Note : reads end from the hightest coordinate on the chromosome in bioperl_alignment object
Usage : print "Start coordinate: " $self->end();
Function : returns end coordinate of the alignment of this feature in chromosomal coordinates
Returns : nothing
Args : none
insertcodetopprevnext
 Title    : insert
Function : calls SUPER::insert, then a method to update the alignment
Returns : nothing
Args : none
match_typecodetopprevnext
 Title    : match_type
Function : returns type of alignment for SUBfeature table
Returns : nothing
Args : none
startcodetopprevnext
 Title    : start
Note : reads start from the lowest coordinate on the chromosome in bioperl_alignment object
Usage : print "Start coordinate: " $self->start();
Function : returns start coordinate of the alignment of this feature in chromosomal coordinates
Returns : nothing
Args : none
updatecodetopprevnext
 Title    : update
Function : calls SUPER::update, then a method to update the alignment
Returns : nothing
Args : none
update_alignmentcodetopprevnext
 Title    : update_alignment
Function : updates the alignment subfeatures based on bioperl_alignment object
:
Returns : nothing
Args : none

Methods code

_blastdescriptiontopprevnext
sub _blast {
   my ($self, @args) = @_;

   $self->throw( "Need to implement _blast method which blasts, parses report into Bio::SearchIO object and sets bioperl_alignment accessor");

   return 1;
}
_get_bioperldescriptiontopprevnext
sub _get_bioperl {
   my ($self, @args) = @_;

   $self->throw_not_implemented();
}
_get_bioperl_alignmentdescriptiontopprevnext
sub _get_bioperl_alignment {
   my ($self, @args) = @_;

   if ( $self->feature_id ) {
      my $bioperl_alignment  = new Bio::SeqFeature::Generic();

      my $chrom_primary_id;

      my $hit_iterator = Chado::Feature->search( name => $self->primary_id().".match");
      
      return undef if $hit_iterator->count() == 0;

      my $hit_feature = new Modware::Feature( -feature_id => $hit_iterator->next()->feature_id() );

        
      my @subfeatures = grep{ $_->type_id->name eq 'match_part' } $hit_feature->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()*[$_->featureloc_feature_id()]->[0]->fmin() ] } @subfeatures; foreach my $hsp ( @hsps ) { my @locs = $hsp->featureloc_feature_id(); my ($location) = grep{ $_->srcfeature_id != $self->feature_id } @locs;; $chrom_primary_id = $location->srcfeature_id->dbxref->accession; my $strand = $location->strand(); my $start = $location->fmin() + 1; my $end = $location->fmax(); my $hsp = new Bio::SeqFeature::Generic( -strand => $strand, -start => $start, -end => $end ); $bioperl_alignment->add_SeqFeature($hsp, 'EXPAND'); } $bioperl_alignment->add_tag_value( 'hit_id', $chrom_primary_id ) if $chrom_primary_id; $self->bioperl_alignment( $bioperl_alignment ); }
}
_get_chromosomedescriptiontopprevnext
sub _get_chromosome {
   my ($self) = @_;

   $self->bioperl_alignment();  # need to call to assign feature to chromosome at the moment
# will eventually store in feature table but right now
# its all in teh subfeature table (as blast hits)
$self->SUPER::_get_chromosome();
}
_initdescriptiontopprevnext
sub _init {
   my ($self, @args) = @_;

   $self->throw_not_implemented();
}
alignment_typedescriptiontopprevnext
sub alignment_type {
   my ($self, @args) = @_;

   $self->throw_not_implemented();
}
bioperl_alignmentdescriptiontopprevnext
sub bioperl_alignment {
   my ($self, $obj) = @_;

  #
# fetches bioperl_alignment from database (_get_bioperl_alignment) if bioperl_alignment is not yet defined
# and the user is not attempting to set the bioperl_alignment
#
defined $self->{bioperl_alignment} || defined $obj || $self->_get_bioperl_alignment(); if(scalar @_ > 1) { use Data::Dumper; print STDERR "Got an alignment".Dumper( $obj ) if DEBUG; if ( $obj ) { $self->strand( $obj->strand() ); $self->{bioperl_alignment} = $obj; if ( $obj->has_tag('hit_id') ){ my $chrom = new Modware::Feature ( -primary_id => [$obj->get_tag_values('hit_id')]->[0] ); print "setting chromosome to ".$chrom->name()."\n" if DEBUG; $self->reference_feature( $chrom ); $self->reference_feature( $self->bioperl_alignment() ); } } else { $self->{bioperl_alignment} = new Bio::SeqFeature::Generic(); } } return $self->{bioperl_alignment};
}
blastdescriptiontopprevnext
sub blast {
   my ($self, @args) = @_;
   $self->throw_not_implemented();
}
enddescriptiontopprevnext
sub end {
   my ($self, $obj) = @_;


   return $self->bioperl_alignment() ? $self->bioperl_alignment() : undef;
}
insertdescriptiontopprevnext
sub insert {
   my ($self, @args) = @_;


   $self->SUPER::insert();
   $self->update_alignment() if $self->{'bioperl_alignment'};
   $self->_update_gene_association() if ( exists $self->{gene} );
   $self->_update_cached_sequence();
   $self->_insert_or_update_featureprop( 'translation_start', $self->phase() + 1  ) if $self->cached_sequences->{'Protein'};
}
lengthdescriptiontopprevnext
sub length {
   my ($self, $obj) = @_;

   return $self->bioperl_alignment() ? $self->bioperl_alignment() : undef;
}
match_typedescriptiontopprevnext
sub match_type {
   my ($self, $obj) = @_;
   if($obj) {
      $self->{match_type} = $obj;
   }
   return $self->{match_type};
}
newdescriptiontopprevnext
sub new {
   my ($type, @args) = @_;

  #
# do not bless it here, assume subclass will bless as a subclass type
#
my $self = {}; bless $self,$type; my @arglist = qw( BIOPERL SOURCE DESCRIPTION ); my ( $bioperl, $source, $description ) = $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;
}
startdescriptiontopprevnext
sub start {
   my ($self, $obj) = @_;

   return $self->bioperl_alignment() ? $self->bioperl_alignment() : undef;
}
updatedescriptiontopprevnext
sub update {
   my ($self, @args) = @_;

   $self->_update_cached_sequence()  if ( exists $self->{bioperl} );
   
   $self->SUPER::update();
   $self->update_alignment() if $self->{'bioperl_alignment'};
   $self->_update_gene_association() if ( exists $self->{gene} );
   $self->_insert_or_update_featureprop( 'translation_start', $self->phase() + 1  ) if $self->cached_sequences->{'Protein'};
}
update_alignmentdescriptiontopprevnext
sub update_alignment {
   my ($self, @args) = @_;

  #
# loop through stored exons (in database)
# for each one pop an exon off of the exon array and update that
# subfeature with that exon's coordinates.
#
# after this, if the exon array is empty, the remaining subfeatures need to be deleted
# if there are exons left, then they all need to be inserted.
#
my $hit_iterator = Chado::Feature->search( name => $self->primary_id().".match"); my $hit_feature; my @hsps = $self->bioperl_alignment(); if ( @hsps && $hit_iterator->count() == 0 ) { $hit_feature = new Modware::Feature( -type => $self->match_type(), -source => 'dictyBase', -reference_feature => $self->reference_feature(), -start => $self->bioperl_alignment(), -end => $self->bioperl_alignment() ); $hit_feature->insert(); $hit_feature->_database_object()->name( $self->primary_id().".match" ); $hit_feature->_database_object()->update(); } else { $hit_feature = new Modware::Feature( -feature_id => $hit_iterator->next()->feature_id() ); } my @subfeatures = $hit_feature->subfeatures(); my @stored_hits = grep{ $_->type_id->name eq 'match_part' } @subfeatures; if ( scalar @hsps == 0 && $hit_feature ) { $hit_feature->_database_object()->delete(); } elsif (scalar @hsps > 0){ $hit_feature->{_featureloc} = Chado::Featureloc->find_or_create( feature_id => $hit_feature->feature_id ); $hit_feature->_featureloc( $self->start() ); $hit_feature->_featureloc( $self->end() ); $hit_feature->_featureloc( $self->strand() ); $hit_feature->_featureloc( $self->reference_feature() ); $hit_feature->_featureloc(); } foreach my $stored_hit ( @stored_hits ) { $stored_hit->delete(); } foreach my $hsp ( @hsps ) { $hit_feature->_insert_subfeature( $hsp, 'match_part' ); }
}

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 _