annotate feather2tsv.py @ 0:6d93529d19d4 draft

planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
author galaxyp
date Thu, 01 Jun 2023 08:34:14 +0000
parents
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
0
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
1 #!/usr/bin/env python
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
2 """
6d93529d19d4 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
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
4 """
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
5
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
6 import argparse
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
7 import os
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
8
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
9 import pandas as pd
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
10
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
11
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
12 def load_calisp_data(filename):
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
13
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
14 # (1) load data
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
15 if os.path.isdir(filename):
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
16 file_data = []
6d93529d19d4 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):
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
18 if not f.endswith(".feather"):
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
19 continue
6d93529d19d4 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)
6d93529d19d4 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))
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
22 base, _ = os.path.splitext(f)
6d93529d19d4 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")
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
24 data = pd.concat(file_data)
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
25 else:
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
26 data = pd.read_feather(filename)
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
27 base, _ = os.path.splitext(filename)
6d93529d19d4 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")
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
29
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
30
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
31 parser = argparse.ArgumentParser(description='feather2tsv')
6d93529d19d4 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')
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
33 args = parser.parse_args()
6d93529d19d4 planemo upload for repository https://github.com/galaxyproteomics/tools-galaxyp/tools/calisp commit 060699366b6dd19ad6c3ef3f332f63cc55d75dce
galaxyp
parents:
diff changeset
34
6d93529d19d4 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)