12This script takes in an MRC file and a set of PDB structure_element files and
13extracts the density values around the residue as defined in config.py
18parser = 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")
28parser.add_argument(
'emdb', type=str, help=
'EMDB id')
29parser.add_argument(
'database_file', type=str,
30 help=
'Name of the database file to write')
31parser.add_argument(
'resolution', type=float,
32 help=
'Resolution of the map')
34args = parser.parse_args()
40database_file = args.database_file
43map_file = os.path.join(args.database_home, emdb,
"0system",
44 "emdb_normalized_new.map")
45emdb_path = os.path.join(args.database_home, emdb)
47pdbs = 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
69xyzref = [
IMP.core.XYZ(p).get_coordinates()
for p
in psref]
83 raise Exception(
"MRC, "+map_file+
", cannot be read")
85mrc.get_header_writable().set_resolution(resolution)
88if mrc.get_header().get_spacing() != config.ref_voxel_size:
94of = 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")
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)
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")
Class for storing model, its restraints, constraints, and particles.
A decorator for a particle representing an atom.
Store info for a chain of a protein.
Hierarchies get_by_type(Hierarchy mhd, GetByType t)
Gather all the molecular particles of a certain level in the hierarchy.
A decorator for a residue.
A decorator for a particle with x,y,z coordinates.
DensityMap * get_resampled(DensityMap *input, double scaling)
Get a resampled version of the map.
DensityMap * read_map(std::string filename, MapReaderWriter *reader)
Read a density map from a file (using the given reader) and return it.
double get_density(const DensityMap *m, const algebra::Vector3D &v)
Get density value at point v, interpolating linearly from the sample values.
IMP::algebra::Transformation3D get_transformation_aligning_first_to_second(const Vector3DsOrXYZs0 &source, const Vector3DsOrXYZs1 &target)
Compute the rigid transform bringing the first point set to the second.
Atom get_atom(Residue rd, AtomType at)
Return a particle atom from the residue.
void transform(Hierarchy h, const algebra::Transformation3D &tr)
Transform a hierarchy. This is aware of rigid bodies.
Hierarchy read_pdb(TextInput input, Model *model, PDBSelector *selector=get_default_pdb_selector(), bool select_first_model=true)
Read all the molecules in the first model of the PDB file.
Basic functionality that is expected to be used by a wide variety of IMP users.
Basic utilities for handling cryo-electron microscopy 3D density maps.
DensityMap * create_density_map(const DensityMap *other)
Create a copy of another map.
void set_log_level(LogLevel l)
Set the current global log level.