13 def get_backbone_particles(pdb):
19 def compute_ccc_of_particle_set(dmap, ps, resolution, threshold=2.0):
22 dc = dmap.get_cropped(ps, threshold**2)
27 dmap.get_header().get_spacing())
28 smap_c = IMP.em.CoarseL2Norm.get_density_from_particle(
33 IMP.em.CoarseL2Norm.get_normalized_intensities(smap_tc, dc_t, resolution)
35 ccc = IMP.em.CoarseCC()
37 return ccc.cross_correlation_coefficient(dc_t, smap_tc, 0.0,
True)
42 def make_reference_density_map():
44 config.res_bounding_points[0], config.res_bounding_points[1])
50 def get_voxel_coordinates(dmap):
52 for v
in range(dmap.get_number_of_voxels()):
53 point = dmap.get_location_by_voxel(v)
54 voxels[v] = (point[0], point[1], point[2])
58 def mutate_residue(residue_particle, new_aa):
62 atoms = rph.get_children()
72 residue_particle.get_model().remove_particle(p)
79 topology = ff.create_topology(rph)
80 topology.add_atom_types(rph)
81 topology.add_missing_atoms(rph)
82 topology.add_coordinates(rph)
84 bonds = topology.add_bonds(rph)
85 ff.create_angles(bonds)
86 ff.create_dihedrals(bonds)
87 topology.add_impropers(rph)
90 def parse_configuration(config_file):
92 f = open(config_file,
"r")
94 for line
in f.readlines():
95 if len(line.strip()) == 0
or line[0] ==
"#":
99 key = line.split(
"=")[0].strip()
100 value = line.split(
"=")[1].strip().split(
" ")[0].strip()
101 value = value.split(
"#")[0].strip()
104 if "." in value
and "/" not in value:
105 config[key] = float(value)
110 config[key] = int(value)
116 def get_psipred_dictionary_from_files(files):
125 chain = pp.split(
".")[-2]
126 print(
"DHSIUDHSA", pp, chain)
127 psipred[chain] = open_ss2_file(pp)
131 def open_ss2_file(filename):
132 f = open(filename,
"r")
135 for line
in f.readlines():
136 if line.strip() ==
"" or line[0] ==
"#":
138 fields = line.split()
139 resid = int(fields[0])
140 outdict[resid] = (float(fields[4]), float(fields[3]),
141 float(fields[5].strip()))
146 def compare_sequences_and_return_offset(fasta, query):
152 if compare_sequences(fasta, query):
156 minoffset = 1-min(query.keys())
157 maxoffset = max(fasta.keys())-max(query.keys())
159 for i
in range(minoffset, maxoffset+1):
160 if compare_sequences(fasta, query, i):
165 def compare_sequences(seq1, seq2, offset=0):
166 minres = numpy.min(list(seq1.keys()))
167 maxres = numpy.max(list(seq1.keys()))
168 for r
in range(minres, maxres+1):
169 if r+offset
not in seq2.keys():
171 elif seq1[r] != seq2[r+offset]:
176 def read_sequences_from_rcsb(sequence_file):
179 for s
in sequences.sequences.keys():
180 s_cs = s.split(
"_")[-1].split(
" ")[0].strip()
183 chains = s_cs.split()[1].split(",")
185 chains = s_cs.split()
189 seqs[s_cs] = sequences[s]
193 def read_sequences(sequence_file):
196 for s
in sequences.sequences.keys():
197 s_cs = s.split(
"|")[-1].strip()
199 chains = s_cs.split()[1].split(
",")
201 chains = s_cs.split()
203 seqs[c] = sequences[s]
207 def get_pdb_offset(pdb, sequences):
211 alpha = IMP.pmi.alphabets.amino_acid
219 for c
in IMP.atom.get_by_type(root_hier, IMP.atom.CHAIN_TYPE):
224 for r
in IMP.atom.get_by_type(c, IMP.atom.RESIDUE_TYPE):
226 rt = res.get_residue_type().get_string()
227 pdbseq[chain][res.get_index()] = \
228 alpha.get_one_letter_code_from_residue_type(rt)
231 for chain
in pdbseq.keys():
232 offset = compare_sequences_and_return_offset(
233 string_to_dict(sequences[chain]), pdbseq[chain])
234 pdb_offsets[chain] = offset
239 def string_to_dict(string, start=1):
241 for i
in range(len(string)):
242 seqdict[i+start] = string[i]
246 def dict_to_string(seqdict):
247 alpha = IMP.pmi.alphabets.amino_acid
248 lastres = max(seqdict.keys())
250 for i
in range(lastres):
251 if i+1
in seqdict.keys():
252 if len(seqdict[i+1]) == 3:
253 seq += alpha.get_one_letter_code_from_residue_type(
Select all backbone (N,CA,C,O) ATOM records.
Set of Python classes to create a multi-state, multi-resolution IMP hierarchy.
DensityMap * get_threshold_map(const DensityMap *orig_map, float threshold)
Return a map with 0 for all voxels below the threshold.
void read_pdb(TextInput input, int model, Hierarchy h)
CHARMM force field parameters.
Class for storing model, its restraints, constraints, and particles.
Select all non-alternative ATOM records.
The standard decorator for manipulating molecular structures.
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.
algebra::BoundingBoxD< 3 > get_bounding_box(const DensityMap *m)
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.
Python classes to represent, score, sample and analyze models.
A dictionary-like wrapper for reading and storing sequence data.
std::string get_data_path(std::string file_name)
Return the full path to one of this module's data files.
Functionality for loading, creating, manipulating and scoring atomic structures.
Hierarchies get_leaves(const Selection &h)