[BioSQL-l] Bug in loading duplicate but non-identical swissprot references

Hilmar Lapp hlapp at gnf.org
Mon Apr 21 01:35:07 EDT 2003


On Monday, April 21, 2003, at 12:09  AM, Elia Stupka wrote:

>> No it doesn't and it certainly shouldn't do so automatically. If you 
>> want that to happen for your application, just call store() on the 
>> reference. Is that not possible?
>
> See my test code, I am calling store twice.

There is some confusion of things which I guess are my fault because I 
tried to let things appear overly simple.

	# creates an object that can potentially be serialized to the database,
	# but that isn't yet
	$pobj = $db->create_persistent($obj);
	# $pobj->primary_key() has no value yet - even if the object exists
	# in the database

	# create() is equivalent to an INSERT - the naming is borrowed
	# from EJB.
	# create() will never update.
	# If the INSERT fails, create() will attempt a lookup and return the
	# result of the lookup (find_by_unique_key). If the adaptor is in
	# caching mode, create() will lookup prior to any insert (because then
	# the lookup will go to the cache first).
	# After return, $pobj->primary_key must have a value or there was an
	# error.
	$pobj = $pobj->create();

	# store() is equivalent to an UPDATE. If called on an object with
	# undefined primary_key it is equivalent to calling create() - and
	# then does NOT update.
	$pobj->store();


>  The first time it stores the reference, the second time it stores the 
> medline dbxref, but does not update the reference dbxref column.

Which, given the above explanations, is the correct behaviour: since 
you create the object fresh, primary key is undefined and hence store() 
equates to create().

If you add $pref->store() after the second $pref->store() (which, to 
avoid confusion, should really read $pref->create()), it will update 
the dbxref column.

$ref = Bio::Annotation::Reference->new(
     -title => 'title',
     -location => 'location',
	                                            -authors => 'author',
	-medline => 900103

                                            );
$pref = $db->create_persistent($ref);
$pref->create();
$pref->store();

BTW you do not need the first commit (and neither the second if you 
just go by verbose output).

>
> By the way this is not any special application, I am just trying to 
> get load_seqdatabase.pl to work with a whole swissprot file ;)
>

If it is able to correctly locate the entry, it will work with the 
swissprot file, irregardless of whether it updated the dbxref column or 
not. For the case at hand you may know that the medline ID is the 
"correct" value, but this is not necessarily the case in general.

BTW your test output did indicate another (harmless) bug which I just 
fixed.

	-hilmar


> Elia
>
> ---
> Bioinformatics Program Manager
> Temasek Life Sciences Laboratory
> 1, Research Link
> Singapore 117604
> Tel. +65 6874 4945
> Fax. +65 6872 7007
>
>
-- 
-------------------------------------------------------------
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