def get_gnps(smiles, inchi, inchikey):
    inchikey_from_smiles, inchikey_from_inchi = utils.get_inchikey(
        smiles, inchi)

    acceptable_key = set([inchikey, inchikey_from_smiles, inchikey_from_inchi])

    found_spectrum_list = []

    for gnps_spectrum in gnps_list:
        if len(gnps_spectrum["InChIKey_smiles"]
               ) > 2 and gnps_spectrum["InChIKey_smiles"] in acceptable_key:
            found_spectrum_list.append(gnps_spectrum)
        elif len(gnps_spectrum["InChIKey_inchi"]
                 ) > 2 and gnps_spectrum["InChIKey_inchi"] in acceptable_key:
            found_spectrum_list.append(gnps_spectrum)

    return found_spectrum_list
def get_mibig(smiles, inchi, inchikey):
    inchikey_from_smiles, inchikey_from_inchi = utils.get_inchikey(
        smiles, inchi)
    acceptable_key = set([
        inchikey.split("-")[0],
        inchikey_from_smiles.split("-")[0],
        inchikey_from_inchi.split("-")[0]
    ])

    BGCID = None

    for mibig_entry in mibig_list:
        if len(mibig_entry["COMPOUND_INCHIKEY"]) > 5 and mibig_entry[
                "COMPOUND_INCHIKEY"].split("-")[0] in acceptable_key:
            BGCID = mibig_entry["BGCID"]
            break

    return BGCID
def structureproxy():
    inchi = request.args.get('inchi', '')
    inchikey = request.args.get('inchikey', '')
    smiles = request.args.get('smiles', '')

    inchikey_from_smiles, inchikey_from_inchi = utils.get_inchikey(
        smiles, inchi)

    inchikey_query = ""
    MIN_LENGTH = 5

    if len(inchikey) > MIN_LENGTH:
        inchikey_query = inchikey
    elif len(inchikey_from_smiles) > MIN_LENGTH:
        inchikey_query = inchikey_from_smiles
    elif len(inchikey_from_inchi) > MIN_LENGTH:
        inchikey_query = inchikey_from_inchi

    # print(inchikey_query)

    # kegg_info = requests.get("http://cts.fiehnlab.ucdavis.edu/rest/convert/InChIKey/KEGG/%s" % (inchikey_query)).json()
    # CHEBI_info = requests.get("http://cts.fiehnlab.ucdavis.edu/rest/convert/InChIKey/CHEBI/%s" % (inchikey_query)).json()
    # BioCyc_info = requests.get("http://cts.fiehnlab.ucdavis.edu/rest/convert/InChIKey/BioCyc/%s" % (inchikey_query)).json()
    # pubchem_info = requests.get("http://cts.fiehnlab.ucdavis.edu/rest/convert/InChIKey/Pubchem CID/%s" % (inchikey_query)).json()
    # ChemSpider_info = requests.get("http://cts.fiehnlab.ucdavis.edu/rest/convert/InChIKey/ChemSpider/%s" % (inchikey_query)).json()
    # LipidMaps_info = requests.get("http://cts.fiehnlab.ucdavis.edu/rest/convert/InChIKey/LipidMaps/%s" % (inchikey_query)).json()
    # DrugBank_info = requests.get("http://cts.fiehnlab.ucdavis.edu/rest/convert/InChIKey/DrugBank/%s" % (inchikey_query)).json()

    # print(pubchem_info)

    # external_links = []
    # external_links += prep_external(kegg_info[0]["results"], "KEGG", "https://www.genome.jp/dbget-bin/www_bget?%s")
    # external_links += prep_external(CHEBI_info[0]["results"], "CHEBI", "https://www.ebi.ac.uk/chebi/searchId.do?chebiId=%s")
    # external_links += prep_external(BioCyc_info[0]["results"], "BioCyc", "https://biocyc.org/compound?orgid=META&id=%s")
    # external_links += prep_external(pubchem_info[0]["results"], "Pubchem", "https://pubchem.ncbi.nlm.nih.gov/compound/%s")
    # external_links += prep_external(ChemSpider_info[0]["results"], "Chem Spider", "http://www.chemspider.com/Chemical-Structure.%s.html")
    # external_links += prep_external(LipidMaps_info[0]["results"], "Lipid Maps", "http://lipidmaps.org/data/LMSDRecord.php?LMID=%s")
    # external_links += prep_external(DrugBank_info[0]["results"], "Drugbank", "https://www.drugbank.ca/drugs/%s")

    # TODO: Fix this to use not the feihn api
    external_links = []

    return render_template('externallist.html',
                           external_links_json=external_links)
def get_npatlas(smiles, inchi, inchikey):
    inchikey_from_smiles, inchikey_from_inchi = utils.get_inchikey(
        smiles, inchi)
    print(inchikey_from_smiles, inchikey_from_inchi)
    acceptable_key = set([
        inchikey.split("-")[0],
        inchikey_from_smiles.split("-")[0],
        inchikey_from_inchi.split("-")[0]
    ])

    NPAID = None

    for npatlas_entry in npatlas_list:
        if len(npatlas_entry["COMPOUND_INCHIKEY"]) > 5 and npatlas_entry[
                "COMPOUND_INCHIKEY"].split("-")[0] in acceptable_key:
            NPAID = npatlas_entry["NPAID"]
            break

    return NPAID
Esempio n. 5
0
def get_gnps_by_structure_task(smiles, inchi, inchikey):
    inchikey_from_smiles, inchikey_from_inchi = utils.get_inchikey(smiles, inchi)

    if "gnps_list" in memory_cache:
        gnps_list = memory_cache["gnps_list"]
    else:
        gnps_df = pd.read_feather("gnps_list.feather")
        gnps_df["InChIKey_smiles"] = gnps_df["InChIKey_smiles"].astype(str)
        gnps_df["InChIKey_inchi"] = gnps_df["InChIKey_inchi"].astype(str)

        gnps_list = gnps_df.to_dict(orient="records")
        memory_cache["gnps_list"] = gnps_list

    acceptable_key = set([inchikey, inchikey_from_smiles, inchikey_from_inchi])

    found_spectrum_list = []

    for gnps_spectrum in gnps_list:
        if len(gnps_spectrum["InChIKey_smiles"]) > 2 and gnps_spectrum["InChIKey_smiles"] in acceptable_key:
            found_spectrum_list.append(gnps_spectrum)
        elif len(gnps_spectrum["InChIKey_inchi"]) > 2 and gnps_spectrum["InChIKey_inchi"] in acceptable_key:
            found_spectrum_list.append(gnps_spectrum)
    
    return found_spectrum_list