[ensembl-dev] searching for genes by description field?
ian Longden
ianlongden at gmail.com
Wed Feb 13 11:15:31 GMT 2013
The problem with this method (it works fine though) is that it needs to get
all the genes which will take up a lot of memory.
An alternative way of doing this is to use the db connection itself and use
this to query the database directly only getting those genes you want..
Here is an example:-
-----------------------------------------------------------------------------------------------------------------
use Bio::EnsEMBL::Registry;
use Bio::SeqIO;
use strict;
my $reg = "Bio::EnsEMBL::Registry";
my $species = "human";
my $search_str = "%breast cancer%";
$reg->load_registry_from_db(
-host => 'ensembldb.ensembl.org',
-user => 'anonymous');
my $core_ga = $reg->get_adaptor($species,"core","gene");
my $sql = 'Select gene_id from gene where description like ?';
my $sth = $core_ga->dbc->prepare($sql) || die "Could not prepare $sql for
core database";
$sth->execute($search_str) or croak( $core_ga->dbc->errstr() );
while (my $gene_id = $sth->fetchrow_array()){
my $gene = $core_ga->fetch_by_dbID($gene_id);
print $gene->stable_id."\t".$gene->description."\n";
}
-----------------------------------------------------------------------------------------------------------------
On Wed, Feb 13, 2013 at 11:09 AM, Adam Witney <awitney at sgul.ac.uk> wrote:
>
> Thanks Andy, in the meantime, I just realised, of course I can just do
> this:
>
> my $genes = $dba->get_GeneAdaptor()->**fetch_all();
>
> foreach my $gene ( @{$genes} ) {
> if ( $gene->description && $gene->description =~ m/$string/ ) {
> # do stuff
> }
> }
>
> Thanks again
>
> Adam
>
>
> On 13/02/2013 10:30, Andy Yates wrote:
>
>> Hi Adam,
>>
>> Currently we do not support this. The actual code which implements this
>> search is in the DBEntryAdaptor and would require edits in there. I can see
>> a point in having this kind of functionality so we will put it on our to-do
>> list.
>>
>> Andy
>>
>> On 13 Feb 2013, at 10:24, Adam Witney <awitney at sgul.ac.uk> wrote:
>>
>>
>>> Hi,
>>>
>>> Is there a method to search the Gene description field. I am currently
>>> using fetch_all_by_external_name, but this only works if the gene has been
>>> annotated with gyrA:
>>>
>>> my $genes = $dba->get_GeneAdaptor()->**fetch_all_by_external_name('**
>>> gyrA');
>>>
>>> What I would like to be able to do is search the data returned by the
>>> description method ($gene->description), is this possible? eg something
>>> like this:
>>>
>>> my $genes = $dba->get_GeneAdaptor()->**fetch_all_by_description('%**
>>> gyrase%');
>>>
>>> Thanks
>>>
>>> Adam
>>>
>>> ______________________________**_________________
>>> Dev mailing list Dev at ensembl.org
>>> Posting guidelines and subscribe/unsubscribe info:
>>> http://lists.ensembl.org/**mailman/listinfo/dev<http://lists.ensembl.org/mailman/listinfo/dev>
>>> Ensembl Blog: http://www.ensembl.info/
>>>
>>
>>
>> ______________________________**_________________
>> Dev mailing list Dev at ensembl.org
>> Posting guidelines and subscribe/unsubscribe info:
>> http://lists.ensembl.org/**mailman/listinfo/dev<http://lists.ensembl.org/mailman/listinfo/dev>
>> Ensembl Blog: http://www.ensembl.info/
>>
>>
> ______________________________**_________________
> Dev mailing list Dev at ensembl.org
> Posting guidelines and subscribe/unsubscribe info:
> http://lists.ensembl.org/**mailman/listinfo/dev<http://lists.ensembl.org/mailman/listinfo/dev>
> Ensembl Blog: http://www.ensembl.info/
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.ensembl.org/pipermail/dev_ensembl.org/attachments/20130213/1ba1799c/attachment.html>
More information about the Dev
mailing list