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

Modware::Search

Gene

Summary Included libraries Package variables Synopsis Description General documentation Methods

Summary
   Modware::Search::Gene - collection of iterators that return iterators of Modware::Feature::GENE objects
Package variables top
No package variables defined.
Included modulestop
Data::Dumper
Modware::Constant
Modware::DBH
Modware::Gene
Modware::Iterator
Modware::Search::Feature
Inherit top
Modware::Search
Synopsistop
   #USE CASE: print gene name, reference feature name, start, and stop of genes whose name starts with 'test'
my @genes = Modware::Search::Gene->Search_all_by_name( 'test%' );

foreach my $gene (@genes) {
print $gene->gene_name()."\t".$gene->reference_feature->name()."\t".$gene->start()."\t".$gene->end()."\n";
}

#USE CASE: Use an iterator (better performance for large data sets) to print
# gene name, reference feature name, start, and stop of genes whose name starts with 't'
my $genes_itr = Modware::Search::Gene->Search_all_by_name( 't%' );

while ( my $gene - $genes_itr->next() ) {
print $gene->gene_name()."\t".$gene->reference_feature->name()."\t".$gene->start()."\t".$gene->end()."\n";
}
Descriptiontop
   Modules in the Modware::Search are all class methods.  These methods
return iterators or arrays of objects (depending on the context)
So Modware:::Search::Gene contains methods that return iterators or arrays of
Modware::Feature::GENE objects.
Methodstop
Count_all_genesDescriptionCode
Count_by_nameDescriptionCode
Count_by_name_and_synonymDescriptionCode
Count_by_synonymDescriptionCode
Search_all_by_nameDescriptionCode
Search_all_genesDescriptionCode
Search_by_nameDescriptionCode
Search_by_name_and_synonymDescriptionCode
Search_by_synonymDescriptionCode
Search_overlapping_by_rangeDescriptionCode
sth_to_iteratorDescriptionCode

Methods description

Count_all_genescodetopprevnext
 Title    : Count_all_genes
:
Function : finds count of all genes in database (including obsoleted genes)
Usage : to get count of all genes in database
: my $count = Modware::Search::Gene->Count_all_genes();
Returns : number
Args : none
Count_by_namecodetopprevnext
 Title    : Count_by_name
:
Function : finds count of genes whose names match optionally wildcarded query pattern
Note : CASE INSENSITIVE, * works as wildcard, Excludes DELETED genes
Usage : to get a count of features with a name like 'ABC%'
: my $count = Modware::Search::Gene->Count_by_name( 'ABC*' );
Returns : number
Args : optionally wildcared query string
Count_by_name_and_synonymcodetopprevnext
 Title    : Count_by_name_and_synonym
:
Function : finds cout of genes whose names or synonyms match optionally wildcarded query pattern
Note : CASE INSENSITIVE, * works as wildcard, Excludes DELETED genes
Usage : to get a count of features with a name like 'ABC%'
: my $count = Modware::Search::Gene->Count_by_name_and_synonym( 'ABC*' );
Returns : number
Args : optionally wildcared query string
Count_by_synonymcodetopprevnext
 Title    : Count_by_synonym
:
Function : finds count of genes whose synonyms match optionally wildcarded query pattern
Note : CASE INSENSITIVE, * works as wildcard
Usage : to get a count of genes with a synonym like 'ABC%'
: my $count = Modware::Search::Gene->Count_by_synonym( 'ABC*' );
Returns : number
Args : optionally wildcared query string
Search_all_by_namecodetopprevnext
 Title    : Search_all_by_name
:
Function : finds list of genes whose names match optionally wildcarded query pattern
Note : CASE INSENSITIVE, * works as wildcard, Includes DELETED genes
Usage : to get a genes of features with a name like 'ABC%'
: my $itr = Modware::Search::Gene->Search_all_by_name( 'ABC*' );
Returns : Iterator or array of Modware::Features (depending on context)
Args : optionally wildcared query string
Search_all_genescodetopprevnext
 Title    : Search_all_genes
:
Function : finds all genes in database (including obsoleted genes)
Usage : to get all genes in database
: my $itr = Modware::Search::Gene->Search_all_genes();
Returns : Iterator or array of Modware::Features (depending on context)
Args : none
Search_by_namecodetopprevnext
 Title    : Search_by_name
:
Function : finds list of genes whose names match optionally wildcarded query pattern
Note : CASE INSENSITIVE, * works as wildcard, Excludes DELETED genes
Usage : to get a list of genes with a name like 'ABC%'
: my $itr = Modware::Search::Gene->Search_by_name( 'ABC*' );
Returns : Iterator or array of Modware::Features (depending on context)
Args : optionally wildcared query string
Search_by_name_and_synonymcodetopprevnext
 Title    : Search_by_name_and_synonym
:
Function : finds list of genes whose names or synonym matches optionally wildcarded query pattern
Note : CASE INSENSITIVE, * works as wildcard, Excludes DELETED genes
Usage : to get a list of genes with a name like 'ABC%'
: my $itr = Modware::Search::Gene->Search_by_name_and_synonym( 'ABC*' );
Returns : Iterator or array of Modware::Features (depending on context)
Args : optionally wildcared query string
Search_by_synonymcodetopprevnext
 Title    : Search_by_synonym
:
Function : finds genes whose synonyms match optionally wildcarded query pattern
Note : CASE INSENSITIVE, * works as wildcard
Usage : to get a list genes with a synonym like 'ABC%'
: my $itr = Modware::Search::Gene->Search_by_synonym( 'ABC*' );
Returns : Iterator or array of Modware::Features (depending on context)
Args : optionally wildcared query string
Search_overlapping_by_rangecodetopprevnext
 Title    : Search_genes_by_position
Usage : Modware::Search::Gene->Search_enclosed_by_range( $reference_feature_name, $range_start, $range_end );
Function : returns all genes that lie fully between two coordinates on a given chromosome
Returns : nothing
Args : reference_feature_name, rang start, range end
sth_to_iteratorcodetopprevnext
 Title    : sth_to_iterator
:
Function : Given a statement handle pointing to feature_ids,
: create an iterator of Modware::Features containing
: the features identified by the feature_ids
:
Returns : an iterator of Features
Args : an active statement handle pointing to feature_ids

Methods code

Count_all_genesdescriptiontopprevnext
sub Count_all_genes {
    my ( $self, @args ) = @_;

    my $dbh    = new Modware::DBH;
    my $results;

    my $sth = $dbh->prepare( "
        SELECT COUNT(G.FEATURE_ID)
          FROM V_GENE_FEATURES G
   " );

    $sth->execute();
    $results = $sth->fetchrow();
    $sth->finish;

    return $results;
}
Count_by_namedescriptiontopprevnext
sub Count_by_name {
    my ( $self, $query ) = @_;

    $query =~ s/\*/\%/g;

    my $dbh    = new Modware::DBH;
    my $results;

    my $sth = $dbh->prepare( "
        SELECT COUNT(G.FEATURE_ID)
          FROM V_GENE_FEATURES G
         WHERE LOWER(G.NAME) LIKE LOWER(?)
   " );

    $sth->execute($query);
    $results = $sth->fetchrow();
    $sth->finish;

    return $results;
}
Count_by_name_and_synonymdescriptiontopprevnext
sub Count_by_name_and_synonym {
    my ( $self, $query ) = @_;
    my @results;
    $query =~ s/\*/\%/g;

    my $dbh    = new Modware::DBH;

    my $sth = $dbh->prepare( "
        SELECT COUNT(FEATURE_ID) 
          FROM (
                  SELECT DISTINCT F.FEATURE_ID, F.NAME
                    FROM V_GENE_FEATURES F
         LEFT OUTER JOIN FEATURE_SYNONYM FS
                      ON FS.FEATURE_ID = F.FEATURE_ID
         LEFT OUTER JOIN SYNONYM_ S
                      ON S.SYNONYM_ID = FS.SYNONYM_ID
         LEFT OUTER JOIN CVTERM T
                      ON S.TYPE_ID = T.CVTERM_ID
                     AND T.CV_ID = ?
                   WHERE UPPER(S.NAME) LIKE UPPER(?)
                      OR LOWER(F.NAME) LIKE LOWER(?)
                ORDER BY UPPER(F.NAME)
         )
   " );

    $sth->execute(  Modware::Constant->Null_cv_id(), $query, $query  );

    $results = $sth->fetchrow();
    $sth->finish;

    return $results;
}
Count_by_synonymdescriptiontopprevnext
sub Count_by_synonym {
    my ( $self, $query ) = @_;

    $query =~ s/\*/\%/g;

    my $dbh    = new Modware::DBH;
    my $results;

    my $sth = $dbh->prepare( "
        SELECT COUNT(DISTINCT FS.FEATURE_ID)
          FROM V_GENE_FEATURES F
    INNER JOIN FEATURE_SYNONYM FS
            ON FS.FEATURE_ID = F.FEATURE_ID
    INNER JOIN SYNONYM S
            ON S.SYNONYM_ID = FS.SYNONYM_ID
    INNER JOIN CVTERM T
            ON S.TYPE_ID = T.CVTERM_ID
           AND T.CV_ID = ?
         WHERE UPPER(S.NAME) LIKE UPPER(?)
   " );

    $sth->execute(  Modware::Constant->Null_cv_id(), $query  );
    $results = $sth->fetchrow();
    $sth->finish;

    return $results;
}
Search_all_by_namedescriptiontopprevnext
sub Search_all_by_name {
    my ( $self, $query ) = @_;

    $query =~ s/\*/\%/g;

    my $dbh    = new Modware::DBH;
    my @results;

    my $sth = $dbh->prepare( "
        SELECT G.FEATURE_ID
          FROM V_ALL_GENE_FEATURES G
         WHERE LOWER(G.NAME) LIKE LOWER(?)
      ORDER BY LOWER(G.NAME)
   " );

    $sth->execute($query);

    # Create iterator object from results
my $itr = $self->sth_to_iterator($sth); $sth->finish(); return wantarray ? $itr->to_array() : $itr;
}
Search_all_genesdescriptiontopprevnext
sub Search_all_genes {
    my ( $self, @args ) = @_;

    my $dbh    = new Modware::DBH;
    my @results;

    my $sth = $dbh->prepare( "
        SELECT G.FEATURE_ID
          FROM V_ALL_GENE_FEATURES G
   " );

    $sth->execute();

    # Create iterator object from results
my $itr = $self->sth_to_iterator($sth); $sth->finish(); return wantarray ? $itr->to_array() : $itr;
}
Search_by_namedescriptiontopprevnext
sub Search_by_name {
    my ( $self, $query ) = @_;

    $query =~ s/\*/\%/g;

    my $dbh    = new Modware::DBH;
    my @results;

    my $sth = $dbh->prepare( "
        SELECT G.FEATURE_ID
          FROM V_GENE_FEATURES G
         WHERE LOWER(G.NAME) LIKE LOWER(?)
      ORDER BY LOWER(G.NAME)
   " );

    $sth->execute($query);

    # Create iterator object from results
my $itr = $self->sth_to_iterator($sth); $sth->finish(); return wantarray ? $itr->to_array() : $itr;
}
Search_by_name_and_synonymdescriptiontopprevnext
sub Search_by_name_and_synonym {
    my ( $self, $query ) = @_;
    my @results;
    $query =~ s/\*/\%/g;

    my $dbh    = new Modware::DBH;

    my $sth = $dbh->prepare( "
        SELECT FEATURE_ID 
          FROM (
                  SELECT DISTINCT F.FEATURE_ID, F.NAME
                    FROM V_GENE_FEATURES F
         LEFT OUTER JOIN FEATURE_SYNONYM FS
                      ON FS.FEATURE_ID = F.FEATURE_ID
         LEFT OUTER JOIN SYNONYM_ S
                      ON S.SYNONYM_ID = FS.SYNONYM_ID
         LEFT OUTER JOIN CVTERM T
                      ON S.TYPE_ID = T.CVTERM_ID
                     AND T.CV_ID = ?
                   WHERE UPPER(S.NAME) LIKE UPPER(?)
                      OR LOWER(F.NAME) LIKE LOWER(?)
                ORDER BY UPPER(F.NAME)
         )
   " );

    $sth->execute(  Modware::Constant->Null_cv_id(), $query, $query  );

    # Create iterator object from results
my $itr = $self->sth_to_iterator($sth); $sth->finish(); return wantarray ? $itr->to_array() : $itr;
}
Search_by_synonymdescriptiontopprevnext
sub Search_by_synonym {
    my ( $self, $query ) = @_;

    $query =~ s/\*/\%/g;

    my $dbh    = new Modware::DBH;
    my @results;

    my $sth = $dbh->prepare( "
        SELECT DISTINCT FS.FEATURE_ID
          FROM V_GENE_FEATURES F
    INNER JOIN FEATURE_SYNONYM FS
            ON FS.FEATURE_ID = F.FEATURE_ID
    INNER JOIN SYNONYM S
            ON S.SYNONYM_ID = FS.SYNONYM_ID
    INNER JOIN CVTERM T
            ON S.TYPE_ID = T.CVTERM_ID
           AND T.CV_ID = ?
         WHERE UPPER(S.NAME) LIKE UPPER(?)
   " );

    $sth->execute(  Modware::Constant->Null_cv_id(), $query  );

    # Create iterator object from results
my $itr = $self->sth_to_iterator($sth); $sth->finish(); return wantarray ? $itr->to_array() : $itr;
}
Search_overlapping_by_rangedescriptiontopprevnext
sub Search_overlapping_by_range {
    my ( $self, $reference_feature_name, $range_start, $range_end ) = @_;

    return Modware::Search::Feature->Search_overlapping_feats_by_range(
        $reference_feature_name, $range_start, $range_end, 'gene' );
}
sth_to_iteratordescriptiontopprevnext
sub sth_to_iterator {
    my ( $self, $sth ) = @_;

    my @data;
    while ( my $row = $sth->fetchrow() ) {
        push( @data, { -feature_id => $row } );
    }

    my $itr = new Modware::Iterator(
        -CLASS => "Modware::Feature",
        -DATA  =>\@ data
    );

    return $itr;
}

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 _