These documents are For the HEAD of the CVS repository on July 19, 2007
Api docs for previous releases
Modware::Search
Gene
Modware::Search::Gene - collection of iterators that return iterators of Modware::Feature::GENE objects
|
No package variables defined. |
#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"; }
|
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.
|
Methods description
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
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
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
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
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
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
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
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
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
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
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
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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;
}
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' );
}
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
Copyright © 2006, Northwestern University
All rights reserved.
|
|