Ejemplo n.º 1
0
def search_init():
  
    res_obj = {}
    try:
        res_obj = apilib.search_init(config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("idmapping_search_init", traceback.format_exc(), path_obj)
Ejemplo n.º 2
0
def search():
 

    form_dict = cgi.FieldStorage()
    record_type = form_dict["recordtype"].value
    input_namespace = form_dict["input_namespace"].value
    output_namespace = form_dict["output_namespace"].value
    input_idlist = []
    if "userfile" in form_dict:
        file_buffer = form_dict["userfile"].file.read()
        file_buffer = file_buffer.replace("\r", "\n")
        file_buffer = file_buffer.replace("\n\n", "\n")
        line_list = file_buffer.split("\n")
        for line in line_list:
            if line.strip() != "" and line.strip() not in input_idlist:
                input_idlist.append(line.strip())

    if "input_idlist" in form_dict:
        if form_dict["input_idlist"].value.strip() != "":
            for word in form_dict["input_idlist"].value.split(","):
                if word.strip() not in input_idlist:
                    input_idlist.append(word.strip())

    query_obj = {"input_idlist":input_idlist, "recordtype":record_type, 
        "input_namespace":input_namespace, "output_namespace":output_namespace}


    res_obj = {}
    try:
        res_obj = apilib.search(query_obj, config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("idmapping_search", traceback.format_exc(), path_obj)
Ejemplo n.º 3
0
def protein_search_init():
  
    res_obj = {}
    try:
        res_obj = apilib.protein_search_init(config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("protein_search_init", traceback.format_exc(), path_obj)
Ejemplo n.º 4
0
def typeahead():

    res_obj = []
    try:
        query_value = util.get_arg_value("query", request.method)
        if query_value == "":
            res_obj = {"error_list":[{"error_code": "missing-query-key-in-query-json"}]}
        elif util.is_valid_json(query_value) == False:
            res_obj = {"error_list":[{"error_code": "invalid-query-json"}]}
        else:
            query_obj = json.loads(query_value)
            util.trim_object(query_obj)
            field_list_one = ["glytoucan_ac", "motif_name", "enzyme_uniprot_canonical_ac", 
                    "glycan_pmid", "enzyme"]
            field_list_two = ["uniprot_canonical_ac", "uniprot_id", "refseq_ac", 
                                "protein_name", "gene_name", "pathway_id", "pathway_name", 
                                "disease_name","disease_id", 
                                "go_id", "go_term", "protein_pmid"] 
            tmp_obj_one, tmp_obj_two = [], []
            if query_obj["field"] in field_list_one:
                tmp_obj_one = apilib.glycan_typeahead(query_obj, config_obj)
            if query_obj["field"] in field_list_two:
                tmp_obj_two = apilib.protein_typeahead(query_obj, config_obj)
            if "error_list" in tmp_obj_one:
                res_obj = tmp_obj_one
            elif "error_list" in tmp_obj_two: 
                res_obj = tmp_obj_two
            else:
                res_obj = tmp_obj_one + tmp_obj_two
    except Exception, e:
        res_obj = errorlib.get_error_obj("typeahead", traceback.format_exc(), path_obj)
Ejemplo n.º 5
0
def misc_messagelist():

    res_obj = {}
    try:
        res_obj = apilib.messagelist(config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("misc_messagelist", traceback.format_exc(), path_obj)
Ejemplo n.º 6
0
def home_init():

    res_obj = {}
    try:
        res_obj = apilib.home_init(config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("home_init", traceback.format_exc(),
                                         path_obj)
Ejemplo n.º 7
0
def protein_detail(uniprot_canonical_ac):

    res_obj = {}
    try:
        if uniprot_canonical_ac in ["", "empty"]:
            res_obj = {"error_list":[{"error_code":"missing-parameter", "field":"uniprot_canonical_ac"}]}
        else:
            query_obj = {"uniprot_canonical_ac":uniprot_canonical_ac}
            util.trim_object(query_obj)
            res_obj = apilib.protein_detail(query_obj, config_obj)    
    except Exception, e:
        res_obj = errorlib.get_error_obj("protein_detail", traceback.format_exc(), path_obj)
Ejemplo n.º 8
0
def idmapping_list():
   
    res_obj = {}
    try:
        query_value = util.get_arg_value("query", request.method)
        if query_value == "": 
            res_obj = {"error_list":[{"error_code": "missing-query-key-in-query-json"}]}
        elif util.is_valid_json(query_value) == False:
            res_obj = {"error_list":[{"error_code": "invalid-query-json"}]}
        else:
            query_obj = json.loads(query_value)
            util.trim_object(query_obj)
            res_obj = util.get_cached_records_direct(query_obj, config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("idmapping_list", traceback.format_exc(), path_obj)
Ejemplo n.º 9
0
def glycan_to_biosynthesis_enzymes():
    
    res_obj = {}
    try:
        query_value = util.get_arg_value("query", request.method)
        if query_value == "":
            res_obj = {"error_list":[{"error_code": "missing-query-key-in-query-json"}]}
        elif util.is_valid_json(query_value) == False:
            res_obj = {"error_list":[{"error_code": "invalid-query-json"}]}
        else:
            query_obj = json.loads(query_value)
            util.trim_object(query_obj)
            res_obj = apilib.glycan_to_biosynthesis_enzymes(query_obj, config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("glycan_to_biosynthesis_enzymes_direct", traceback.format_exc(), path_obj)
Ejemplo n.º 10
0
def protein_search():

    res_obj = {}
    try:
        query_value = util.get_arg_value("query", request.method)
        if query_value == "":
            res_obj = {"error_list":[{"error_code": "missing-query-key-in-query-json"}]}
        elif util.is_valid_json(query_value) == False:
            res_obj = {"error_list":[{"error_code": "invalid-query-json"}]}
        else:
            query_obj = json.loads(query_value)
            util.trim_object(query_obj)
            res_obj = apilib.protein_search(query_obj, config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("protein_search", traceback.format_exc(), path_obj)
Ejemplo n.º 11
0
def site_detail(site_id):

    res_obj = {}
    try:
        if site_id in ["", "empty"]:
            res_obj = {
                "error_list": [{
                    "error_code": "missing-parameter",
                    "field": "site_id"
                }]
            }
        else:
            query_obj = {"site_id": site_id}
            util.trim_object(query_obj)
            res_obj = apilib.site_detail(query_obj, config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("site_detail", traceback.format_exc(),
                                         path_obj)
Ejemplo n.º 12
0
def glycan_image(glytoucan_ac):

    res_obj = {}
    try:
        if glytoucan_ac in ["", "empty"]:
            res_obj = {
                "error_list": [{
                    "error_code": "missing-parameter",
                    "field": "glytoucan_ac"
                }]
            }
        else:
            query_obj = {"glytoucan_ac": glytoucan_ac}
            img_file = apilib.glycan_image(query_obj, config_obj)
            return send_file(img_file, mimetype='image/png')
    except Exception, e:
        res_obj = errorlib.get_error_obj("glycan_image",
                                         traceback.format_exc(), path_obj)
Ejemplo n.º 13
0
def glycan_detail(glytoucan_ac):

    res_obj = {}
    try:
        if glytoucan_ac in ["", "empty"]:
            res_obj = {
                "error_list": [{
                    "error_code": "missing-parameter",
                    "field": "glytoucan_ac"
                }]
            }
        else:
            query_obj = {"glytoucan_ac": glytoucan_ac}
            util.trim_object(query_obj)
            res_obj = apilib.glycan_detail(query_obj, config_obj)
    except Exception, e:
        res_obj = errorlib.get_error_obj("glycan_detail",
                                         traceback.format_exc(), path_obj)
Ejemplo n.º 14
0
def categorized_typeahead():

    res_obj = []
    try:
        query_value = util.get_arg_value("query", request.method)
        if query_value == "":
            res_obj = {"error_list":[{"error_code": "missing-query-key-in-query-json"}]}
        elif util.is_valid_json(query_value) == False:
            res_obj = {"error_list":[{"error_code": "invalid-query-json"}]}
        else:
            query_obj = json.loads(query_value)
            util.trim_object(query_obj)
            tmp_obj = apilib.categorized_typeahead(query_obj, config_obj)
            if "error_list" in tmp_obj:
                res_obj = tmp_obj
            else:
                res_obj = tmp_obj
    except Exception, e:
        res_obj = errorlib.get_error_obj("categorized_typeahead", traceback.format_exc(), path_obj)