def determine_leaflets(universe,phosphateSelection):
    '''
    From a selection of phosphates, determine which belong to the upper and lower leaflets.
    
    Keyword arguments:
    universe -- an MDAnalysis Universe object
    phosphateSelection -- a string specifying how to select the phosphate atoms (e.g. "name P1")         
    '''
    leaflets = {}

    # calculate the z value of the phosphates defining the bilayer (assumes bilayer is in x and y..)
    po4=universe.selectAtoms(phosphateSelection)
    bilayerCentre = po4.centerOfGeometry()[2]
    
    # apply the MDAnalysis LeafletFinder graph-based method to determine the two largest groups which
    #  should correspond to the upper and lower leaflets
    phosphates = LeafletFinder(universe,phosphateSelection)

    
    # find the two largest groups - required as the first two returned by LeafletFinder, whilst usually are the largest, this is not always so
    (a,b) = largest_groups(phosphates.sizes())
    
    # check to see where the first leaflet lies
    if phosphates.group(a).centroid()[2] > bilayerCentre:
        leaflets[1] = phosphates.group(a)
        leaflets[2] = phosphates.group(b)
    else:
        leaflets[2] = phosphates.group(a)
        leaflets[1] = phosphates.group(b)

    return leaflets
Ejemplo n.º 2
0
def determine_leaflets(universe, phosphateSelection="name P*"):
    '''
    From a selection of phosphates, determine which belong to the upper and lower leaflets.
    Keyword arguments:
    universe -- an MDAnalysis Universe object
    phosphateSelection -- a string specifying how to select the phosphate atoms (e.g. "name P1")
    '''
    leaflets = {}
    #print(universe)
    # calculate the z value of the phosphates defining the bilayer (assumes bilayer is in x and y..)
    #po4=universe.atoms.select_atoms(phosphateSelection)
    #bilayerCentre = po4.center_of_geometry()[2]
    #print(bilayerCentre)

    # apply the MDAnalysis LeafletFinder graph-based method to determine the two largest groups which
    #  should correspond to the upper and lower leaflets
    phosphates = LeafletFinder(universe, phosphateSelection)

    # find the two largest groups - required as the first two returned by LeafletFinder, whilst usually are the largest, this is not always so
    (a, b) = largest_groups(phosphates.sizes())
    layer1_avz = np.mean(phosphates.group(a).center_of_geometry()[2])
    layer2_avz = np.mean(phosphates.group(b).center_of_geometry()[2])
    bilayerCentre = (layer1_avz + layer2_avz) / 2.
    # check to see where the first leaflet lies
    if phosphates.group(a).centroid()[2] > bilayerCentre:
        #print(phosphates.group(b).residues.atoms)
        leaflets["upper"] = phosphates.group(a).residues.atoms
        leaflets["lower"] = phosphates.group(b).residues.atoms
    else:
        leaflets["lower"] = phosphates.group(a).residues.atoms
        leaflets["upper"] = phosphates.group(b).residues.atoms

    return leaflets
Ejemplo n.º 3
0
def dpth(u):
	L = LeafletFinder(u, 'name P')
	L0 = L.group(0)
	L1 = L.group(1)
	"""bi_cntr = (np.mean(L0.positions,axis=0)[-1]+np.mean(L1.positions,axis=0)[-1])/2"""
	int_cntr=L0.centroid()[-1]
	return int_cntr
Ejemplo n.º 4
0
def dpth(u, pro_z):
    L = LeafletFinder(u, 'name P')
    L0 = L.group(0)
    L1 = L.group(1)
    """bi_cntr = (np.mean(L0.positions,axis=0)[-1]+np.mean(L1.positions,axis=0)[-1])/2"""
    int_cntr = L1.centroid()[-1]
    bi_cntr_dpth = (pro_z - int_cntr)
    return bi_cntr_dpth
Ejemplo n.º 5
0
def dpth(u):
	L = LeafletFinder(u, 'name P')
	L0 = L.group(0)
	L1 = L.group(1)
	"""bi_cntr = (np.mean(L0.positions,axis=0)[-1]+np.mean(L1.positions,axis=0)[-1])/2"""
	int_cntr=L0.centroid()[-1]
	return int_cntr


if __name__ == "__main__":
    u = MDAnalysis.Universe("gs_dopc_laur.gro","gs_dopc_laur_small.trr")
    #dye=u.select_atoms("resid 28662 and (type N or type O or name C24)", updating = True)
    dye=u.select_atoms("resid 28663 and (not type H)", updating = True)
    leaflet_P = u.select_atoms("name P", updating = True)
    L = LeafletFinder(u, 'name P')
    L0 = L.group(0)
    L1 = L.group(1)
    data=np.empty([len(dye)+1,len(u.trajectory)])  
    for i, ts in enumerate(tqdm.tqdm(u.trajectory[0::1])):
        leaflet_pos_z = L1.centroid()[-1]        
        for j, atom in enumerate(dye):
            data[0,i] = u.trajectory.time
            atom_z = atom.position[-1]
            distance_atom_bound = - atom_z + leaflet_pos_z
            data[j+1,i] = distance_atom_bound
    ax = sns.heatmap(data[1:,:], xticklabels = 1000)
    
	#plotting
    i=0
    fig = plt.figure(figsize=(24,8))	
    for name in "Prodan1","Prodan2":
        int((u.dimensions[1] * 1.1) * pixelWidth),
        int((u.dimensions[2] * 1.1) * pixelWidth)
    ])

    speciesList = ['unsaturated', 'saturated', 'cholesterol']

    # find out where the centre of the bilayer lies
    bilayer = u.select_atoms("name PO4 or name ROH")
    bilayerCentre = bilayer.center_of_geometry()[2]

    # use the MDAnalysis analysis function LeafletFinder to identify the two bilayers
    bilayerLeaflets = LeafletFinder(u, 'name PO4 or name ROH')
    bilayerLeaflet = {}

    # check to see where the first leaflet lies
    if bilayerLeaflets.group(0).centroid()[2] > bilayerCentre:
        leafletList = ["upper", "lower"]
    else:
        leafletList = ["lower", "upper"]

    imageLookup = {}
    imageLookup['unsaturated'] = {
        'colour': 'Blues',
        'range': [0, 0.0240],
        'sigma': 4.1,
        'ticks': [0, 0.012, 0.024]
    }
    imageLookup['saturated'] = {
        'colour': 'Reds',
        'range': [0, 0.0240],
        'sigma': 4.1,
        
    # create an array with the maximum number of pixels (voxels)
    originalNumberPixels = numpy.array([int((u.dimensions[0]*1.1) * pixelWidth),int((u.dimensions[1]*1.1) * pixelWidth),int((u.dimensions[2]*1.1) * pixelWidth)])

    speciesList = ['unsaturated','saturated','cholesterol']

    # find out where the centre of the bilayer lies
    bilayer = u.select_atoms("name PO4 or name ROH")
    bilayerCentre = bilayer.center_of_geometry()[2]
    
    # use the MDAnalysis analysis function LeafletFinder to identify the two bilayers
    bilayerLeaflets = LeafletFinder(u,'name PO4 or name ROH')
    bilayerLeaflet = {}

    # check to see where the first leaflet lies
    if bilayerLeaflets.group(0).centroid()[2] > bilayerCentre:
        leafletList = ["upper","lower"]
    else:
        leafletList = ["lower","upper"]            
    
    imageLookup = {}
    imageLookup['unsaturated'] = {'colour': 'Blues', 'range': [0,0.0240], 'sigma': 4.1, 'ticks': [0,0.012,0.024]}
    imageLookup['saturated'] = {'colour': 'Reds', 'range': [0,0.0240], 'sigma': 4.1, 'ticks': [0,0.012,0.024]}
    imageLookup['cholesterol'] = {'colour': 'Purples', 'range': [0,0.0240], 'sigma': 4.1, 'ticks': [0,0.012,0.024]}
    imageLookup['mask'] = {'colour': 'RdBu', 'range': [-0.2,1.2], 'ticks': [0,1]}
    imageLookup['edges'] = {'colour': 'Greys', 'range': [0,1], 'ticks': [0,1]}
    
            
    # calculate how wide the bilayer is in pixels
    numberPixels = numpy.array([int((u.dimensions[0]+2) * pixelWidth),int((u.dimensions[1]+2) * pixelWidth),int((u.dimensions[2]+2) * pixelWidth)])