예제 #1
0
v = None

r = None

for res in range(1, 101):
    if os.path.exists(os.path.join(folder, file_fr.format(nf - 1, res))):
        frames.append([
            DR.io.load_DIFRATE(os.path.join(dir0, file_fr.format(k, res)))
            for k in range(nf)
        ])
        ct.append(DR.io.load_DIFRATE(os.path.join(dir0, file_ct.format(res))))
        ctp.append(DR.io.load_DIFRATE(os.path.join(dir0,
                                                   file_ctp.format(res))))
        print('reloading residue {0}'.format(res))
    else:
        sel_res(mol, res, in_place=True)

        "frames is a list of dictionaries, each dictionary defines a frame"

        "Librational frame (defined by selections)"
        frames = [{'Type': 'librations', 'sel1': 1, 'sel2': 2, 'full': True}]

        "Index for the MOI frames"
        "We omit the headgroup, backbone, and carbonyls"
        "np.nan means this frame won't act on this particular bond"
        frame_index = np.concatenate(
            (np.nan * np.ones(19), 0 * np.ones(31), [np.nan], 1 * np.ones(33)))
        "Selections for chain 1, chain 2"
        sel = [mol.sel1[k == frame_index].unique for k in range(2)]
        "Index for MOIxy frame (same as MOI, minus the double bonded carbons)"
        frame_index=np.concatenate((np.nan*np.ones(19),0*np.ones(31),\
예제 #2
0
folder='data_frames'
file='f{0}_fit'

scaling=1/np.array([0.067,0.67,0.67,0.67])
chimera_cmds=['turn x -90','view all','set bgColor white','lighting soft'] 

assert DR.chimeraX.is_chimera_setup(),'Bon-bon plots require ChimeraX. Please install ChimeraX first, and then run pyDIFRATE.chimeraX.set_chimera_path(path), with path as the location of the ChimeraX executable'
for fr in range(4):
    assert os.path.exists(os.path.join(folder,file.format(fr))),"{0} does not exist".format(os.path.join(folder,file.format(fr)))

frame=[DR.io.load_DIFRATE(os.path.join(folder,file.format(fr))) for fr in range(4)]

frame[0].sens.molecule.load_struct('POPC.pdb') #Load a pdb of POPC
for f in frame:f.sens.molecule=frame[0].sens.molecule
frame[0].sens.molecule.MDA2pdb(select='resid 1')
sel_res(frame[0].sens.molecule,1,in_place=True)   #Select correct bonds for plotting

def Bonbon_fr(frame_index,rho_index=None):
    """
    Generates the bon-bon plots for all detectors, for the given frame
    """
    
    if rho_index is None:
        for k in range(4):
            frame[frame_index].draw_rho3D(k,chimera_cmds=chimera_cmds,scaling=scaling[frame_index])
    else:
        frame[frame_index].draw_rho3D(rho_index,chimera_cmds=chimera_cmds,scaling=scaling[frame_index])
    time.sleep(5)   
    """Deletion of frame deletes the pdb of POPC. Delay inserted so 
    that chimera launches before this deletion occurs"""
예제 #3
0
import pyDIFRATE as DR
from lipid_selections import sel_res
import numpy as np

ef = DR.frames  #Frames module

assert DR.chimeraX.is_chimera_setup(
), 'Tensor plots require ChimeraX. Please install ChimeraX first, and then run pyDIFRATE.chimeraX.set_chimera_path(path), with path as the location of the ChimeraX executable'

#%% Load the pdb
top = 'POPC.pdb'  #Topology (pdb also includes positions at one time point)
mol = DR.molecule(top)  #Load the molecule

res = 1
sel_res(mol, res, in_place=True)  #Select bonds corresponding to stored tensors

mol.MDA2pdb(select='resid 1')  #Generate a pdb in the molecule object

"We still need to define the tensor directions to correctly plot the tensors"
mol.tensor_frame(Type='bond', sel1=2, sel2=1)  #Define tensor frames

scale0 = [2, 2, 2.5, 2.5]

chimera_cmds = ['turn x -90', 'view all', 'set bgColor white']
A = DR.io.load_DIFRATE('tensors')  #Load the tensors


#%% Define the plotting function
def plot_tensor(frame_index, tensor='A_0m_finF', scaling=None):
    """
예제 #4
0
log-spacing, and so we continue to sample more sparsely (repeating this pattern 
10 times!). Log-spacing is motivated by the fact that the difference between say,
the first and second time point may be fairly large in the correlation function,
due to quickly decaying components. However, the difference between the 10000 and
10001 point will not be (it could have some differences due to noise). However,
it cannot have real differences, because all rapidly changing components are 
already gone.
"""

r = None  #Clear detectors

for res in range(1, 257):  #Sweep over the copies
    if not (os.path.exists(os.path.join(
            folder,
            file.format(res)))):  #Don't run this fit if file already exists
        sel_res(mol, res, in_place=True)  #Selects the desired residue
        "(sets mol.sel1 and mol.sel2 to be lists of the atoms in the bonds for the current POPC molecule)"

        data = DR.Ct_fast.Ct2data(
            mol, n=n)  #Extracts the correlation function, stores in data

        if r is None:
            if res == 1:  #If first residue, then we may automatically set the detectors
                data.detect.r_no_opt(
                    nd
                )  #r_no_opt yields nd un-optimized (direct from SVD) detectors
                r = data.detect
                DR.io.save_DIFRATE(os.path.join(folder, 'r'), r)
            else:
                """If res is not None, but r is not defined (calculation has been restarted),
                then we re-load the results from residue 1
예제 #5
0
     [13, 14]))  #These are the positions where we use experimental data
for lbl0, R in zip(expfit.label[index], expfit.R[index, :4]):
    for k, lbl in enumerate(combfit.label):
        if lbl0 == lbl[:len(
                lbl0
        )]:  #See if the beginning of the MD label matches the experiment
            combfit.R[k] = R  #Copy over the data

"Here, we create the bon-bon plots"
#List of commands to make nice plots in chimeraX
chimera_cmds = ['turn x -90', 'view all', 'set bgColor white', 'lighting soft']
scaling = 1 / combfit.R.max(
)  #Scaling factor for bon-bon plots (use same for all plots for better comparison)

assert DR.chimeraX.is_chimera_setup(
), 'Bon-bon plots require ChimeraX. Please install ChimeraX first, and then run pyDIFRATE.chimeraX.set_chimera_path(path), with path as the location of the ChimeraX executable'

combfit.sens.molecule.load_struct('POPC.pdb')  #Load a pdb of POPC
sel_res(combfit.sens.molecule, 1,
        in_place=True)  #Select correct bonds for plotting
combfit.sens.molecule.MDA2pdb(
    select='resid 1')  #Transfer pdb into correct location for plotting


def Bonbon(rho_index):
    """
    Plots the detector responses for total motion for the specified detector
    """
    combfit.draw_rho3D(rho_index, scaling=scaling,
                       chimera_cmds=chimera_cmds)  #Draw the bon-bon plot