def main(argv): d2l = getlims() d2t = gettargets() excerpt = '/Users/berriz/Work/scratch/excerpt.tsv' header, rows = rt.readtable(excerpt, headerrow=0) sigclass = co.namedtuple('sigclass', header[1:], rename=True) flds = set(si.SignatureData._fields) t2s = dict() rn.seed(0) for row in sorted(rows): drug, vv = row[0], row[1:] if drug not in d2t: continue rangetested = d2l[drug] signature = tuple(convert_conc_row(vv)) isclinical = rn.random() < ISCLINICAL_CUTOFF isselective = rn.random() < ISSELECTIVE_CUTOFF isprimary = rn.random() < ISPRIMARY_CUTOFF data = si.SignatureData(**(sd.superdict(locals()).subdict(flds))) for t in d2t[drug]: t2s.setdefault(t, []).append(data) for vv in t2s.values(): drugs = set(v.drug for v in vv) assert len(drugs) == len(vv) print ' LATEST =', pp.pprint(t2s)
def parseEvent(self, isctx=False): ev = superdict() self.io.reset() for line in self.io: if line == '\n': break self.processLine(ev, line) if not isctx: rawlength = ev.get('Content_Length') if rawlength: ev.rawresponse = self.io.read(int(rawlength)) self.io.reset() self.io.truncate() return ev
def dispatchEvent(self, ctx, event): ctx.data = superdict(event.copy()) reactor.callLater(0, self.eventHandler, superdict(ctx.copy())) self.ctx = self.rawlen = None
def readRawResponse(self): self.io.reset() chunk = self.io.read(int(self.ctx.Content_Length)) self.io.reset() self.io.truncate() return superdict(rawresponse=chunk)