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

Modware::Feature

GENE

Summary Included libraries Package variables Synopsis Description General documentation Methods

Summary
   Modware::Feature::GENE - Modware representation of a gene
Package variables top
No package variables defined.
Included modulestop
Modware::Feature
Modware::Root
Inherit top
Modware::Feature
Synopsistop
 # USE CASE: PRINT A LIST OF FEATURES ASSOCIATED WITH THIS GENE

my $gene = new Modware::Gene( -gene_name => 'test_CURATED' );

foreach $feature ( @{ $gene->features() } ) {
print $feature->primary_id()."\n";
}
Descriptiontop
  This object attempts to group together all information about a gene
Most of this information is returned as references to arrays of other objects. For example
the features array is one such association.

The features method returns all non-deleted features which are associated with this gene.
Methodstop
_database_objectDescriptionCode
_get_featuresDescriptionCode
_initDescriptionCode
_insert_featureDescriptionCode
_update_featureDescriptionCode
deleted_featuresDescriptionCode
endDescriptionCode
featuresDescriptionCode
gene_nameDescriptionCode
insertDescriptionCode
insert_or_updateNo descriptionCode
nameDescriptionCode
name_descriptionDescriptionCode
newNo descriptionCode
reference_featureDescriptionCode
startDescriptionCode
strandDescriptionCode
updateDescriptionCode

Methods description

_database_objectcodetopprevnext
 Title    : _database_object
Usage : my $ids = $self->_database_object($database_object);
Function : gets/sets the Chado::Feature object
used to read/write from the database
Returns : Chado::Feature object
Args : optional: reference to a Chado::Feature object
_get_featurescodetopprevnext
 Title    : _get_features
Usage : $gene->_get_features();
Function : gets the features array for this gene (called from features)
Returns : nothing
Args : none
_initcodetopprevnext
 Title    : _init
Note : sets attributes specific to gene
Usage : called internally by new
Function :
Returns : nothing
Args : none
_insert_featurecodetopprevnext
 Title    : _insert_feature
Function : put gene_name into name field. Uniquename
: is a special identifier which is usually equal to the gene_name
: unless the gene_name is a primary_id. THen its not globally unique
: so make it unique by prepending 'Gene:' to the front.
Returns : nothing
Args : none
_update_featurecodetopprevnext
 Title    : _update_feature
Function : put gene_name into name field. Uniquename
: is a special identifier which is usually equal to the gene_name
: unless the gene_name is a primary_id. THen its not globally unique
: so make it unique by prepending Gene: to the front.
Returns : nothing
Args : none
deleted_featurescodetopprevnext
 Title    : deleted_features
Note : Read only, cannot set
Usage : To print the primary_id of all deleted features associated with this feature
: print map { print $_->primary_id()."\n" } @{ $self->deleted_features() };
Function : gets the deleted features array of the gene
Returns : string
Args : optional: features object
endcodetopprevnext
 Title    : end
Usage : $gene->end();
Function : gets hightest coord from primary feature(s)
Returns : nothing
Args : none
NOTE : CANNOT SET -- COMPLETELY DERIVED
featurescodetopprevnext
 Title    : features
Note : Fetches the features array associated with this gene
: This is lazy evaluated so as to avoid an infinite loop
: of creating a gene which gets its features which gets its gene
: which gets its features .....
: May make feature and genes singletons, then use circular refs and 'weaken'
Usage : To print the primary_id of all features associated with this feature
: print map { print $_->primary_id()."\n" } @{ $self->features() };
Function : gets/sets the features array of the gene
Returns : string
Args : optional: features object
gene_namecodetopprevnext
 Title    : gene_name
Usage : print $gene->gene_name()
Function : returns gene name
Returns : string
Args : string ( optional )
Note : will possibly be deprecated in favor of more generic 'name' method
insertcodetopprevnext
 Title    : insert
Usage : $gene->insert();
Function : writes data in object to the database;
Returns : nothing
Args : none
namecodetopprevnext
 Title    : name
Usage : $self->name( $some_name );
: or
: print $self->name();
Function : gets/sets name
Returns : name string
Args : name ( optional )
name_descriptioncodetopprevnext
 Title    : name_description
Note : Brief description of gene name origin
Usage : $self->name_description( 'Strctural maintenance of Chromosome 1' );
: or
: print $self->name_description();
Function : gets/sets the name_description attribute of the feature
Returns : string
Args : optional: name_description string
reference_featurecodetopprevnext
 Title    : reference_feature
Usage : $gene->reference_feature();
Function : returns the reference featyre of the primary feature
Returns : contig or chromosome object
Args : none
NOTE : CANNOT SET -- COMPLETELY DERIVED
startcodetopprevnext
 Title    : start
Usage : $gene->start();
Function : gets lowest start coord from primary feature(s)
Note : this method relies on the fact that the primary features array
: is sorted by absolute start position
Returns : nothing
Args : none
NOTE : CANNOT SET -- COMPLETELY DERIVED
strandcodetopprevnext
 Title    : strand
Usage : $gene->strand();
Function : gets strand from primary feature(s)
Returns : nothing
Args : none
NOTE : CANNOT SET -- COMPLETELY DERIVED
updatecodetopprevnext
 Title    : update
Usage : $gene->update();
Function : writes data in object to the database;
: CURRENTLY ONLY UPDATES THE LOCUS TABLE !!!!
Returns : nothing
Args : none

Methods code

_database_objectdescriptiontopprevnext
sub _database_object {
   my ($self, $obj) = @_;
   if($obj) {
      $self->{_database_object} = $obj;
   }
   return $self->{_database_object};
}
_get_featuresdescriptiontopprevnext
sub _get_features {
   my ($self) = @_;

   my @feature_rows =  $self->_relationship_subjects( 'part_of' );

  #
# grep is necessary because we return undef for features with no adapter yet
#
my @features = grep {$_} map { new Modware::Feature( -feature_id => $_->feature_id ) } @feature_rows; my @live_features = grep { !$_->is_deleted } @features; my @dead_features = grep { $_->is_deleted } @features; $self->features(\@live_features); $self->deleted_features(\@dead_features);
}
_initdescriptiontopprevnext
sub _init {
   my ($self, @args) = @_;

   delete $self->{primary_id};

  #
# if its coming from the database, set certain properties from the database
#
if ( $self->_database_object ) { $self->gene_name( $self->_database_object->name ); }
}
_insert_featuredescriptiontopprevnext
sub _insert_feature {
   my ($self, @args) = @_;

   my ($cvterm) = Chado::Cvterm->get_single_row(
      cv_id => Modware::Constant->Sequence_ontology_id(),
      name  => $self->type
   );

   $self->throw( "cannot insert a feature with out a valid SO type.") if !$cvterm;

   my $type_id    = $cvterm->cvterm_id;

   my $feautre_row = Chado::Feature->create({
     organism_id => Modware::Constant->Organism_id(),
     dbxref_id   => undef,
     name        => $self->name(),
     uniquename  => $self->name(),
     type_id     => $type_id,
     is_obsolete => $self->is_deleted() || 0
   });

   $self->feature_id( $feautre_row->feature_id );
}
_update_featuredescriptiontopprevnext
sub _update_feature {
   my ($self, @args) = @_;

   $self->_database_object( $self->is_deleted() );
   $self->_database_object( $self->gene_name );
   $self->_database_object( $self->gene_name() );

   $self->_database_object();
}
deleted_featuresdescriptiontopprevnext
sub deleted_features {
   my ($self, $obj) = @_;

   exists $self->{deleted_features} || scalar @_ > 1 || $self->_get_features();

   if(scalar @_ > 1) {
      $self->{deleted_features} = $obj;
   }
   return $self->{deleted_features};
}
enddescriptiontopprevnext
sub end {
   my ($self) = @_;

   if ( @{$self->features()} ) {
      my @features = @{ $self->features() };

      if ( $features[0]->start() ) {
         @features    = sort{ $b->end() <=> $a->end() } @features;
         return $features[0]->end();
      }
      return undef;
   }
   return undef;
}
featuresdescriptiontopprevnext
sub features {
   my ($self, $obj) = @_;

  #
# fetches features from database (_get_features) if features is not yet defined
# and the user is not attempting to set the features
#
exists $self->{features} || scalar @_ > 1 || $self->_get_features(); if(scalar @_ > 1) { $self->{features} = $obj; } return $self->{features};
}
gene_namedescriptiontopprevnext
sub gene_name {
   my ($self, $obj) = @_;
   #warn "gene_name method in Modware::Feature::GENE is deprecated, use name instead\n";
return scalar @_ > 1 ? $self->name( $obj ) : $self->name();
}
insertdescriptiontopprevnext
sub insert {
   my ($self) = @_;

   $self->SUPER::insert();
}
insert_or_updatedescriptiontopprevnext
sub insert_or_update {
   my ($self) = @_;

   $self->feature_id ? $self->update() : $self->insert();
}
namedescriptiontopprevnext
sub name {
   my ($self, $obj) = @_;
   if($obj) {
      $self->{name} = $obj;
   }
   return $self->{name};
}
name_descriptiondescriptiontopprevnext
sub name_description {
   my ($self, $obj) = @_;
  #
# fetches name_description from database (_get_name_description) if name_description is not yet defined
# and the user is not attempting to set the name_description options
#
exists $self->{name_description} || scalar @_ > 1 || $self->name_description( $self->_get_featureprop( 'name description' ) ); if(scalar @_ > 1) { $self->{name_description} = $obj; } return $self->{name_description};
}
newdescriptiontopprevnext
sub new {
   my ($type, @args) = @_;

   my $self = {};
   bless $self,$type;

   my @arglist = qw(
     GENE_NAME DESCRIPTION SOURCE NAME_DESCRIPTION NAME
   );

   my (
      $gene_name, $description, $source, $name_description, $name
    )   = $self->_rearrange( [@arglist], @args );


  #
# Default source to dictyBase curator
#
$source ||= 'Curator'; if ( $gene_name ) { warn "-gene_name argument to gene constructor is deprecated, please use -name instead\n"; $name = $gene_name; } $self->source ( $source ) if defined $source; $self->type ( 'gene' ); $self->description ( $description ) if defined $description; $self->gene_name ( $name ) if defined $name; $self->name_desciption ( $name_description ) if defined $name_description; $self->qualifiers( [] ); $self->_init(); return $self;
}
reference_featuredescriptiontopprevnext
sub reference_feature {
   my ($self) = @_;

   if ( @{$self->features()} ) {
      my @features = @{ $self->features() };

      if ( $features[0]->reference_feature() ) {
         return $features[0]->reference_feature();
      }
      return undef;
   }
   return undef;
}
startdescriptiontopprevnext
sub start {
   my ($self) = @_;

   if ( @{$self->features()} ) {
      my @features = @{ $self->features() };

      if ( $features[0]->start() ) {
         @features    = sort{ $a->start() <=> $b->start() } @features;
         return $features[0]->start();
      }
      return undef;
   }
   return undef;
}
stranddescriptiontopprevnext
sub strand {
   my ($self) = @_;

   if ( @{$self->features()} ) {
      my @features = @{ $self->features() };

      if ( $features[0]->start() ) {
         return $features[0]->strand();
      }
      return undef;
   }
   return undef;
}
updatedescriptiontopprevnext
sub update {
   my ($self) = @_;

   $self->SUPER::update();

   if ( exists $self->{features} ) {
      $self->_update_featureloc();
   }
   $self->_insert_or_update_featureprop( 'name description', $self->name_description() ) if exists $self->{name_description};
}

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 _