[Bioperl-l] rank in bioperl-db PersistentObjectI

Hilmar Lapp hlapp at gnf.org
Fri Jun 6 15:13:30 EDT 2003



> -----Original Message-----
> From: Michael Thon [mailto:mrthon at unity.ncsu.edu] 
> Sent: Friday, June 06, 2003 11:33 AM
> To: bioperl-l at portal.open-bio.org
> Subject: [Bioperl-l] rank in bioperl-db PersistentObjectI
> 
> 
> I've been getting an 'Use of uninitialized value in numeric 
> gt (>) at...' error

Note that this not an error. It's a warning only. You may be safe to
ignore it, because the rank should be set by the adaptor before update
or insert for those objects that do not have it set, and because at the
specific position in the code comparing to undef just evaluates to false
and does no harm.

I'm saying 'may be' instead of 'are' because for some annotation
associations the rank is part of the unique (or primary) key, namely for
bioentry-reference and bioentry-qualifier. So, if you had a reference
twice for a bioentry (with ranks 1 and 2), and merging in your
annotation loses the ranks and flips the order, the order will not be
updated in the database.

> in a script that I'm writing to load 
> annotations into Bio::Seq objects that already exist in a 
> bioperl-db database.  The error is coming from the line:
>         foreach (@anns) { $r = $_->rank if $_->rank > $r; } 
> from the file: bioperl-db/scripts/biosql/merge-unique-ann.pl
> 
> Actually, I copied this subroutine into a custom script that 
> I'm writing to move data from another db into a bioperl-db.  
> I think the problem is that some previously loaded 
> annotations have no rank and $r is being set to undef sometimes

This should not happen. $r is initialized to 1, so it can only be
modified in the loop if a rank is at least bigger than 1. (undef >
$value) is always false, regardless of $value.

If the warning bothers you, change the condition to

	.... if defined($_->rank) && ($_->rank > $r); }


> I could modify the subroutine or I could ensure that all of 
> my annotations have a rank before they are inserted into the 
> database.

The only situation in which you need to worry about this is when you
absolutely want to preserve an existing order, or if you need to make
sure an existing association of the participating objects is properly
updated if there is more than 1 association of those objects (e.g., same
bioentry with different reference is a different association, regardless
of rank).

>  I'm not sure what rank is used for at this point 
> so I'm not sure if can safely ignore it and remove all 
> assignment of rank in all of my annotations

Rank really is sort of an artifact from biosql being a relational schema
because 1-n or n-n associations don't preserve order, unlike an array in
a programming language. I've tried to hide rank from people who don't
want to be bothered with it, so it is introduced by the
PersistentObjectI wrapper implementation. You can always access it and
set it on a persistent object, but the Bioperl objects themselves do not
(and should not) know about those ranks.

Hope this helps,

	-hilmar
> 
> _______________________________________________
> Bioperl-l mailing list
> Bioperl-l at portal.open-bio.org 
> http://portal.open-> bio.org/mailman/listinfo/bioperl-l
> 



More information about the Bioperl-l mailing list