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]
Beispiel #2
0
for metal, data in zip(mFit, parsedData):
    ex = []
    ca = []
    for atom, exp_pcs, error in data:
        ex.append(exp_pcs)
        ca.append(metal.atom_pcs(atom))
    exp.append(ex)
    cal.append(ca)

#### Plot the correlation ####
from matplotlib import pyplot as plt
fig, ax = plt.subplots(figsize=(5, 5))

# Plot the data
for e, c, name, colour in zip(exp, cal, ['Tb', 'Er', 'Yb'], ['r', 'g', 'b']):
    qfactor = fit.qfactor(e, c)
    ax.plot(e,
            c,
            marker='o',
            lw=0,
            ms=1,
            c=colour,
            label="{0:} - {1:5.3f}".format(name, qfactor))

# Plot a diagonal
l, h = ax.get_xlim()
ax.plot([l, h], [l, h], '-k', zorder=0)
ax.set_xlim(l, h)
ax.set_ylim(l, h)

# Axis labels
Beispiel #3
0
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])

# Calculate the Q-factor
qfac = fit.qfactor(data)

# Save the fitted tensor to file
mFit.save('calbindin_Er_HN_PCS_tensor.txt')

#### Plot the correlation ####
from matplotlib import pyplot as plt
fig, ax = plt.subplots(figsize=(5, 5))

# Plot the data
ax.plot(data['exp'],
        data['cal'],
        marker='o',
        lw=0,
        ms=3,
        c='r',
Beispiel #4
0
#### Plot the correlation ####
from matplotlib import pyplot as plt
fig = plt.figure(figsize=(5, 10))
ax1 = fig.add_subplot(211)
ax2 = fig.add_subplot(212)
ax1.set_title('A28C-C1-Tb')
ax2.set_title('S57C-C1-Tb')

for sol, ax, data in zip([sol1, sol2], [ax1, ax2], [data1, data2]):

    # Calculate ensemble averages
    dataEAv = fit.ensemble_average(data)

    # Calculate the Q-factor
    qfac = fit.qfactor(data, ensembleAverage=True)

    # Plot all models
    ax.plot(data['exp'],
            data['cal'],
            marker='o',
            lw=0,
            ms=2,
            c='b',
            alpha=0.5,
            label="All models: Q = {:5.4f}".format(qfac))

    # Plot the ensemble average
    ax.plot(dataEAv['exp'],
            dataEAv['cal'],
            marker='o',
# Refine the tensors using non-linear regression
fitParameters = ['x', 'y', 'z', 'ax', 'rh', 'a', 'b', 'g']
mFit, datas = fit.nlr_fit_metal_from_pcs(mGuess, parsedData, fitParameters)

# Save the fitted tensors to files
for name, metal in zip(['Tb', 'Er', 'Yb'], mFit):
    metal.save("tensor_{}.txt".format(name))

#### Plot the correlation ####
from matplotlib import pyplot as plt
fig, ax = plt.subplots(figsize=(5, 5))

# Plot the data
for d, name, colour in zip(datas, ['Tb', 'Er', 'Yb'], ['r', 'g', 'b']):
    qfactor = fit.qfactor(d)
    ax.plot(d['exp'],
            d['cal'],
            marker='o',
            lw=0,
            ms=1,
            c=colour,
            label="{0:} - {1:5.3f}".format(name, qfactor))

# Plot a diagonal
l, h = ax.get_xlim()
ax.plot([l, h], [l, h], '-k', zorder=0)
ax.set_xlim(l, h)
ax.set_ylim(l, h)

# Axis labels