Print

Print


Dear Magnus,

Merging any kind of objects is a very difficult job. The thing is that all
objects have unique identifiers, and that a lot of links are unchangeable
in the API. In short there is no legal way in the API to change e.g. a
link from a shift to a Resonance to point to another Resonance.

In theory you could do it by making new copies of lots of objects and then
removing the originals. Which would be a pain. In practice we are
bypassing the API and its protections, using the
ccpnmr/analysis/MergeObjects.mergeObjects. That is done by hand and quite
likely it is not present in C.

Wayne (back next week) is the person to answer about the C API. There
might be different wways to override teh API protections in the new
version coming up (we have an 'override' attribute), but Wayne should have
a look at it.

Yours,

Rasmus

---------------------------------------------------------------------------
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, 19 Jul 2007, Magnus Lundborg wrote:

> Hello,
>
> I'm having problems merging two resonances using the C Api. Both
> resonances are linked to the same atom. I have tried looking at the
> mergeResonances (...) function in the Python Api, but the problem is
> that I don't think mergeObjects (...) is available in the C Api (or is
> it?). Currently I'm trying to manually set the peakDimContribs and
> shifts to the correct resonance, but it's not working (it gets invalid).
>
> My current code is:
>
> peakDimContribs=Nmr_Resonance_GetPeakDimContribs(matchingResonance);
>           if(peakDimContribs)
>         {
>           for(j=0;j<ApiCollection_Len(peakDimContribs);j++)
>             {
>               peakDimContrib=ApiCollection_Get(peakDimContribs,j);
>               Nmr_PeakDimContrib_SetResonance(peakDimContrib,resonance);
>             }
>         }
>           shifts=Nmr_Resonance_GetShifts(matchingResonance);
>           if(shifts)
>         {
>           for(j=0;j<ApiCollection_Len(shifts);j++)
>             {
>               shift=ApiCollection_Get(shifts,j);
>               Nmr_Shift_SetResonance(shift,resonance);
>             }
>         }
>
>
> where resonance and matchingResonance are the two resonances I'm trying
> to merge. I guess my current way of thinking is a bit flawed, but I
> can't see why it isn't working. Do you have any suggestions?
>
> Another problem I have is that there doesn't seem to be an
> Nmr_Resonance_Delete (...) function in the C Api. How do I delete a
> resonance?
>
> Thanks for any hints and advice.
> /Magnus
>