Skip to content
Snippets Groups Projects
Commit af947b10 authored by Alessandro Vullo's avatar Alessandro Vullo
Browse files

[ENSCORESW-777]. Added GeneAdaptor support for fetching genes by source(s).

parent 0c2da0a1
No related branches found
No related tags found
No related merge requests found
......@@ -251,6 +251,55 @@ sub fetch_by_stable_id {
return $gene;
}
=head2 fetch_all_by_source
Arg [1] : String $source
listref of $sources
The source of the gene to retrieve. You can have as an argument a reference
to a list of sources
Example : $genes = $gene_adaptor->fetch_all_by_source('havana');
$genes = $gene_adaptor->fetch_all_by_source(['ensembl', 'vega']);
Description: Retrieves an array reference of gene objects from the database via its source or sources.
The gene will be retrieved in its native coordinate system (i.e.
in the coordinate system it is stored in the database). It may
be converted to a different coordinate system through a call to
transform() or transfer(). If the gene or exon is not found
undef is returned instead.
Returntype : listref of Bio::EnsEMBL::Gene
Exceptions : if we cant get the gene in given coord system
Caller : general
Status : Stable
=cut
sub fetch_all_by_source {
my ($self, $source) = @_;
my @genes = @{$self->generic_fetch($self->source_constraint($source))};
return \@genes;
}
=head2 source_constraint
Arg [1] : String $source
listref of $sources
The source of the gene to retrieve. You can have as an argument a reference
to a list of sources
Description: Used internally to generate a SQL constraint to restrict a transcript query by source
Returntype : String
Exceptions : If source is not supplied
Caller : general
Status : Stable
=cut
sub source_constraint {
my ($self, $sources, $inline_variables) = @_;
my $constraint = "g.is_current = 1";
my $in_statement = $self->generate_in_constraint($sources, 'g.source', SQL_VARCHAR, $inline_variables);
$constraint .= " and $in_statement";
return $constraint;
}
=head2 fetch_all_by_biotype
Arg [1] : String $biotype
......
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment