-
Notifications
You must be signed in to change notification settings - Fork 0
/
draw_mb.py
32 lines (27 loc) · 945 Bytes
/
draw_mb.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
import numpy as np
def random_point_in_circle():
"""
return x and y coordinates in a cycle of radius 400
"""
length = np.sqrt(np.random.uniform(0, 400))
angle = np.pi * np.random.uniform(0, 2)
x = length * np.cos(angle)
y = length * np.sin(angle)
return x,y
def draw_mb(cmb, tk, filepath):
"""
write membrane entries (represented by O and N atoms) to the output file
input:
- cmb: center of membrane
- tk: membrane thickness
- filepath: path of output file
"""
z_upper = cmb + tk / 2
z_lower = cmb - tk / 2
with open(filepath, 'a') as outfile:
for i in range(5000, 6000):
x,y = random_point_in_circle()
line = f'\nHETATM{i:>5d} O DUM A5000 {x:8.3f}{y:8.3f}{z_lower:8.3f}'
outfile.write(line)
line = f'\nHETATM{i:>5d} N DUM A5000 {x:8.3f}{y:8.3f}{z_upper:8.3f}'
outfile.write(line)