| 1 | #
|
|---|
| 2 | # Create command htube that shows helices as tubes by moving each CA that is in a helix to the center
|
|---|
| 3 | # of CA position over a six residue sliding window. Example
|
|---|
| 4 | #
|
|---|
| 5 | # htube #0 windowSize 6 radius 1.5
|
|---|
| 6 | #
|
|---|
| 7 | def helix_tubes(atoms, guideAtom = 'CA', windowSize = 6, radius = 1.5):
|
|---|
| 8 |
|
|---|
| 9 | # Make table of guide atoms in sliding window.
|
|---|
| 10 | window_atoms = {}
|
|---|
| 11 | for a in atoms:
|
|---|
| 12 | if a.name == guideAtom:
|
|---|
| 13 | rid = a.residue.id
|
|---|
| 14 | rnum = rid.position
|
|---|
| 15 | for rn in range(rnum - windowSize/2, rnum + windowSize/2 + 1):
|
|---|
| 16 | window_atoms.setdefault((rid.chainId,rn),[]).append(a)
|
|---|
| 17 |
|
|---|
| 18 | # Move guide atom coordinates to average in window
|
|---|
| 19 | from chimera import numpyArrayFromAtoms as atom_coordinates, Point, RibbonStyleFixed
|
|---|
| 20 | round = RibbonStyleFixed((radius, radius))
|
|---|
| 21 | for a in atoms:
|
|---|
| 22 | r = a.residue
|
|---|
| 23 | if r.isHelix and a.name == guideAtom:
|
|---|
| 24 | chain_id, res_num = r.id.chainId, r.id.position
|
|---|
| 25 | win_atoms = window_atoms[(chain_id,res_num)]
|
|---|
| 26 | x,y,z = atom_coordinates(win_atoms).mean(axis=0)
|
|---|
| 27 | a.setCoord(Point(x,y,z))
|
|---|
| 28 | r.ribbonDisplay = True
|
|---|
| 29 | r.ribbonStyle = round
|
|---|
| 30 |
|
|---|
| 31 | def htube_command(cmd_name, args):
|
|---|
| 32 |
|
|---|
| 33 | from Commands import parse_arguments, atoms_arg, string_arg, int_arg, float_arg
|
|---|
| 34 | required_args = [('atoms', atoms_arg)]
|
|---|
| 35 | optional_args = []
|
|---|
| 36 | keyword_args = [('guideAtom', string_arg),
|
|---|
| 37 | ('windowSize', int_arg),
|
|---|
| 38 | ('radius', float_arg)]
|
|---|
| 39 | kw = parse_arguments(cmd_name, args, required_args, optional_args, keyword_args)
|
|---|
| 40 | helix_tubes(**kw)
|
|---|
| 41 |
|
|---|
| 42 |
|
|---|
| 43 | from Midas.midas_text import addCommand
|
|---|
| 44 | addCommand('htube', htube_command)
|
|---|