[BioSQL-l] Re: update seqfeature
Simon Foote
simon.foote at nrc-cnrc.gc.ca
Wed Jun 22 09:15:54 EDT 2005
I get the problem now, that would then be a bug in biojava. It should
do an internal check to see if a source/type term change will cause a
non-unique exception and if so, then also update the rank to the next
available one. One solution would be to catch the exception then do a
select for the max(rank) for the given bioentry_id, source_term_id,
type_term_id and then increment it by one.
In fact, it would probably be wise to always update the rank when
changing either the source or type term, so that the ranks stay
incrementally consistent, if that really matters.
Simon
Martina wrote:
> Hi Simon,
>
> sorry, I might haven't made that clear enough:
> The problem only exists with changing a feature source (or type, but I
> didn't try that) because of the composite unique index in biosql
> seqfeature table, it doesn't check if the location is the same or not,
> but the combination of type, source, bioentry id and rank has to be
> unique. So if I insert a new feature, the rank gets increased by
> BioJava somehow and all is well, but if I update an existing features
> source and hit by accident the same combination as anothers fetures
> type, source, .. I get the exception and the source doesn't change.
> At least that is what I suppose is happening.
>
> My question was how to handle this situation?
>
> Martina
>
>
> Simon Foote wrote:
>
>> Hi Martina,
>>
>> Biojava should handle that correctly. I haven't done it by changing
>> a feature source, but I have with changing a feature's location and
>> strand. For changing a location:
>>
>> // Get the Feature you wish to edit
>> StrandedFeature sf = ex. use a feature filter to grab the feature by
>> it's ID
>> Location loc = new Location(100, 1100);
>> sf.setLocation(loc);
>>
>> Since you have already retrieved the feature to edit, biojava will
>> automatically do this as an update and not an insert. Or it should
>> in all cases where you are modifying a pre-existing feature.
>>
--
Bioinformatics Programmer
Pathogen Genomics
Institute for Biological Sciences
National Research Council of Canada
[T] 613-990-0561 [F] 613-952-9092
simon.foote at nrc-cnrc.gc.ca
More information about the BioSQL-l
mailing list