Mercurial > repos > galaxyp > calisp
annotate feather2tsv.py @ 0:d158a7909193 draft default tip
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
| author | galaxyp | 
|---|---|
| date | Thu, 01 Jun 2023 08:33:58 +0000 | 
| parents | |
| children | 
| rev | line source | 
|---|---|
| 0 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 1 #!/usr/bin/env python | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 2 """ | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 3 based on https://github.com/kinestetika/Calisp/blob/master/benchmarking/sip%20benchmarking.ipynb | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 4 """ | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 5 | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 6 import argparse | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 7 import os | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 8 | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 9 import pandas as pd | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 10 | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 11 | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 12 def load_calisp_data(filename): | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 13 | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 14 # (1) load data | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 15 if os.path.isdir(filename): | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 16 file_data = [] | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 17 for f in os.listdir(filename): | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 18 if not f.endswith(".feather"): | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 19 continue | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 20 f = os.path.join(filename, f) | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 21 file_data.append(pd.read_feather(f)) | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 22 base, _ = os.path.splitext(f) | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 23 file_data[-1].to_csv(f"{base}.tsv", sep="\t") | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 24 data = pd.concat(file_data) | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 25 else: | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 26 data = pd.read_feather(filename) | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 27 base, _ = os.path.splitext(filename) | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 28 data.to_csv(f"{base}.tsv", sep="\t") | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 29 | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 30 | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 31 parser = argparse.ArgumentParser(description='feather2tsv') | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 32 parser.add_argument('--calisp_output', required=True, help='feather file') | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 33 args = parser.parse_args() | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 34 | 
| 
d158a7909193
planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
 galaxyp parents: diff
changeset | 35 data = load_calisp_data(args.calisp_output) | 
