website.py 文件源码

python
阅读 20 收藏 0 点赞 0 评论 0

项目:MetaSRA-pipeline 作者: deweylab 项目源码 文件源码
def get_searched_term_ids(usr_in):
    term_names_db = web.database(dbn='sqlite', db='static/term_names.sqlite')
    usr_in = usr_in.strip()
    results =  term_names_db.query(
        "SELECT term_id FROM term_names WHERE term_name=$term_name", 
        vars={'term_name':usr_in}
    )
    term_ids = Set([r["term_id"].encode('utf-8') for r in results])
    print "Found term IDs for query '%s': %s" % (usr_in, term_ids)

    # If no terms were found check if the input was an ontology term ID
    if len(term_ids) == 0 and len(usr_in.split(":")) == 2:
        pref = usr_in.split(":")[0]
        suff = usr_in.split(":")[1]
        valid_pref = pref in Set(["DOID", "UBERON", "CVCL", "CL", "EFO"])
        valid_suff = suff.isdigit()
        if valid_pref and valid_suff:
            print "User input '%s' can be interpreted as a term ID" % usr_in
            term_ids = Set([usr_in])

    return term_ids
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号