def test_string_vs_atomgroup_proper(universe, lipid_heads): lfls_ag = LeafletFinder(universe, lipid_heads, pbc=True) lfls_string = LeafletFinder(universe, LIPID_HEAD_STRING, pbc=True) groups_ag = lfls_ag.groups() groups_string = lfls_string.groups() assert_equal(groups_string[0].indices, groups_ag[0].indices) assert_equal(groups_string[1].indices, groups_ag[1].indices)
def test_string_vs_atomgroup_proper(self): from MDAnalysis.analysis.leaflet import LeafletFinder lfls_ag = LeafletFinder(self.universe, self.lipid_heads, pbc=True) lfls_string = LeafletFinder(self.universe, self.lipid_head_string, pbc=True) groups_ag = lfls_ag.groups() groups_string = lfls_string.groups() assert_equal(groups_string[0].indices, groups_ag[0].indices) assert_equal(groups_string[1].indices, groups_ag[1].indices)
def density(u, lipid_sel, lipid_heads, lipids, nbins): sel = "resname " + str(lipids[str(lipid_sel)]) + " and (name " + str(lipid_heads[str(lipid_sel)] + ")") print "Lipid selection = " + str(lipids[str(lipid_sel)]) # xu, xl, yu, yl, zu, zl = [], [], [], [], [], [] lip_coord_store = [] for frame in range(len(u.trajectory)): u.trajectory[frame] if frame % 10 == 0: print frame L = LeafletFinder(universe=u, selectionstring=sel) leaflet_upper = L.groups(0) leaflet_lower = L.groups(1) for particle in range(len(leaflet_upper)): lip_coord_store.append((leaflet_upper[particle].position[0], leaflet_upper[particle].position[1], leaflet_upper[particle].position[2]))
def density(u, lipid_sel, lipid_heads, lipids, nbins): sel = "resname " + str(lipids[str(lipid_sel)]) + " and (name " + str( lipid_heads[str(lipid_sel)] + ")") print "Lipid selection = " + str(lipids[str(lipid_sel)]) xu, yu, xl, yl = [], [], [], [] for frame in range(len(u.trajectory)): u.trajectory[frame] # if u.trajectory.frame == 100: # break if frame % 10 == 0: print frame L = LeafletFinder(universe=u, selectionstring=sel) leaflet_upper = L.groups(0) leaflet_lower = L.groups(1) for particle in range(len(leaflet_upper)): xu.append(leaflet_upper[particle].position[0]) yu.append(leaflet_upper[particle].position[1]) for particle in range(len(leaflet_lower)): xl.append(leaflet_lower[particle].position[0]) yl.append(leaflet_lower[particle].position[1]) xuedges = np.linspace(np.min(xu), np.max(xu), nbins) yuedges = np.linspace(np.min(yu), np.max(yu), nbins) xledges = np.linspace(np.min(xl), np.max(xl), nbins) yledges = np.linspace(np.min(yl), np.max(yl), nbins) H_upper, plot_xu, plot_yu = np.histogram2d(x=xu, y=yu, bins=(xuedges, yuedges)) H_lower, plot_xl, plot_yl = np.histogram2d(x=xl, y=yl, bins=(xledges, yledges)) # compress data for return H = [H_upper, H_lower] edges = { 'ul_xedge': xuedges, 'ul_yedge': yuedges, 'll_xedge': xledges, 'll_yedge': yledges } return lipid_sel, H, edges
def test_leaflet_finder(self): from MDAnalysis.analysis.leaflet import LeafletFinder lfls = LeafletFinder(self.universe, self.lipid_heads, pbc=True) top_heads, bottom_heads = lfls.groups() # Make top be... on top. if top_heads.center_of_geometry()[2] < bottom_heads.center_of_geometry()[2]: top_heads,bottom_heads = (bottom_heads,top_heads) assert_equal(top_heads.indices, np.arange(1,2150,12), err_msg="Found wrong leaflet lipids") assert_equal(bottom_heads.indices, np.arange(2521,4670,12), err_msg="Found wrong leaflet lipids")
def mbrane_density(u, lipid_heads, lipid_heads_z, lipids): print "Analysing lipids..." #u.trajectory[-1] half_box = u.dimensions[2] / 2 for frame in range(len(u.trajectory)): u.trajectory[frame] print frame for lipid in lipids: sel = "resname " + str( lipids[lipid]) + " and (name " + str(lipid_heads[lipid] + ")") L = LeafletFinder(universe=u, selectionstring=sel, pbc=False) leaflet_upper = L.groups(0) leaflet_lower = L.groups(1) #com_upper = leaflet_upper.center_of_geometry() for particle in range(len(leaflet_upper)): lipid_heads_z[lipid]['z'].append( leaflet_upper[particle].position[2]) for particle in range(len(leaflet_lower)): lipid_heads_z[lipid]['z'].append( leaflet_lower[particle].position[2]) lipid_z_populated = lipid_heads_z return lipid_z_populated
#LOGGER.info('FlipFlopHeadgroups = {}'.format(defFlipFlopHeadgroups)) # -------------------------------------------------------------------------- # Define top/bottom leaflets # Get beads that define the bilayer leaflets # (not in bilayer middle, but closly packed, use linker + first tail bead of lipids that do not flip-flop) defHeadgroups = MDAnalysis.core.groups.AtomGroup([], syst) for i in list(lipidTypeDic.values()): defHeadgroups += i.getLeafletSelection(syst) # get leaflets rcutoff, n = optimize_cutoff(syst, defHeadgroups) lfls = LeafletFinder(syst, defHeadgroups, cutoff=rcutoff, pbc=True) grps = lfls.groups() if len(grps) == 2: LOGGER.info('Found {} leaflet groups'.format(len(grps))) # check if they're even top_head = grps[0] bot_head = grps[1] rt = float(len(top_head)) / len(bot_head) if rt > 1.3 or rt < 0.77: raise ValueError('Found uneven leaflets. top = {}, bot = {}'.format( len(top_head), len(bot_head))) LOGGER.info('Found leaflets of size {}, {}'.format(len(top_head), len(bot_head)))
pass parser = argparse.ArgumentParser() parser.add_argument("--echo", help = "echo the string you use here") parser.add_argument("--square", help = "display a square of a given number", type = int) args = parser.parse_args() if args.square: print(args.square**2) elif args.echo: print(args.echo) u = MDAnalysis.Universe("min_bilayer_NP.gro", "traj_comp.xtc") L = LeafletFinder(u,'name PO4') leaflet0 = L.groups(0) leaflet1 = L.groups(1) l1_id = leaflet0.resids l2_id = leaflet1.resids for ids in l1_id: residue_id = "resid {}".format(ids) head_position = u.select_atoms(residue_id).select_atoms('name PO4') tail_position1 = u.select_atoms(residue_id).select_atoms('name C3A or name D3A') tail_position2 = u.select_atoms(residue_id).select_atoms('name C3B or name D3B') #print(head_position.positions, tail_position1.positions, tail_position2.positions) print(calc_vec(tail_position1.positions[0][0], head_position.positions[0][0], tail_position1.positions[0][1], head_position.positions[0][1], tail_position1.positions[0][2], head_position.positions[0][2]), ids) #print (A) for ids in l2_id: pass
print "# Optimized cutoff={cutoff:.1f} A, finding {N:d} disconnected groups".format( **vars()) else: cutoff = options.cutoff print "# Using fixed cutoff={cutoff:.1f} A".format(**vars()) LF = LeafletFinder(u, options.selection, cutoff=cutoff, pbc=options.pbc) print "# group sizes = {0!r} ".format(LF.sizes()) # two leaflets def print_line(symbol="-"): print "#" + (12 + 5) * symbol print_line("=") print "#{0!s:>2} {1!s:>5} {2!s:>6}".format("ll", "resn", "count") print_line("=") for groupindex in xrange(len(LF.components)): resnames = [a.resname for a in LF.groups(groupindex)] # there CERTAINLY is a better way to count occurrences than this... keys = np.unique(resnames) for k in keys: count = resnames.count(k) print " {0:2d} {1!s:>5} {2:6d}".format(groupindex, k, count) total = LF.sizes()[groupindex] if total > 1: print_line() print "#{0:2d} {1!s:>5} {2:6d}".format(groupindex, '', total) print
Coordinates = {} Pixels = {} PixelMesh = {} DensityMesh = {} ThicknessMesh = {} # initialise the XYZCoordinates for species in ['unsaturated', 'saturated', 'cholesterol']: for leaflet in ["upper", "lower"]: Coordinates[(species, leaflet)] = [] # extract the coordinates of the lipid species present for i in [0, 1]: # define saturated and unsaturated phases bilayerLeaflet[('unsaturated', i)] = bilayerLeaflets.groups( i).selectAtoms("resname DUPC and name PO4") bilayerLeaflet[('saturated', i)] = bilayerLeaflets.groups( i).selectAtoms("resname DPPC and name PO4") bilayerLeaflet[('cholesterol', i)] = bilayerLeaflets.groups( i).selectAtoms("resname CHOL and name ROH") for species in ['unsaturated', 'saturated', 'cholesterol']: Coordinates[(species, leafletList[i])] = pixelWidth * bilayerLeaflet[ (species, i)].coordinates() # now process the coordinates for leaflet in leafletList: for species in speciesList:
raise RuntimeError("Failed cutoff optimization, try without --optimize") print "# Optimized cutoff=%(cutoff).1f A, finding %(N)d disconnected groups" % vars() else: cutoff = options.cutoff print "# Using fixed cutoff=%(cutoff).1f A" % vars() LF = LeafletFinder(u, options.selection, cutoff=cutoff, pbc=options.pbc) print "# group sizes = %r " % LF.sizes() # two leaflets def print_line(symbol="-"): print "#" + (12 + 5) * symbol print_line("=") print "#%2s %5s %6s" % ("ll", "resn", "count") print_line("=") for groupindex in xrange(len(LF.components)): resnames = [a.resname for a in LF.groups(groupindex)] # there CERTAINLY is a better way to count occurrences than this... keys = np.unique(resnames) for k in keys: count = resnames.count(k) print " %2d %5s %6d" % (groupindex, k, count) total = LF.sizes()[groupindex] if total > 1: print_line() print "#%2d %5s %6d" % (groupindex, '', total) print
class mem_analysis: """ Class for analysis of membranes from .data and .xtc files """ def __init__(self, prefix, pre_out=None): """ Reads .data and .xtc into universe Defines static atomgroups based on type Reads parameter values (nsteps, nlipids) Initiates bbox and leaflets based on first frame Initiates dictionary out for storage of data Writes lipid type to out['lip'] """ if not pre_out: self.pre_out = prefix else: self.pre_out = pre_out self.u = mda.Universe(prefix + '.data', prefix + '.xtc') self.ref = mda.Universe(prefix + '.data') self.nsteps = len(self.u.trajectory) self.ts = 0 b = self.u.trajectory[0].dimensions[0:3] self.bbox = np.array([0, 0, 0, b[0], b[1], b[2]]).reshape(2,3) # Define atomgroups self.atomgroups = {} self.atomgroups['nc3'] = self.u.select_atoms('type 1', updating=True) self.atomgroups['dopc'] = self.u.select_atoms('type 2', updating=True) self.atomgroups['dogl'] = self.u.select_atoms('type 9', updating=True) self.atomgroups['tails'] = self.u.select_atoms('type 7', updating=True) self.atomgroups['heads'] = self.u.select_atoms('type 2 9', updating=True) self.dnlipids = len(self.atomgroups['heads']) self.membranes = {} # Set leaflets self.leaflets = LeafletFinder(self.u, self.atomgroups['dopc'], cutoff=15, pbc=True) sizes = np.array(list(self.leaflets.sizes().values())) l = [self.leaflets.groups(i) for i in np.argsort(-sizes)[:2]] if l[0].center_of_geometry()[2] > l[1].center_of_geometry()[2]: self.atomgroups['ul_dopc'], self.atomgroups['ll_dopc'] = l[0], l[1] else: self.atomgroups['ul_dopc'], self.atomgroups['ll_dopc'] = l[1], l[0] # Make out dict self.out = {'lip':[],'r':[], 's': [], 'j': [], 'k': [], 'd': [], 'rho': [], 'l': [], 'apl': [], 'd_nc3':[]} self.out_box = [] for key in self.out.keys(): self.out[key] = [[] for i in range(len(self.atomgroups['heads']))] # Add lipid types to out['lip'] for head in self.atomgroups['heads']: if head in self.atomgroups['dopc']: self.out['lip'][head.resid - 1] = 'dopc' else: self.out['lip'][head.resid - 1] = 'dogl' def update_membranes(self): """ Computes all membranes Updates dynamic atomgroups """ self.membranes['ul_dopc'] = Membrane(self.atomgroups['ul_dopc'].atoms.positions, labels=self.atomgroups['ul_dopc'].atoms.resids, periodic=True, bbox=self.bbox, boundary_layer=0.5) self.membranes['ul_dopc'].fit_points_to_box_xy() self.membranes['ul_dopc'].compute_pnormals(knbrs=36) self.membranes['ul_dopc'].compute_approx_surface(exactness_level=8) self.membranes['ul_dopc'].compute_membrane_surface() self.membranes['ul_dopc'].compute_properties() self.membranes['ll_dopc'] = Membrane(self.atomgroups['ll_dopc'].atoms.positions, labels=self.atomgroups['ll_dopc'].atoms.resids, periodic=True, bbox=self.bbox, boundary_layer=0.5) self.membranes['ll_dopc'].fit_points_to_box_xy() self.membranes['ll_dopc'].compute_pnormals(knbrs=36) self.membranes['ll_dopc'].compute_approx_surface(exactness_level=8) self.membranes['ll_dopc'].compute_membrane_surface() self.membranes['ll_dopc'].compute_properties() Membrane.compute_thickness(self.membranes['ul_dopc'], self.membranes['ll_dopc']) # Generate NC3 membranes self.atomgroups['ul_nc3'] = self.u.select_atoms('resid ' + ' '.join(map(str, self.atomgroups['ul_dopc'].atoms.resids))).intersection(self.atomgroups['nc3']) self.atomgroups['ll_nc3'] = self.u.select_atoms('resid ' + ' '.join(map(str, self.atomgroups['ll_dopc'].atoms.resids))).intersection(self.atomgroups['nc3']) self.membranes['ul_nc3'] = Membrane(self.atomgroups['ul_nc3'].atoms.positions, labels=self.atomgroups['ul_nc3'].atoms.resids, periodic=True, bbox=self.bbox, boundary_layer=0.5) self.membranes['ul_nc3'].fit_points_to_box_xy() self.membranes['ul_nc3'].compute_pnormals(knbrs=36) self.membranes['ul_nc3'].compute_approx_surface(exactness_level=8) self.membranes['ul_nc3'].compute_membrane_surface() self.membranes['ul_nc3'].compute_properties() self.membranes['ll_nc3'] = Membrane(self.atomgroups['ll_nc3'].atoms.positions, labels=self.atomgroups['ll_nc3'].atoms.resids, periodic=True, bbox=self.bbox, boundary_layer=0.5) self.membranes['ll_nc3'].fit_points_to_box_xy() self.membranes['ll_nc3'].compute_pnormals(knbrs=36) self.membranes['ll_nc3'].compute_approx_surface(exactness_level=8) self.membranes['ll_nc3'].compute_membrane_surface() self.membranes['ll_nc3'].compute_properties() # Compute all distances from dogl to closest membrane and determine upper / lower / flipflop self.membranes['dogl'] = Membrane.compute(self.atomgroups['dogl'].atoms.positions, self.atomgroups['dogl'].atoms.resids, periodic=True, bbox=self.bbox) Membrane.compute_thickness(self.membranes['dogl'], self.membranes['ul_nc3'], mtype='exact') self.ul_dogl_dist = np.column_stack((self.membranes['dogl'].labels, self.membranes['dogl'].properties['thickness'])) ul_dogl_labels = np.array([int(lip[0]) for lip in self.ul_dogl_dist if lip[1] < flipflop_offset]) if len(ul_dogl_labels) > 0: self.atomgroups['ul_dogl'] = self.u.select_atoms('resid ' + ' '.join(map(str, ul_dogl_labels))).intersection(self.atomgroups['dogl']) else: self.atomgroups['ul_dogl'] = self.u.atoms[[]] Membrane.compute_thickness(self.membranes['dogl'], self.membranes['ll_nc3'], mtype='exact') self.ll_dogl_dist = np.column_stack((self.membranes['dogl'].labels, self.membranes['dogl'].properties['thickness'])) ll_dogl_labels = np.array([int(lip[0]) for lip in self.ll_dogl_dist if lip[1] < flipflop_offset]) if len(ll_dogl_labels) > 0: self.atomgroups['ll_dogl'] = self.u.select_atoms('resid ' + ' '.join(map(str, ll_dogl_labels))).intersection(self.atomgroups['dogl']) else: self.atomgroups['ll_dogl'] = self.u.atoms[[]] # Generate ff_dogl membrane from lipids not in ul and ll ff_dogl_labels = np.array([lip for lip in self.membranes['dogl'].labels if lip not in np.union1d(ul_dogl_labels, ll_dogl_labels)]) if len(ff_dogl_labels) > 0: self.atomgroups['ff_dogl'] = self.u.select_atoms('resid ' + ' '.join(map(str, ff_dogl_labels))).intersection(self.atomgroups['dogl']) else: self.atomgroups['ff_dogl'] = self.u.atoms[[]] # Generate combines membranes self.atomgroups['ul'] = self.atomgroups['ul_dopc'] + self.atomgroups['ul_dogl'] self.atomgroups['ll'] = self.atomgroups['ll_dopc'] + self.atomgroups['ll_dogl'] self.membranes['ul'] = Membrane(self.atomgroups['ul'].atoms.positions, labels=self.atomgroups['ul'].atoms.resids, periodic=True, bbox=self.bbox, boundary_layer=0.5) self.membranes['ul'].fit_points_to_box_xy() self.membranes['ul'].compute_pnormals(knbrs=36) self.membranes['ul'].compute_approx_surface(exactness_level=8) self.membranes['ul'].compute_membrane_surface() self.membranes['ul'].compute_properties() self.membranes['ll'] = Membrane(self.atomgroups['ll'].atoms.positions, labels=self.atomgroups['ll'].atoms.resids, periodic=True, bbox=self.bbox, boundary_layer=0.5) self.membranes['ll'].fit_points_to_box_xy() self.membranes['ll'].compute_pnormals(knbrs=36) self.membranes['ll'].compute_approx_surface(exactness_level=8) self.membranes['ll'].compute_membrane_surface() self.membranes['ll'].compute_properties() # Compute thickness and densities self.membranes['ul'].compute_density(rho_type, sigma, 'density', True, self.membranes['ul'].labels) self.membranes['ll'].compute_density(rho_type, sigma, 'density', True, self.membranes['ll'].labels) Membrane.compute_thickness(self.membranes['ul_nc3'], self.membranes['ll_nc3']) for key in self.membranes: self.membranes[key].write_all(self.pre_out + '/' + key + '_' + str(self.ts)) def write_to_out(self): """ Save all lipids to self.out. Switch case for lipid type and u/l/f """ for head in self.atomgroups['heads']: if head in self.atomgroups['ul_dopc']: i_ul_dopc = np.where(self.membranes['ul_dopc'].labels==head.resid)[0][0] i_ul_nc3 = np.where(self.membranes['ul_nc3'].labels==head.resid)[0][0] i_ul = np.where(self.membranes['ul'].labels==head.resid)[0][0] self.out['l'][head.resid - 1].append('u') self.out['r'][head.resid - 1].append(head.position) self.out['d'][head.resid - 1].append('na') self.out['d_nc3'][head.resid - 1].append(self.membranes['ul_nc3'].properties['thickness'][i_ul_nc3]) self.out['rho'][head.resid - 1].append(self.membranes['ul'].properties['density'][i_ul]) self.out['j'][head.resid - 1].append(self.membranes['ul'].memb_smooth.mean_curv[i_ul]) self.out['k'][head.resid - 1].append(self.membranes['ul'].memb_smooth.gaus_curv[i_ul]) self.out['apl'][head.resid - 1].append(self.membranes['ul'].memb_smooth.pareas[i_ul]) elif head in self.atomgroups['ll_dopc']: i_ll_dopc = np.where(self.membranes['ll_dopc'].labels==head.resid)[0][0] i_ll_nc3 = np.where(self.membranes['ll_nc3'].labels==head.resid)[0][0] i_ll = np.where(self.membranes['ll'].labels==head.resid)[0][0] self.out['l'][head.resid - 1].append('l') self.out['r'][head.resid - 1].append(head.position) self.out['d'][head.resid - 1].append('na') self.out['d_nc3'][head.resid - 1].append(self.membranes['ll_nc3'].properties['thickness'][i_ll_nc3]) self.out['rho'][head.resid - 1].append(self.membranes['ll'].properties['density'][i_ll]) self.out['j'][head.resid - 1].append(self.membranes['ll'].memb_smooth.mean_curv[i_ll]) self.out['k'][head.resid - 1].append(self.membranes['ll'].memb_smooth.gaus_curv[i_ll]) self.out['apl'][head.resid - 1].append(self.membranes['ll'].memb_smooth.pareas[i_ll]) elif head in self.atomgroups['ul_dogl']: i_ul = np.where(self.membranes['ul'].labels==head.resid)[0][0] self.out['l'][head.resid - 1].append('u') self.out['r'][head.resid - 1].append(head.position) d_ul = self.ul_dogl_dist[self.ul_dogl_dist[:,0]==head.resid, 1] d_ll = self.ll_dogl_dist[self.ll_dogl_dist[:,0]==head.resid, 1] self.out['d'][head.resid - 1].append([d_ul, d_ll]) self.out['d_nc3'][head.resid - 1].append('na') self.out['rho'][head.resid - 1].append(self.membranes['ul'].properties['density'][i_ul]) self.out['j'][head.resid - 1].append(self.membranes['ul'].memb_smooth.mean_curv[i_ul]) self.out['k'][head.resid - 1].append(self.membranes['ul'].memb_smooth.gaus_curv[i_ul]) self.out['apl'][head.resid - 1].append(self.membranes['ul'].memb_smooth.pareas[i_ul]) elif head in self.atomgroups['ll_dogl']: i_ll = np.where(self.membranes['ll'].labels==head.resid)[0][0] self.out['l'][head.resid - 1].append('l') self.out['r'][head.resid - 1].append(head.position) d_ul = self.ul_dogl_dist[self.ul_dogl_dist[:,0]==head.resid, 1] d_ll = self.ll_dogl_dist[self.ll_dogl_dist[:,0]==head.resid, 1] self.out['d'][head.resid - 1].append([d_ul, d_ll]) self.out['d_nc3'][head.resid - 1].append('na') self.out['rho'][head.resid - 1].append(self.membranes['ll'].properties['density'][i_ll]) self.out['j'][head.resid - 1].append(self.membranes['ll'].memb_smooth.mean_curv[i_ll]) self.out['k'][head.resid - 1].append(self.membranes['ll'].memb_smooth.gaus_curv[i_ll]) self.out['apl'][head.resid - 1].append(self.membranes['ll'].memb_smooth.pareas[i_ll]) elif head in self.atomgroups['ff_dogl']: self.out['l'][head.resid - 1].append('f') self.out['r'][head.resid - 1].append(head.position) d_ul = self.ul_dogl_dist[self.ul_dogl_dist[:,0]==head.resid, 1] d_ll = self.ll_dogl_dist[self.ll_dogl_dist[:,0]==head.resid, 1] self.out['d'][head.resid - 1].append([d_ul, d_ll]) self.out['d_nc3'][head.resid - 1].append('na') self.out['rho'][head.resid - 1].append('na') self.out['j'][head.resid - 1].append('na') self.out['k'][head.resid - 1].append('na') self.out['apl'][head.resid - 1].append('na') def write_to_json(self): with open(self.pre_out + '.json', 'w') as f: json.dump(self.out, f, cls=NumpyEncoder) def run(self, trange=None): """ Loops over trajectory Update ul_dopc and ll_dopc every n steps (dopc's generally don't flipflop) Call update_membranes to recalculate membranes Call write_out to add properties to self.out """ if not trange: trange = (0, self.nsteps) elif len(trange) == 1: trange = (trange[0], self.nsteps) print(trange) print(len(self.u.trajectory)) for ts in self.u.trajectory[trange[0] : trange[1] : 1]: print(ts.frame) self.ts = ts.frame b = ts.dimensions[0:3] self.bbox = np.array([0,0,0, b[0], b[1], b[2]]).reshape(2,3) self.out_box.append(self.bbox) self.update_membranes() self.write_to_out() self.write_to_json()
def test_component_index_is_not_none(universe, lipid_heads): lfls_ag = LeafletFinder(universe, lipid_heads, cutoff=15.0, pbc=True) assert_almost_equal(len(lfls_ag.groups(component_index=0)), 180, decimal=4)
def test_cutoff_update_default(universe, lipid_heads): lfls_ag = LeafletFinder(universe, lipid_heads, cutoff=15.0, pbc=True) lfls_ag.update() assert_almost_equal(lfls_ag.cutoff, 15.0, decimal=4) assert_almost_equal(len(lfls_ag.groups()), 2, decimal=4)
Coordinates = {} Pixels = {} PixelMesh = {} DensityMesh = {} ThicknessMesh = {} # initialise the XYZCoordinates for species in ['unsaturated','saturated','cholesterol']: for leaflet in ["upper","lower"]: Coordinates[(species,leaflet)] = [] # extract the coordinates of the lipid species present for i in [0,1]: # define saturated and unsaturated phases bilayerLeaflet[('unsaturated',i)] = bilayerLeaflets.groups(i).selectAtoms("resname DUPC and name PO4") bilayerLeaflet[('saturated',i)] = bilayerLeaflets.groups(i).selectAtoms("resname DPPC and name PO4") bilayerLeaflet[('cholesterol',i)] = bilayerLeaflets.groups(i).selectAtoms("resname CHOL and name ROH") for species in ['unsaturated','saturated','cholesterol']: Coordinates[(species,leafletList[i])] = pixelWidth*bilayerLeaflet[(species,i)].coordinates() # now process the coordinates for leaflet in leafletList: for species in speciesList: frontstem = "png/image-" endstem = "-" + species + "-" + leaflet + "-" + outputStem + ".png" # create a list of the coordinates in pixel format