def get_qfac(protein_file, npc, res_num, q_fac_dict):
    """Fit and individual tensor to each model in the bundle and save each Q-factor into an universal dictionary"""
    # Load the protein, load the npc
    prot = protein.load_pdb(protein_file)
    rawData = dataparse.read_pcs(npc)
    qfactor_sep = {}

    # Initialize metal instance for search and set the initial position
    mStart = metal.Metal()
    mStart.position = prot[0]['A'][res_num]['CA'].position

    # Loop: for every model fit an individual tensor and store Q-factors and tensor components into a dict
    for model in prot:
        parsedData = prot.parse(rawData, models=model.id)
        [mGuess], _ = fit.svd_gridsearch_fit_metal_from_pcs([mStart],
                                                            [parsedData],
                                                            radius=10,
                                                            points=10)
        [mFit], [data] = fit.nlr_fit_metal_from_pcs([mGuess], [parsedData])
        qfactor_sep[model.id] = fit.qfactor(data)
        # Save in universal dictionary
        if type(q_fact_dict[model.id]) == list:
            q_fac_dict[model.id].append(fit.qfactor(data))
        else:
            q_fac_dict[model.id] = [fit.qfactor(data)]

    minModel, minQfac = sorted(qfactor_sep.items(), key=lambda x: x[1])[0]
def get_tensor(protein_file, model, npc, res_num, tag_number):
    """Fit a tensor only to the specified model of the bundle pdb and writes down the corresponding components and
    ORI"""
    # Load the protein, load the npc
    prot = protein.load_pdb(protein_file)
    rawData = dataparse.read_pcs(npc)

    # Initialize metal instance for search and set the initial position
    mStart = metal.Metal()
    mStart.position = prot[model]['A'][res_num]['CA'].position

    # Get tensor on single structure
    for mod in prot:
        if mod.id == model:
            parsedData = prot.parse(rawData, models=mod.id)
            [mGuess], [data
                       ] = fit.svd_gridsearch_fit_metal_from_pcs([mStart],
                                                                 [parsedData],
                                                                 radius=10,
                                                                 points=10)
            [mFit], [data] = fit.nlr_fit_metal_from_pcs([mGuess], [parsedData])

    Axial = round(mFit.ax * 1E32, 3)
    Rhombicity = round((mFit.rh / mFit.ax), 3)

    # Generate .pcs metal center file
    name = os.path.splitext(protein_file)[0] + "_metal_centers.pcs"
    f = open(name, 'a+')
    f.write(5 * " " + str(tag_number) + (14 - len(str(Axial))) * " " +
            str(Axial) + "E+04      " + str(Rhombicity) + 5 * " " +
            str(Tag_dictionary[tag_number]) + "\n")

    # Extract information about the metal center position relative to the protein backbone and write them
    ori = mFit.position
    name_ori_upl = os.path.splitext(protein_file)[0] + "_ORI_UPL.upl"
    name_ori_lol = os.path.splitext(protein_file)[0] + "_ORI_LOL.lol"
    u = open(name_ori_upl, 'a+')
    l = open(name_ori_lol, 'a+')
    for res_num in Ori_dictionary[tag_number]:
        res = prot[model]['A'][res_num]['CA'].position
        res_type = prot[model]['A'][res_num].get_resname()
        d = math.sqrt(((ori[0] - res[0])**2) + ((ori[1] - res[1])**2) +
                      ((ori[2] - res[2])**2))
        d_upl = round((d * 1E10) + 0.5, 2)
        d_lol = round((d * 1E10) - 0.5, 2)
        u.write((3 - len(str(res_num))) * " " + str(res_num) + " " + res_type +
                "  CA    " + str(Tag_dictionary[tag_number]) + " ORI  A0" +
                (10 - len(str(d_upl))) * " " + str(d_upl) + "\n")
        l.write((3 - len(str(res_num))) * " " + str(res_num) + " " + res_type +
                "  CA    " + str(Tag_dictionary[tag_number]) + " ORI  A0" +
                (10 - len(str(d_lol))) * " " + str(d_lol) + "\n")
from paramagpy import protein, fit, dataparse, metal
import numpy as np

# Load the PDB file
prot = protein.load_pdb('../data_files/2bcb.pdb')

# Load the PCS data
rawData = dataparse.read_pcs('../data_files/calbindin_Er_HN_PCS_errors.npc')

# Associate PCS data with atoms of the PDB
parsedData = prot.parse(rawData)

# Define an initial tensor
mStart = metal.Metal()

# Set the starting position to an atom close to the metal
mStart.position = prot[0]['A'][56]['CA'].position

# Calculate an initial tensor from an SVD gridsearch
[mGuess], [data] = fit.svd_gridsearch_fit_metal_from_pcs([mStart],
                                                         [parsedData],
                                                         radius=10,
                                                         points=10)

# Refine the tensor using non-linear regression
[mFit], [data] = fit.nlr_fit_metal_from_pcs([mGuess], [parsedData])

# Estimate uncertainty sourcing noise from the models of the PDB
[mod_all], [mod_std] = fit.fit_error_models(fit.nlr_fit_metal_from_pcs,
                                            initMetals=[mFit],
                                            dataArrays=[parsedData])
Exemple #4
0
# Load the PDB file
prot = protein.load_pdb('../data_files/4icbH_mut.pdb')

# Load the PCS data
rawData1 = dataparse.read_pcs('../data_files/calbindin_Tb_HN_PCS.npc')
rawData2 = dataparse.read_pcs('../data_files/calbindin_Er_HN_PCS.npc')
rawData3 = dataparse.read_pcs('../data_files/calbindin_Yb_HN_PCS.npc')

# Associate PCS data with atoms of the PDB
parsedData = []
for rd in [rawData1, rawData2, rawData3]:
    parsedData.append(prot.parse(rd))

# Make a list of starting tensors
mStart = [metal.Metal(), metal.Metal(), metal.Metal()]

# Set the starting position to an atom close to the metal
mStart[0].position = prot[0]['A'][56]['CA'].position

# Calculate initial tensors from an SVD gridsearch
mGuess = fit.svd_gridsearch_fit_metal_from_pcs(mStart,
                                               parsedData,
                                               radius=10,
                                               points=10)

# Refine the tensors using non-linear regression
fitParameters = ['x', 'y', 'z', 'ax', 'rh', 'a', 'b', 'g']
mFit = fit.nlr_fit_metal_from_pcs(mGuess, parsedData, fitParameters)

# Save the fitted tensors to files
Exemple #5
0
from paramagpy import protein, fit, dataparse, metal

# Load the PDB file
prot = protein.load_pdb('../data_files/2kox.pdb')

# Load the RDC data
rawData1 = dataparse.read_rdc('../data_files/ubiquitin_a28c_c1_Tb_HN.rdc')
rawData2 = dataparse.read_rdc('../data_files/ubiquitin_s57c_c1_Tb_HN.rdc')

# Associate RDC data with atoms of the PDB
parsedData1 = prot.parse(rawData1)
parsedData2 = prot.parse(rawData2)

# Define an initial tensor
mStart1 = metal.Metal(B0=18.8, temperature=308.0)
mStart2 = metal.Metal(B0=18.8, temperature=308.0)

# Calculate the tensor using SVD
[sol1], [data1] = fit.svd_fit_metal_from_rdc([mStart1], [parsedData1],
                                             ensembleAverage=True)
[sol2], [data2] = fit.svd_fit_metal_from_rdc([mStart2], [parsedData2],
                                             ensembleAverage=True)

# Save the fitted tensor to file
sol1.save('ubiquitin_a28c_c1_Tb_tensor.txt')
sol2.save('ubiquitin_s57c_c1_Tb_tensor.txt')

#### Plot the correlation ####
from matplotlib import pyplot as plt
fig = plt.figure(figsize=(5, 10))
ax1 = fig.add_subplot(211)
from paramagpy import protein, metal, fit, dataparse
from matplotlib import pyplot as plt
import numpy as np

prot = protein.load_pdb('../data_files/parashift_Tb.pdb')
pre_exp = dataparse.read_pre('../data_files/parashift_Tb_R1_exp.pre')
exp = prot.parse(pre_exp)

m = metal.Metal(taur=0.42E-9, B0=1.0, temperature=300.0)
m.set_lanthanide('Tb')

m.g_tensor = np.array([[1754.0, -859.0, -207.0], [-859.0, 2285.0, -351.0],
                       [-207.0, -351.0, -196.0]]) * 1E-60

m0 = metal.Metal(taur=0.42E-9, B0=1.0, temperature=300.0)
m0.set_lanthanide('Tb')

[mfit], [data] = fit.nlr_fit_metal_from_pre([m0], [exp],
                                            params=('t1e', 'gax', 'grh', 'a',
                                                    'b', 'g'),
                                            rtypes=['r1'],
                                            usesbm=False,
                                            usegsbm=True,
                                            usedsa=True,
                                            usecsa=False,
                                            progress=None)

pos = np.array([a.position for a in exp['atm']])
gam = np.array([a.gamma for a in exp['atm']])

fig = plt.figure(figsize=(5, 5))
from paramagpy import protein, fit, dataparse, metal
import numpy as np

# Load the PDB file and get iron centre
prot = protein.load_pdb('../data_files/1bzrH.pdb')
ironAtom = prot[0]['A'][("H_HEM", 154, " ")]['FE']

# Make high and low spin Fe paramagnetic centers
met_cn = metal.Metal(position=ironAtom.position,
                     B0=18.79,
                     temperature=303.0,
                     taur=5.7E-9)
met_f = met_cn.copy()
met_cn.iso = 4.4E-32
met_f.iso = 30.1E-32

# Load experimental data
data_cn = prot.parse(dataparse.read_ccr("../data_files/myoglobin_cn.ccr"))
data_f = prot.parse(dataparse.read_ccr("../data_files/myoglobin_f.ccr"))

# Calculate the cross-correlated realxation
compare_cn = []
for H, N, value, error in data_cn[['atm', 'atx', 'exp', 'err']]:
    delta = met_cn.atom_ccr(H, N)
    compare_cn.append((value, delta * 0.5))

compare_f = []
for H, N, value, error in data_f[['atm', 'atx', 'exp', 'err']]:
    delta = met_f.atom_ccr(H, N)
    compare_f.append((value, delta * 0.5))