CcpnForum
Import sparky project - Printable Version

+- CcpnForum (https://www.ccpn.ac.uk/forums)
+-- Forum: CcpNmr Analysis Version 3 (https://www.ccpn.ac.uk/forums/forumdisplay.php?fid=4)
+--- Forum: V3 General (https://www.ccpn.ac.uk/forums/forumdisplay.php?fid=8)
+--- Thread: Import sparky project (/showthread.php?tid=84)



Import sparky project - ashubiotech - 04-14-2020

Hi,
     I was trying to analyze the analyze the titration data. I have imported the sparky project to ccpnmr, but different .save files have different chain names. Is there any way to make the same chain name for all these Spectra.

Thank you


RE: Import sparky project - pcavanderwel - 04-14-2020

(04-14-2020, 12:43 PM)ashubiotech Wrote: Hi,
     I was trying to analyze the analyze the titration data. I have imported the sparky project to ccpnmr, but different .save files have different chain names. Is there any way to make the same chain name for all these Spectra.

Thank you

Hello,

One option might be to simply edit the .save files? They are simple text files so you maybe can easily do a search/replace on them, to make the assignments (more) consistent?


Best wishes,
Patrick


RE: Import sparky project - VickyH - 04-14-2020

Hi,

hopefully the following macro should move all your peak assignments into a single NmrChain called 'molecule' (you can re-name it afterwards) and then remove all the other NmrChains created during import.

Python
  1. # Do this on every peak in the project
  2. for peak in project.peaks:
  3. # Get the assignments in all dimensions for a peak
  4. for assignOptions in peak.assignedNmrAtoms:
  5. for assignment in assignOptions:
  6. # Create the new assignment string with 'molecule' as the NmrChain
  7. temp = str(assignment)
  8. assignmentComponents = temp.split('.')
  9. assignmentComponents[0] = 'NA:molecule'
  10. assignmentComponents[3] = assignmentComponents[3][0:-1]
  11. newAssignment = '.'.join(assignmentComponents)
  12. # get parameters needed for creation of new NmrChain, NmrResidue, NmrAtom and Peak Assignment
  13. chainPid = 'NC:molecule'
  14. resPid = 'NR:molecule.' + '.'.join(assignmentComponents[1:-1])
  15. seqCode = assignmentComponents[1]
  16. resType = assignmentComponents[2]
  17. atomName = assignmentComponents[3]
  18. axCde = assignmentComponents[3][0]
  19. # Create new NmrChain, NmrResidue and NmrAtom if necessary
  20. project.fetchNmrChain('molecule')
  21. get(chainPid).fetchNmrResidue(seqCode, resType)
  22. get(resPid).fetchNmrAtom(atomName)
  23. # Change the peak assignment to the new one
  24. get(peak.pid).assignDimension(axCde, newAssignment)
  25.  
  26. # Remove all the (now obsolete) NmrChains that are not NC:molecule and the default NC:@-
  27. for nmrChain in project.nmrChains:
  28. if nmrChain.id != '@-':
  29. if nmrChain.id != 'molecule':
  30. project.deleteObjects(nmrChain)



If you need to switch your amino acids from one-letter to three-letter code you can use the following:

Python
  1. def convertResidueCode(residueName, inputCodeType='oneLetter', outputCodeType='threeLetter', molType ='protein'):
  2. """
  3. :param inputCodeType: oneLetter, threeLetter, synonym, molFormula
  4. :type inputCodeType: str
  5. :param molType: 'protein', 'DNA', 'RNA'
  6. :type molType: str
  7. :return: the same residue with the new letter code/name
  8. :rtype: str
  9. """
  10. from ccpnmodel.ccpncore.lib.chemComp.ChemCompOverview import chemCompStdDict
  11. modes = ['oneLetter', 'threeLetter', 'synonym', 'molFormula'] # order as they come from ChemCom dictionary
  12. if inputCodeType not in modes or outputCodeType not in modes:
  13. print('Code type not recognised. It has to be one of: ', modes)
  14. return
  15. for k, v in chemCompStdDict.get(molType).items():
  16. dd = {i:j for i,j in zip(modes,v)}
  17. if residueName == dd.get(inputCodeType):
  18. return dd.get(outputCodeType)
  19.  
  20.  
  21. def convertNmrChain1to3LetterCode(nmrChain, molType='protein'):
  22. """
  23. converts NmrResidues from 1 to 3 LetterCode.
  24. :param nmrChain: Ccpn object NmrChain
  25. :param molType: 'protein', 'DNA', 'RNA'
  26. :return:
  27. """
  28. for nmrResidue in nmrChain.nmrResidues:
  29. if len(nmrResidue.residueType) == 1:
  30. newNmrResidueName = convertResidueCode(nmrResidue.residueType, inputCodeType='oneLetter', outputCodeType='threeLetter', molType=molType)
  31. try:
  32. nmrResidue.rename('.'.join([nmrResidue.sequenceCode, newNmrResidueName]))
  33. except Exception as err:
  34. print('Error renaming NmrResidue %s.' %nmrResidue.pid, err)
  35. else:
  36. if not nmrResidue.residueType:
  37. print('Skipping... ResidueType not found for nmrResidue %s' %nmrResidue.pid)
  38. else:
  39. print('Skipping... Could not rename to 3 Letter code for nmrResidue %s' % nmrResidue.pid)
  40.  
  41.  
  42. # Do this on every NmrChain in the project
  43. for nmrChain in project.nmrChains:
  44. convertNmrChain1to3LetterCode(nmrChain)



Best wishes,
Vicky


RE: Import sparky project - ashubiotech - 04-14-2020

Thanks Vicky,
it worked perfectly. I was able to get the binding curve but the window for fitting was empty. Is there any mistake? Another thing is I could not change the relative contribution of particular atoms (nitrogen and proton).

Ashish


RE: Import sparky project - VickyH - 04-15-2020

Hi Ashish,

in the Chemical Shift Mapping module, try going to the settings (click on gear icon in the top left corner). Then scroll down to "Select NmrAtoms" and click on the "NmrAtoms settings" box (see attached figure). Here you can change the contributions for each of the different isotope types.
I'm not quite sure why the Fittings window is empty - though it is for me as well, so this is probably a bug of some kind. Will investigate.

Best wishes,

Vicky


RE: Import sparky project - VickyH - 04-15-2020

Hi Ashish,

I've had another play and it looks as though the fitting should show once you click on a new residue in the table or graph. For some residues you might not see a fit, e.g. if the data is really bad because a peak doesn't move as part of the titration.

Best wishes,

Vicky


RE: Import sparky project - ashubiotech - 04-20-2020

Thanks Vicky,
Although I had tried to see the fitting curve but did not get successful. I got only the binding curves, not actual fitting.

Ashish