def process_job(job, session): if log: log.info("Processing job %d by worker %d" % (job.id, os.getpid())) #log.info("Job: %s, %d, %d, %s, %s" % (job.alphabet, job.n, job.p, H, dist)) result = _rna.doAll(job.rna_data.encode("ascii"),job.wlen,job.wshift,job.gap,job.start,job.end,job.seed) sres = [] for a in result: if a.score>=20: sres += [{"start":a.start,"end":a.end,"score":a.score}] job.result=json.dumps(sres) job.finish_time = datetime.datetime.now() if len(job.error_string)>0: job.status = ST_ERROR else: job.status = ST_DONE session.commit() log.info("Worker %d has finished job %d" % (os.getpid(), job.id))
_ = "Test 2. Check for module working" sys.stderr.write(_ + " (please wait, it takes some time)... ") f = gzip.open(RESOURCE_PATH+"/in.txt.gz", "r") SS = f.read().strip() f.close() sfrom=0 end=-1 seed=4 dist=50 wlen=3000 wshift=1000 minscore=19 try: res = _rna.doAll(SS,wlen,wshift,0.25,sfrom,10000,seed) except: failed[1] = True if failed[1]: sys.stderr.write("FAILED\n") sys.exit(30) else: sys.stderr.write("PASSED\n") _ = "Test 3. Check for result correctness" sys.stderr.write(_ + "... ") result_data = str() csvfile = StringIO.StringIO(result_data) writer = csv.writer(csvfile, dialect="excel")
if args.wlen: wlen=args.wlen; if args.wshift: wshift=args.wshift; if args.minscore: minscore=args.minscore; try: sequences = bioformats.read_sequences_from_file(args.FILE) except bioformats.BioFormatException as e: sys.stderr.write("Error: "+e.text+"\n") sys.exit(1) if not sequences: sys.stderr.write("Error: file does not contain any sequence\n") sys.exit(2) name, seq = sequences[0] res = _rna.doAll(seq.encode('ascii'),wlen,wshift,minscore,sfrom,10000,seed) import csv writer = csv.writer(sys.stdout, dialect="excel") writer.writerow(["start", "end", "score"]) for a in res: writer.writerow([a.start, a.end, a.score])