[BioSQL-l] namespace and find_by_unique_key
Hilmar Lapp
hlapp at gnf.org
Thu May 6 20:20:41 EDT 2004
You mean when querying for a sequence? It should absolutely be taken
into account. Here is the code in
PrimarySeqAdaptor::get_unique_key_query (SeqAdaptor.pm inherits from
it), with comments inserted.
my $ns;
# if the seq object has a namespace set, look it up
if($obj->namespace()) {
$ns = Bio::BioEntry->new(-namespace => $obj->namespace());
$ns = $self->_bionamespace_adaptor()->find_by_unique_key($ns);
}
# If the seq object has primary_id() defined, add it first as a unique
key query.
if($obj->primary_id() && ($obj->primary_id() !~
/=(HASH|ARRAY)\(0x/)) {
my $uk_h = { 'primary_id' => $obj->primary_id(), };
# include the namespace only if it was present (and found by lookup)
$uk_h->{'bionamespace'} = $ns->primary_key() if $ns;
push(@ukqueries, $uk_h);
}
# If accession# is defined, add it together with version to the unique
key queries
if($obj->accession_number()) {
my $uk_h = {
'accession_number' => $obj->accession_number(),
'version' => ($obj->version() || 0),
};
# again, namespace only if it was present and found by lookup
$uk_h->{'bionamespace'} = $ns->primary_key() if $ns;
push(@ukqueries, $uk_h);
}
return @ukqueries;
The inherited find_by_unique_key() will try as many queries as are in
the returned array, in this case 1 or 2 (unless neither accession# nor
primary_id are defined). If the namespace was not set, or was set but
failed to look up successfully, it won't be included in either query.
The algorithm stops after the first successful query; i.e., if the
array contains two queries and the query by primary_id() is successful,
the query by accession# and version is disregarded.
If the namespace was set and is present in the database, but is not
included in the generated unique key query, that's a bug. Otherwise
it's a feature ;)
Are you sure it's not included in the generated query when it should
be? I.e., have you turned on debugging mode and looked at the generated
query and what is being bound? If you're unsure where to look then send
me the output with debugging activated (call $db->verbose(1) before you
obtain any persistence adaptor).
-hilmar
On Thursday, May 6, 2004, at 03:13 PM, Marc Logghe wrote:
> Hi,
> Is there a way to query a *specific* namespace using the
> find_by_unique_key() method ?
> It looks like when you set the namespace attribute in the query seq
> object it is never taken into account; only the accession and version
> are.
> Is this a feature/bug , or rather am I missing something ?
> Thanks,
> ML
>
> _______________________________________________
> BioSQL-l mailing list
> BioSQL-l at open-bio.org
> http://open-bio.org/mailman/listinfo/biosql-l
>
--
-------------------------------------------------------------
Hilmar Lapp email: lapp at gnf.org
GNF, San Diego, Ca. 92121 phone: +1-858-812-1757
-------------------------------------------------------------
More information about the BioSQL-l
mailing list