示例#1
0
def get_contacts_file(pdbIN, selection_string, selection, dist_file):
    import MDAnalysis
    from MDAnalysis.analysis import contacts
    u = MDAnalysis.Universe(pdbIN + "_COM.pdb")
    #select protein molecule
    protein = u.select_atoms(selection_string)
    #  resid square array
    residArray = square_matrix_tuple(protein.resids, [('r1', 'i'),
                                                      ('r2', 'i')])
    # resname square array
    resnameArray = square_matrix_tuple(convert3to1(protein.resnames),
                                       [('r1', 'S10'), ('r2', 'S10')])
    #
    cutoff = get_custom_matrix(dist_file, resnameArray, len(protein.resnames))
    # contacts routine
    ca1 = contacts.Contacts(u,
                            selection=(selection_string, selection_string),
                            refgroup=(protein, protein),
                            radius=cutoff)
    # initial contact list
    initial_contacts_resid = residArray[ca1.initial_contacts]
    # initial distance list
    distance_contacts_resid = ca1.r0[0][ca1.initial_contacts]
    # initial  resname list
    resname_contacts_resid = resnameArray[ca1.initial_contacts]
    cutoff_array = cutoff[ca1.initial_contacts]
    # write the native contacts found.
    write_contact_file(initial_contacts_resid, distance_contacts_resid,
                       resname_contacts_resid, pdbIN, selection, cutoff_array)
示例#2
0
 def _run_Contacts(self, **kwargs):
     acidic = self.universe.select_atoms(self.sel_acidic)
     basic = self.universe.select_atoms(self.sel_basic)
     return contacts.Contacts(self.universe,
                              selection=(self.sel_acidic, self.sel_basic),
                              refgroup=(acidic, basic),
                              radius=6.0,
                              **kwargs).run()
 def _run_Contacts(self, universe, start=None, stop=None, step=None, **kwargs):
     acidic = universe.select_atoms(self.sel_acidic)
     basic = universe.select_atoms(self.sel_basic)
     return contacts.Contacts(
         universe,
         select=(self.sel_acidic, self.sel_basic),
         refgroup=(acidic, basic),
         radius=6.0,
         **kwargs).run(start=start, stop=stop, step=step)
示例#4
0
 def test_distance_box(self, pbc, expected):
     u = mda.Universe(TPR, XTC)
     sel_basic = "(resname ARG LYS)"
     sel_acidic = "(resname ASP GLU)"
     acidic = u.select_atoms(sel_acidic)
     basic = u.select_atoms(sel_basic)
     
     r = contacts.Contacts(u, select=(sel_acidic, sel_basic),
                     refgroup=(acidic, basic), radius=6.0, pbc=pbc)
     r.run()
     assert_array_almost_equal(r.timeseries[:, 1], expected)
    def test_villin_unfolded(self):
        # both folded
        f = mda.Universe(contacts_villin_folded)
        u = mda.Universe(contacts_villin_folded)
        sel = "protein and not name H*"

        grF = f.select_atoms(sel)

        q = contacts.Contacts(u,
                              select=(sel, sel),
                              refgroup=(grF, grF),
                              method="soft_cut")
        q.run()

        results = soft_cut(f, u, sel, sel)
        assert_almost_equal(q.timeseries[:, 1], results[:, 1])
示例#6
0
sel_1 = "segid AP1"
sel_2 = "segid AP2"

selection_1 = u.select_atoms(sel_1)
selection_2 = u.select_atoms(sel_2)
#print selection_1
#print selection_2

#q1q2 = contacts.q1q2(u, selection=(sel_1, sel_2), radius=6)
#q1q2.run()

#ca1 = contacts.Contacts(u, selection=(sel_1, sel_2), refgroup=(selection_1, selection_2), radius=6.0)
ca1 = contacts.Contacts(u,
                        selection=(sel_1, sel_2),
                        refgroup=(selection_1, selection_2),
                        radius=6.0,
                        start=0,
                        stop=1001)

ca1.run()

#f, ax = plt.subplots(1, 2, figsize=plt.figaspect(0.5))
#ax[0].plot(q1q2.timeseries[:, 0], q1q2.timeseries[:, 1], label='q1')
#ax[0].plot(q1q2.timeseries[:, 0], q1q2.timeseries[:, 2], label='q2')
#ax[0].legend(loc='best')
#ax[1].plot(q1q2.timeseries[:, 1], q1q2.timeseries[:, 2], '.-')

average_contacts = numpy.mean(ca1.timeseries[:, 1])
print('average contacts = {}'.format(average_contacts))

f, ax = plt.subplots()
示例#7
0
t_ref = mda.Universe('begin.pdb', top='begin.pdb')
group1 = t_ref.select_atoms('segid A and (name C* or name N* or name O* or name S*)')
num_walkers = 16
for en in range(num_walkers):
    for it in range(81, 85):
        dirname = 'iter.%06d/00.enhcMD/%03d/' % (it, en)
        os.system('cp begin.pdb md-nosol.tpr trj.sh index_p.ndx %s' % dirname)
        os.chdir(dirname)
        os.system('sh trj.sh')
        trjname = 'md_done.xtc'
        u = mda.Universe("begin.pdb", trjname)
        filename = 'Q_heavyatoms.cs'
        wf = open(filename, 'w')
        sel2 = 'segid B and (name C* or name N* or name O* or name S*)'
        group2 = t_ref.select_atoms(sel2)
        nc = contacts.Contacts(u, selection=("segid A and (name C* or name N* or name O* or name S*)", sel2),
                               refgroup=(group1, group2), method='soft_cut')
        nc.run()
        bound = nc.timeseries[:, 1]
        for b in bound:
            wf.write(str(b) + '\n')
        wf.close()
        os.chdir('/home/dongdong/SCR/pdz.run02')

import numpy as np
import matplotlib.pyplot as plt
import matplotlib.font_manager as font_manager
import os

font_path = '/home/dongdong/tigress/calibribold.ttf'
font_prop = font_manager.FontProperties(fname=font_path, size=16)
leg_prop = font_manager.FontProperties(fname=font_path, size=10)
示例#8
0
def native_contacts(gro_list, traj_list, num_proteins, N_resid):
    c_pal = ['#225ea8', '#41b6c4', '#c7e9b4']

    ax = plt.subplot(111)
    ax.set(xlabel='Frame',
           ylabel='% of Native Contacts',
           title='Native Contacts')
    ax.set_ylim([0, 100])

    if len(gro_list) == 1:
        compare = False

        u = mda.Universe(gro_list[0], traj_list[0])
        protein_length = len(u.select_atoms("protein and name CA"))
        print u
        print protein_length
        #for frame in u.trajectory:

        #   print u.trajectory[frame].time

        print "One universe loaded..."

        # Initialise dicts, first for each protein, second for the residues you wish to calc the Native Conts for.

        protein_dict = {}
        protein_res_to_calc_dict = {}
        regions_for_NC_analysis = {}

        # Get protein information and store in dictionaries

        for j in range(num_proteins):

            print "j = ", j

            if j == 0:

                start = ((j * (protein_length / num_proteins)) + 1)

                end = (j * (protein_length / num_proteins)) + N_resid

                print "start and end = ", start, end

                protein_dict["p" + str(j)] = u.select_atoms("resid " + str(1) +
                                                            ":" + str(N_resid))

                protein_res_to_calc_dict["p" + str(j) + "res"] = {}

                protein_res_to_calc_dict["p" + str(j) +
                                         "res"]["sel"] = u.select_atoms(
                                             "(resid " + str(1) + ":" +
                                             str(N_resid) +
                                             ") and (not name CA N O H*)")

                print protein_res_to_calc_dict["p" + str(j) +
                                               "res"]["sel"].resnames
                print protein_res_to_calc_dict["p" + str(j) +
                                               "res"]["sel"].resids

                # print protein_res_to_calc_dict
                # store the string used to select this part of the protein for future use

                protein_res_to_calc_dict["p" + str(j) +
                                         "res"]["sel_string"] = "resid " + str(
                                             1) + ":" + str(N_resid)

                j += 1

            elif j >= 1:

                # make sure you're in the right place for the next protein

                # print "one protein length", protein_length / num_proteins
                # print "num proteins", num_proteins
                # print "n resid", N_resid

                start = (j * (protein_length / num_proteins)) + 1

                end = (j * (protein_length / num_proteins)) + N_resid

                print "protein length = ", protein_length
                print "num prots = ", num_proteins

                print "start and end = ", start, end

                protein_res_to_calc_dict["p" + str(j) + "res"] = {}

                # populate dicts
                protein_dict["p" +
                             str(j)] = u.select_atoms("resid " + str(start) +
                                                      ":" + str(end))

                protein_res_to_calc_dict["p" + str(j) +
                                         "res"]["sel"] = u.select_atoms(
                                             "(resid " + str(start) + ":" +
                                             str(end) +
                                             ") and (not name CA N O H*)")

                print protein_res_to_calc_dict["p" + str(j) +
                                               "res"]["sel"].resnames
                print protein_res_to_calc_dict["p" + str(j) +
                                               "res"]["sel"].resids

                # store the string used to select this part of the protein for future use

                protein_res_to_calc_dict["p" + str(j) +
                                         "res"]["sel_string"] = "resid " + str(
                                             start) + ":" + str(end)

                j += 1

        print protein_dict

        for k, key in enumerate(protein_dict):

            print "current key = ", key

            # A
            sel0 = protein_res_to_calc_dict["p0res"][
                "sel_string"]  # + " and (not name CA N O H*)"
            # sel0 = "(resid " + str(1) + ":" + str(N_resid) + ") and (not name CA N O H*)"
            ref0 = protein_res_to_calc_dict["p0res"]["sel"]

            # B
            sel1 = protein_res_to_calc_dict["p1res"]["sel_string"]
            ref1 = protein_res_to_calc_dict["p1res"]["sel"]

            # C
            sel2 = protein_res_to_calc_dict["p2res"]["sel_string"]
            ref2 = protein_res_to_calc_dict["p2res"]["sel"]

            # For first protein
            if key == "p0":

                comb_ref = ref1 + ref2

                print ""
                print "selections"
                print ""
                print "sel0 = ", sel0
                print "sel1 = ", sel1
                print "sel2 = ", sel2
                print ""

                print "references"
                print ""
                print "ref0 = ", len(ref0)
                print "ref1 = ", len(ref1)
                print "ref2 = ", len(ref2)
                print ""

                print "selection check"
                print sel0 + " and not name CA N O H*"
                print sel1 + " or " + sel2 + " and not name CA N O H*"

                #"(resid 1:10) and (not name CA N O H*)"
                #"(resid 124:134 or resid 247:257) and (not name CA N O H*)"

                # A - BC
                regions_for_NC_analysis["A_BC"] = contacts.Contacts(
                    u,
                    selection=(sel0 + " and not name CA N O H*", sel1 +
                               " or " + sel2 + " and not name CA N O H*"),
                    refgroup=(ref0, comb_ref),
                    radius=6.0)

                regions_for_NC_analysis["A_BC"].run()

                print np.mean(regions_for_NC_analysis["A_BC"].timeseries[:, 1])

                plt.plot(
                    np.linspace(
                        0, 200,
                        len(regions_for_NC_analysis["A_BC"].timeseries[:, 0])),
                    (100 * regions_for_NC_analysis["A_BC"].timeseries[:, 1]),
                    alpha=0.5,
                    label='Chain A',
                    c=c_pal[k])

            elif key == "p1":

                comb_ref = ref0 + ref2

                # B - AC
                regions_for_NC_analysis["B_AC"] = contacts.Contacts(
                    u,
                    selection=(sel1 + " and not name CA N O H*", sel0 +
                               " or " + sel2 + " and not name CA N O H*"),
                    refgroup=(ref1, comb_ref),
                    radius=6.0)

                regions_for_NC_analysis["B_AC"].run()

                print np.mean(regions_for_NC_analysis["B_AC"].timeseries[:, 1])

                plt.plot(
                    np.linspace(
                        0, 200,
                        len(regions_for_NC_analysis["B_AC"].timeseries[:, 0])),
                    (100 * regions_for_NC_analysis["B_AC"].timeseries[:, 1]),
                    alpha=0.5,
                    label='Chain B',
                    c=c_pal[k])

            elif key == "p2":

                comb_ref = ref0 + ref1

                # C - AB
                regions_for_NC_analysis["C_AB"] = contacts.Contacts(
                    u,
                    selection=(sel2 + " and not name CA N O H*", sel0 +
                               " or " + sel1 + " and not name CA N O H*"),
                    refgroup=(ref2, comb_ref),
                    radius=6.0)

                regions_for_NC_analysis["C_AB"].run()

                print np.mean(regions_for_NC_analysis["C_AB"].timeseries[:, 1])

                print np.array(regions_for_NC_analysis["C_AB"].timeseries[:,
                                                                          0])

                plt.plot(
                    np.linspace(
                        0, 200,
                        len(regions_for_NC_analysis["C_AB"].timeseries[:, 0])),
                    (100 * regions_for_NC_analysis["C_AB"].timeseries[:, 1]),
                    alpha=0.5,
                    label='Chain C',
                    c=c_pal[k])

            else:
                continue

        # for key in regions_for_NC_analysis:

        avg = 100 * (np.mean([
            regions_for_NC_analysis["A_BC"].timeseries[:, 1],
            regions_for_NC_analysis["B_AC"].timeseries[:, 1],
            regions_for_NC_analysis["C_AB"].timeseries[:, 1]
        ],
                             axis=0))

        #print ({k: np.mean([v[:, 1]], axis=0) for k, v in regions_for_NC_analysis.items()})

        print np.mean([
            regions_for_NC_analysis[k].timeseries[:, 1]
            for k, v in regions_for_NC_analysis.items()
        ],
                      axis=0)

        plt.plot(avg, color='black', alpha=1, label='Avg')

        plt.legend()

        plt.savefig('NC_plot_' + str(num_proteins) + "prot_syst" + '.svg',
                    format='svg')

        plt.show()
        plt.clf()

        ###### COMPARE TWO SYSTEMS #######

    elif len(gro_list) != 1:
        compare = True

        u_list = [
            mda.Universe(gro_list[0], traj_list[0]),
            mda.Universe(gro_list[1], traj_list[1])
        ]

        print "Two universes loaded..."

        # Initialise dicts, first for each protein, second for the residues you wish to calc the Native Conts for.

        protein_dict = {}
        protein_res_to_calc_dict = {}
        regions_for_NC_analysis = {}
        avg_dict = {}

        # Get protein information and store in dictionaries, for each system

        # Initialise dicts for each system present

        for s, system in enumerate(gro_list):

            protein_dict["s" + str(s)] = {}
            protein_res_to_calc_dict["s" + str(s)] = {}
            regions_for_NC_analysis["s" + str(s)] = {}

        for s, system in enumerate(gro_list):

            print s

            if s > 0:
                c_pal = ['#ae017e', '#f768a1', '#fcc5c0']

            else:
                c_pal = ['#225ea8', '#41b6c4', '#c7e9b4']

            for j in range(num_proteins):

                if j == 0:

                    #system, protein, region ----> dict structure

                    protein_dict["s" + str(s)][
                        "p" + str(j)] = u_list[s].select_atoms("resid " +
                                                               str(1) + ":" +
                                                               str(N_resid))

                    protein_res_to_calc_dict["s" + str(s)]["p" + str(j) +
                                                           "res"] = {}

                    protein_res_to_calc_dict["s" + str(s)][
                        "p" + str(j) + "res"]["sel"] = u_list[s].select_atoms(
                            "(resid " + str(1) + ":" + str(N_resid) +
                            ") and (not name CA N O H*)")

                    # print protein_res_to_calc_dict["s" + str(s)]["p" + str(j) + "res"]["sel"].resnames
                    # print protein_res_to_calc_dict["s" + str(s)]["p" + str(j) + "res"]["sel"].resids

                    # print protein_res_to_calc_dict
                    # store the string used to select this part of the protein for future use

                    protein_res_to_calc_dict["s" + str(s)][
                        "p" + str(j) + "res"]["sel_string"] = "resid " + str(
                            1) + ":" + str(N_resid)

                    j += 1

                elif j >= 1:

                    # make sure you're in the right place for the next protein, for the current system

                    protein_length = len(
                        u_list[s].select_atoms("protein and name CA"))

                    start = (j * (protein_length / num_proteins)) + 1

                    end = (j * (protein_length / num_proteins)) + N_resid

                    protein_res_to_calc_dict["s" + str(s)]["p" + str(j) +
                                                           "res"] = {}

                    # populate dicts
                    protein_dict["s" + str(s)][
                        "p" + str(j)] = u_list[s].select_atoms("resid " +
                                                               str(start) +
                                                               ":" + str(end))

                    protein_res_to_calc_dict["s" + str(s)][
                        "p" + str(j) + "res"]["sel"] = u_list[s].select_atoms(
                            "(resid " + str(start) + ":" + str(end) +
                            ") and (not name CA N O H*)")

                    # print protein_res_to_calc_dict["s" + str(s)]["p" + str(j) + "res"]["sel"].resnames
                    # print protein_res_to_calc_dict["s" + str(s)]["p" + str(j) + "res"]["sel"].resids

                    # store the string used to select this part of the protein for future use

                    protein_res_to_calc_dict["s" + str(s)][
                        "p" + str(j) + "res"]["sel_string"] = "resid " + str(
                            start) + ":" + str(end)

                    j += 1

            for k, key in enumerate(protein_dict["s" + str(s)]):

                print "current system, chain = ", s, key

                # A
                sel0 = protein_res_to_calc_dict["s" + str(s)]["p0res"][
                    "sel_string"]  # + " and (not name CA N O H*)"
                # sel0 = "(resid " + str(1) + ":" + str(N_resid) + ") and (not name CA N O H*)"
                ref0 = protein_res_to_calc_dict["s" + str(s)]["p0res"]["sel"]

                # B
                sel1 = protein_res_to_calc_dict["s" +
                                                str(s)]["p1res"]["sel_string"]
                ref1 = protein_res_to_calc_dict["s" + str(s)]["p1res"]["sel"]

                # C
                sel2 = protein_res_to_calc_dict["s" +
                                                str(s)]["p2res"]["sel_string"]
                ref2 = protein_res_to_calc_dict["s" + str(s)]["p2res"]["sel"]

                # For first protein
                if key == "p0":

                    comb_ref = ref1 + ref2

                    # "(resid 1:10) and (not name CA N O H*)"
                    # "(resid 124:134 or resid 247:257) and (not name CA N O H*)"

                    # A - BC
                    regions_for_NC_analysis[
                        "s" + str(s)]["A_BC"] = contacts.Contacts(
                            u_list[s],
                            selection=(sel0 + " and not name CA N O H*",
                                       sel1 + " or " + sel2 +
                                       " and not name CA N O H*"),
                            refgroup=(ref0, comb_ref),
                            radius=6.0)

                    regions_for_NC_analysis["s" + str(s)]["A_BC"].run()

                    print np.mean(
                        regions_for_NC_analysis["s" +
                                                str(s)]["A_BC"].timeseries[:,
                                                                           1])

                    plt.plot(
                        regions_for_NC_analysis["s" +
                                                str(s)]["A_BC"].timeseries[:,
                                                                           0],
                        (100 * regions_for_NC_analysis["s" + str(s)]
                         ["A_BC"].timeseries[:, 1]),
                        alpha=0.3,
                        label='Chain A (system ' + str(s) + ')',
                        c=c_pal[k])

                elif key == "p1":

                    comb_ref = ref0 + ref2

                    # B - AC
                    regions_for_NC_analysis[
                        "s" + str(s)]["B_AC"] = contacts.Contacts(
                            u_list[s],
                            selection=(sel1 + " and not name CA N O H*",
                                       sel0 + " or " + sel2 +
                                       " and not name CA N O H*"),
                            refgroup=(ref1, comb_ref),
                            radius=6.0)

                    regions_for_NC_analysis["s" + str(s)]["B_AC"].run()

                    plt.plot(
                        regions_for_NC_analysis["s" +
                                                str(s)]["B_AC"].timeseries[:,
                                                                           0],
                        (100 * regions_for_NC_analysis["s" + str(s)]
                         ["B_AC"].timeseries[:, 1]),
                        alpha=0.3,
                        label='Chain B (system ' + str(s) + ')',
                        c=c_pal[k])

                elif key == "p2":

                    comb_ref = ref0 + ref1

                    # C - AB
                    regions_for_NC_analysis[
                        "s" + str(s)]["C_AB"] = contacts.Contacts(
                            u_list[s],
                            selection=(sel2 + " and not name CA N O H*",
                                       sel0 + " or " + sel1 +
                                       " and not name CA N O H*"),
                            refgroup=(ref2, comb_ref),
                            radius=6.0)

                    regions_for_NC_analysis["s" + str(s)]["C_AB"].run()

                    plt.plot(
                        regions_for_NC_analysis["s" +
                                                str(s)]["C_AB"].timeseries[:,
                                                                           0],
                        (100 * regions_for_NC_analysis["s" + str(s)]
                         ["C_AB"].timeseries[:, 1]),
                        alpha=0.3,
                        label='Chain C (system ' + str(s) + ')',
                        c=c_pal[k])

                else:
                    continue

            time_data = np.linspace(0, 200, 2501)  # need to generalise this

            avg = np.mean([
                regions_for_NC_analysis["s" + str(s)]["A_BC"].timeseries[:, 1],
                regions_for_NC_analysis["s" + str(s)]["B_AC"].timeseries[:, 1],
                regions_for_NC_analysis["s" + str(s)]["C_AB"].timeseries[:, 1]
            ],
                          axis=0)

            avg_spl = 100 * avg

            xnew = np.linspace(
                np.min(time_data), np.max(time_data), 300
            )  # No. represents number of points to make between min and max

            power_smooth_avg = spline(time_data, avg_spl, xnew)

            print time_data
            print avg
            print power_smooth_avg
            print ""

            print time_data[0]
            print avg[0]
            print power_smooth_avg[0]

    #      plt.plot(xnew, power_smooth_avg, label='Avg (system ' + str(s) + ')', alpha=1, color='black')

    #plt.plot(avg, color='black', alpha=1, label='Avg (system ' + str(s) + ')')

    # need to add this method below for a more general calc of mean -- ???
    #print np.mean([regions_for_NC_analysis[k].timeseries[:, 1] for k, v in regions_for_NC_analysis["s" + str(s)].items()], axis=0)

        plt.legend()

        plt.savefig('compare_plot_' + str(num_proteins) + "prot_syst" + '.svg',
                    format='svg')

        plt.show()
        plt.clf()
示例#9
0
import matplotlib.pyplot as plt
import numpy

u = mda.Universe('/home/bdv1/VMD_SaveFolder/PRB-0-HIE_ProteinOnly.pdb', '/home/bdv1/Desktop/PRB-0-protein-025.dcd')

ref = mda.Universe('/home/bdv1/MDA_Scripts/PDB_000-9184.pdb')

hel_1 = "resnum 2:18"
hel_2 = "resnum 20:31"
hel_3 = "resnum 33:47"

helix_1 = ref.select_atoms(hel_1)
helix_2 = ref.select_atoms(hel_2)
helix_3 = ref.select_atoms(hel_3)

ca12 = contacts.Contacts(u, selection=(hel_1, hel_2), refgroup=(helix_1, helix_2), radius=2000, method=contacts.radius_cut_q, kwargs={"radius":15.0}, start=4200, stop=8200).run()
ca23 = contacts.Contacts(u, selection=(hel_2, hel_3), refgroup=(helix_2, helix_3), radius=2000, method=contacts.radius_cut_q, kwargs={"radius":15.0}, start=4200, stop=8200).run()
ca13 = contacts.Contacts(u, selection=(hel_1, hel_3), refgroup=(helix_1, helix_3), radius=2000, method=contacts.radius_cut_q, kwargs={"radius":15.0}, start=4200, stop=8200).run()


x12 = ca12.timeseries[:,0]
y12 = ca12.timeseries[:,1]

x23 = ca23.timeseries[:,0]
y23 = ca23.timeseries[:,1]

x13 = ca13.timeseries[:,0]
y13 = ca13.timeseries[:,1]

N = 50
cumsum, moving_aves12 = [0], []
示例#10
0
#first, testing to see if the PDB file of default results in same
#ref = mda.Universe('/home/bdv1/MDA_Scripts/PDB_000-default.pdb')
#it does, atleast at radius 20

#ref = mda.Universe('/home/bdv1/MDA_Scripts/VMD_test_newdrop/PRB-0-protein_autopsf_formatted(good one?).pdb')
# wait why would this work I just made this I have to make it into the one
# frame thing again what the heck
hel_1 = "resnum 2:18"
hel_2 = "resnum 20:31"
hel_3 = "resnum 33:47"

helix_1 = ref.select_atoms(hel_1)
helix_2 = ref.select_atoms(hel_2)
helix_3 = ref.select_atoms(hel_3)

ca1 = contacts.Contacts(u, selection=(hel_1, hel_2), refgroup=(helix_1, helix_2), radius=2000, method=contacts.radius_cut_q, kwargs={"radius":15.0}, stop=9999).run()

print ca1.timeseries[:, 0]
print ca1.timeseries[:, 1]

f, ax = plt.subplots()
ax.plot(ca1.timeseries[:, 0], ca1.timeseries[:, 1])
#ax.set(xlabel='frame', ylable='fraction of native contacts', title='PRB-025 Native Contacts')
ax.set_ylim(0, 1.0)
f.show()
plt.pause(30)




示例#11
0
    options = parser.parse_args()

    if options.plot_type == "single":

        uni = load_uni(options.gro_file, options.xtc_file)

        sel_basic = "(resname ARG LYS) and (name NH* NZ)"
        sel_acidic = "(resname ASP GLU) and (name OE* OD*)"

        acidic = uni.select_atoms(sel_acidic)
        basic = uni.select_atoms(sel_basic)

        ca = contacts.Contacts(uni,
                               selection=(sel_acidic, sel_basic),
                               refgroup=(acidic, basic),
                               radius=options.cut_off,
                               verbose=True)

        ca.run()

        np.save('contact_analysis_data.npy', ca.timeseries[:, 1])

        plot_single(ca.timeseries[:, 1])

    elif options.plot_type == "multiple":

        plot_multiple(options.data_list)

    else:
示例#12
0
                 '/home/bdv1/Desktop/rpn11_ubq.dcd')

sec_1 = "resname RN11"
section_1 = u.select_atoms(sec_1)
print section_1
sel_1 = "name RN11"
sel_2 = "name UBQ"

selection_1 = u.select_atoms(sel_1)
selection_2 = u.select_atoms(sel_2)

print selection_1
print selection_2

ca1 = contacts.Contacts(u,
                        selection=(sel_1, sel_2),
                        refgroup=(selection_1, selection_2),
                        radius=6.0)

ca1.run()

average_contacts = numpy.mean(ca1.timeseries[:, 1])
print('average contacts = {}'.format(average_contacts))

f, ax = plt.subplots()
ax.plot(ca1.timeseries[:, 0], ca1.timeseries[:, 1])
ax.set(xlabel='frame',
       ylabel='fraction of native contacts',
       title='Native Contacts, average = {:.2f}'.format(average_contacts))
#save('outfile_mdatests')
plt.ion()
示例#13
0
import numpy
# example trajectory (transition of AdK from closed to open)
u = mda.Universe(PSF,DCD)
# crude definition of salt bridges as contacts between NH/NZ in ARG/LYS and
# OE*/OD* in ASP/GLU. You might want to think a little bit harder about the
# problem before using this for real work.
sel_basic = "(resname ARG LYS) and (name NH* NZ)"
sel_acidic = "(resname ASP GLU) and (name OE* OD*)"
# reference groups (first frame of the trajectory, but you could also use a
# separate PDB, eg crystal structure)
acidic = u.select_atoms(sel_acidic)
basic = u.select_atoms(sel_basic)
# set up analysis of native contacts ("salt bridges"); salt bridges have a
# distance <6 A
ca1 = contacts.Contacts(u, selection=(sel_acidic, sel_basic),
                        refgroup=(acidic, basic), radius=6.0)
# iterate through trajectory and perform analysis of "native contacts" Q
ca1.run()
# print number of averave contacts
average_contacts = numpy.mean(ca1.timeseries[:, 1])
print('average contacts = {}'.format(average_contacts))
# plot time series q(t)
f, ax = plt.subplots()
ax.plot(ca1.timeseries[:, 0], ca1.timeseries[:, 1])
ax.set(xlabel='frame', ylabel='fraction of native contacts',
       title='Native Contacts, average = {:.2f}'.format(average_contacts))
plt.ion()

f.show()
plt.pause(20)
示例#14
0
 def compute_average_contacts(self, cutoff=5, selection1="protein", selection2="protein"):
     atoms_1, atoms_2 = self.u.select_atoms(selection1), universe.select_atoms(selection2)
     ca = contacts.Contacts(self.u, selection=(selection1, selection2),
                     refgroup=(atoms_1, atoms_2), radius=self.cutoff)
     ca.run()
     return np.mean(ca.timeseries[:, 1])