On 3/9/18 1:31 AM, Shyam Saladi wrote: > It is possible to specify a selection by the sequence of their residues? > Usually, I use model.residue_range(), but this can be tedious. > > Ideally, I'd like to do something like > model.residue_sequence('NNPLGTPGTS') to select all occurrences of that > sequence.
No, but it's pretty straightforward to write a little bit of Python to get what you want. Something like the following should work:
def residue_sequence(model, search): one_letter = "".join(r.code for r in model.residues) start = 0 ranges = [] while True: f = one_letter.find(search, start) if f >= 0: ranges.append(model.residue_range(f, f+len(search)-1)) start = f+len(search) else: return ranges return selection(residue_sequence(model, 'NNPLGTPGTS'))
Ben Webb, Modeller Caretaker