def check_disconnected_residues(self): """ Looks for residues that belong to the chain, are not connected to the chain and represents synthetic residues, ligands or stereoisomers. """ temp = [] st = ModernaStructure('residues', self.standard + self.unidentified_rna) all_resi = [x for x in st] if len(all_resi) == 1: temp.append(all_resi[0].identifier) elif not self.continuous: for x in range(len(all_resi) - 1): if not are_residues_connected(all_resi[x], all_resi[x + 1]): if len(all_resi) == 2: temp += [y.identifier for y in all_resi] elif x + 1 == len(all_resi) - 1: temp.append(all_resi[x + 1].identifier) elif not are_residues_connected(all_resi[x + 1], all_resi[x + 2]): temp.append(all_resi[x + 1].identifier) # checking whether disconnected residues are not sandard or modified ones for resi in temp: if not self.is_typical_category_residue(st[resi]): self.disconnected_residues.append(st[resi])
def _identify_upper_anchors(self, model, anchor5, anchor3): """Find residues connecting to anchors if any""" upper5, upper3 = None, None if model: upper = model.find_residues_in_range(anchor5.identifier, anchor3.identifier) if len(upper) > 0: if are_residues_connected(anchor5, model[upper[0]]): upper5 = model[upper[0]] if are_residues_connected(model[upper[-1]], anchor3): upper3 = model[upper[-1]] return upper5, upper3
def write_bb_status(self): log.write_message(str(self.is_intact())) self.write_resi_status(self.resi1) self.write_resi_status(self.resi2) if are_residues_connected(self.resi1, self.resi2): log.write_message('connection between both residues OK') else: log.write_message('connection between both residues BROKEN')
def is_intact(self): """Checks whether the backbone is complete.""" if not is_backbone_intact(self.resi1, mode="3'") or \ not is_backbone_intact(self.resi2, mode="5'") or \ not are_residues_connected(self.resi1, self.resi2) or \ not is_phosphate_intact(self.resi2) or \ is_backbone_congested(self.resi1, mode="3'") or \ is_backbone_congested(self.resi2, mode="5'"): return False return True
def __are_there_any_clashes__(self, neighbors): """ The method eats output of the search_all method of NeighborSearch object. It generates tuples of clashing residues. """ if len(neighbors) != 0: for first_atom, second_atom in neighbors: first_atom_radius = self.__get_atom_radius__(first_atom) second_atom_radius = self.__get_atom_radius__(second_atom) distance_between_atom_centers = first_atom - second_atom resi_1 = first_atom.get_parent() resi_2 = second_atom.get_parent() if (first_atom.get_name() == 'O3\''\ and second_atom.get_name() == 'P') or \ (first_atom.get_name() == 'P'\ and second_atom.get_name() == 'O3\'') \ and \ (are_residues_connected(resi_1, resi_2) or \ are_residues_connected(resi_2, resi_1)): # 15 May 2009: # TP: feature requested by MM & KR # Its really a temporary solution and it will be changed # when ModernaStructure.are_residues_connected() is ready! # (because we have to make sure that those two residues # are linear neighbours) minimum_distance_between_atom_centers = 1.413 else: minimum_distance_between_atom_centers = \ first_atom_radius + second_atom_radius #TODO: could be checked before calculating the atom-atom # distance explicitly if resi_1 != resi_2 and distance_between_atom_centers < \ minimum_distance_between_atom_centers: #We have a clash! if self.compare_residues(resi_1, resi_2) <0: yield resi_1, resi_2 else: yield resi_2, resi_1
def get_sequence(self): """ Returns a Sequence object containing the one-letter sequence of this ModernaStructure instance, including modifications. """ seq = [] previous_resi = None for res in self: if previous_resi: if not are_residues_connected(previous_resi, res): seq.append(alphabet[MISSING_RESIDUE]) seq.append(alphabet[res.long_abbrev]) previous_resi = res return Sequence(seq)
def test_validation(self): """Makes sure test data is set up properly.""" self.assertFalse(is_backbone_intact(self.resi2)) self.assertFalse(are_residues_connected(self.resi1, self.resi2))
def test_build_backbone_connection(self): """Checks whether two residues are properly connected.""" bb = PhosphateBuilder(self.resi1, self.resi2) bb.build() self.assertTrue(are_residues_connected(self.resi1, self.resi2))
def test_is_connected_reverse(self): """Reverse order of residues changes the result.""" connected = are_residues_connected(self.t['5'], self.t['4']) self.assertFalse(connected)
def test_is_connected_to_false(self): """The 3'O (n) and P (n+1) must be close together.""" connected = are_residues_connected(self.t['4'], self.t['6']) self.assertFalse(connected)