-
Notifications
You must be signed in to change notification settings - Fork 0
/
worker_function.py
46 lines (32 loc) · 1.05 KB
/
worker_function.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
__author__ = 'xiuchengquek'
__author__ = 'xiuchengquek'
import sys
import time
import zmq
from rna_distance import run_distance
reciever_ip = 'tcp://192.168.11.203:5559'
sinker_ip = 'tcp://192.168.11.203:5558'
context = zmq.Context()
# Get reciever
receiver = context.socket(zmq.PULL)
receiver.connect(reciever_ip)
sinker = context.socket(zmq.PUSH)
sinker.connect(sinker_ip)
while True:
data = receiver.recv_json()
ref = data['ref']
struct_file = data['structure_file']
alignment_pair = data['alignment_pair']
sys.stdout.write('working on %s\n' %alignment_pair)
sys.stdout.flush()
structures = run_distance.read_structure_file(struct_file)
structures = set(structures)
results = run_distance.run_distance_pexpect(ref, structures)
out_file = "data/rnadistance_results/%s.rnadist.results.txt" % alignment_pair
with open(out_file, 'w+') as f:
for score in results:
f.write("%s\n" % score)
sinker.send_json({
'sender' : 'worker',
'body' : "%s\tcompleted" % alignment_pair
})