Esempio n. 1
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)
Esempio n. 2
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)
Esempio n. 3
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)
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)
Esempio n. 5
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)
Esempio n. 6
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)
Esempio n. 7
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)
Esempio n. 8
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)