def body(self): b1 = self.P[0].ref b2 = self.P[1].ref b3 = self.P[2].ref b4 = self.P[3].ref data = (b1, b2, b3, b4) #print data maxval = 0 maxname = '' minval = 1 minname = '' for i in data: if i[1] >= maxval: maxval = i[1] maxname = i[0] if i[1] <= minval: minval = i[1] minname = i[0] return Object((maxname, maxval)), Object((minname, minval))
def body(self): filename = self.P[0].ref.name n = 0.0 a = 0 t = 0 c = 0 g = 0 with open(filename) as f: for line in f: n = float(len(line)) #print line for letter in line: if letter == 'A': a = a + 1 elif letter == 'T': t = t + 1 elif letter == 'C': c = c + 1 elif letter == 'G': g = g + 1 r1 = ('a', a / n) r2 = ('c', t / n) r3 = ('t', c / n) r4 = ('g', g / n) r5 = ('Len', n) return Object(r1), Object(r2), Object(r3), Object(r4), Object(r5)
def body(self): a = self.P[0].ref b = self.P[1].ref r = a + b return Object(r)
def body(self): in1 = self.P[0].ref r = fn_raw.end_raw(in1) flow = Object(r) return flow
def body(self): in1 = self.P[0].ref in2 = self.P[1].ref r = fn_raw.count_raw(in1, in2) flow = Object(r) return flow
def body(self): in1 = self.P[0].ref r = fn_raw.cr_to_csv_raw(in1) flow = Object(r) return flow
def body(self): a = self.P[0].ref b = self.P[1].ref import numpy r = numpy.subtract(a, b) return Object(r)
def body(self): lst = self.P[0].ref n = self.P[1].ref res = lst[n] flow = Object(res) return flow
def body(self): a = self.P[0].ref b = self.P[1].ref import numpy r = numpy.matmul(a, b) return Object(r)
def body(self): #unpack values from input dataflows in1 = self.P[0].ref # apply function res = fn_double(in1) # pack the values again flow = Object(res) # return output dataflow return flow
def body(self): a = self.P[0].ref b = self.P[1].ref import numpy r = numpy.nan try: r = a / b except Exception as e: print e err.error("\"div-0-err\"") return Object(r)
def body(self): import math aprob = self.P[0].ref[1] cprob = self.P[1].ref[1] tprob = self.P[2].ref[1] gprob = self.P[3].ref[1] H = aprob * math.log(aprob, 4) + cprob * math.log( cprob, 4) + tprob * math.log(tprob, 4) + gprob * math.log( gprob, 4) #print H return Object(H)
# return output dataflow return flow class Double(Module): # overwrite the body def body(self): #unpack values from input dataflows in1 = self.P[0].ref # apply function res = fn_double(in1) # pack the values again flow = Object(res) # return output dataflow return flow d1 = Object(111) d2 = Object(222) d3 = Add(d1, d2).run() d4 = Object(1000) d5 = Mul(d3, d4).run() print d5.ref
import sys from ProvModel import Object, Module import fn_logged in1 = sys.argv[1] in2 = sys.argv[2] d1 = Object(in1) d2 = Object(in2) m = fn_logged.count_logged(d1, d2) d3 = m.run() sys.stdout.write(d3.ref)
def body(self): in1 = self.P[0].ref print in1 + ' as in' return Object(in1 + ' as out')
def body(self): r = 1 / 0 return Object(r)
graph = Graph(password = '******') class T(Module): def body(self): in1 = self.P[0].ref print in1 + ' as in' return Object(in1 + ' as out') Qres = open('query eval.csv', 'a') # millis = int(round(time.time() * 1000)) for i in range(0, 5000): d1 = Object(str(i)) m = T(d1) d2 = m.run() t0 = int(round(time.time() * 1000)) q1 = 'match(n) return n' d = graph.run(q1) t1 = int(round(time.time() * 1000)) Qres.write(str(t1-t0) + ',') t0 = int(round(time.time() * 1000)) q2 = 'match(n:Object) where n.VALUE = \'' + str(i) + '\' return n' d = graph.run(q2) t1 = int(round(time.time() * 1000)) Qres.write(str(t1-t0) + ',')
import sys from ProvModel import Module, File, Object import fn_logged import psutil in1 = sys.argv[1] d1 = Object(in1) m = fn_logged.end_logged(d1) d2 = m.run() sys.stdout.write(d2.ref)
from ProvModel import Module, Object class T(Module): def body(self): in1 = self.P[0].ref print in1 + ' as in' return Object(in1 + ' as out') d1 = Object('INSTR') m = T(d1) d2 = m.run() print d2.ref