2 A bunch of algorithms operating on two views.
4 Authors: Marco Biasini, Pascal Benkert
10 if view.chain_count!=1:
11 raise RuntimeError(
"chain count of view must be one")
14 def _GetChains(view_a, view_b):
15 return _GetChain(view_a), _GetChain(view_b)
20 return view.CreateEmptyView()
21 return view.handle.CreateEmptyView()
25 view_add_flags=mol.ViewAddFlag.INCLUDE_ATOMS):
27 Pair residues by residue number.
29 not_supported=
"PairResiduesByNum has no support for unsorted chains"
30 chain_a, chain_b=_GetChains(view_a, view_b)
31 if not chain_a.InSequence()
or not chain_b.InSequence():
32 raise RuntimeError(not_supported)
33 residues_a=chain_a.residues
34 residues_b=chain_b.residues
35 residues_a=iter(chain_a.residues)
36 residues_b=iter(chain_b.residues)
37 result_a=_EmptyView(view_a)
38 result_b=_EmptyView(view_b)
43 while r1.number<r2.number:
45 while r2.number<r1.number:
47 assert r1.number==r2.number
48 result_a.AddResidue(r1, view_add_flags)
49 result_b.AddResidue(r2, view_add_flags)
52 return result_a, result_b
56 Returns a view with one or two representative atom per amino acid residue.
58 There are two basic modes, controlled by the alpha_and_beta parameter:
60 When the parameter is false, for residues with a sidechain, the C-beta atom is
61 used, for residues without sidechain, the C-alpha atom is used. Note that this
62 is different from using the selection
64 (aname=CA and rname=GLY) or (aname=CB and rname!=GLY)
66 When the alpha_and_beta parameter is true, both C-alpha and C-beta (if
67 available) are added to the view.
69 If chain is not equal to None, only atoms of the chain with that chain name
70 will be added to the view.
72 e_view=ent.CreateEmptyView()
76 for res
in ent.residues:
78 if res.IsPeptideLinking():
79 atom = res.FindAtom(
'CB')
84 if alpha_and_beta == 1:
85 atom = res.FindAtom(
'CA')
90 atom = res.FindAtom(
'CA')
95 if alpha_and_beta == 1:
98 elif chain !=
"" and ent.FindChain(chain).IsValid():
99 for res
in ent.FindChain(chain).GetResidueList():
101 if res.IsPeptideLinking():
102 atom = res.FindAtom(
'CB')
106 if alpha_and_beta == 1:
107 atom = res.FindAtom(
'CA')
112 atom = res.FindAtom(
'CA')
117 if alpha_and_beta == 1: