PPTs logo

Table Of Contents

The ParaParser module - Builds data structures from paramagnetic parameters

Introduction and notes

API Documentation, Usage Examples and Doctests

class ParaParser.PCSParser(stdin)

A PCS object that stores X-tensor parameters, coordinates and datasets.

Takes given information and builds an object (on doParse() call). This object facilitates data storage of the X-tensor parameters, metal position <mx, my, mz>, shape, Axial and Rhombic and orientation, Alpha, Beta and Gamma, the experimental data and the spins for which experimental data is defined. This object also facilitates retrival and manipulation of this stored information.

Parameters:
  • stdin – A list of paramagnetic parameters.(with 12 elements) The 1st element is ignored (historical reasons). The subsequent items are the datatype, pdb file, and experimental data file, Mx, My, Mz, Axial, Rhombic, Alpha, Beta and Gamma.

Example Usage/Doctests:

>>> # HERE IT IS SHOWN HOW THIS MODULE CAN BE USED
>>> # INPUT & PARSING
>>>
>>> from numpy import array
>>> indat = ['Example', 'pcs', '../tests/STRUCTURES/2AXD.pdb',         '../tests/DATASETS/PCS/THETA/DY.npc', 5, -6, -19, 39, 7, 37, 120, 43 ]
>>> p = PCSParser(indat)
>>> p.doParse()
>>> x,y,z  = p.getAllXarray(), p.getAllYarray(), p.getAllZarray()
>>>
>>> # ADDING NEW DATA POST PARSING
>>> # TEST: addElement(self, at, res, exp, tol, coord, useFit=0)
>>> p.writeDataSetNumbat("DY_check.npc")
Data in numbat format written to: DY_check.npc
>>> p.addElement('N', 66, 1.1, 0.000, array([1.000, 2.000, 3.000]))
>>> p.writeDataSetNumbat("DY_check.1.npc")
Data in numbat format written to: DY_check.1.npc
>>> xm,ym,zm  = p.getAllXarray(), p.getAllYarray(), p.getAllZarray()
>>> print xm[len(xm)-1], ym[len(ym)-1], zm[len(zm)-1]
1.0 2.0 3.0
>>>
>>> # REMOVING DATA POST PARSING
>>> # TEST: removeElement(self, at, res)
>>> p.removeElement('N', 66)
>>> p.removeElement('C', 66)
No such element found.
>>> p.writeDataSetNumbat("DY_check.2.npc")
Data in numbat format written to: DY_check.2.npc
>>>
>>> # SAVING A SESSION
>>> # TEST: saveSession(self, outname)
>>> p.saveSession("saved.ppt")
>>>
>>> # ADDING RANDOM ERROR
>>> # TEST
>>>     #addErrorGaussianMeas(self, delta=0.0, rseed=1):
>>>     #addErrorFlatMeas(self, delta=0.0, rseed=1):
>>>     #addErrorGaussCoords(self, delta, rseed=1):
>>>     #addErrorFlatCoords(self, delta, rseed=1):
>>> ori_exp = p.getAllMeasarray()
>>> rubbish = p.addErrorGaussianMeas()  # Do nothing as tol = 0 for dataset
Random seed for addition of Gaussian error is  1
>>> dse = p.getParsed()
>>> for i in range(0, len(dse)):        # Update the tolerances...
...     dse[i].setTol(0.1)
...
>>> rubbish = p.addErrorGaussianMeas()
Random seed for addition of Gaussian error is  1
>>> p.writeDataSetNumbat("DY_check.3.npc")
Data in numbat format written to: DY_check.3.npc
>>> p.reloadParaData(rubbish)
>>> p.writeDataSetNumbat("DY_check.4.npc")
Data in numbat format written to: DY_check.4.npc
>>> rubbish = p.addErrorFlatMeas(0.05)
Random seed for addition of square error is  1
>>> p.writeDataSetNumbat("DY_check.5.npc")
Data in numbat format written to: DY_check.5.npc
>>> rubbish = p.addErrorFlatMeas(0.1)
Random seed for addition of square error is  1
>>> p.writeDataSetNumbat("DY_check.6.npc")
Data in numbat format written to: DY_check.6.npc
addElement(at, res, exp, tol, coord, useFit=0)

Add a ParaData element to the datastructure

Note

Elements are instantiated as the ParaData base class

Parameters:
  • at – The spin type (atom identifier)
  • res – The residue id (residue number for the given atom)
  • exp – The experimental value
  • tol – The experimental tolerance
  • coord – The coordinates of the spin
  • useFit – Use this experimental value in fit [OPTIONAL]
addErrorFlatCoords(delta, rseed=1)

Add random error from a “square” distribution to the coordinates

Note

When using the square distribution, provided that delta is <= the experimental tolerance, generated error will not be larger than the experimental tolerance.

Parameters:
  • delta – Delta parameter to define the upper and lower limits [(exp val-delta), exp val,(exp val +delta).
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorFlatMeas(delta=0.0, rseed=1)

Add random error from a “square” dist to the experimental value

Note

When using the square distribution, provided that delta is <= the experimental tolerance, generated error will not be larger than the experimental tolerance.

Parameters:
  • delta – By default upper lower limits are [(exp val-tol), exp val, (exp val +tol)]. By passing a value for delta, the upper and lower limits become [(exp val-delta), exp val,(exp val +delta).
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorGaussCoords(delta, rseed=1)

Add random Gaussian error to the coordinates

The original data structure of ParaData elements is returned

Note

When using a Gaussian distribution, ~ 32% of the time the generated error will be larger or than the experimental tolerance.

Parameters:
  • delta – The sigma parameter for the distribution
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorGaussianMeas(delta=0.0, rseed=1)

Add random Gaussian error to the measured experimental value

The original data structure of ParaData elements is returned

Note

When using a Gaussian distribution, ~ 32% of the time the generated error will be larger or than the experimental tolerance.

Parameters:
  • delta – By default sigma is the experimental tolerance. By passing a value for delta, sigma becomes delta [OPTIONAL]
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
Return type:

list

doParse()

Parse the given the imput parameters, build ParaData objects allowing for easy retrival and manipulation

getAllMeasarray()

Returns all parsed experimental data in a single array [for fitting]

Return type:array
getAllTolarray()

Returns all parsed exp tolerances in a single array [for fitting]

Return type:array
getAllXarray()

Returns all parsed x coordinates in a single array [for fitting]

Return type:array
getAllYarray()

Returns all parsed y coordinates in a single array [for fitting]

Return type:array
getAllZarray()

Returns all parsed z coordinates in a single array [for fitting]

Return type:array
getAlpha()

Return the X-tensor frame Alpha angle

getAxial()

Return the X-tensor’s Axial component in SI units

getAxialVVU()

Return the X-tensor’s axial component in VVU units

getBeta()

Return the X-tensor frame Beta angle

getDataType()

Returns the type of paramagnetic effect parsed

Return type:str
getDataset()

Returns the dataset (post readlines())

Return type:list
getGamma()

Return the X-tensor frame Gamma angle

getMetalLoc()

Return the numpy array containing the metal position

getMetalLocx()

Return the metal x coordinate

getMetalLocy()

Return the metal y coordinate

getMetalLocz()

Return the metal z coordinate

getNumModels()

Returns number of models contained in the Bio.PDB structure object

Return type:int

Example Usage/Doctests

>>> indat = ['Example', 'pcs', '../tests/STRUCTURES/2AXD.pdb',         '../tests/DATASETS/PCS/THETA/DY.npc']
>>> p = ParaParser(indat)
>>> print p.getNumModels()
12
getPDBFn()

Returns the PDB file parsed

Return type:str
getParaDataFn()

Returns the paramagnetic data file parsed

Return type:str
getParsed()

Returns the list of ParaData objects (post doParse() call)

Return type:list
getRhombic()

Return the X-tensor’s rhombic component in SI units

getRhombicVVU()

Return the X-tensor’s rhombic component in VVU units

getStructure()

Returns the Bio.PDB structure object

This structure object is of a Structure/Model/Chain/Residue/Atom architecture.

See: http://biopython.org/DIST/docs/cookbook/biopdb_faq.pdf and
http://biopython.org/DIST/docs/api/Bio.PDB-module.html
Return type:Bio.PDB structure object
getTensorParams()

Return an array of all 8 X-tensor parameters.

getTensorParamsNice()

Print all 8 X-tensor parameters

parsingErrorMSG()

The parsing has failed as the datastructure in the object is empty

randomRemoveElements(percent, rseed=1)

Randomly remove ParaData elements from the objects datastructure

The original data structure of ParaData elements is returned

Parameters:
  • percent – Percentage to remove
  • percent – float
reloadParaData(paraDataList)

Load a data structure of ParaData elements into the current object

Parameters:
  • paraDataList – A list of ParaData elements
removeElement(at, res)

Remove a ParaData element from the datastructure

Parameters:
  • at – The spin type (atom identifier)
  • res – The residue id (residue number for the given atom)
saveSession(outname)

Pickle (store the entire object state). A way to save sessions

Parameters:
  • outname – the filename to store the pickled state in

Example Usage/DocTests

>>> import sys
>>> import os
>>> from ParaUtils import loadSession
>>> 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 = PREParser(dataset)
>>> pre.doParse()
>>> calcer = PRE(pre)
>>> av = calcer.calc()
>>> pre.saveSession("test.session")
>>> pre2 = loadSession("test.session")
>>> if pre.getSiteParams().all() != pre2.getSiteParams().all():
...     print "Failure!"
setAlpha(alpha)

Set/Change the X-tensor frame Alpha angle

Parameters:
  • alpha – The Alpha angle in degrees
setAxial(axial)

Set/Change the X-tensor’s Axial component (converted to VVU units)

Parameters:
  • axial – The axial component in SI units
setBeta(beta)

Set/Change the X-tensor frame Beta angle

Parameters:
  • beta – The Beta angle in degrees
setCalcedToObs()

The calculated values become the experimental values

setGamma(gamma)

Set/Change the X-tensor frame Gamma angle

Parameters:
  • gamma – The Gamma angle in degrees
setMetalLoc(metal_xyz)

Set/Change the metal position

Parameters:
  • metal_xyz – The metal ion x,y,z coordinates
setMetalLocx(mx)

Set/Change the metal x coordinate

Parameters:
  • mx – The x coordinate
setMetalLocy(my)

Set/Change the metal y coordinate

Parameters:
  • my – The y coordinate
setMetalLocz(mz)

Set/Change the metal z coordinate

Parameters:
  • mz – The x coordinate
setModel(num)

Change the model (coordinates) associated with the dataset

Parameters:
  • num – Model number (1->1, 2->2)
setPDBFn(pdb_name)

Set/Change the PDB file to be parsed

Parameters:
  • pdb_name – The name (and path) to the PDB file
setParaDataFn(para_name)

Set/Change the paramagnetic data file to be parsed

Parameters:
  • para_name – The name (and path) to the paramagnetic data file
setRhombic(rhombic)

Set/Change the X-tensor’s Rhombic component (converted to VVU units)

Parameters:
  • rhombic – The rhombic component in SI units
setTensorParam(params)

Set all 8 X-tensor parameters given an array of such data

Parameters:
  • params – array of the 8 X-tensor parameters: Mx, My, Mz, Ax, Rh, A, B, G
writeDataSetNumbat(fname)

Write the data (in the Numbat format) to a user specified file

Parameters:
  • fname – The output filename

Example Usage/Doctests:

>>> 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 = RDCParser(dataset)
>>> rdc.doParse()
>>> rdc.writeDataSetNumbat('rdc_test.npc')
Data in numbat format written to: rdc_test.npc
class ParaParser.PREParser(stdin)

A PRE object that stores PRE centre parameters, coordinates and datasets.

Takes given information and builds an object (on doParse() call). This object facilitates data storage of the PRE parameters, metal position <mx, my, mz> and PRE constant, the experimental data and the spins for which experimental data is defined. This object also facilitates retrival and manipulation of this stored information.

Parameters:
  • stdin – A list of paramagnetic parameters.(with 8 elements) The 1st element is ignored (historical reasons). The subsequent items are the datatype, pdb file, and experimental data file, Mx, My, Mz, and PRE_constant.

Example Usage/Doctests

addElement(at, res, exp, tol, coord, useFit=0)

Add a ParaData element to the datastructure

Note

Elements are instantiated as the ParaData base class

Parameters:
  • at – The spin type (atom identifier)
  • res – The residue id (residue number for the given atom)
  • exp – The experimental value
  • tol – The experimental tolerance
  • coord – The coordinates of the spin
  • useFit – Use this experimental value in fit [OPTIONAL]
addErrorFlatCoords(delta, rseed=1)

Add random error from a “square” distribution to the coordinates

Note

When using the square distribution, provided that delta is <= the experimental tolerance, generated error will not be larger than the experimental tolerance.

Parameters:
  • delta – Delta parameter to define the upper and lower limits [(exp val-delta), exp val,(exp val +delta).
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorFlatMeas(delta=0.0, rseed=1)

Add random error from a “square” dist to the experimental value

Note

When using the square distribution, provided that delta is <= the experimental tolerance, generated error will not be larger than the experimental tolerance.

Parameters:
  • delta – By default upper lower limits are [(exp val-tol), exp val, (exp val +tol)]. By passing a value for delta, the upper and lower limits become [(exp val-delta), exp val,(exp val +delta).
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorGaussCoords(delta, rseed=1)

Add random Gaussian error to the coordinates

The original data structure of ParaData elements is returned

Note

When using a Gaussian distribution, ~ 32% of the time the generated error will be larger or than the experimental tolerance.

Parameters:
  • delta – The sigma parameter for the distribution
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorGaussianMeas(delta=0.0, rseed=1)

Add random Gaussian error to the measured experimental value

The original data structure of ParaData elements is returned

Note

When using a Gaussian distribution, ~ 32% of the time the generated error will be larger or than the experimental tolerance.

Parameters:
  • delta – By default sigma is the experimental tolerance. By passing a value for delta, sigma becomes delta [OPTIONAL]
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
Return type:

list

doParse()

Parse the given the imput parameters, build ParaData objects allowing for easy retrival and manipulation

getAllMeasarray()

Returns all parsed experimental data in a single array [for fitting]

Return type:array
getAllTolarray()

Returns all parsed exp tolerances in a single array [for fitting]

Return type:array
getAllXarray()

Returns all parsed x coordinates in a single array [for fitting]

Return type:array
getAllYarray()

Returns all parsed y coordinates in a single array [for fitting]

Return type:array
getAllZarray()

Returns all parsed z coordinates in a single array [for fitting]

Return type:array
getConstant()

Return the value of the PRE constant

getDataType()

Returns the type of paramagnetic effect parsed

Return type:str
getDataset()

Returns the dataset (post readlines())

Return type:list
getMetalLoc()

Return the numpy array containing the metal position

getMetalLocx()

Return the metal x coordinate

getMetalLocy()

Return the metal y coordinate

getMetalLocz()

Return the metal z coordinate

getNumModels()

Returns number of models contained in the Bio.PDB structure object

Return type:int

Example Usage/Doctests

>>> indat = ['Example', 'pcs', '../tests/STRUCTURES/2AXD.pdb',         '../tests/DATASETS/PCS/THETA/DY.npc']
>>> p = ParaParser(indat)
>>> print p.getNumModels()
12
getPDBFn()

Returns the PDB file parsed

Return type:str
getParaDataFn()

Returns the paramagnetic data file parsed

Return type:str
getParsed()

Returns the list of ParaData objects (post doParse() call)

Return type:list
getSiteParams()

Return all 4 PRE centre parameters

getSiteParamsNice()

Print all 4 PRE centre parameters

getStructure()

Returns the Bio.PDB structure object

This structure object is of a Structure/Model/Chain/Residue/Atom architecture.

See: http://biopython.org/DIST/docs/cookbook/biopdb_faq.pdf and
http://biopython.org/DIST/docs/api/Bio.PDB-module.html
Return type:Bio.PDB structure object
parsingErrorMSG()

The parsing has failed as the datastructure in the object is empty

randomRemoveElements(percent, rseed=1)

Randomly remove ParaData elements from the objects datastructure

The original data structure of ParaData elements is returned

Parameters:
  • percent – Percentage to remove
  • percent – float
reloadParaData(paraDataList)

Load a data structure of ParaData elements into the current object

Parameters:
  • paraDataList – A list of ParaData elements
removeElement(at, res)

Remove a ParaData element from the datastructure

Parameters:
  • at – The spin type (atom identifier)
  • res – The residue id (residue number for the given atom)
saveSession(outname)

Pickle (store the entire object state). A way to save sessions

Parameters:
  • outname – the filename to store the pickled state in

Example Usage/DocTests

>>> import sys
>>> import os
>>> from ParaUtils import loadSession
>>> 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 = PREParser(dataset)
>>> pre.doParse()
>>> calcer = PRE(pre)
>>> av = calcer.calc()
>>> pre.saveSession("test.session")
>>> pre2 = loadSession("test.session")
>>> if pre.getSiteParams().all() != pre2.getSiteParams().all():
...     print "Failure!"
setCalcedToObs()

The calculated values become the experimental values

setConstant(constant)

Set/Change the value of the PRE constant

Parameters:
  • constant – The PRE constant
setMetalLoc(metal_xyz)

Set/Change the metal position

Parameters:
  • metal_xyz – The metal ion x,y,z coordinates
setMetalLocx(mx)

Set/Change the metal x coordinate

Parameters:
  • mx – The x coordinate
setMetalLocy(my)

Set/Change the metal y coordinate

Parameters:
  • my – The y coordinate
setMetalLocz(mz)

Set/Change the metal z coordinate

Parameters:
  • mz – The z coordinate
setModel(num)

Change the model (coordinates) associated with the dataset

Parameters:
  • num – Model number (1->1, 2->2)
setPDBFn(pdb_name)

Set/Change the PDB file to be parsed

Parameters:
  • pdb_name – The name (and path) to the PDB file
setParaDataFn(para_name)

Set/Change the paramagnetic data file to be parsed

Parameters:
  • para_name – The name (and path) to the paramagnetic data file
setSiteParam(params)

Set all 4 PRE centre parameters given an array of such data

Parameters:
  • params – array of the 4 PRE centre parameters: Mx, My, Mz, PRE_constant.
writeDataSetNumbat(fname)

Write the data (in the Numbat format) to a user specified file

Parameters:
  • fname – The output filename

Example Usage/Doctests:

>>> 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 = RDCParser(dataset)
>>> rdc.doParse()
>>> rdc.writeDataSetNumbat('rdc_test.npc')
Data in numbat format written to: rdc_test.npc
class ParaParser.ParaParser(stdin)

Builds an object that stores parameters, coordinates and datasets

Base class of a *parser object. Takes given information and builds an object. This object facilitates data storage, retrival and manipulation of paramagentic information.

Parameters:
  • stdin – A list of paramagnetic parameters.(with 4 elements) The 1st element is ignored (maintained for historical reasons). The subsequent items are the datatype, pdb file, and experimental data file.
addElement(at, res, exp, tol, coord, useFit=0)

Add a ParaData element to the datastructure

Note

Elements are instantiated as the ParaData base class

Parameters:
  • at – The spin type (atom identifier)
  • res – The residue id (residue number for the given atom)
  • exp – The experimental value
  • tol – The experimental tolerance
  • coord – The coordinates of the spin
  • useFit – Use this experimental value in fit [OPTIONAL]
addErrorFlatCoords(delta, rseed=1)

Add random error from a “square” distribution to the coordinates

Note

When using the square distribution, provided that delta is <= the experimental tolerance, generated error will not be larger than the experimental tolerance.

Parameters:
  • delta – Delta parameter to define the upper and lower limits [(exp val-delta), exp val,(exp val +delta).
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorFlatMeas(delta=0.0, rseed=1)

Add random error from a “square” dist to the experimental value

Note

When using the square distribution, provided that delta is <= the experimental tolerance, generated error will not be larger than the experimental tolerance.

Parameters:
  • delta – By default upper lower limits are [(exp val-tol), exp val, (exp val +tol)]. By passing a value for delta, the upper and lower limits become [(exp val-delta), exp val,(exp val +delta).
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorGaussCoords(delta, rseed=1)

Add random Gaussian error to the coordinates

The original data structure of ParaData elements is returned

Note

When using a Gaussian distribution, ~ 32% of the time the generated error will be larger or than the experimental tolerance.

Parameters:
  • delta – The sigma parameter for the distribution
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorGaussianMeas(delta=0.0, rseed=1)

Add random Gaussian error to the measured experimental value

The original data structure of ParaData elements is returned

Note

When using a Gaussian distribution, ~ 32% of the time the generated error will be larger or than the experimental tolerance.

Parameters:
  • delta – By default sigma is the experimental tolerance. By passing a value for delta, sigma becomes delta [OPTIONAL]
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
Return type:

list

getAllMeasarray()

Returns all parsed experimental data in a single array [for fitting]

Return type:array
getAllTolarray()

Returns all parsed exp tolerances in a single array [for fitting]

Return type:array
getAllXarray()

Returns all parsed x coordinates in a single array [for fitting]

Return type:array
getAllYarray()

Returns all parsed y coordinates in a single array [for fitting]

Return type:array
getAllZarray()

Returns all parsed z coordinates in a single array [for fitting]

Return type:array
getDataType()

Returns the type of paramagnetic effect parsed

Return type:str
getDataset()

Returns the dataset (post readlines())

Return type:list
getNumModels()

Returns number of models contained in the Bio.PDB structure object

Return type:int

Example Usage/Doctests

>>> indat = ['Example', 'pcs', '../tests/STRUCTURES/2AXD.pdb',         '../tests/DATASETS/PCS/THETA/DY.npc']
>>> p = ParaParser(indat)
>>> print p.getNumModels()
12
getPDBFn()

Returns the PDB file parsed

Return type:str
getParaDataFn()

Returns the paramagnetic data file parsed

Return type:str
getParsed()

Returns the list of ParaData objects (post doParse() call)

Return type:list
getStructure()

Returns the Bio.PDB structure object

This structure object is of a Structure/Model/Chain/Residue/Atom architecture.

See: http://biopython.org/DIST/docs/cookbook/biopdb_faq.pdf and
http://biopython.org/DIST/docs/api/Bio.PDB-module.html
Return type:Bio.PDB structure object
parsingErrorMSG()

The parsing has failed as the datastructure in the object is empty

randomRemoveElements(percent, rseed=1)

Randomly remove ParaData elements from the objects datastructure

The original data structure of ParaData elements is returned

Parameters:
  • percent – Percentage to remove
  • percent – float
reloadParaData(paraDataList)

Load a data structure of ParaData elements into the current object

Parameters:
  • paraDataList – A list of ParaData elements
removeElement(at, res)

Remove a ParaData element from the datastructure

Parameters:
  • at – The spin type (atom identifier)
  • res – The residue id (residue number for the given atom)
saveSession(outname)

Pickle (store the entire object state). A way to save sessions

Parameters:
  • outname – the filename to store the pickled state in

Example Usage/DocTests

>>> import sys
>>> import os
>>> from ParaUtils import loadSession
>>> 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 = PREParser(dataset)
>>> pre.doParse()
>>> calcer = PRE(pre)
>>> av = calcer.calc()
>>> pre.saveSession("test.session")
>>> pre2 = loadSession("test.session")
>>> if pre.getSiteParams().all() != pre2.getSiteParams().all():
...     print "Failure!"
setCalcedToObs()

The calculated values become the experimental values

setModel(num)

Change the model (coordinates) associated with the dataset

Parameters:
  • num – Model number (1->1, 2->2)
setPDBFn(pdb_name)

Set/Change the PDB file to be parsed

Parameters:
  • pdb_name – The name (and path) to the PDB file
setParaDataFn(para_name)

Set/Change the paramagnetic data file to be parsed

Parameters:
  • para_name – The name (and path) to the paramagnetic data file
writeDataSetNumbat(fname)

Write the data (in the Numbat format) to a user specified file

Parameters:
  • fname – The output filename

Example Usage/Doctests:

>>> 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 = RDCParser(dataset)
>>> rdc.doParse()
>>> rdc.writeDataSetNumbat('rdc_test.npc')
Data in numbat format written to: rdc_test.npc
class ParaParser.RDCParser(stdin)

A RDC object that stores Alignment-tensor parameters, coordinates and datasets.

Takes given information and builds an object (on doParse() call). This object facilitates data storage of the Alignment-tensor parameters, shape, Axial and Rhombic, orientation, Alpha, Beta and Gamma ,the experimental data and the spins for which experimental data is defined. This object also facilitates retrival and manipulation of this stored information.

Parameters:
  • stdin – A list of paramagnetic parameters.(with 9 elements) The 1st element is ignored (historical reasons). The subsequent items are the datatype, pdb file, and experimental data file, Axial and Rhombic and Alpha, Beta, Gamma.

Example Usage/Doctests

addElement(at1, res, exp, tol, c1, at2, c2, useFit=0)

Add a ParaData element to the datastructure

Parameters:
  • at1 – The spin type (atom identifier) of spin 1 in the RDC
  • res – The residue id (residue number for the given atom)
  • exp – The experimental value
  • tol – The experimental tolerance
  • c1 – The coordinate of the spin 1 in the RDC
  • at2 – The spin type (atom identifier) of spin 2 in the RDC
  • c2 – The coordinate of the spin 2 in the RDC
  • useFit – Use this experimental value in fit [OPTIONAL]
addErrorFlatCoords(delta, rseed=1)

Add random error from a “square” distribution to the coordinates

Note

When using the square distribution, provided that delta is <= the experimental tolerance, generated error will not be larger than the experimental tolerance.

Parameters:
  • delta – Delta parameter to define the upper and lower limits [(exp val-delta), exp val,(exp val +delta).
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorFlatMeas(delta=0.0, rseed=1)

Add random error from a “square” dist to the experimental value

Note

When using the square distribution, provided that delta is <= the experimental tolerance, generated error will not be larger than the experimental tolerance.

Parameters:
  • delta – By default upper lower limits are [(exp val-tol), exp val, (exp val +tol)]. By passing a value for delta, the upper and lower limits become [(exp val-delta), exp val,(exp val +delta).
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorGaussCoords(delta, rseed=1)

Add random Gaussian error to the coordinates

The original data structure of ParaData elements is returned

Note

When using a Gaussian distribution, ~ 32% of the time the generated error will be larger or than the experimental tolerance.

Parameters:
  • delta – The sigma parameter for the distribution
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
addErrorGaussianMeas(delta=0.0, rseed=1)

Add random Gaussian error to the measured experimental value

The original data structure of ParaData elements is returned

Note

When using a Gaussian distribution, ~ 32% of the time the generated error will be larger or than the experimental tolerance.

Parameters:
  • delta – By default sigma is the experimental tolerance. By passing a value for delta, sigma becomes delta [OPTIONAL]
  • rseed – Set the seed for the random generator [OPTIONAL, default is 1]
Return type:

list

doParse()

Parse the given the imput parameters, build ParaData objects allowing for easy retrival and manipulation

Warning

The ordering of atomtypes in the input file should be is very important!

Numbat format:

RESNUM ATOMTYPE1ATOMTYPE2 EXP_RDC EXP_TOL

For ATOMTYPE1ATOMTYPE2 = HN

ATOMTYPE1 must be the atom that is referenced second in the PDB file while ATOMTYPE2 must be the atom that referenced first in the pdb file.

getAllMeasarray()

Returns all parsed experimental data in a single array [for fitting]

Return type:array
getAllTolarray()

Returns all parsed exp tolerances in a single array [for fitting]

Return type:array
getAllXarray()

Returns all x coordinates in a single array (x2) [for fitting]

getAllYarray()

Returns all y coordinates in a single array (x2) [for fitting]

getAllZarray()

Returns all z coordinates in a single array (x2) [for fitting]

getAlpha()

Return the Alignment-tensor’s frame Alpha angle

getAxial()

Return the Alignment-tensor’s Axial component in SI units

getB0()

Return the magnetic field strength (in Tesla)

200 MHz -> 4.7 T, 300 MHz -> 7.0 T, 500 MHz -> 11.7 T, 800 MHz -> 18.8 T, 900 MHz -> 21.1 T

getBeta()

Return the Alignment-tensor’s frame Beta angle

getDataType()

Returns the type of paramagnetic effect parsed

Return type:str
getDataset()

Returns the dataset (post readlines())

Return type:list
getGamma()

Return the Alignment-tensor’s frame Gamma angle

getNumModels()

Returns number of models contained in the Bio.PDB structure object

Return type:int

Example Usage/Doctests

>>> indat = ['Example', 'pcs', '../tests/STRUCTURES/2AXD.pdb',         '../tests/DATASETS/PCS/THETA/DY.npc']
>>> p = ParaParser(indat)
>>> print p.getNumModels()
12
getOrder()

Return the order paramameter

getPDBFn()

Returns the PDB file parsed

Return type:str
getParaDataFn()

Returns the paramagnetic data file parsed

Return type:str
getParsed()

Returns the list of ParaData objects (post doParse() call)

Return type:list
getRhombic()

Return the Alignment-tensor’s Rhombic component in SI units

getStructure()

Returns the Bio.PDB structure object

This structure object is of a Structure/Model/Chain/Residue/Atom architecture.

See: http://biopython.org/DIST/docs/cookbook/biopdb_faq.pdf and
http://biopython.org/DIST/docs/api/Bio.PDB-module.html
Return type:Bio.PDB structure object
getTemp()

Return the temperature (in Kelvin)

getTensorParams()

Return all 5 Alignment-tensor parameters

getTensorParamsNice()

Print all 5 Alignment-tensor parameters

parsingErrorMSG()

The parsing has failed as the datastructure in the object is empty

randomRemoveElements(percent, rseed=1)

Randomly remove ParaData elements from the objects datastructure

The original data structure of ParaData elements is returned

Parameters:
  • percent – Percentage to remove
  • percent – float
reloadParaData(paraDataList)

Load a data structure of ParaData elements into the current object

Parameters:
  • paraDataList – A list of ParaData elements
removeElement(at, res)

Remove a ParaData element from the datastructure

Parameters:
  • at – The spin type (atom identifier)
  • res – The residue id (residue number for the given atom)
saveSession(outname)

Pickle (store the entire object state). A way to save sessions

Parameters:
  • outname – the filename to store the pickled state in

Example Usage/DocTests

>>> import sys
>>> import os
>>> from ParaUtils import loadSession
>>> 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 = PREParser(dataset)
>>> pre.doParse()
>>> calcer = PRE(pre)
>>> av = calcer.calc()
>>> pre.saveSession("test.session")
>>> pre2 = loadSession("test.session")
>>> if pre.getSiteParams().all() != pre2.getSiteParams().all():
...     print "Failure!"
setAlpha(alpha)

Set/Change the Alignment-tensor’s frame Alpha angle

Parameters:
  • alpha – The Alpha angle in degrees
setAxial(axial)

Set/Change the Alignment-tensor’s Axial component [to VVU units]

Parameters:
  • axial – The Axial component in SI units
setB0(b0)

Set/Change the magnetic field strength (in Tesla)

Parameters:
  • b0 – Field strength in Tesla
setBeta(beta)

Set/Change the Alignment-tensor’s frame Beta angle

Parameters:
  • beta – The Beta angle in degrees
setCalcedToObs()

The calculated values become the experimental values

setGamma(gamma)

Set/Change the Alignment-tensor’s frame Gamma angle

Parameters:
  • gamma – The Gamma angle in degrees
setModel(num)

Change the model (coordinates) associated with the dataset

Parameters:
  • num – Model number (1->1, 2->2)
setOrder(Odparam)

Set/Change the order paramameter

Parameters:
  • Odparam – The order parameter
setPDBFn(pdb_name)

Set/Change the PDB file to be parsed

Parameters:
  • pdb_name – The name (and path) to the PDB file
setParaDataFn(para_name)

Set/Change the paramagnetic data file to be parsed

Parameters:
  • para_name – The name (and path) to the paramagnetic data file
setRhombic(rhombic)

Set/Change the Alignment-tensor’s Rhombic component [to VVU units]

Parameters:
  • rhombic – The Rhombic component in SI units
setTemp(temperature)

Set/Change the temperature (in Kelvin)

Parameters:
  • temperature – Experimental temperature in Kelvin
setTensorParams(params)

Set all 5 X-tensor parameters given an array of such data

Parameters:
  • params – array of the 5 Alignment-tensor parameters: Ax, Rh, A, B, G
writeDataSetNumbat(fname)

Write the data (in the Numbat format) to a user specified file

Parameters:
  • fname – The output filename

Example Usage/Doctests:

>>> 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 = RDCParser(dataset)
>>> rdc.doParse()
>>> rdc.writeDataSetNumbat('rdc_test.npc')
Data in numbat format written to: rdc_test.npc

Quirks/TODO