コード例 #1
0
    def run(self):
        while True:
            data = self.receiver.recv_json()
            ref = "this is %s" % data['ref']
            struct_file =  data['structure_file']
            alignment_pair = data['alignment_pair']
            print(alignment_pair)

            structures = run_distance.read_structure_file(struct_file)
            print(structures)
            run_distance.run_distance_pexpect(ref, structures)
            print('done')
コード例 #2
0
    def run_with_poll(self):
        self.start_poll()
        while True:
            socks = dict(self.poller.poll(1000))
            if socks:
                if socks.get(self.receiver) == zmq.POLLIN:
                    print ("got message ")
                    data = self.receiver.recv_json(zmq.NOBLOCK)
                    ref = "this is %s" % data['ref']
                    struct_file =  data['structure_file']
                    alignment_pair = data['alignment_pair']
                    print(alignment_pair)

                    structures = run_distance.read_structure_file(struct_file)
                    print(structures)
                    run_distance.run_distance_pexpect(ref, structures)
                    print('done')
            else:
                print('still watiing')
コード例 #3
0
# 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