CalcPara currently supports calculating PCS, PRE and RDC. CCR will be implemented in the future as it is not particularly popular at the moment. The orientation dependent paramagnetic effects (PCS and RDC) can be calculated in ZYZ or ZXZ convention. We reccomend ZYZ.
Below is script to convert RDCs calculated by Numbat and output in Xplor .tbl format to a .npc format for use in pyParaTools. It must be noted that Numbat nicely outputs all elements seperated by a space:
...
...
( resid 2 and name H )
( resid 2 and name N ) 1.61108 0.00000
...
This may not be the case for data coming from other programs or deposited in the BMRB.
convert_tbl_to_numbat.py:
# If you have Xplor-NIH formatted RDC tbl's you can use this script
# to generate Numbat formatted files
import sys
infile = open(sys.argv[1])
dat = infile.readlines()
i = 5
while i < len(dat):
x = dat[i].split()
if len(x) == 9:
num = dat[i-1].split()[2]
# NOTE: HN is fixed. Could handle others with not much additional code
print num,'\t', 'HN','\t', x[7],'\t','0.0'
i=i+1
[source code, hires.png, pdf]
A PCS effect calcer
Parameters: |
|
---|---|
Return type: | A list (floats) of average PCS values. This is only useful if a ParsedObjL is provided |
Calculate PCS for a given set of spins/parameters in given convention
Note
This method updates the calculated values in the ParsedObj. It is the only way to populate this ParsedObj variable.
Warning
If calling this method on the same object multiple times, unexpected behaviour can be experienced. This was due to the parsedObjL still being populated hence the del ParsedObjL[0:len(ParsedObjL)] statement.
Example Usage/Doctests:
>>> # Check the agreement with Numbat's calculated PCS.
>>> import sys
>>> import os
>>> sys.path.append(os.path.abspath('.'))
>>> from ParaParser import *
>>> from CalcPara import *
>>> dataset = ['TESTPCSCALC', 'pcs', '../tests/STRUCTURES/2AXD.pdb',
... '../tests/DATASETS/PCS/THETA/DY.zero.npc', '4.9', '-6.1', '-19.1',
... '37.0', '8.0', '37.0', '119.0', '39.0']
>>> pcs_set1 = PCSParser(dataset)
>>> pcs_set1.doParse()
>>> calcer = PCS(pcs_set1, 'ZYZ')
>>> av = calcer.calc()
>>> # Compare with numbat
>>> numbat_calc = []
>>> in1 = open('../tests/DATASETS/PCS/THETA/DY.numbat.npc')
>>> dat1 = in1.readlines()
>>> in1.close()
>>> for i in range(0, len(dat1)):
... numbat_calc.append(float(dat1[i].split()[2]))
...
>>> len(av) == len(numbat_calc)
True
>>> failures = []
>>> for i in range(0, len(av)):
... if abs(av[i] - numbat_calc[i]) > 0.01:
... failures.append('fail'+str(i+1))
...
>>> print(failures)
[]
>>> del av
>>> del numbat_calc
>>> del failures
>>> numbat_calc = []
>>> #Test that the averaging indeed works
>>> pcs_set2 = PCSParser(dataset)
>>> pcs_set2.setModel(2) #Sets the second model
>>> pcs_set2.doParse()
>>> calcer = PCS(pcs_set1, 'ZYZ', [pcs_set2])
>>> av = calcer.calc()
>>> in2 = open('../tests/DATASETS/PCS/THETA/DY.numbat_av_mods1and2.npc')
>>> dat2 = in2.readlines()
>>> in2.close()
>>> for i in range(0, len(dat2)):
... numbat_calc.append(float(dat2[i].split()[2]))
...
>>> len(av) == len(numbat_calc)
True
>>> failures = []
>>> for i in range(0, len(av)):
... if abs(av[i] - numbat_calc[i]) > 0.01:
... failures.append('fail'+str(i+1))
...
>>> print(failures)
[]
Return the convention :rtype: str
Return the ParaParser object :rtype: ParaParser object
Return the list of ParaParser objects :rtype: list
Set the convention to be used with this calcer :param c: The convention :type c: str
Set the ParaParser object associated with this calcer :param obj: The ParaParser object :type obj: ParaParser object
Set a list of ParaParser objects associated with this calcer :param objL: The list of ParaParser objects :type objL: list
A PRE effect calcer
Parameters: |
|
---|---|
Return type: | A list (floats) of average PRE values. This is only useful if a ParsedObjL is provided |
Calculate PRE for a given set of spins/parameters
See also
The note and warning for PCS.
Example Usage/Doctests:
>>> # Check the agreement with PREfit (and PREFit_dimer) calculated PRE.
>>> import sys
>>> import os
>>> sys.path.append(os.path.abspath('.'))
>>> from ParaParser import *
>>> from CalcPara import *
>>> dataset = ['TESTPRECALC', 'pre', '../tests/STRUCTURES/m0.pdb',
... '../tests/DATASETS/PRE/LZIPPER/dummy.npc','-5.559','28.782','3.344',
... '10000000']
>>> pre_set1 = PREParser(dataset)
>>> pre_set1.doParse()
>>> calcer = PRE(pre_set1)
>>> av = calcer.calc()
>>> # Compare with PREfit (for monomer)
>>> prefit_calc = []
>>> in1 = open('../tests/DATASETS/PRE/LZIPPER/pre_fit.dat')
>>> dat1 = in1.readlines()
>>> in1.close()
>>> for i in range(0, len(dat1)):
... prefit_calc.append(float(dat1[i].split()[1]))
...
>>> len(av) == len(prefit_calc)
True
>>> failures = []
>>> for i in range(0, len(av)):
... if abs(av[i] - prefit_calc[i]) > 0.01:
... failures.append('fail'+str(i+1))
...
>>> print(failures)
[]
>>> del av
>>> del prefit_calc
>>> del failures
>>> prefit_av_calc = []
>>> #Test that the averaging indeed works
>>> #NOTE: Although I refer to a dimer, really av of 1 site/2 structures
>>> pre_set2 = PREParser(dataset)
>>> pre_set2.setModel(2) #Sets the second model
>>> pre_set2.doParse()
>>> calcer = PRE(pre_set1, [pre_set2])
>>> av = calcer.calc()
>>> in2 = open('../tests/DATASETS/PRE/LZIPPER/pre_fit_av.dat')
>>> dat2 = in2.readlines()
>>> in2.close()
>>> for i in range(0, len(dat2)):
... prefit_av_calc.append(float(dat2[i].split()[1]))
...
>>> len(av) == len(prefit_av_calc)
True
>>> failures = []
>>> for i in range(0, len(av)):
... if abs(av[i] - prefit_av_calc[i]) > 0.01:
... failures.append('fail'+str(i+1))
...
>>> print(failures)
[]
>>> #**How to update ParsedObj manually for calculated averages**
>>> ParaObjList = pre_set1.getParsed()
>>> len(ParaObjList) == len(av)
True
>>> for i in range(0, len(av)):
... ParaObjList[i].setCVal(av[i])
...
>>> v1, v2 = ParaObjList[0].getCVal(), av[0]
>>> v1 == v2
array([ True], dtype=bool)
Return the ParaParser object :rtype: ParaParser object
Return the list of ParaParser objects :rtype: list
Set the ParaParser object associated with this calcer :param obj: The ParaParser object :type obj: ParaParser object
Set a list of ParaParser objects associated with this calcer :param objL: The list of ParaParser objects :type objL: list
A RDC effect calcer
Parameters: |
|
---|---|
Return type: | A list (floats) of average RDC values. This is only useful if a ParsedObjL is provided |
warning:: At the moment this method only supports HN RDC
Calculate RDC for a given set of spins/parameters
See also
The note and warning for PCS.
Example Usage/Doctests:
>>> # Check the agreement with Numbat and REDCATS calculated RDC.
>>> import sys
>>> import os
>>> sys.path.append(os.path.abspath('.'))
>>> from ParaParser import *
>>> from CalcPara import *
>>> dataset = ['TESTRDCCALC', 'rdc', '../tests/STRUCTURES/2AXD.pdb',
... '../tests/DATASETS/RDC/THETA/DY.zero.npc',
... '37.0', '8.0', '37.0', '119.0', '39.0']
>>> rdc_set1 = RDCParser(dataset)
>>> rdc_set1.doParse()
>>> calcer = RDC(rdc_set1, 'ZYZ')
>>> av = calcer.calc()
>>> # Compare with numbat
>>> numbat_calc = []
>>> in1 = open('../tests/DATASETS/RDC/THETA/DY.numbat.npc')
>>> dat1 = in1.readlines()
>>> in1.close()
>>> for i in range(0, len(dat1)):
... numbat_calc.append(float(dat1[i].split()[2]))
...
>>> len(av) == len(numbat_calc)
True
>>> failures = []
>>> for i in range(0, len(av)):
... if abs(av[i] - numbat_calc[i]) > 0.1:
... failures.append('fail'+str(i+1))
...
>>> print(failures)
[]
Return the convention :rtype: str
Return the type of RDC i.e. HN :rtype: str
Return what Nitrogen labelling has been used. :rtype: int
Return the ParaParser object :rtype: ParaParser object
Return the list of ParaParser objects :rtype: list
Set the convention to be used with this calcer :param c: The convention :type c: str
Set the type of RDC i.e. HN associated with this calcer :param exp_t: The type of experiment :type exp_t: str
Set the Nitrogen labelling associated with this calcer :param setNLabel: The Nitrogen labelling N14 (0) or N15 (1) :type setNLabel: int
Set the ParaParser object associated with this calcer :param obj: The ParaParser object :type obj: ParaParser object
Set a list of ParaParser objects associated with this calcer :param objL: The list of ParaParser objects :type objL: list