def perform_bilayer_removing(atoms, ref_lipid_atom, ref_water_atom, verbose): """ Remove the water molecules inside a bilayer""" if verbose: print() print("Checking the reference atom...") if not find_ref_atom(atoms, ref_lipid_atom): raise RefObjectError( ("The reference atom {0} for the bilayer was not find. " "Exiting...").format(ref_lipid_atom)) if not find_ref_atom(atoms, ref_water_atom): raise RefObjectError( ("The reference atom {0} for the water was not find. " "Exiting...").format(ref_water_atom)) # Get Z mean for the upper and lower leaflet z_lower, z_upper = z_mean_values(atoms, ref_lipid_atom) if verbose: print("Removing water inside the bilayer...") # Remove water molecules inside the bilayer temp_atoms, nb_water_removed = remove_water(atoms, z_upper, z_lower, ref_water_atom) if verbose: print("Renumber residues and atoms...") output = groIO.renumber(temp_atoms) return (output, nb_water_removed)
def perform_bilayer_removing(atoms, ref_lipid_atom, ref_water_atom, verbose): """ Remove the water molecules inside a bilayer""" if verbose: print() print("Checking the reference atom...") if not find_ref_atom(atoms, ref_lipid_atom): raise RefObjectError(("The reference atom {0} for the bilayer was not find. " "Exiting...").format(ref_lipid_atom)) if not find_ref_atom(atoms, ref_water_atom): raise RefObjectError(("The reference atom {0} for the water was not find. " "Exiting...").format(ref_water_atom)) # Get Z mean for the upper and lower leaflet z_lower, z_upper = z_mean_values(atoms, ref_lipid_atom) if verbose: print("Removing water inside the bilayer...") # Remove water molecules inside the bilayer temp_atoms, nb_water_removed = remove_water(atoms, z_upper, z_lower, ref_water_atom) if verbose: print("Renumber residues and atoms...") output = groIO.renumber(temp_atoms) return (output, nb_water_removed)
def perform_sphere_removing(atoms, sphere_residus, sphere_radius, ref_water_residue, verbose): """ Remove the water molecules inside a sphere centered on the geometrical center of the atom with a given set of residue name """ if verbose: print() print("The reference residue for the sphere is {0}".format( ", ".join(sphere_residus))) print("The reference residue for the water is {0}".format( ref_water_residue)) for residue in sphere_residus: if not find_ref_residue(atoms, residue): raise RefObjectError( ("The reference residue {0} for the sphere was not find. " "Exiting...").format(residue)) if not find_ref_residue(atoms, ref_water_residue): raise RefObjectError( ("The reference residue {0} for water was not find. " "Exiting...").format(ref_water_residue)) resids = get_resids(atoms, sphere_residus) dic_center = geometric_center(atoms, resids) if not verbose: print("Removing water molecules...") output_atoms = atoms sum_water_removed = 0 for resid, center in dic_center.items(): if verbose: print( "Removing water inside the sphere centered ({x:.1f} {y:.1f} {z:.1f})" " on residue {res}".format(res=resid, **center)) tmp_atoms, nb_water_removed = remove_sphere(output_atoms, ref_water_residue, center, sphere_radius) sum_water_removed += nb_water_removed output_atoms = groIO.renumber(tmp_atoms) return (output_atoms, sum_water_removed)
def _create_runumbered(atoms, removed_res): """ Remove residues from a structure and renumber the atoms and residues. :Parameters: - atoms: the list of dictionnary for atoms - remove_res: a list of resid to remove from the structure :Returns: - the new list renumbered """ # Remove some residues keep = [atom for atom in atoms if not atom['resid'] in removed_res] # Renumber residues and atoms renumbered = groIO.renumber(keep) return renumbered
def perform_sphere_removing(atoms, sphere_residus, sphere_radius, ref_water_residue, verbose): """ Remove the water molecules inside a sphere centered on the geometrical center of the atom with a given set of residue name """ if verbose: print() print("The reference residue for the sphere is {0}".format(", ".join(sphere_residus))) print("The reference residue for the water is {0}".format(ref_water_residue)) for residue in sphere_residus: if not find_ref_residue(atoms, residue): raise RefObjectError(("The reference residue {0} for the sphere was not find. " "Exiting...").format(residue)) if not find_ref_residue(atoms, ref_water_residue): raise RefObjectError(("The reference residue {0} for water was not find. " "Exiting...").format(ref_water_residue)) resids = get_resids(atoms, sphere_residus) dic_center = geometric_center(atoms, resids) if not verbose: print("Removing water molecules...") output_atoms = atoms sum_water_removed = 0 for resid, center in dic_center.items(): if verbose: print("Removing water inside the sphere centered ({x:.1f} {y:.1f} {z:.1f})" " on residue {res}".format(res=resid, **center)) tmp_atoms, nb_water_removed = remove_sphere(output_atoms, ref_water_residue, center, sphere_radius) sum_water_removed += nb_water_removed output_atoms = groIO.renumber(tmp_atoms) return (output_atoms, sum_water_removed)