9 from .
import imp_tools
12 This script takes in an MRC file and a set of PDB structure_element files and
13 extracts the density values around the residue as defined in config.py
18 parser = argparse.ArgumentParser(
19 description=
'Given an MRC file and set of PDB structure_element files, '
20 'extracts the density values around the residue')
22 "--database_home", dest=
"database_home", type=str,
23 help=
"Directory containing all data files used in the protocol",
26 "--reference_pdb", dest=
"refpdb", type=str,
27 help=
"Reference PDB", default=
"reference/ref.pdb")
28 parser.add_argument(
'emdb', type=str, help=
'EMDB id')
29 parser.add_argument(
'database_file', type=str,
30 help=
'Name of the database file to write')
31 parser.add_argument(
'resolution', type=float,
32 help=
'Resolution of the map')
34 args = parser.parse_args()
40 database_file = args.database_file
43 map_file = os.path.join(args.database_home, emdb,
"0system",
44 "emdb_normalized_new.map")
45 emdb_path = os.path.join(args.database_home, emdb)
47 pdbs = glob.glob(emdb_path+
"/1structure_elements/*.pdb")
50 print(
"No structure elements for this system")
53 xml = config.get_xml(emdb)
54 resolution = tools.get_resolution_from_xml(xml)
57 resolution = args.resolution
63 resis = IMP.atom.get_by_type(ref_mh, IMP.atom.RESIDUE_TYPE)
69 xyzref = [
IMP.core.XYZ(p).get_coordinates()
for p
in psref]
81 mrc = IMP.em.read_map(map_file, mrw)
83 raise Exception(
"MRC, "+map_file+
", cannot be read")
85 mrc.get_header_writable().set_resolution(resolution)
88 if mrc.get_header().get_spacing() != config.ref_voxel_size:
89 mrc = IMP.em.get_resampled(mrc, config.ref_voxel_size)
94 of = open(database_file,
"w")
97 pdbname = pdb.split(
'/')[-1].split(
'.')[0]
99 if pdbname.startswith(
'h'):
105 ilc = tools.is_length_correct_for_parts(pdb)
108 print(
"SE", os.path.basename(pdb),
109 "skipped: | is_length_correct:", ilc)
112 print(
"SE", os.path.basename(pdb),
"getting residue densities")
116 residues = IMP.atom.get_by_type(mh, IMP.atom.RESIDUE_TYPE)
122 ats = [
IMP.atom.Atom(a).get_atom_type()
for a
in res.get_children()]
124 if (IMP.atom.AT_CB
not in ats
and
136 rid = res.get_index()
138 resname = res.get_residue_type().get_string()
142 imp_tools.mutate_residue(res,
"ALA")
165 xform_tot = xform1*xform2
168 config.ref_voxel_size)
169 for v
in range(res_map.get_number_of_voxels()):
170 point = res_map.get_location_by_voxel(v)
173 xf_point = xform_tot.get_inverse().get_transformed(point)
175 val = IMP.em.get_density(mrc, xf_point)
178 res_map.set_value(point[0], point[1], point[2], val)
183 sc_string = tools.get_voxel_value_string(res_map)
184 print(
"current PDB name", pdbname)
185 outstring = tools.catstring([emdb, resolution, pdbname, chain, rid,
186 resname, SS]) +
" " + sc_string
188 of.write(outstring+
"\n")
Atom get_atom(Residue rd, AtomType at)
Return a particle atom from the residue.
void read_pdb(TextInput input, int model, Hierarchy h)
Class for storing model, its restraints, constraints, and particles.
void transform(Hierarchy h, const algebra::Transformation3D &tr)
Transform a hierarchy. This is aware of rigid bodies.
DensityMap * create_density_map(const IMP::algebra::GridD< 3, S, V, E > &arg)
Create a density map from an arbitrary IMP::algebra::GridD.
A decorator for a particle representing an atom.
Basic utilities for handling cryo-electron microscopy 3D density maps.
A decorator for a particle with x,y,z coordinates.
void set_log_level(LogLevel l)
Set the current global log level.
A decorator for a residue.
Basic functionality that is expected to be used by a wide variety of IMP users.
Store info for a chain of a protein.
Transformation3D get_transformation_aligning_first_to_second(Vector3Ds a, Vector3Ds b)