Ejemplo n.º 1
0
def usecases_search_init():

    res_obj = {}
    try:
        res_obj = apilib.usecases_search_init(db_obj)
    except Exception, e:
        res_obj = apilib.get_error_obj("usecases_search_init",
                                       traceback.format_exc(), path_obj)
Ejemplo n.º 2
0
def glycan_to_enzyme_gene_loci(tax_id, glytoucan_ac):

    res_obj = {}
    try:
        if glytoucan_ac in ["", "empty"] or tax_id in ["", "empty"]:
            res_obj = {"error_code": "missing-parameter"}
        else:
            query_obj = {"glytoucan_ac": glytoucan_ac, "tax_id": int(tax_id)}
            trim_object(query_obj)
            res_obj = apilib.glycan_to_enzyme_gene_loci(query_obj, db_obj)
    except Exception, e:
        res_obj = apilib.get_error_obj("glycan_to_enzyme_gene_loci",
                                       traceback.format_exc(), path_obj)
Ejemplo n.º 3
0
def species_to_glycoproteins(tax_id, evidence_type):

    res_obj = {}
    try:
        if evidence_type in ["", "empty"] or tax_id in ["", "empty"]:
            res_obj = {"error_code": "missing-parameter"}
        else:
            query_obj = {"evidence_type": evidence_type, "tax_id": int(tax_id)}
            trim_object(query_obj)
            res_obj = apilib.species_to_glycoproteins(query_obj, db_obj)
    except Exception, e:
        res_obj = apilib.get_error_obj("species_to_glycoproteins",
                                       traceback.format_exc(), path_obj)
Ejemplo n.º 4
0
def species_to_glycohydrolases(tax_id):

    res_obj = {}
    try:
        if tax_id in ["", "empty"]:
            res_obj = {"error_code": "missing-parameter"}
        else:
            query_obj = {"tax_id": int(tax_id)}
            trim_object(query_obj)
            res_obj = apilib.species_to_glycohydrolases(query_obj, db_obj)
    except Exception, e:
        res_obj = apilib.get_error_obj("species_to_glycohydrolases",
                                       traceback.format_exc(), path_obj)
Ejemplo n.º 5
0
def protein_to_orthologs(uniprot_canonical_ac):

    res_obj = {}
    try:
        if uniprot_canonical_ac in ["", "empty"]:
            res_obj = {"error_code": "missing-parameter"}
        else:
            query_obj = {"uniprot_canonical_ac": uniprot_canonical_ac}
            trim_object(query_obj)
            res_obj = apilib.protein_to_orthologs(query_obj, db_obj)
    except Exception, e:
        res_obj = apilib.get_error_obj("protein_to_orthologs",
                                       traceback.format_exc(), path_obj)
Ejemplo n.º 6
0
def biosynthesis_enzyme_to_glycans(tax_id, uniprot_canonical_ac):

    res_obj = {}
    try:
        if uniprot_canonical_ac in ["", "empty"] or tax_id in ["", "empty"]:
            res_obj = {"error_code": "missing-parameter"}
        else:
            query_obj = {
                "uniprot_canonical_ac": uniprot_canonical_ac,
                "tax_id": int(tax_id)
            }
            trim_object(query_obj)
            res_obj = apilib.biosynthesis_enzyme_to_glycans(query_obj, db_obj)
    except Exception, e:
        res_obj = apilib.get_error_obj("biosynthesis_enzyme_to_glycans",
                                       traceback.format_exc(), path_obj)
Ejemplo n.º 7
0
def ortholog_list():

    res_obj = {}
    try:
        query_value = get_arg_value("query", request.method)
        if query_value == "":
            res_obj = {"error_code": "missing-query-key-in-query-json"}
        elif apilib.is_valid_json(query_value) == False:
            res_obj = {"error_code": "invalid-query-json"}
        else:
            query_obj = json.loads(query_value)
            trim_object(query_obj)
            res_obj = apilib.ortholog_list(query_obj, db_obj)
    except Exception, e:
        res_obj = apilib.get_error_obj("ortholog_list", traceback.format_exc(),
                                       path_obj)
def main():

    usage = "\n%prog  [options]"
    parser = OptionParser(usage, version="%prog version___")
    parser.add_option("-s",
                      "--svctype",
                      action="store",
                      dest="svctype",
                      help="SVC name")
    parser.add_option("-q",
                      "--queryfile",
                      action="store",
                      dest="queryfile",
                      help="Query JSON file")
    (options, args) = parser.parse_args()
    for key in ([options.queryfile, options.svctype]):
        if not (key):
            parser.print_help()
            sys.exit(0)

    global config_obj
    global path_obj
    config_obj = json.loads(open("./conf/config.json", "r").read())
    path_obj = config_obj[config_obj["server"]]["pathinfo"]
    db_obj = config_obj[config_obj["server"]]["dbinfo"]

    res_obj = {}
    query_obj = json.loads(open(options.queryfile, "r").read())
    svc_type = options.svctype

    try:

        if svc_type == "search_init":
            res_obj = apilib.protein_search_init(db_obj)
            print json.dumps(res_obj, indent=4)
        elif svc_type == "glycan_to_biosynthesis_enzymes":
            res_obj = apilib.glycan_to_biosynthesis_enzymes(query_obj, db_obj)
            print json.dumps(res_obj, indent=4)
        elif svc_type == "glycan_to_glycoproteins":
            res_obj = apilib.glycan_to_glycoproteins(query_obj, db_obj)
            print json.dumps(res_obj, indent=4)
        elif svc_type == "species_to_glycosyltransferases":
            res_obj = apilib.species_to_glycosyltransferases(query_obj, db_obj)
            print json.dumps(res_obj, indent=4)
        elif svc_type == "species_to_glycohydrolases":
            res_obj = apilib.species_to_glycohydrolases(query_obj, db_obj)
            print json.dumps(res_obj, indent=4)
        elif svc_type == "species_to_glycoproteins":
            res_obj = apilib.species_to_glycoproteins(query_obj, db_obj)
            print json.dumps(res_obj, indent=4)
        elif svc_type == "disease_to_glycosyltransferases":
            res_obj = apilib.disease_to_glycosyltransferases(query_obj, db_obj)
            print json.dumps(res_obj, indent=4)
        elif svc_type == "protein_to_orthologs":
            res_obj = apilib.protein_to_orthologs(query_obj, db_obj)
            print json.dumps(res_obj, indent=4)
        elif svc_type == "glycan_to_enzyme_gene_loci":
            res_obj = apilib.glycan_to_enzyme_gene_loci(query_obj, db_obj)
            print json.dumps(res_obj, indent=4)

    except Exception, e:
        res_obj = apilib.get_error_obj("proteinsearch", traceback.format_exc(),
                                       path_obj)
        print traceback.format_exc()