def _format_alignment_with_ligands(self, template, aligned_template_seq): from MDAnalysis.lib.util import convert_aa_code sel = template.universe.select_atoms("protein and name CA") resnames = sel.resnames.tolist() resnames_one_letter = [convert_aa_code(x) for x in resnames] # get the last four AAs in the aligned target sequence end_chunk = aligned_template_seq[-4:][::-1] aa_store = [] # loop over residues in reverse for i, letter in enumerate(resnames_one_letter[::-1]): # read a chunk of four AAs current_chunk = resnames_one_letter[::-1][i : i + 4] # if the end of the aligned target sequence is hit, stop if current_chunk == end_chunk: break # otherwise store the one letter AAs that need to be added else: aa_store.append(letter) # create a one element list of dashes dashes = "".join(["-" for x in aa_store]) # create one element list of AAs in the canonical order amino_acids = "".join(aa_store[::-1]) return amino_acids, dashes
def sequence(self): from MDAnalysis.lib.util import convert_aa_code pdb_seq = [] three_l_codes = [ convert_aa_code(i) for i in list(AminoAcidSequence.ALPHABET) ] for r in self.universe.residues: if r.resname in three_l_codes: pdb_seq.append(convert_aa_code(r.resname)) else: continue s = "".join(pdb_seq) return AminoAcidSequence(s)
def test_ValueError(self, x): with pytest.raises(ValueError): util.convert_aa_code(x)
def test_convert_aa_1to3(self, resname1, strings): assert util.convert_aa_code(resname1) == strings[0]
def test_convert_aa_3to1(self, resname3, resname1): assert util.convert_aa_code(resname3) == resname1
def check_convert_aa_1to3(resname1, resname3_canonical): assert_equal(util.convert_aa_code(resname1), resname3_canonical)
def check_convert_aa_3to1(resname3, resname1): assert_equal(util.convert_aa_code(resname3), resname1)
def convert3to1(aminoList): from MDAnalysis.lib.util import convert_aa_code out = [] for r in aminoList: out.append(convert_aa_code(r)) return out