Dear All,
Tim is right. It was never allowed to have duplicate links between two
objects, but I had forgotten that if you did e.g.
myShift.peaks = list_of_peaks
I had to check whether list_of_peaks contained duplicates. We do check
now, but some old files do not conform to the rules.
The problem is that this could occur anywhere (in theory), and that is
technically difficult to fix in the standard backwards compatibility
code. We could set the API so that it automatically removed duplicates and
did not complain, but that would mean that you could set a link to a list
of five peaks and have only four of them remain, without warning or
explanation.
In the meantime, any time you get an error of the type
'somePackage.someClass.someRole list may not contain duplicates'
You should change the code
if values.count(value) != 1:
raise ApiError('somePackage.someClass.someRole list may not
contain duplicates')
to
while values.count(value) > 1:
values.remove(value)
This will remove the illegal duplicates. Once you have done that and saved
your data files you can remove the fix from the API code.
Yours,
Rasmsu
---------------------------------------------------------------------------
Dr. Rasmus H. Fogh Email: [log in to unmask]
Dept. of Biochemistry, University of Cambridge,
80 Tennis Court Road, Cambridge CB2 1GA, UK. FAX (01223)766002
On Thu, 2 Sep 2004, Tim Stevens wrote:
> > setattr(obj,tag,targets)
> > File "/usr/progs/ccpnmr/ccpnmr1.0/python/ccp/api/Nmr.py", line 2536, in
> > setPeaks
> > raise ApiError('ccp.Nmr.AbstractMeasurement.peaks list may not contain
> > duplicates')
> > memops.general.Implementation.ApiError: ccp.Nmr.AbstractMeasurement.peaks list
> > may not contain duplicates
> >
> > what's that all about then?
>
> More constraints/rules have been put into the data model. This constraint
> wasn't followed in the past, so a compatibility problem arises. A backward
> compatibility fix is needed. Rasmus?
>
>
> In the mean time the following should work:
>
> In $CCPN_HOME/python/ccp/api/Nmr.py, near line 2536 change
>
> if values.count(value) != 1:
> raise ApiError('ccp.Nmr.AbstractMeasurement.peaks list may not contain duplicates')
>
> to
>
> while values.count(value) > 1:
> values.remove(value)
> #raise ApiError('ccp.Nmr.AbstractMeasurement.peaks list may not contain duplicates')
>
> If you like you can restore Nmr.py to its previous state after you've
> loaded and saved your project.
>
>
> Tim
>
> -------------------------------------------------------------------------------
> Dr Tim Stevens Email: [log in to unmask]
> Department of Biochemistry [log in to unmask]
> University of Cambridge Phone: +44 1223 766022 (office)
> 80 Tennis Court Road +44 7816 338275 (mobile)
> Old Addenbrooke's Site +44 1223 364613 (home)
> Cambridge CB2 1GA WWWeb: http://www.bio.cam.ac.uk/~tjs23
> United Kingdom http://www.pantonia.co.uk
> -------------------------------------------------------------------------------
> ------ +NH3CH(CH(CH3)OH)C(O)NHCH(CH(CH3)CH2CH3)C(O)NHCH(CH2CH2SCH3)CO2- -------
> -------------------------------------------------------------------------------
>
|