Alternatively, here is a (relatively quick and dirty) macro which will export Sparky peak lists for all HSQC spectra in your project (i.e. spectra where you have set the Experiment Type to 15N HSQC/HMQC with ET).
In the final line of the code you can specify the file path for where all the peak lists will be saved.
The peak lists will be of the form:
Assignment w2 w1
N53H-N 8.142 114.311
M54H-N 8.474 120.49
K55H-N 8.347 121.413
L56H-N 8.488 124.722
G57H-N 8.288 109.328
Q58H-N 8.872 122.38
K59H-N 8.609 126.762
V60H-N 9.515 125.574
Vicky
from collections import defaultdict
import pandas as pd
chemCompCodesDict = {
'Ala': ('A', 'ALA', 'ALANINE', 'C3H7N1O2'),
'Cys': ('C', 'CYS', 'CYSTEINE', 'C3H7N1O2S1'),
'Asp': ('D', 'ASP', 'ASPARTIC ACID', 'C4H6N1O4'),
'Glu': ('E', 'GLU', 'GLUTAMIC ACID', 'C5H8N1O4'),
'Phe': ('F', 'PHE', 'PHENYLALANINE', 'C9H11N1O2'),
'Gly': ('G', 'GLY', 'GLYCINE', 'C2H5N1O2'),
'His': ('H', 'HIS', 'L-Histidine', 'C6H10N3O2'),
'Ile': ('I', 'ILE', 'ISOLEUCINE', 'C6H13N1O2'),
'Lys': ('K', 'LYS', 'LYSINE', 'C6H15N2O2'),
'Leu': ('L', 'LEU', 'LEUCINE', 'C6H13N1O2'),
'Met': ('M', 'MET', 'METHIONINE', 'C5H11N1O2S1'),
'Asn': ('N', 'ASN', 'ASPARAGINE', 'C4H8N2O3'),
'Pro': ('P', 'PRO', 'PROLINE', 'C5H9N1O2'),
'Gln': ('Q', 'GLN', 'GLUTAMINE', 'C5H10N2O3'),
'Arg': ('R', 'ARG', 'ARGININE', 'C6H15N4O2'),
'Ser': ('S', 'SER', 'SERINE', 'C3H7N1O3'),
'Thr': ('T', 'THR', 'THREONINE', 'C4H9N1O3'),
'Val': ('V', 'VAL', 'VALINE', 'C5H11N1O2'),
'Trp': ('W', 'TRP', 'TRYPTOPHAN', 'C11H12N2O2'),
'Tyr': ('Y', 'TYR', 'TYROSINE', 'C9H11N1O3'),
}
def convertResidueCode(residueName, inputCodeType='threeLetter', outputCodeType='oneLetter'):
"""
This will convert the three-letter AA codes used in Analysis to the one-letter code used in Sparky
:param inputCodeType: oneLetter, threeLetter, synonym, molFormula
:type inputCodeType: str
:return: the same residue with the new letter code/name
:rtype: str
"""
modes = ['oneLetter', 'threeLetter', 'synonym', 'molFormula'] # order as they come from ChemCom dictionary
if inputCodeType not in modes or outputCodeType not in modes:
print('Code type not recognised. It has to be one of: ', modes)
return
for k, v in chemCompCodesDict.items():
dd = {i:j for i,j in zip(modes,v)}
if residueName == dd.get(inputCodeType):
return dd.get(outputCodeType)
for pl in project.peakLists:
if pl.spectrum.experimentType == 'H[N]':
sparkyDict = defaultdict(list)
for pk in pl.peaks:
label = ''
resAdded = False
for dim in pk.peakList.spectrum.dimensions:
for na in pk.assignmentsByDimensions[dim-1]:
if resAdded is False:
if na.nmrResidue.residueType is not None:
resType = convertResidueCode(na.nmrResidue.residueType, inputCodeType='threeLetter', outputCodeType='oneLetter')
label = label+resType
if na.nmrResidue.sequenceCode is not None:
label = label+na.nmrResidue.sequenceCode
resAdded = True
label = label+na.name
else:
label = label+'-'+na.name
if label == '':
label = '?-?'
if dim == 1:
sparkyDict['w2'].append(round(pk.position[dim - 1], 3))
elif dim == 2:
sparkyDict['w1'].append(round(pk.position[dim - 1], 3))
sparkyDict['Assignment'].append(label)
df = pd.DataFrame(sparkyDict)
filename = pl.spectrum.name+'_sparky.txt'
df.to_csv(path_or_buf='~/Documents/Temp/'+filename, sep=' ', columns=['Assignment', 'w2', 'w1'], index=False)