def get_nucleic_acid_backbone(hierarchy, backbone='minimal'): """ Returns the atoms in the backbone of the nucleic acid contained in the hierarchy. backbone 'minimal' returns the atoms: ["P", "O5'", "C5'", "C4'", "C3'", "O3'"] backbone 'trace' returns the atoms C4' """ # log.debug("get_nucleic_acid_backbone") backbone_atoms = [] if backbone == 'minimal': backbone_atoms = ["P", "O5'", "C5'", "C4'", "C3'", "O3'"] elif backbone == 'trace': backbone_atoms = ["C4'"] else: raise ValueError("Wrong value for the type of backbone") backbone_atom_types = [atom.AtomType(t) for t in backbone_atoms] h_chains = atom.get_by_type(hierarchy, atom.CHAIN_TYPE) backbone = [] if len(h_chains) > 1: raise ValueError("The hierarchy mas more than one chain") h_residues = atom.get_by_type(hierarchy, atom.RESIDUE_TYPE) for hr in h_residues: res = atom.Residue(hr) if not (res.get_is_dna() or res.get_is_rna()): raise ValueError("Residue is not part of a nucleic acid") h_atoms = atom.get_by_type(hr, atom.ATOM_TYPE) for at in h_atoms: if atom.Atom(at).get_atom_type() in backbone_atom_types: backbone.append(at) return backbone
def get_selection_as_atom_hierarchy(model, S): """ Gets a selection of particles and decorates them as Atoms. Then all of them are put into a big residue. I have this to use with the multifit.create_coarse_molecule_from_molecule() function """ ph = IMP.kernel.Particle(model) h = atom.Residue.setup_particle(ph) for p in S.get_selected_particles(): h.add_child(atom.Atom(p)) return h
def get_particle_infos_for_pdb_writing(self, name, atomistic=False): # index_residue_pair_list={} # the resindexes dictionary keep track of residues that have been already # added to avoid duplication # highest resolution have highest priority resindexes_dict = {} # this dictionary dill contain the sequence of tuples needed to # write the pdb particle_infos_for_pdb = [] geometric_center = [0, 0, 0] atom_count = 0 atom_index = 0 for n, p in enumerate(impatom.get_leaves(self.dictionary_pdbs[name])): # this loop gets the protein name from the # particle leave by descending into the hierarchy (protname, is_a_bead) = IMP.pmi.tools.get_prot_name_from_particle( p, self.dictchain[name]) if protname not in resindexes_dict: resindexes_dict[protname] = [] if impatom.Atom.get_is_setup(p) and atomistic: atom_index += 1 residue = impatom.Residue(impatom.Atom(p).get_parent()) rt = residue.get_residue_type() resind = residue.get_index() atomtype = impatom.Atom(p).get_atom_type() xyz = list(IMP.core.XYZ(p).get_coordinates()) geometric_center[0] += xyz[0] geometric_center[1] += xyz[1] geometric_center[2] += xyz[2] atom_count += 1 particle_infos_for_pdb.append( (xyz, atom_index, atomtype, rt, self.dictchain[name][protname], resind)) resindexes_dict[protname].append(resind) elif impatom.Residue.get_is_setup(p): residue = impatom.Residue(p) resind = residue.get_index() # skip if the residue was already added by atomistic resolution # 0 if resind in resindexes_dict[protname]: continue else: resindexes_dict[protname].append(resind) atom_index += 1 rt = residue.get_residue_type() xyz = IMP.core.XYZ(p).get_coordinates() geometric_center[0] += xyz[0] geometric_center[1] += xyz[1] geometric_center[2] += xyz[2] atom_count += 1 particle_infos_for_pdb.append( (xyz, atom_index, impatom.AT_CA, rt, self.dictchain[name][protname], resind)) # if protname not in index_residue_pair_list: # index_residue_pair_list[protname]=[(atom_index,resind)] # else: # index_residue_pair_list[protname].append((atom_index,resind)) elif impatom.Fragment.get_is_setup(p) and not is_a_bead: resindexes = IMP.pmi.tools.get_residue_indexes(p) resind = resindexes[len(resindexes) / 2] if resind in resindexes_dict[protname]: continue else: resindexes_dict[protname].append(resind) atom_index += 1 rt = impatom.ResidueType('BEA') xyz = IMP.core.XYZ(p).get_coordinates() geometric_center[0] += xyz[0] geometric_center[1] += xyz[1] geometric_center[2] += xyz[2] atom_count += 1 particle_infos_for_pdb.append( (xyz, atom_index, impatom.AT_CA, rt, self.dictchain[name][protname], resind)) else: if is_a_bead: atom_index += 1 rt = impatom.ResidueType('BEA') resindexes = IMP.pmi.tools.get_residue_indexes(p) resind = resindexes[len(resindexes) / 2] xyz = IMP.core.XYZ(p).get_coordinates() geometric_center[0] += xyz[0] geometric_center[1] += xyz[1] geometric_center[2] += xyz[2] atom_count += 1 particle_infos_for_pdb.append( (xyz, atom_index, impatom.AT_CA, rt, self.dictchain[name][protname], resind)) # if protname not in index_residue_pair_list: # index_residue_pair_list[protname]=[(atom_index,resind)] # else: # index_residue_pair_list[protname].append((atom_index,resind)) geometric_center = (geometric_center[0] / atom_count, geometric_center[1] / atom_count, geometric_center[2] / atom_count) return (particle_infos_for_pdb, geometric_center) '''