all_lipids = loos.selectAtoms(system, all_lipid_selection) # NOTE: target_lipids must be a subset of all_lipids target_lipids = loos.selectAtoms(all_lipids, target_lipid_selection) slicer = ZSliceSelector(zmin, zmax) # TODO: this should probably be a command line option # Note: normally, this small a padding might be a problem for Voronoi # decomposition with 1 atom/lipid. However, we're not using the areas # (which is what gets screwed up by lack of padding), and 15 ought # to be big enough to make sure we've got 1 layer of lipid around # the protein. padding = 15. protein_centroid = loos.AtomicGroup() protein_centroid.append(loos.Atom()) # set up space to hold the neigbor time series neighbor_timeseries = numpy.zeros( [len(target_lipids), len(traj)], numpy.float) for frame in traj: # Use the centroid of the protein slice to represent the protein protein_slice = slicer(protein) centroid = protein_slice.centroid() protein_centroid[0].coords(centroid) # We assume you're using 1 atom/lipid. # Applying slice operation here allows you to be sloppy # with your selections. all_lipids_slice = slicer(all_lipids)
except OSError as inst: print 'Error creating output directory %s : ' % output_directory print inst sys.exit(1) if not os.access(output_directory, os.W_OK): print "Error: no permission to write to output directory ", output_directory sys.exit(1) helices = [] helix_centroids = loos.AtomicGroup() for h in args.helix_ranges: first, last = h.split(":") helix_string = '(resid >= ' + first + ') ' + '&& (resid <= ' + last + ')' helix = loos.selectAtoms(protein, helix_string) helices.append(helix) helix_centroids.append(loos.Atom()) target = loos.selectAtoms(system, args.target_string) target = loos.selectAtoms(target, "!hydrogen") chains = target.splitByResidue() if (args.zmin > args.zmax): tmp = args.zmax args.zmax = args.zmin args.zmin = tmp slicers = [] block_size = (args.zmax - args.zmin) / args.zblocks for i in range(args.zblocks): z1 = args.zmin + i * block_size
sys.stderr.write("Finished bump-checking water against lipid\n") sys.stderr.write("Current # water molecules: %d\n" % (len(water.full_system) / 3)) sys.stderr.write("Adding salt\n") # regenerate the list of oxygens water_oxygens = loos.selectAtoms(water.full_system, 'name =~ "^O"') water_residues = water.full_system.splitByResidue() # now replace waters with salt salts = [] for salt in config.salt: ions = loos.AtomicGroup() for i in range(salt.numres): a = loos.Atom() a.resname(salt.resname) a.segid(salt.segname) a.name(salt.atomname) a.resid(i + 1) # pick a water oxygen at random, replace it with salt ox = random.choice(water_oxygens) a.coords(ox.coords()) ions.append(a) # remove this water for w in water_residues: if ox in w: water.full_system.remove(w) water_oxygens.remove(ox)
selections = sys.argv[4:] system = loos.createSystem(system_filename) traj = loos.pyloos.Trajectory(traj_filename, system) helices = [] for s in selections: helices.append(loos.selectAtoms(system, s)) # Make a fake atomicgroup to hold the placeholder atoms new_group = loos.AtomicGroup() resnum = 1 for i in range(len(helices)): a = loos.Atom() b = loos.Atom() c = loos.Atom() a.resid(resnum) b.resid(resnum) c.resid(resnum) a.name("CENT") b.name("PLUS") c.name("MIN") new_group.append(a) new_group.append(b) new_group.append(c) resnum+=1