def unannotated(userid): """Find an un-annotated chromosome.""" names = db.UserProfiles(userid).get() shuffle(names) chorder = list(db.ChromLengths.CHROM_ORDER) shuffle(chorder) for name in names: ac = db.AnnotationCounts(userid, name) counts = ac.get() for ch in chorder: if counts[ch] == 0: return name, ch
def all_profiles(request): userid = authenticated_userid(request) profile_names = db.UserProfiles(userid).get() profiles = table_profiles(profile_names, userid) urls = [db.COPIES_EXPORT_URL % p for p in profiles if p["copies"] > 0] info = { 'profile_count': len(profile_names), "copy_urls": "\n".join(urls), 'profiles': profiles, 'user': userid, } return info
def forbidden_userprofiles(request): userid = authenticated_userid(request) allowed = db.UserProfiles(userid).get() md = request.matchdict looking = md["profiles"].split(',') if "profiles" in md else [] if "name" in md: for name in md["name"].split(","): looking.append(name) # print looking, allowed for pname in looking: if pname not in allowed: raise Forbidden()
def home(request): userid = authenticated_userid(request) profile_names = db.UserProfiles(userid).get() # show only a few of the most recently uploaded profiles. profiles = table_profiles(profile_names[:5], userid) info = { 'profile_count': len(profile_names), 'profiles': profiles, 'user': userid, } pname = 'nb18' if pname in profile_names: info['plot'] = plotJS([pname], ['17'], 'standard') else: info["plot"] = None return info
r.put(probes) r = db.Profile(info["name"]) info.update(probeInfo) info["uploader"] = userid info["uploaded_on"] = datetime.now() info["ready"] = False r.put(info) # save gz profile to disk. f.seek(0) out_name = db.secret_file("%(name)s.bedGraph.gz" % info) saved = gzip.open(out_name, "w") for data in f: saved.write(data) saved.close() # add profile to user lists. uprofs = [db.UserProfiles(u) for u in db_users] to_update = [r for r in uprofs if r.compatible(info)] for r in to_update: r.add(info["name"]) # add profile to processing queue. db.ProfileQueue.db.append(info["name"]) # need to return error none to avoid template nameError. info["error"] = None return info HEADER_TEMPLATES = { "bed": 'track visibility=%(visibility)s name=%(name)s%(table)s description="%(description)s %(table)s" itemRgb=on', "bedGraph": 'track type=bedGraph visibility=%(visibility)s alwaysZero=on graphType=points yLineMark=0 yLineOnOff=on name=%(name)s%(table)s description="%(description)s %(table)s"',