-
Notifications
You must be signed in to change notification settings - Fork 29
/
SBU_geometry.py
44 lines (31 loc) · 975 Bytes
/
SBU_geometry.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
from bbcif_properties import calc_edge_len
import numpy as np
def SBU_coords(TG, ea_dict, csbl):
SBU_coords = []
SBU_coords_append = SBU_coords.append
for node in TG.nodes(data=True):
vertex = node[0]
xvecs = []
xvecs_append = xvecs.append
for e0, e1, edict in TG.edges(data=True):
if vertex in (e0,e1):
ecif = edict['cifname']
positive_direction = edict['pd']
ind = edict['index']
length = calc_edge_len(ecif,'edges')
if vertex == positive_direction[0]:
direction = 1
ov = positive_direction[1]
else:
direction = -1
ov = positive_direction[0]
xvecname,dx_v,xvec = ea_dict[vertex][ind]
dx_ov = ea_dict[ov][ind][1]
if length < 0.1:
total_length = dx_v + dx_ov + csbl
else:
total_length = dx_v + dx_ov + length + 2*csbl
svec = (xvec/np.linalg.norm(xvec)) * total_length * direction
xvecs_append([ind, svec])
SBU_coords_append((vertex, xvecs))
return SBU_coords