Ejemplo n.º 1
0
def test_2_scalar_couplings(get_fn):
    t = md.load(get_fn('frame0.h5'))  # This is Alanine dipeptide
    for model in ["Ruterjans1999", "Bax2007", "Bax1997"]:
        indices, J = md.compute_J3_HN_HA(t)
        eq(indices.shape, (1, 4))
        eq(J.shape, (501, 1))
        J = J.mean()
        assert abs(J - 6.06) <= 2.0, "Value is far from experimental value."
Ejemplo n.º 2
0
def test_2_scalar_couplings():
    t = md.load(get_fn('frame0.h5'))  # This is Alanine dipeptide
    for model in ["Ruterjans1999", "Bax2007", "Bax1997"]:
        indices, J = md.compute_J3_HN_HA(t)
        eq(indices.shape, (1, 4))
        eq(J.shape, (501, 1))
        J = J.mean()
        assert abs(J - 6.06) <= 2.0, "Value is far from experimental value."
Ejemplo n.º 3
0
def test_3_scalar_couplings(get_fn):
    t = md.load(get_fn('1bpi.pdb'))
    for model in ["Bax2007"]:
        indices_HA, J_HA = md.compute_J3_HN_HA(t)
        indices_C, J_C = md.compute_J3_HN_C(t)
        indices_CB, J_CB = md.compute_J3_HN_CB(t)

        eq(indices_HA.shape, (57, 4))
        eq(indices_C.shape, (57, 4))
        eq(indices_CB.shape, (57, 4))
        eq(J_HA.shape, (1, 57))
        eq(J_C.shape, (1, 57))
        eq(J_CB.shape, (1, 57))

        np.testing.assert_almost_equal(J_HA[0, 0], 0.48885268)
        np.testing.assert_almost_equal(J_C[0, 0], 3.840529)
        np.testing.assert_almost_equal(J_CB[0, 0], 2.5702963)
Ejemplo n.º 4
0
def test_3_scalar_couplings(get_fn):
    t = md.load(get_fn('1bpi.pdb'))
    for model in ["Bax2007"]:
        indices_HA, J_HA = md.compute_J3_HN_HA(t)
        indices_C, J_C = md.compute_J3_HN_C(t)
        indices_CB, J_CB = md.compute_J3_HN_CB(t)

        eq(indices_HA.shape, (57, 4))
        eq(indices_C.shape, (57, 4))
        eq(indices_CB.shape, (57, 4))
        eq(J_HA.shape, (1, 57))
        eq(J_C.shape, (1, 57))
        eq(J_CB.shape, (1, 57))

        np.testing.assert_almost_equal(J_HA[0, 0], 0.48885268)
        np.testing.assert_almost_equal(J_C[0, 0], 3.840529)
        np.testing.assert_almost_equal(J_CB[0, 0], 2.5702963)
Ejemplo n.º 5
0
    def analyze(self, traj):
        top, bonds = traj.top.to_dataframe()
        ind, values = md.compute_J3_HN_HA(traj)
        prediction = pd.DataFrame({"value":values.mean(0)})

        prediction["resSeq"] = top.ix[ind[:, -1]].resSeq.values  # Set the residue numbers to the last (fourth) atom in the dihedral
        
        if top.ix[0].resName == "ACE":
            prediction["resSeq"] -= 1  # HARDCODED Hack to account for the ACE residue!!!!!!!!!!  Fix me later!
        
        prediction["AA"] = top.ix[ind[:, -1]].resName.values
        prediction["expt"] = "3JHNHA"
        prediction["system"] = self.identifier
        prediction["sigma"] = 0.36
        
        multi_index = prediction.set_index(["system", "expt", "resSeq"]).index
        prediction["identifier"] = multi_index_to_str(multi_index)
        prediction = prediction.set_index("identifier")

        return prediction        
Ejemplo n.º 6
0
    def analyze(self, traj):
        top, bonds = traj.top.to_dataframe()
        ind, values = md.compute_J3_HN_HA(traj)
        prediction = pd.DataFrame({"value": values.mean(0)})

        prediction["resSeq"] = top.ix[
            ind[:,
                -1]].resSeq.values  # Set the residue numbers to the last (fourth) atom in the dihedral

        if top.ix[0].resName == "ACE":
            prediction[
                "resSeq"] -= 1  # HARDCODED Hack to account for the ACE residue!!!!!!!!!!  Fix me later!

        prediction["AA"] = top.ix[ind[:, -1]].resName.values
        prediction["expt"] = "3JHNHA"
        prediction["system"] = self.identifier
        prediction["sigma"] = 0.36

        multi_index = prediction.set_index(["system", "expt", "resSeq"]).index
        prediction["identifier"] = multi_index_to_str(multi_index)
        prediction = prediction.set_index("identifier")

        return prediction
Ejemplo n.º 7
0
def index2res(structure):
    """
    The function creates list of residues based on files with indexes, used to calculate
    J3 coupling constants. This stuff should have been done during J3 calculations, because
    outputing atom indexes is meaningless, as they depend on topology.For example, amide
    nitrogen of the second residue may have different atomic number in pdb, containing only
    backbone,than in pdb, containing both backbone and sidechain.

    In the input file, each line correspond to 4 indexes of atoms, which form a dihedral
    angle, used to compute J3. For Halpha-HN, this list includs atoms, forming phi
    dihedral angle. These are C(i-1),N(i),Ca(i),C(i). We are interested in residue,
    Nitrogen from which participates in forming a bond. So we are looling for the 2 atom
    (1 by Python numeration)

    Input:

           structure - mdtraj frame

    Output:

           residue_index - list of Python-numerated residue ids.
           residue_name

    """

    index, J3_inp = md.compute_J3_HN_HA(structure)
    assert (index.shape[0] == structure.n_residues - 1)
    residue_index = []
    residue_name = []

    for i in range(0, index.shape[0]):
        atom_index = int(index[i, 1])
        assert (structure.top.atom(atom_index).name == 'N')
        residue_index.append(structure.top.atom(atom_index).residue.index)
        residue_name.append(structure.top.atom(atom_index).residue.name)

    return (residue_index, residue_name)
Ejemplo n.º 8
0
def test_3_scalar_couplings():
    t = md.load(get_fn('1bpi.pdb'))
    for model in ["Ruterjans1999", "Bax2007", "Bax1997"]:
        indices, J = md.compute_J3_HN_HA(t)
Ejemplo n.º 9
0
def test_3_scalar_couplings():
    t = md.load(get_fn('1bpi.pdb'))
    for model in ["Ruterjans1999", "Bax2007", "Bax1997"]:
        indices, J = md.compute_J3_HN_HA(t)
Ejemplo n.º 10
0
                    metavar='pairs',
                    type=str,
                    help='filename of pairs to calc 3J const')
parser.add_argument('weight',
                    metavar='weight',
                    type=str,
                    help='filename of weights')

args = parser.parse_args()
xtc = args.xtc
pdb = args.pdb
basename = args.basename

t = md.load(xtc, top=pdb)

list, J3_HN_HA = md.compute_J3_HN_HA(t)

pairs = []
f = open(args.pairs, 'r')
l = f.readlines()
f.close()
for item in l:
    pairs.append(item)

w = []
f = open(args.weight, 'r')
l = f.readlines()
f.close()
for item in l:
    i = item.split()
    w.append(float(i[1]))
parsed = nmrpystar.parse(open("./19127.str").read())
print(parsed.status)

q = parsed.value.saves["coupling_constant_list_1"].loops[1]
x = pd.DataFrame(q.rows, columns=q.keys)
x = x[[
    "Coupling_constant.Seq_ID_1", "Coupling_constant.Val",
    "Coupling_constant.Val_err"
]]
x.rename(columns={
    "Coupling_constant.Seq_ID_1": "resSeq",
    "Coupling_constant.Val": "value",
    "Coupling_constant.Val_err": "err"
},
         inplace=True)

# Need to make dtypes match to do eventual comparison.
x["resSeq"] = x["resSeq"].astype('int')
x["value"] = x["value"].astype('float')

expt = x.set_index(["resSeq"]).value

top, bonds = t.top.to_dataframe()
ind, values = md.compute_J3_HN_HA(t)
prediction = pd.Series(values.mean(0), top.ix[ind[:, -1]].resSeq)

delta = (expt - prediction).dropna()
delta.name = "value"

rms = (delta**2.).mean(0)**0.5
parsed = nmrpystar.parse(open("./19127.str").read())
print(parsed.status)

q = parsed.value.saves["coupling_constant_list_1"].loops[1]
x = pd.DataFrame(q.rows, columns=q.keys)
x = x[["Coupling_constant.Seq_ID_1", "Coupling_constant.Val", "Coupling_constant.Val_err"]]
x.rename(
    columns={
        "Coupling_constant.Seq_ID_1": "resSeq",
        "Coupling_constant.Val": "value",
        "Coupling_constant.Val_err": "err",
    },
    inplace=True,
)

# Need to make dtypes match to do eventual comparison.
x["resSeq"] = x["resSeq"].astype("int")
x["value"] = x["value"].astype("float")

expt = x.set_index(["resSeq"]).value

top, bonds = t.top.to_dataframe()
ind, values = md.compute_J3_HN_HA(t)
prediction = pd.Series(values.mean(0), top.ix[ind[:, -1]].resSeq)


delta = (expt - prediction).dropna()
delta.name = "value"

rms = (delta ** 2.0).mean(0) ** 0.5
    reference.append(xyz)

reference = pd.DataFrame(reference, columns=["seq", "resSeq", "value"])
reference = reference.set_index(["seq", "resSeq"]).value
reference = reference.drop_duplicates()


data = []
for (ff, water, seq) in products:
    try:
        aa0, aa1 = seq.split("_")[1]
        aa_string = "%s%s" % (aa0, aa1)
        t = md.load("./dcd/%s_%s_%s.dcd" % (ff, water, seq), top="./pdbs/%s.pdb" % (seq))[1500:]
    except:
        continue
    #phi = md.compute_phi(t)[1] * 180 / np.pi
    #J0, J1 = scalar_couplings.J3_HN_HA(phi).mean(0)
    J0, J1 = md.compute_J3_HN_HA(t)[1].mean(0)
    data.append([ff, water, aa_string, 0, J0])
    data.append([ff, water, aa_string, 1, J1])

data = pd.DataFrame(data, columns=["ff", "water", "seq", "resSeq", "value"])


X = data.pivot_table(cols=["seq", "resSeq"], rows=["ff", "water"], values="value")
delta = X - reference
Z = (delta / 0.36)
rms_by_model = (Z ** 2.).mean(1) ** 0.5
rms_by_model