Ejemplo n.º 1
0
def compute_mdtraj_order_parmeters(trajectory_file, rmsd_reference_structure=None):
    # documentation: http://mdtraj.org/1.8.0/analysis.html#
    trajectory = md.load(trajectory_file)

    return_values = []
    return_value_names = []

    if not rmsd_reference_structure == None:
        reference = md.load(rmsd_reference_structure)
        rmsd = md.rmsd(trajectory, reference)
        return_values.append(rmsd)
        return_value_names.append("RMSD")

    hydrogen_bonds = np.array([np.sum(x) for x in md.kabsch_sander(trajectory)])
    return_values.append(hydrogen_bonds)
    return_value_names.append("HBondEnergy")

    ss = md.compute_dssp(trajectory)
    shape = ss.shape
    transdict = dict(zip(list(set(list(ss.flatten()))),range(len(list(set(list(ss.flatten())))))))
    ss = np.array([transdict[x] for x in ss.flatten()]).reshape(shape).T
    return_values.append(ss)
    return_value_names.append("SecondaryStructure")

    rg = md.compute_rg(trajectory)
    return_values.append(rg)
    return_value_names.append("Rg")

    distances, residue_pairs = md.compute_contacts(trajectory, scheme='ca')
    contacts = md.geometry.squareform(distances, residue_pairs)
    return_values.append(contacts)
    return_value_names.append("Contacts")

    return dict(zip(return_value_names, return_values))
Ejemplo n.º 2
0
def hydrogenbond(pdbfile):
    """
        Calculate number of hydrogen bonds [1,2] and hydrogen bond energy [3]
        using three methods as implemented in MDtraj [4] for a single PDB file.
        [1] E. N. Baker and R. E. Hubbard, "Hydrogen bonding in globular proteins",
            Progress in Biophysics and Molecular Biology, vol. 44, no. 2, 
            pp. 97-179, 1984.
        [2] P. Wernet et al., "The Structure of the First Coordination Shell in 
            Liquid Water", Science, vol. 304, no. 5673, pp. 995-999, 2004.
        [3] W. Kabsch and C. Sander, "Dictionary of protein secondary structure: 
            Pattern recognition of hydrogen-bonded and geometrical features",
            Biopolymers, vol. 22, no. 12, pp. 2577"2637, 1983.
        [4] R. T. McGibbon et al., "MDTraj: A Modern Open Library for the 
            Analysis of Molecular Dynamics Trajectories", Biophysical Journal, 
            vol. 109, no. 8, pp. 1528-1532, 2015.
    """
    pdb = mdtraj.load(pdbfile)
    desc = dict()
    desc['HB_BH'] = float(mdtraj.baker_hubbard(pdb).shape[0])
    desc['HB_WN'] = float(mdtraj.wernet_nilsson(pdb)[0].shape[0])
    desc['HB_KS'] = float(mdtraj.kabsch_sander(pdb)[0].sum())
    return desc
Ejemplo n.º 3
0
        formatter_class=argparse.RawDescriptionHelpFormatter)

    #parser.add_argument('-', "--", help="", default="")

    parser.add_argument("-v",
                        "--verbose",
                        action="store_true",
                        help="be verbose")
    parser.add_argument("file", help="", default="", nargs='+')
    return parser


if __name__ == '__main__':
    parser = get_parser()
    args = parser.parse_args()

    if list != type(args.file):
        args.file = [args.file]

    for f in args.file:
        import mdtraj as md
        print(f, '---------------------')
        t = md.load(f)
        print(md.kabsch_sander(t))
        hb = md.wernet_nilsson(t)
        print(hb)
        print(len(hb[0]))
        hb = md.baker_hubbard(t)
        print(hb)
        print(len(hb))
Ejemplo n.º 4
0
#Step 7 Analysis (change the input file name)
import pickle
import mdtraj as md

with open('fs-khybrid-clusters0020-centers.pickle', 'rb') as f:
    ctr_structs = md.join(pickle.load(f))

#Step 8
hbonds = md.kabsch_sander(ctr_structs)

#Step 9
import matplotlib.pylab as plt
weighted_hbond_mtx = sum(p * h for p, h in zip(m.eq_probs_, hbonds)).todense()
plt.imshow(weighted_hbond_mtx, cmap='viridis_r')
plt.colorbar()

all_hbonds = set()

#Step11
# accumulate all the possible pairs of residues involved in hbonds
for i in range(len(ctr_structs)):
    donors, acceptors = np.where(hbonds[i].todense() != 0)
    all_hbonds.update([(d, a) for d, a in zip(donors, acceptors)])

# make a list so that it's ordered
all_hbonds = list(all_hbonds)

# this matrix of length n_states will have each binary feature vector
hbond_presence = np.zeros((m.n_states_, len(all_hbonds)), dtype='uint8')

# set each value i, j to one if state i has hbond j.