methylene and methyl proton assignment names in sparky

216 views
Skip to first unread message

Jun Yang

unread,
Jun 3, 2021, 1:59:52 PM6/3/21
to NMR POKY/SPARKY USER GROUP
Hi Colleagues,

Recently I found out the function of "assignment distances". However, because all the methylene and methyl protons are individually names in pdb file, they can't be matched to the assignments in sparky when we assign methyl protons as "#" (eg, Leu HD1#), and methylene protons as "1/2" (eg, Leu HB1/2). I wonder whether the new Sparky version can accommodate this nomenclature, eg, when calculate distance to methyl protons, use the average distance of the distances to the three protons, and to the methylene protons, use the average of the two protons?

Thanks in advance.

Bests,

Jun

Lee, Woonghee

unread,
Jun 3, 2021, 2:10:42 PM6/3/21
to yangj...@gmail.com, NMR POKY/SPARKY USER GROUP

Jun,

 

I don’t think so. Sorry.

 

Best,

Woonghee  

 

--

Woonghee Lee, I.E.I.P., M.S., Ph.D.

 

Assistant Professor

Department of Chemistry

University of Colorado Denver

1151 Arapahoe St. (Science Bldg.) Rm 4128A

Denver, CO 80217-3364, USA

Office: +1-303-315-7672

woongh...@ucdenver.edu

 

https://poky.clas.ucdenver.edu

https://poky.clas.ucdenver.edu/wlee-group

https://clas.ucdenver.edu/chemistry/woonghee-lee

 

Shipping/Mailing Address:

Woonghee Lee

1201 5th St. UCD CHEM-194

P.O. Box 173364 (USPS)

Denver, CO 80204, USA

--
You received this message because you are subscribed to the Google Groups "NMR POKY/SPARKY USER GROUP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nmr-sparky+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/nmr-sparky/67adeba9-51b8-4a55-af67-686cf00c7c4an%40googlegroups.com.

Jun Yang

unread,
Jun 3, 2021, 4:29:36 PM6/3/21
to NMR POKY/SPARKY USER GROUP
Actually I just figured it out the nomenclature of methylene and methyl protons, which solves the issue. Thanks. 

Lee, Woonghee

unread,
Jun 3, 2021, 4:32:00 PM6/3/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Would you elaborate for others?

I remember I added some features to support pseudo/meta nomenclature a few years ago, so I think it will sort of works if you follow IUPAC but I am uncertain it resolves # and 1/2 postfixes.

 

Woonghee

 

--

Woonghee Lee, I.E.I.P., M.S., Ph.D.

 

Assistant Professor

Department of Chemistry

University of Colorado Denver

1151 Arapahoe St. (Science Bldg.) Rm 4128A

Denver, CO 80217-3364, USA

Office: +1-303-315-7672

woongh...@ucdenver.edu

 

https://poky.clas.ucdenver.edu

https://poky.clas.ucdenver.edu/wlee-group

https://clas.ucdenver.edu/chemistry/woonghee-lee

 

Shipping/Mailing Address:

Woonghee Lee

1201 5th St. UCD CHEM-194

P.O. Box 173364 (USPS)

Denver, CO 80204, USA

 

Jun Yang

unread,
Jun 6, 2021, 7:00:09 PM6/6/21
to NMR POKY/SPARKY USER GROUP
Use Q for queudo protons and M for methyl protons.

Another issue with assignment distance extension is that when I click a peak, the peak assignment and alterative assignments will be listed in the window. If I click one assignment in the list, the peak location will automatically move to the position corresponding to the assignment. My question is whether there is a way to assign the assignment to a variable that I want to use later? Because I'm not familiar with python, I wonder whether you have the ability to do so. Here is what I find in "distance.py" that is responsible for "assignment distance" extension:

These are where the click are bound:
pl.listbox.bind('<ButtonRelease-1>', self.select_peak_or_assignment_cb)
pl.listbox.bind('<ButtonRelease-2>', self.goto_peak_or_assignment_cb)

There are the definition of the two procedures:
def select_peak_or_assignment_cb(self, event):
   pora = self.peak_list.event_line_data(event)
   if type(pora) == types.InstanceType:
      sputil.select_peak(pora)
   elif type(pora) == types.TupleType or type(pora) == types.ListType:
      sputil.select_peak(self.settings.spectrum.find_peak(pora))

def goto_peak_or_assignment_cb(self, event):
   pora = self.peak_list.event_line_data(event)
   if type(pora) == types.InstanceType:
      sputil.show_peak(pora)
   elif type(pora) == types.TupleType or type(pora) == types.ListType:
      sputil.show_assignment(pora, self.settings.spectrum)
 
Initially I thought "pora" represents the assignment information line, but it turns out not a text variable, thus can't be displayed. If you can extract the assignment informtion from this "pora" variable, that would solve my issue.

Thanks in advance.

Jun

Lee, Woonghee

unread,
Jun 7, 2021, 11:42:43 AM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Use Q for queudo protons and M for methyl protons.

That’s what I thought it would work. You can just detach the number at the end as well

 

Another issue with assignment distance extension is that when I click a peak, the peak assignment and alterative assignments will be listed in the window. If I click one assignment in the list, the peak location will automatically move to the position corresponding to the assignment. My question is whether there is a way to assign the assignment to a variable that I want to use later?

It needs some thinking on the user interaction on the ui. Some fix might end up with unexpected problems. But I will think.

Jun Yang

unread,
Jun 7, 2021, 1:14:14 PM6/7/21
to NMR POKY/SPARKY USER GROUP
Is "pora" an instance object? Is it possible to extract the assignment information from it?

Lee, Woonghee

unread,
Jun 7, 2021, 1:18:50 PM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Dear Jun,

 

pora.assignment will give you what you want to know.

Jun Yang

unread,
Jun 7, 2021, 1:52:18 PM6/7/21
to NMR POKY/SPARKY USER GROUP
I add following line:

outFile=open("./junk","w"); outFile.write(pora.assignment)

When I click an assignment, it generates following error:
AttributeError: 'tuple' object has no attribute 'assignment'

Is there anything else I need to mofidy?

Thanks

Lee, Woonghee

unread,
Jun 7, 2021, 1:53:31 PM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Sorry. Try pora[0].assignment instead.

Cheers,

Lee, Woonghee

unread,
Jun 7, 2021, 1:58:13 PM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Basically, you loop the pora tuple and write assignment.

 

outFile=open(‘./junk’,’w’)

for p in pora:

outFile.write(p.assignment)

outFile.close()

--

Woonghee Lee, I.E.I.P., M.S., Ph.D.

 

Assistant Professor

Department of Chemistry

University of Colorado Denver

1151 Arapahoe St. (Science Bldg.) Rm 4128A

Denver, CO 80217-3364, USA

Office: +1-303-315-7672

woongh...@ucdenver.edu

 

https://poky.clas.ucdenver.edu

https://poky.clas.ucdenver.edu/wlee-group

https://clas.ucdenver.edu/chemistry/woonghee-lee

 

Shipping/Mailing Address:

Woonghee Lee

1201 5th St. UCD CHEM-194

P.O. Box 173364 (USPS)

Denver, CO 80204, USA

 

Jun Yang

unread,
Jun 7, 2021, 1:59:27 PM6/7/21
to NMR POKY/SPARKY USER GROUP
I got "AttributeError: __getitem__" if using "outFile.write(pora[0].assignment)"

Jun Yang

unread,
Jun 7, 2021, 2:02:34 PM6/7/21
to NMR POKY/SPARKY USER GROUP
If I use your loop script, it generates following error:

TypeError: iteration over non-sequence

Lee, Woonghee

unread,
Jun 7, 2021, 2:05:37 PM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Jun,

 

pora is either peak instance or a tuple of resonances.

 

So you can try to write

 

pora.assignment

 

or

 

‘%f,%f,%f’ % pora

 

So you can try to use “try”

 

try:
  outFile.write(pora.assignment)

except:

outFile.write(‘%f,%f,%f’ % pora)

Jun Yang

unread,
Jun 7, 2021, 2:30:08 PM6/7/21
to NMR POKY/SPARKY USER GROUP
I run your latest suggestion about "try" segment and got "TypeError: float argument required"

If I change to "outFile.write(pora)" in except, it shows "TypeError: argument 1 must be string or read-only character buffer, not tuple"

If I changed to "outFile.write(pora[0])" in except, it shows "TypeError: argument 1 must be string or read-only character buffer, not instance"

If I changed to "outFile.write(pora[0].assignment)" in except, it shows "AttributeError: assignment"

Any further suggestion?

Lee, Woonghee

unread,
Jun 7, 2021, 2:35:55 PM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Jun, my bad. It should be,

 

try:
  outFile.write(pora.assignment)

except:

outFile.write(‘%s,%s,%s’ % (pora[0].name, pora[1].name, pora[2].name))

 

Let me know if that doesn’t work.

Jun Yang

unread,
Jun 7, 2021, 3:41:34 PM6/7/21
to NMR POKY/SPARKY USER GROUP
It works now! However, I have three issues:

1. Since the assignment is only between two atoms, pora[2].name is not valid. 

2. if I click the alternative assignment (ie, line 2 and below), that assignment will be highlighted and written to the file, however, if I click the assignment (ie, line 1), that assignment will be highlights for a fraction of a second and then disappear, and nothing will be written to the file. Actually it will erase all previous entries from alternative assignment outputs. Why is that?

3. All these alternative assignment clicks go through the condition of "except". Under what condition it will go through "try" route?

Thanks again for your prompt help!

Lee, Woonghee

unread,
Jun 7, 2021, 3:45:23 PM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Hi Jun,

 

2. If you just use ‘w’, it will overwrite the file. I wonder if you want to use ‘w+’ instead.

3. “pora.assignment” is valid when pora is an instance of Peak class. If not, it will go into except block because “assignment” isn’t callable. In that case, the pora is a tuple of Resonance class and they will have ‘name’ member variable.

Lee, Woonghee

unread,
Jun 7, 2021, 3:49:20 PM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

2. Probably, ‘a’ not ‘w+’. Sorry again. But you have to make sure to close the file when leaving the function.

Cheers,

Woonghee

 

--

Woonghee Lee, I.E.I.P., M.S., Ph.D.

 

Assistant Professor

Department of Chemistry

University of Colorado Denver

1151 Arapahoe St. (Science Bldg.) Rm 4128A

Denver, CO 80217-3364, USA

Office: +1-303-315-7672

woongh...@ucdenver.edu

 

https://poky.clas.ucdenver.edu

https://poky.clas.ucdenver.edu/wlee-group

https://clas.ucdenver.edu/chemistry/woonghee-lee

 

Shipping/Mailing Address:

Woonghee Lee

1201 5th St. UCD CHEM-194

P.O. Box 173364 (USPS)

Denver, CO 80204, USA

 

From: "Lee, Woonghee" <WOONGH...@UCDENVER.EDU>


Date: Monday, June 7, 2021 at 1:45 PM
To: Jun Yang <yangj...@gmail.com>

Jun Yang

unread,
Jun 7, 2021, 4:35:01 PM6/7/21
to NMR POKY/SPARKY USER GROUP
In my understand, the command "outFile.write(pora.assignment)" will fall into the condition "type(pora) == types.InstanceType", while "outFile.write(‘%s,%s’ % (pora[0].name, pora[1].name))" will fall into the condition "type(pora) == types.TupleType or type(pora) == types.ListType", right?

Lee, Woonghee

unread,
Jun 7, 2021, 5:00:01 PM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Jun Yang

unread,
Jun 7, 2021, 5:03:04 PM6/7/21
to NMR POKY/SPARKY USER GROUP
I wonder under what condition it will be an instance of Peak class. Do you have an example that I can check?

Lee, Woonghee

unread,
Jun 7, 2021, 5:06:04 PM6/7/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Jun,

 

You can simply search “self.peak_list.append” in the distance.py. Second argument to the function will be set to pora. There are only four cases.

Jun Yang

unread,
Jun 8, 2021, 2:58:55 PM6/8/21
to NMR POKY/SPARKY USER GROUP
I can now output the assignment to a file, how can I output the same information to clipboard?

Jun Yang

unread,
Jun 8, 2021, 3:24:44 PM6/8/21
to NMR POKY/SPARKY USER GROUP
I tried to use module "pyperclip", ie, pyperclip.copy('content'). It works as expect in regular python. However, in the python shell via sparky, it generates such error: 

qdbus: symbol lookup error: /lib64/libQtDBus.so.4: undefined symbol: _ZN6QMutex12lockInternalEv

From NMRFAM-Sparky, I see you have at least two cases of extracting information from clipboard, one is from openfromclipboard.py and the other from "paste files in the clipboard to open all at once". It seems that I could follow your idea to copy the assignment to the clipboard, is that right?

Lee, Woonghee

unread,
Jun 8, 2021, 3:27:32 PM6/8/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

pyperclip is the third-party module that does not come with NMRFAM-SPARKY.

You should use tk’s functions.

You can clear and add some texts to the clipboard by

 

session.tk.clipboard_clear()

session.tk.clipboard_append(‘something’)

Jun Yang

unread,
Jun 8, 2021, 3:48:00 PM6/8/21
to NMR POKY/SPARKY USER GROUP
It works! Wonderful! Thanks.

Jun Yang

unread,
Aug 2, 2021, 7:07:23 PM8/2/21
to NMR POKY/SPARKY USER GROUP
Hi Woonghee,

Can "assignment distance" be only used in 3D or 2D dataset, but not both? I opened an "ad" windows from a 3D dataset. After I close it and try to open another one from a 2D data, it still shows the one for 3D. Is that true?

Thanks.

Jun

Lee, Woonghee

unread,
Aug 3, 2021, 12:18:17 PM8/3/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Hi Jun,

 

It works for both datasets. You cannot open two “ad” windows at the same time. You should change the spectrum in the same window.

 

Best,

Woonghee

 

--

Woonghee Lee, I.E.I.P., M.S., Ph.D.

 

Assistant Professor

Department of Chemistry

University of Colorado Denver

1151 Arapahoe St. (Science Bldg.) Rm 4128A

Denver, CO 80217-3364, USA

Office: +1-303-315-7672

woongh...@ucdenver.edu

 

https://poky.clas.ucdenver.edu

https://poky.clas.ucdenver.edu/wlee-group

https://clas.ucdenver.edu/chemistry/woonghee-lee

 

Shipping/Mailing Address:

Woonghee Lee

1201 5th St. UCD CHEM-194

P.O. Box 173364 (USPS)

Denver, CO 80204, USA

 

From: <nmr-s...@googlegroups.com> on behalf of Jun Yang <yangj...@gmail.com>
Date: Monday, August 2, 2021 at 5:07 PM
To: NMR POKY/SPARKY USER GROUP <nmr-s...@googlegroups.com>
Subject: Re: [NMR POKY/SPARKY] methylene and methyl proton assignment names in sparky

 

[External Email - Use Caution]

Jun Yang

unread,
Aug 4, 2021, 12:43:09 PM8/4/21
to NMR POKY/SPARKY USER GROUP
Hi Woonghee,

I see. I didn't see there is an option to switch dataset in the middle of the window. It works well once I switch to the correct data.

Another is about crosshair in 2D N-hsqc and corresponding 3D N-noesy. I have both spectra axes synchronized on N and H-acq (w1) and crosshair movement in 2D also moves correctly in 3D. However it doesn't work from the other way, ie, crosshair movement in 3D does NOT trigger any movement in 2D. I guess it's probably because there are two H axes in 3D data because it works well in 3D HNCACB dataset. Is there a trick to choose which proton axis it links based on synchronizatoin scheme?

Thanks again for your prompt reply.

Bests,

Jun

Lee, Woonghee

unread,
Aug 4, 2021, 12:46:24 PM8/4/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Hi Jun,

 

Just open Command Finder (cf) and type crosshair. There are a few options you can try. If neither works, you can try to change the axis order by nmrPipe.

 

Best,

Woonghee

 

--

Woonghee Lee, I.E.I.P., M.S., Ph.D.

 

Assistant Professor

Department of Chemistry

University of Colorado Denver

1151 Arapahoe St. (Science Bldg.) Rm 4128A

Denver, CO 80217-3364, USA

Office: +1-303-315-7672

woongh...@ucdenver.edu

 

https://poky.clas.ucdenver.edu

https://poky.clas.ucdenver.edu/wlee-group

https://clas.ucdenver.edu/chemistry/woonghee-lee

 

Shipping/Mailing Address:

Woonghee Lee

1201 5th St. UCD CHEM-194

P.O. Box 173364 (USPS)

Denver, CO 80204, USA

 

From: <nmr-s...@googlegroups.com> on behalf of Jun Yang <yangj...@gmail.com>
Date: Wednesday, August 4, 2021 at 10:43 AM
To: NMR POKY/SPARKY USER GROUP <nmr-s...@googlegroups.com>
Subject: Re: [NMR POKY/SPARKY] methylene and methyl proton assignment names in sparky

 

[External Email - Use Caution]

Jun Yang

unread,
Aug 4, 2021, 12:58:12 PM8/4/21
to NMR POKY/SPARKY USER GROUP
Hi Woonghee,

Thanks for the prompt reply. I looked up about crosshair. I understand all commands about crosshair except "reflection crosshair (rx)", what does it do? Also changing order of proton via nmrpipe won't work because I still end with two proton axes. The only possible solution would be the ability to rename the axis. I assume if I rename the indirectly-detected proton axis as something other than "H" as default, maybe it will then work. This feature would be handy when I move the cursor on 3D dataset and like to know its corresponding location on 2D data.

Best,

Jun

Lee, Woonghee

unread,
Aug 4, 2021, 2:47:58 PM8/4/21
to Jun Yang, NMR POKY/SPARKY USER GROUP

Hi Jun,

 

‘rx’ is to show the peak marker for reduced dimensionality experiments that y axis position needs offset adjustment.

You cannot rename one proton axis name to the other because it will be changed back to 1H again. Still I believe changing the axis order works.

Jun Yang

unread,
Aug 5, 2021, 9:32:55 AM8/5/21
to Lee, Woonghee, NMR POKY/SPARKY USER GROUP
I see. When you suggest changing axis order, do you mean to switch the two proton axes order, or involves N or C axis as well? How exactly will the new order to be of my original order is w1 (n or c), w2 (indirect proton), w3 (direct proton), and w1 & w3 is synchronized with 2d hsqc?

Thanks

Jun

Lee, Woonghee

unread,
Aug 5, 2021, 9:34:58 AM8/5/21
to Jun Yang, NMR POKY/SPARKY USER GROUP
Just change two Hs and let us know the results. 
Get Outlook for iOS

From: Jun Yang <yangj...@gmail.com>
Sent: Thursday, August 5, 2021 7:32:41 AM
To: Lee, Woonghee <WOONGH...@UCDENVER.EDU>

Cc: NMR POKY/SPARKY USER GROUP <nmr-s...@googlegroups.com>
Subject: Re: [NMR POKY/SPARKY] methylene and methyl proton assignment names in sparky

Jun Yang

unread,
Aug 5, 2021, 11:09:32 PM8/5/21
to NMR POKY/SPARKY USER GROUP
I use the following option in the nmrpipe to spark format conversion "pipe2spk -231 n-noesy%03d.DAT n-noesy3" and open it in poky. Now
my w1 remains unchanged as N axis, but w2 and w3 are exchanged. When I test the crosshair movement, the proton dimension in 2D and H-acq dimension are now synchronized, except the movements become orthogonal to each other, which is not easy way to compare. I guess I'll just live with the current situation and use 2D crosshair to check the peak alignment.

Thanks for the suggestion, though.

Best

Jun

Lee, Woonghee

unread,
Aug 5, 2021, 11:18:21 PM8/5/21
to Jun Yang, NMR POKY/SPARKY USER GROUP
Jun,

If protons are orthogonal to each other, isn't that the thing you can just transpose by xx ?

Woonghee

From: nmr-s...@googlegroups.com <nmr-s...@googlegroups.com> on behalf of Jun Yang <yangj...@gmail.com>
Sent: Thursday, August 5, 2021 9:09:32 PM

To: NMR POKY/SPARKY USER GROUP <nmr-s...@googlegroups.com>
Subject: Re: [NMR POKY/SPARKY] methylene and methyl proton assignment names in sparky
 
[External Email - Use Caution]I use the following option in the nmrpipe to spark format conversion "pipe2spk -231 n-noesy%03d.DAT n-noesy3" and open it in poky. Now
--
You received this message because you are subscribed to the Google Groups "NMR POKY/SPARKY USER GROUP" group.
To unsubscribe from this group and stop receiving emails from it, send an email to nmr-sparky+...@googlegroups.com.

Jun Yang

unread,
Aug 6, 2021, 9:45:42 PM8/6/21
to NMR POKY/SPARKY USER GROUP
Interesting, that trick actually works! Thanks a lot!    Jun
Reply all
Reply to author
Forward
0 new messages