Mercurial > repos > ggricourt > data_manager_bigg
changeset 14:8e8a9e51f1d7 draft
"planemo upload for repository https://github.com/brsynth/synbiocad-galaxy-wrappers commit 7db54c0555a12ecb8b3f756032228c54fe028e0a-dirty"
author | ggricourt |
---|---|
date | Wed, 09 Mar 2022 15:18:07 +0000 |
parents | c1d4f14dc768 |
children | 44119168868c |
files | data_manager/.tmp.py.swp data_manager/metanetx_chem_prop_fetcher.py data_manager/metanetx_chem_prop_fetcher.xml |
diffstat | 3 files changed, 22 insertions(+), 7 deletions(-) [+] |
line wrap: on
line diff
--- a/data_manager/metanetx_chem_prop_fetcher.py Wed Mar 09 14:22:54 2022 +0000 +++ b/data_manager/metanetx_chem_prop_fetcher.py Wed Mar 09 15:18:07 2022 +0000 @@ -4,7 +4,7 @@ import shutil import sys import tempfile -import pandas as pd +# import pandas as pd try: # For Python 3.0 and later from urllib.request import Request, urlopen @@ -46,12 +46,28 @@ shutil.copyfile(ftmp.name, path) +# def records_chem_prop_pandas(path): +# df = pd.read_csv(path, sep="\t") +# df["name"] = df.apply(lambda x: "%s: %s (%s)" % (x["ID"], x["name"], x["formula"]), axis=1) +# df.drop(columns=["reference", "formula", "charge", "mass", "InChIKey", "SMILES"], inplace=True) +# df.rename(columns={"ID": "value", "InChI": "inchi"}) +# return df.to_dict('records') + + def records_chem_prop(path): - df = pd.read_csv(path, sep="\t") - df["name"] = df.apply(lambda x: "%s: %s (%s)" % (x["ID"], x["name"], x["formula"]), axis=1) - df.drop(columns=["reference", "formula", "charge", "mass", "InChIKey", "SMILES"], inplace=True) - df.rename(columns={"ID": "value", "InChI": "inchi"}) - return df.to_dict('records') + records = [] + with open(path) as fid: + for ix, line in enumerate(fid): + if ix == 0: + continue + line = line.split("\t") + if line[7] != '': + records.append({ + "value": line[0], + "name": "%s: %s (%s)" % (line[0], line[1], line[3]), + "inchi": line[7], + }) + return records if __name__ == "__main__":
--- a/data_manager/metanetx_chem_prop_fetcher.xml Wed Mar 09 14:22:54 2022 +0000 +++ b/data_manager/metanetx_chem_prop_fetcher.xml Wed Mar 09 15:18:07 2022 +0000 @@ -2,7 +2,6 @@ <description>Get InChI value of compound in chem_prop.tsv file available from Metanetx</description> <requirements> <requirement type="package" version="3.8">python</requirement> - <requirement type="package" version="1.4">pandas</requirement> </requirements> <command detect_errors="exit_code"><![CDATA[ python '$__tool_directory__/metanetx_chem_prop_fetcher.py'