met-annot-unifier 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- met_annot_unifier-0.0.1/LICENSE +21 -0
- met_annot_unifier-0.0.1/PKG-INFO +117 -0
- met_annot_unifier-0.0.1/README.md +96 -0
- met_annot_unifier-0.0.1/met_annot_unifier/__init__.py +0 -0
- met_annot_unifier-0.0.1/met_annot_unifier/aligner/__init__.py +0 -0
- met_annot_unifier-0.0.1/met_annot_unifier/aligner/aligner.py +179 -0
- met_annot_unifier-0.0.1/met_annot_unifier/aligner/parser.py +215 -0
- met_annot_unifier-0.0.1/met_annot_unifier/aligner/utils.py +27 -0
- met_annot_unifier-0.0.1/met_annot_unifier/cli.py +68 -0
- met_annot_unifier-0.0.1/met_annot_unifier/foo.py +17 -0
- met_annot_unifier-0.0.1/pyproject.toml +118 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2024, Pierre-Marei Allard
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,117 @@
|
|
|
1
|
+
Metadata-Version: 2.1
|
|
2
|
+
Name: met-annot-unifier
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: A Python project to combine tabular outputs from GNPS, Sirius and ISDB
|
|
5
|
+
Home-page: https://github.com/mapp-metabolomics-unit/met-annot-unifier
|
|
6
|
+
Author: Pierre-Marie Allard
|
|
7
|
+
Author-email: pierre-marie.allard@unifr.ch
|
|
8
|
+
Requires-Python: >=3.9,<4.0
|
|
9
|
+
Classifier: Programming Language :: Python :: 3
|
|
10
|
+
Classifier: Programming Language :: Python :: 3.9
|
|
11
|
+
Classifier: Programming Language :: Python :: 3.10
|
|
12
|
+
Classifier: Programming Language :: Python :: 3.11
|
|
13
|
+
Classifier: Programming Language :: Python :: 3.12
|
|
14
|
+
Requires-Dist: click (>=8.1.7,<9.0.0)
|
|
15
|
+
Requires-Dist: pandas (>=2.2.0,<3.0.0)
|
|
16
|
+
Requires-Dist: pyarrow (>=15.0.0,<16.0.0)
|
|
17
|
+
Project-URL: Documentation, https://mapp-metabolomics-unit.github.io/met-annot-unifier/
|
|
18
|
+
Project-URL: Repository, https://github.com/mapp-metabolomics-unit/met-annot-unifier
|
|
19
|
+
Description-Content-Type: text/markdown
|
|
20
|
+
|
|
21
|
+
# met-annot-unifier
|
|
22
|
+
|
|
23
|
+
[](https://img.shields.io/github/v/release/mapp-metabolomics-unit/met-annot-unifier)
|
|
24
|
+
[](https://github.com/mapp-metabolomics-unit/met-annot-unifier/actions/workflows/main.yml?query=branch%3Amain)
|
|
25
|
+
[](https://codecov.io/gh/mapp-metabolomics-unit/met-annot-unifier)
|
|
26
|
+
[](https://img.shields.io/github/commit-activity/m/mapp-metabolomics-unit/met-annot-unifier)
|
|
27
|
+
[](https://img.shields.io/github/license/mapp-metabolomics-unit/met-annot-unifier)
|
|
28
|
+
|
|
29
|
+
A Python project to combine tabular outputs from GNPS, Sirius and ISDB
|
|
30
|
+
|
|
31
|
+
- **Github repository**: <https://github.com/mapp-metabolomics-unit/met-annot-unifier/>
|
|
32
|
+
- **Documentation** <https://mapp-metabolomics-unit.github.io/met-annot-unifier/>
|
|
33
|
+
|
|
34
|
+
## Quickstart
|
|
35
|
+
|
|
36
|
+
### Installation
|
|
37
|
+
|
|
38
|
+
met-annot-unifier is available on PyPi and can be installed with pip:
|
|
39
|
+
|
|
40
|
+
```bash
|
|
41
|
+
pip install met-annot-unifier
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
### Usage
|
|
45
|
+
|
|
46
|
+
For now the package is only available as a command line tool. You can run it with the following command:
|
|
47
|
+
|
|
48
|
+
```bash
|
|
49
|
+
python -m met_annot_unifier.cli
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
Get help on the available modes with:
|
|
53
|
+
|
|
54
|
+
```bash
|
|
55
|
+
python -m met_annot_unifier.cli --help
|
|
56
|
+
```
|
|
57
|
+
|
|
58
|
+
#### Examples
|
|
59
|
+
|
|
60
|
+
You can align the annotations tables from GNPS, Sirius and ISDB using two modes:
|
|
61
|
+
|
|
62
|
+
- `align-horizontally`: This will return a long table with a single row for each unique compound (according to their planar structures or IK2D). This mode can be useful to output a table to be viewed in [Datawarrior](https://openmolecules.org/datawarrior/) or similar tools for chemical structures exploration.
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
python -m met_annot_unifier.cli align-horizontally --gnps-file <path-to-gnps-table> --sirius-file <path-to-sirius-table> --isdb-file <path-to-isdb-table> --output <output-path>
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
- `align-vertically`: This will return a wide table with a single row per feature (m/z and retention time) and columns for each of the three sources. This mode can be useful to output a table to be added to a molecular network to be visualized in [Cytoscape](https://cytoscape.org/) or similar tools for network visualization.
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
python -m met_annot_unifier.cli align-vertically --gnps-file <path-to-gnps-table> --sirius-file <path-to-sirius-table> --isdb-file <path-to-isdb-table> --output <output-path>
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
You can find example tables in the `examples/data` folder of this repository. So from the root of this repository you can run the following command to align the tables horizontally:
|
|
75
|
+
|
|
76
|
+
```bash
|
|
77
|
+
python -m met_annot_unifier.cli align-horizontally --gnps-file examples/data/gnps_output_example.tsv --sirius-file examples/data/sirius_output_example.tsv --isdb-file examples/data/isdb_output_example.tsv --output examples/data/aligned_table_horizontally.csv
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Getting started with your project
|
|
81
|
+
|
|
82
|
+
First, create a repository on GitHub with the same name as this project, and then run the following commands:
|
|
83
|
+
|
|
84
|
+
```bash
|
|
85
|
+
git init -b main
|
|
86
|
+
git add .
|
|
87
|
+
git commit -m "init commit"
|
|
88
|
+
git remote add origin git@github.com:mapp-metabolomics-unit/met-annot-unifier.git
|
|
89
|
+
git push -u origin main
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
Finally, install the environment and the pre-commit hooks with
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
make install
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
You are now ready to start development on your project!
|
|
99
|
+
The CI/CD pipeline will be triggered when you open a pull request, merge to main, or when you create a new release.
|
|
100
|
+
|
|
101
|
+
To finalize the set-up for publishing to PyPi or Artifactory, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/publishing/#set-up-for-pypi).
|
|
102
|
+
For activating the automatic documentation with MkDocs, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/mkdocs/#enabling-the-documentation-on-github).
|
|
103
|
+
To enable the code coverage reports, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/codecov/).
|
|
104
|
+
|
|
105
|
+
## Releasing a new version
|
|
106
|
+
|
|
107
|
+
- Create an API Token on [Pypi](https://pypi.org/).
|
|
108
|
+
- Add the API Token to your projects secrets with the name `PYPI_TOKEN` by visiting [this page](https://github.com/mapp-metabolomics-unit/met-annot-unifier/settings/secrets/actions/new).
|
|
109
|
+
- Create a [new release](https://github.com/mapp-metabolomics-unit/met-annot-unifier/releases/new) on Github.
|
|
110
|
+
- Create a new tag in the form `*.*.*`.
|
|
111
|
+
|
|
112
|
+
For more details, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/cicd/#how-to-trigger-a-release).
|
|
113
|
+
|
|
114
|
+
---
|
|
115
|
+
|
|
116
|
+
Repository initiated with [fpgmaas/cookiecutter-poetry](https://github.com/fpgmaas/cookiecutter-poetry).
|
|
117
|
+
|
|
@@ -0,0 +1,96 @@
|
|
|
1
|
+
# met-annot-unifier
|
|
2
|
+
|
|
3
|
+
[](https://img.shields.io/github/v/release/mapp-metabolomics-unit/met-annot-unifier)
|
|
4
|
+
[](https://github.com/mapp-metabolomics-unit/met-annot-unifier/actions/workflows/main.yml?query=branch%3Amain)
|
|
5
|
+
[](https://codecov.io/gh/mapp-metabolomics-unit/met-annot-unifier)
|
|
6
|
+
[](https://img.shields.io/github/commit-activity/m/mapp-metabolomics-unit/met-annot-unifier)
|
|
7
|
+
[](https://img.shields.io/github/license/mapp-metabolomics-unit/met-annot-unifier)
|
|
8
|
+
|
|
9
|
+
A Python project to combine tabular outputs from GNPS, Sirius and ISDB
|
|
10
|
+
|
|
11
|
+
- **Github repository**: <https://github.com/mapp-metabolomics-unit/met-annot-unifier/>
|
|
12
|
+
- **Documentation** <https://mapp-metabolomics-unit.github.io/met-annot-unifier/>
|
|
13
|
+
|
|
14
|
+
## Quickstart
|
|
15
|
+
|
|
16
|
+
### Installation
|
|
17
|
+
|
|
18
|
+
met-annot-unifier is available on PyPi and can be installed with pip:
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install met-annot-unifier
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
### Usage
|
|
25
|
+
|
|
26
|
+
For now the package is only available as a command line tool. You can run it with the following command:
|
|
27
|
+
|
|
28
|
+
```bash
|
|
29
|
+
python -m met_annot_unifier.cli
|
|
30
|
+
```
|
|
31
|
+
|
|
32
|
+
Get help on the available modes with:
|
|
33
|
+
|
|
34
|
+
```bash
|
|
35
|
+
python -m met_annot_unifier.cli --help
|
|
36
|
+
```
|
|
37
|
+
|
|
38
|
+
#### Examples
|
|
39
|
+
|
|
40
|
+
You can align the annotations tables from GNPS, Sirius and ISDB using two modes:
|
|
41
|
+
|
|
42
|
+
- `align-horizontally`: This will return a long table with a single row for each unique compound (according to their planar structures or IK2D). This mode can be useful to output a table to be viewed in [Datawarrior](https://openmolecules.org/datawarrior/) or similar tools for chemical structures exploration.
|
|
43
|
+
|
|
44
|
+
```bash
|
|
45
|
+
python -m met_annot_unifier.cli align-horizontally --gnps-file <path-to-gnps-table> --sirius-file <path-to-sirius-table> --isdb-file <path-to-isdb-table> --output <output-path>
|
|
46
|
+
```
|
|
47
|
+
|
|
48
|
+
- `align-vertically`: This will return a wide table with a single row per feature (m/z and retention time) and columns for each of the three sources. This mode can be useful to output a table to be added to a molecular network to be visualized in [Cytoscape](https://cytoscape.org/) or similar tools for network visualization.
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
python -m met_annot_unifier.cli align-vertically --gnps-file <path-to-gnps-table> --sirius-file <path-to-sirius-table> --isdb-file <path-to-isdb-table> --output <output-path>
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
You can find example tables in the `examples/data` folder of this repository. So from the root of this repository you can run the following command to align the tables horizontally:
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
python -m met_annot_unifier.cli align-horizontally --gnps-file examples/data/gnps_output_example.tsv --sirius-file examples/data/sirius_output_example.tsv --isdb-file examples/data/isdb_output_example.tsv --output examples/data/aligned_table_horizontally.csv
|
|
58
|
+
```
|
|
59
|
+
|
|
60
|
+
## Getting started with your project
|
|
61
|
+
|
|
62
|
+
First, create a repository on GitHub with the same name as this project, and then run the following commands:
|
|
63
|
+
|
|
64
|
+
```bash
|
|
65
|
+
git init -b main
|
|
66
|
+
git add .
|
|
67
|
+
git commit -m "init commit"
|
|
68
|
+
git remote add origin git@github.com:mapp-metabolomics-unit/met-annot-unifier.git
|
|
69
|
+
git push -u origin main
|
|
70
|
+
```
|
|
71
|
+
|
|
72
|
+
Finally, install the environment and the pre-commit hooks with
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
make install
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
You are now ready to start development on your project!
|
|
79
|
+
The CI/CD pipeline will be triggered when you open a pull request, merge to main, or when you create a new release.
|
|
80
|
+
|
|
81
|
+
To finalize the set-up for publishing to PyPi or Artifactory, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/publishing/#set-up-for-pypi).
|
|
82
|
+
For activating the automatic documentation with MkDocs, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/mkdocs/#enabling-the-documentation-on-github).
|
|
83
|
+
To enable the code coverage reports, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/codecov/).
|
|
84
|
+
|
|
85
|
+
## Releasing a new version
|
|
86
|
+
|
|
87
|
+
- Create an API Token on [Pypi](https://pypi.org/).
|
|
88
|
+
- Add the API Token to your projects secrets with the name `PYPI_TOKEN` by visiting [this page](https://github.com/mapp-metabolomics-unit/met-annot-unifier/settings/secrets/actions/new).
|
|
89
|
+
- Create a [new release](https://github.com/mapp-metabolomics-unit/met-annot-unifier/releases/new) on Github.
|
|
90
|
+
- Create a new tag in the form `*.*.*`.
|
|
91
|
+
|
|
92
|
+
For more details, see [here](https://fpgmaas.github.io/cookiecutter-poetry/features/cicd/#how-to-trigger-a-release).
|
|
93
|
+
|
|
94
|
+
---
|
|
95
|
+
|
|
96
|
+
Repository initiated with [fpgmaas/cookiecutter-poetry](https://github.com/fpgmaas/cookiecutter-poetry).
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,179 @@
|
|
|
1
|
+
from functools import reduce
|
|
2
|
+
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
from met_annot_unifier.aligner.parser import (
|
|
6
|
+
extract_feature_id,
|
|
7
|
+
prefix_columns,
|
|
8
|
+
process_gnps_data,
|
|
9
|
+
process_isdb_data,
|
|
10
|
+
process_sirius_data,
|
|
11
|
+
standardize_column_names,
|
|
12
|
+
)
|
|
13
|
+
from met_annot_unifier.aligner.utils import count_sources, determine_source
|
|
14
|
+
|
|
15
|
+
gnps_file = "/Users/pma/Dropbox/git_repos/mapp-metabolomics-unit/met-annot-unifier/tests/data/gnps_output_example.tsv"
|
|
16
|
+
sirius_file = (
|
|
17
|
+
"/Users/pma/Dropbox/git_repos/mapp-metabolomics-unit/met-annot-unifier/tests/data/sirius_output_example.tsv"
|
|
18
|
+
)
|
|
19
|
+
isdb_file = "/Users/pma/Dropbox/git_repos/mapp-metabolomics-unit/met-annot-unifier/tests/data/isdb_output_example.tsv"
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def align_data_vertically(gnps_file: str, sirius_file: str, isdb_file: str) -> pd.DataFrame:
|
|
23
|
+
"""
|
|
24
|
+
Aligns and merges data from GNPS, Sirius, and ISDB datasets. This is done vertically, in other words, we keep go from a wide to long format.
|
|
25
|
+
The function standardizes column names, prefixes them to indicate their source, merges the data based on 'feature_id'
|
|
26
|
+
and 'IK2D', and then creates consolidated 'Sources' and 'SMILES' columns.
|
|
27
|
+
|
|
28
|
+
Args:
|
|
29
|
+
gnps_file (str): File path for the GNPS data in TSV format.
|
|
30
|
+
sirius_file (str): File path for the Sirius data in TSV format.
|
|
31
|
+
isdb_file (str): File path for the ISDB data in TSV format.
|
|
32
|
+
|
|
33
|
+
Returns:
|
|
34
|
+
pandas.DataFrame: A DataFrame with aligned and merged data from GNPS, Sirius, and ISDB.
|
|
35
|
+
|
|
36
|
+
Example:
|
|
37
|
+
>>> gnps_file = 'path/to/gnps_data.tsv'
|
|
38
|
+
>>> sirius_file = 'path/to/sirius_data.tsv'
|
|
39
|
+
>>> isdb_file = 'path/to/isdb_data.tsv'
|
|
40
|
+
>>> aligned_data = align_data(gnps_file, sirius_file, isdb_file)
|
|
41
|
+
>>> print(aligned_data.columns)
|
|
42
|
+
Index(['feature_id', 'IK2D', 'Sources', 'SMILES', ...], dtype='object')
|
|
43
|
+
"""
|
|
44
|
+
|
|
45
|
+
# Read and process GNPS data
|
|
46
|
+
gnps_data = process_gnps_data(gnps_file)
|
|
47
|
+
|
|
48
|
+
# For debugging we pprint the dataframes
|
|
49
|
+
# pprint(gnps_data)
|
|
50
|
+
|
|
51
|
+
# Read and process Sirius data
|
|
52
|
+
sirius_data = process_sirius_data(sirius_file)
|
|
53
|
+
|
|
54
|
+
# For debugging we pprint the dataframes
|
|
55
|
+
# pprint(sirius_data)
|
|
56
|
+
|
|
57
|
+
# Read and process ISDB data
|
|
58
|
+
isdb_data = process_isdb_data(isdb_file)
|
|
59
|
+
|
|
60
|
+
# For debugging we pprint the dataframes
|
|
61
|
+
# pprint(isdb_data)
|
|
62
|
+
|
|
63
|
+
# Merge the dataframes on 'feature_id' and 'InChiKey' with an outer join
|
|
64
|
+
combined_data = pd.concat([gnps_data, sirius_data, isdb_data], axis=0, ignore_index=True)
|
|
65
|
+
# Group by 'feature_id' and 'IK2D' and combine the annotations
|
|
66
|
+
merged_data = combined_data.groupby(["feature_id", "IK2D"], as_index=False).agg(
|
|
67
|
+
lambda x: ", ".join(x.dropna().astype(str).unique())
|
|
68
|
+
)
|
|
69
|
+
|
|
70
|
+
# Create the 'Sources' column by concatenating sirius_Source, isdb_Source, and gnps_Source
|
|
71
|
+
merged_data["Sources"] = merged_data.apply(
|
|
72
|
+
lambda row: ", ".join(filter(None, [row.get("sirius_Source"), row.get("isdb_Source"), row.get("gnps_Source")])),
|
|
73
|
+
axis=1,
|
|
74
|
+
)
|
|
75
|
+
|
|
76
|
+
# Create a SMILES column by choosing form the sirius_SMILES, isdb_SMILES, and gnps_smiles columns with this order of preference (sirius, isdb, gnps)
|
|
77
|
+
|
|
78
|
+
merged_data["SMILES"] = merged_data.apply(
|
|
79
|
+
lambda row: row.get("sirius_SMILES")
|
|
80
|
+
if row.get("sirius_SMILES")
|
|
81
|
+
else row.get("isdb_SMILES")
|
|
82
|
+
if row.get("isdb_SMILES")
|
|
83
|
+
else row.get("gnps_SMILES"),
|
|
84
|
+
axis=1,
|
|
85
|
+
)
|
|
86
|
+
|
|
87
|
+
# Select columns
|
|
88
|
+
|
|
89
|
+
selected_columns = ["feature_id", "IK2D", "Sources", "SMILES"]
|
|
90
|
+
|
|
91
|
+
# Place the selected columns at the front of the dataframe
|
|
92
|
+
|
|
93
|
+
merged_data = merged_data[
|
|
94
|
+
selected_columns + [column for column in merged_data.columns if column not in selected_columns]
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
return merged_data
|
|
98
|
+
|
|
99
|
+
|
|
100
|
+
def align_data_horizontally(gnps_file: str, sirius_file: str, isdb_file: str) -> pd.DataFrame:
|
|
101
|
+
"""
|
|
102
|
+
Aligns and merges data from GNPS, Sirius, and ISDB datasets. This is done horizontally, in other words, we keep the data in a wide format.
|
|
103
|
+
The function standardizes column names, prefixes them to indicate their source, merges the data based on 'feature_id'.
|
|
104
|
+
|
|
105
|
+
Args:
|
|
106
|
+
gnps_file (str): File path for the GNPS data in TSV format.
|
|
107
|
+
sirius_file (str): File path for the Sirius data in TSV format.
|
|
108
|
+
isdb_file (str): File path for the ISDB data in TSV format.
|
|
109
|
+
|
|
110
|
+
Returns:
|
|
111
|
+
pandas.DataFrame: A DataFrame with aligned and merged data from GNPS, Sirius, and ISDB.
|
|
112
|
+
|
|
113
|
+
Example:
|
|
114
|
+
>>> gnps_file = 'path/to/gnps_data.tsv'
|
|
115
|
+
>>> sirius_file = 'path/to/sirius_data.tsv'
|
|
116
|
+
>>> isdb_file = 'path/to/isdb_data.tsv'
|
|
117
|
+
>>> aligned_data = align_data(gnps_file, sirius_file, isdb_file)
|
|
118
|
+
>>> print(aligned_data.columns)
|
|
119
|
+
Index(['feature_id', 'IK2D', 'gnps_Source', 'gnps_SMILES', 'sirius_Source', ...], dtype='object')
|
|
120
|
+
"""
|
|
121
|
+
|
|
122
|
+
# Read and process GNPS data
|
|
123
|
+
gnps_data = pd.read_csv(gnps_file, sep="\t")
|
|
124
|
+
gnps_data = standardize_column_names(gnps_data, "InChIKey-Planar", "IK2D")
|
|
125
|
+
gnps_data = standardize_column_names(gnps_data, "#Scan#", "feature_id")
|
|
126
|
+
gnps_data = standardize_column_names(gnps_data, "Smiles", "SMILES")
|
|
127
|
+
gnps_data = prefix_columns(gnps_data, "gnps_", exclude_columns=[])
|
|
128
|
+
gnps_data = standardize_column_names(gnps_data, "gnps_feature_id", "feature_id")
|
|
129
|
+
|
|
130
|
+
# For debugging we pprint the dataframes
|
|
131
|
+
# pprint(gnps_data)
|
|
132
|
+
|
|
133
|
+
# Read and process Sirius data
|
|
134
|
+
sirius_data = pd.read_csv(sirius_file, sep="\t")
|
|
135
|
+
sirius_data = standardize_column_names(sirius_data, "InChIkey2D", "IK2D")
|
|
136
|
+
sirius_data = standardize_column_names(sirius_data, "id", "feature_id")
|
|
137
|
+
sirius_data = standardize_column_names(sirius_data, "smiles", "SMILES")
|
|
138
|
+
sirius_data = prefix_columns(sirius_data, "sirius_", exclude_columns=[])
|
|
139
|
+
sirius_data = extract_feature_id(sirius_data, "sirius_feature_id")
|
|
140
|
+
sirius_data = standardize_column_names(sirius_data, "sirius_feature_id", "feature_id")
|
|
141
|
+
|
|
142
|
+
# For debugging we pprint the dataframes
|
|
143
|
+
# pprint(sirius_data)
|
|
144
|
+
|
|
145
|
+
# Read and process ISDB data
|
|
146
|
+
isdb_data = pd.read_csv(isdb_file, sep="\t")
|
|
147
|
+
isdb_data = standardize_column_names(isdb_data, "short_inchikey", "IK2D")
|
|
148
|
+
isdb_data = standardize_column_names(isdb_data, "feature_id", "feature_id")
|
|
149
|
+
isdb_data = standardize_column_names(isdb_data, "structure_smiles", "SMILES")
|
|
150
|
+
isdb_data = prefix_columns(isdb_data, "isdb_", exclude_columns=[])
|
|
151
|
+
isdb_data = standardize_column_names(isdb_data, "isdb_feature_id", "feature_id")
|
|
152
|
+
|
|
153
|
+
# For debugging we pprint the dataframes
|
|
154
|
+
# pprint(isdb_data)
|
|
155
|
+
|
|
156
|
+
# Merge multiple dataframes horizontally on 'feature_id
|
|
157
|
+
|
|
158
|
+
dataframes = [gnps_data, sirius_data, isdb_data]
|
|
159
|
+
|
|
160
|
+
merged_data = reduce(lambda left, right: pd.merge(left, right, on=["feature_id"], how="outer"), dataframes)
|
|
161
|
+
|
|
162
|
+
# Create the 'Sources' column. Fill it according the content of the tool_IK2D columns.
|
|
163
|
+
# E.g. if sirius_IK2D is not null and matches isdb_IK2D, then the source is 'SIRIUS, ISDB'
|
|
164
|
+
|
|
165
|
+
merged_data["source"] = merged_data.apply(determine_source, axis=1)
|
|
166
|
+
|
|
167
|
+
merged_data["source_number"] = merged_data["source"].apply(count_sources)
|
|
168
|
+
|
|
169
|
+
# Select columns
|
|
170
|
+
|
|
171
|
+
selected_columns = ["feature_id", "source", "source_number"]
|
|
172
|
+
|
|
173
|
+
# Place the selected columns at the front of the dataframe
|
|
174
|
+
|
|
175
|
+
merged_data = merged_data[
|
|
176
|
+
selected_columns + [column for column in merged_data.columns if column not in selected_columns]
|
|
177
|
+
]
|
|
178
|
+
|
|
179
|
+
return merged_data
|
|
@@ -0,0 +1,215 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
import pandas as pd
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
def parse_gnps(file_path: str) -> pd.DataFrame:
|
|
7
|
+
# Read the GNPS output file
|
|
8
|
+
data = pd.read_csv(file_path, sep="\t")
|
|
9
|
+
# Extract necessary columns and any other processing
|
|
10
|
+
return data
|
|
11
|
+
|
|
12
|
+
|
|
13
|
+
def parse_sirius(file_path: str) -> pd.DataFrame:
|
|
14
|
+
# Read the Sirius output file
|
|
15
|
+
data = pd.read_csv(file_path, sep="\t")
|
|
16
|
+
# Extract necessary columns and any other processing
|
|
17
|
+
return data
|
|
18
|
+
|
|
19
|
+
|
|
20
|
+
def parse_isdb(file_path: str) -> pd.DataFrame:
|
|
21
|
+
# Read the ISDB output file
|
|
22
|
+
data = pd.read_csv(file_path, sep="\t")
|
|
23
|
+
# Extract necessary columns and any other processing
|
|
24
|
+
return data
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def standardize_column_names(df: pd.DataFrame, original_column_name: str, final_column_name: str) -> pd.DataFrame:
|
|
28
|
+
"""
|
|
29
|
+
Standardizes the column names of a dataframe.
|
|
30
|
+
|
|
31
|
+
Args:
|
|
32
|
+
df (pandas.DataFrame): The dataframe to standardize.
|
|
33
|
+
original_column_name (str): The current name of the column to be standardized.
|
|
34
|
+
final_column_name (str): The final standardized name for the column.
|
|
35
|
+
|
|
36
|
+
Returns:
|
|
37
|
+
pandas.DataFrame: The dataframe with standardized column names.
|
|
38
|
+
|
|
39
|
+
Example:
|
|
40
|
+
>>> df = pd.DataFrame({'InChIKey-Planar': [1, 2], 'OtherColumn': [3, 4]})
|
|
41
|
+
>>> standardized_df = standardize_column_names(df, 'InChIKey-Planar', 'InChiKey')
|
|
42
|
+
>>> standardized_df.columns
|
|
43
|
+
Index(['InChiKey', 'OtherColumn'], dtype='object')
|
|
44
|
+
"""
|
|
45
|
+
standardized_df = df.rename(columns={original_column_name: final_column_name})
|
|
46
|
+
return standardized_df
|
|
47
|
+
|
|
48
|
+
|
|
49
|
+
def extract_feature_id(df: pd.DataFrame, feature_id_column: str) -> pd.DataFrame:
|
|
50
|
+
"""
|
|
51
|
+
Extracts the numeric feature ID from a string in the specified column of a dataframe.
|
|
52
|
+
|
|
53
|
+
Args:
|
|
54
|
+
df (pandas.DataFrame): The dataframe containing the feature ID strings.
|
|
55
|
+
feature_id_column (str): The name of the column containing the feature ID strings.
|
|
56
|
+
|
|
57
|
+
Returns:
|
|
58
|
+
pandas.DataFrame: The dataframe with the feature ID extracted.
|
|
59
|
+
|
|
60
|
+
Example:
|
|
61
|
+
>>> df = pd.DataFrame({'FeatureID': ['573_mapp_batch_00020_gf_sirius_58', '574_mapp_batch_00021_gf_sirius_59']})
|
|
62
|
+
>>> cleaned_df = extract_feature_id(df, 'FeatureID')
|
|
63
|
+
>>> cleaned_df['FeatureID']
|
|
64
|
+
0 58
|
|
65
|
+
1 59
|
|
66
|
+
Name: FeatureID, dtype: int64
|
|
67
|
+
"""
|
|
68
|
+
|
|
69
|
+
def extract_id(feature_string: Optional[str]) -> Optional[int]:
|
|
70
|
+
if isinstance(feature_string, str):
|
|
71
|
+
# Split the string by '_' and extract the last part, then convert to integer
|
|
72
|
+
return int(feature_string.split("_")[-1])
|
|
73
|
+
else:
|
|
74
|
+
# Handle non-string inputs (like None or NaN)
|
|
75
|
+
# You can decide how to handle this - raise an error, return None, or something else
|
|
76
|
+
return None # or raise ValueError("Invalid feature string")
|
|
77
|
+
|
|
78
|
+
df[feature_id_column] = df[feature_id_column].apply(extract_id)
|
|
79
|
+
return df
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
def prefix_columns(df: pd.DataFrame, prefix: str, exclude_columns: Optional[list] = None) -> pd.DataFrame:
|
|
83
|
+
"""
|
|
84
|
+
Prefixes all columns in a dataframe with the specified prefix, excluding specified columns.
|
|
85
|
+
|
|
86
|
+
Args:
|
|
87
|
+
df (pandas.DataFrame): The dataframe to modify.
|
|
88
|
+
prefix (str): The prefix to add to the column names.
|
|
89
|
+
exclude_columns (list, optional): List of column names to exclude from prefixing. Defaults to None.
|
|
90
|
+
|
|
91
|
+
Returns:
|
|
92
|
+
pandas.DataFrame: The dataframe with prefixed column names.
|
|
93
|
+
|
|
94
|
+
Example:
|
|
95
|
+
>>> df = pd.DataFrame({'feature_id': [1, 2], 'data': [3, 4], 'info': [5, 6]})
|
|
96
|
+
>>> prefixed_df = prefix_columns(df, 'gnps_', exclude_columns=['feature_id'])
|
|
97
|
+
>>> prefixed_df.columns
|
|
98
|
+
Index(['feature_id', 'gnps_data', 'gnps_info'], dtype='object')
|
|
99
|
+
"""
|
|
100
|
+
if exclude_columns is None:
|
|
101
|
+
exclude_columns = []
|
|
102
|
+
|
|
103
|
+
for column in df.columns:
|
|
104
|
+
if column not in exclude_columns:
|
|
105
|
+
df = df.rename(columns={column: f"{prefix}{column}"})
|
|
106
|
+
return df
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
def add_source_column(df: pd.DataFrame, source_name: str) -> pd.DataFrame:
|
|
110
|
+
"""
|
|
111
|
+
Adds a 'Source' column to a dataframe, labeling all rows with the specified source name.
|
|
112
|
+
|
|
113
|
+
Args:
|
|
114
|
+
df (pandas.DataFrame): The dataframe to modify.
|
|
115
|
+
source_name (str): The name of the source to add (e.g., 'GNPS', 'ISDB', 'SIRIUS').
|
|
116
|
+
|
|
117
|
+
Returns:
|
|
118
|
+
pandas.DataFrame: The dataframe with the 'Source' column added.
|
|
119
|
+
"""
|
|
120
|
+
df["Source"] = source_name
|
|
121
|
+
return df
|
|
122
|
+
|
|
123
|
+
|
|
124
|
+
def process_gnps_data(gnps_file: str) -> pd.DataFrame:
|
|
125
|
+
"""
|
|
126
|
+
Reads and processes GNPS data. This function standardizes column names, prefixes them to indicate their source,
|
|
127
|
+
and extracts 'feature_id' and 'IK2D' from the data.
|
|
128
|
+
|
|
129
|
+
Args:
|
|
130
|
+
gnps_file (str): File path for the GNPS data in TSV format.
|
|
131
|
+
|
|
132
|
+
Returns:
|
|
133
|
+
pandas.DataFrame: A DataFrame with processed GNPS data.
|
|
134
|
+
|
|
135
|
+
Example:
|
|
136
|
+
>>> gnps_file = 'path/to/gnps_data.tsv'
|
|
137
|
+
>>> gnps_data = process_gnps_data(gnps_file)
|
|
138
|
+
>>> print(gnps_data.columns)
|
|
139
|
+
Index(['feature_id', 'IK2D', ...], dtype='object')
|
|
140
|
+
"""
|
|
141
|
+
|
|
142
|
+
# Read and process GNPS data
|
|
143
|
+
gnps_data = pd.read_csv(gnps_file, sep="\t")
|
|
144
|
+
gnps_data = add_source_column(gnps_data, "GNPS")
|
|
145
|
+
gnps_data = standardize_column_names(gnps_data, "InChIKey-Planar", "IK2D")
|
|
146
|
+
gnps_data = standardize_column_names(gnps_data, "#Scan#", "feature_id")
|
|
147
|
+
gnps_data = standardize_column_names(gnps_data, "Smiles", "SMILES")
|
|
148
|
+
gnps_data = prefix_columns(gnps_data, "gnps_", exclude_columns=[])
|
|
149
|
+
gnps_data = standardize_column_names(gnps_data, "gnps_IK2D", "IK2D")
|
|
150
|
+
gnps_data = standardize_column_names(gnps_data, "gnps_feature_id", "feature_id")
|
|
151
|
+
|
|
152
|
+
return gnps_data
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
def process_sirius_data(sirius_file: str) -> pd.DataFrame:
|
|
156
|
+
"""
|
|
157
|
+
Reads and processes Sirius data. This function standardizes column names, prefixes them to indicate their source,
|
|
158
|
+
and extracts 'feature_id' and 'IK2D' from the data.
|
|
159
|
+
|
|
160
|
+
Args:
|
|
161
|
+
sirius_file (str): File path for the Sirius data in TSV format.
|
|
162
|
+
|
|
163
|
+
Returns:
|
|
164
|
+
pandas.DataFrame: A DataFrame with processed Sirius data.
|
|
165
|
+
|
|
166
|
+
Example:
|
|
167
|
+
>>> sirius_file = 'path/to/sirius_data.tsv'
|
|
168
|
+
>>> sirius_data = process_sirius_data(sirius_file)
|
|
169
|
+
>>> print(sirius_data.columns)
|
|
170
|
+
Index(['feature_id', 'IK2D', ...], dtype='object')
|
|
171
|
+
"""
|
|
172
|
+
|
|
173
|
+
# Read and process Sirius data
|
|
174
|
+
sirius_data = pd.read_csv(sirius_file, sep="\t")
|
|
175
|
+
sirius_data = add_source_column(sirius_data, "SIRIUS")
|
|
176
|
+
sirius_data = standardize_column_names(sirius_data, "InChIkey2D", "IK2D")
|
|
177
|
+
sirius_data = standardize_column_names(sirius_data, "id", "feature_id")
|
|
178
|
+
sirius_data = standardize_column_names(sirius_data, "smiles", "SMILES")
|
|
179
|
+
sirius_data = prefix_columns(sirius_data, "sirius_", exclude_columns=[])
|
|
180
|
+
sirius_data = extract_feature_id(sirius_data, "sirius_feature_id")
|
|
181
|
+
sirius_data = standardize_column_names(sirius_data, "sirius_IK2D", "IK2D")
|
|
182
|
+
sirius_data = standardize_column_names(sirius_data, "sirius_feature_id", "feature_id")
|
|
183
|
+
|
|
184
|
+
return sirius_data
|
|
185
|
+
|
|
186
|
+
|
|
187
|
+
def process_isdb_data(isdb_file: str) -> pd.DataFrame:
|
|
188
|
+
"""
|
|
189
|
+
Reads and processes ISDB data. This function standardizes column names, prefixes them to indicate their source,
|
|
190
|
+
and extracts 'feature_id' and 'IK2D' from the data.
|
|
191
|
+
|
|
192
|
+
Args:
|
|
193
|
+
isdb_file (str): File path for the ISDB data in TSV format.
|
|
194
|
+
|
|
195
|
+
Returns:
|
|
196
|
+
pandas.DataFrame: A DataFrame with processed ISDB data.
|
|
197
|
+
|
|
198
|
+
Example:
|
|
199
|
+
>>> isdb_file = 'path/to/isdb_data.tsv'
|
|
200
|
+
>>> isdb_data = process_isdb_data(isdb_file)
|
|
201
|
+
>>> print(isdb_data.columns)
|
|
202
|
+
Index(['feature_id', 'IK2D', ...], dtype='object')
|
|
203
|
+
"""
|
|
204
|
+
|
|
205
|
+
# Read and process ISDB data
|
|
206
|
+
isdb_data = pd.read_csv(isdb_file, sep="\t")
|
|
207
|
+
isdb_data = add_source_column(isdb_data, "ISDB")
|
|
208
|
+
isdb_data = standardize_column_names(isdb_data, "short_inchikey", "IK2D")
|
|
209
|
+
isdb_data = standardize_column_names(isdb_data, "feature_id", "feature_id")
|
|
210
|
+
isdb_data = standardize_column_names(isdb_data, "structure_smiles", "SMILES")
|
|
211
|
+
isdb_data = prefix_columns(isdb_data, "isdb_", exclude_columns=[])
|
|
212
|
+
isdb_data = standardize_column_names(isdb_data, "isdb_IK2D", "IK2D")
|
|
213
|
+
isdb_data = standardize_column_names(isdb_data, "isdb_feature_id", "feature_id")
|
|
214
|
+
|
|
215
|
+
return isdb_data
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Function to determine matching sources
|
|
2
|
+
import pandas as pd
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
def determine_source(row: pd.Series) -> str:
|
|
6
|
+
sources = []
|
|
7
|
+
# Check if all are equal
|
|
8
|
+
if row["gnps_IK2D"] == row["sirius_IK2D"] == row["isdb_IK2D"]:
|
|
9
|
+
return "GNPS,ISDB,SIRIUS"
|
|
10
|
+
if row["gnps_IK2D"] == row["sirius_IK2D"]:
|
|
11
|
+
sources.append("GNPS")
|
|
12
|
+
sources.append("SIRIUS")
|
|
13
|
+
if row["gnps_IK2D"] == row["isdb_IK2D"]:
|
|
14
|
+
sources.append("GNPS")
|
|
15
|
+
sources.append("ISDB")
|
|
16
|
+
if row["sirius_IK2D"] == row["isdb_IK2D"]:
|
|
17
|
+
sources.append("ISDB")
|
|
18
|
+
sources.append("SIRIUS")
|
|
19
|
+
return ",".join(sorted(set(sources)))
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
# Function to count the sources
|
|
23
|
+
def count_sources(source_str: str) -> int:
|
|
24
|
+
if source_str:
|
|
25
|
+
# Count unique source names (they are comma-separated)
|
|
26
|
+
return len(set(source_str.split(",")))
|
|
27
|
+
return 0
|
|
@@ -0,0 +1,68 @@
|
|
|
1
|
+
from typing import Optional
|
|
2
|
+
|
|
3
|
+
import click
|
|
4
|
+
|
|
5
|
+
from met_annot_unifier.aligner.aligner import align_data_horizontally, align_data_vertically
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
@click.group()
|
|
9
|
+
def cli() -> None:
|
|
10
|
+
"""Description for your CLI tool."""
|
|
11
|
+
print("CLI is running")
|
|
12
|
+
pass
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@cli.command()
|
|
16
|
+
@click.option("--gnps-file", type=click.Path(exists=True), help="Path to GNPS output file.")
|
|
17
|
+
@click.option("--sirius-file", type=click.Path(exists=True), help="Path to Sirius output file.")
|
|
18
|
+
@click.option("--isdb-file", type=click.Path(exists=True), help="Path to ISDB output file.")
|
|
19
|
+
@click.option("--output", "-o", type=click.Path(), help="Output file to save the merged data.")
|
|
20
|
+
def align_vertically(gnps_file: str, sirius_file: str, isdb_file: str, output: Optional[str] = None) -> None:
|
|
21
|
+
"""CLI tool to align and merge data from GNPS, Sirius, and ISDB.
|
|
22
|
+
|
|
23
|
+
Args:
|
|
24
|
+
gnps_file (str): Path to GNPS output file.
|
|
25
|
+
sirius_file (str): Path to Sirius output file.
|
|
26
|
+
isdb_file (str): Path to ISDB output file.
|
|
27
|
+
output (str, optional): Output file to save the merged data. Defaults to None.
|
|
28
|
+
|
|
29
|
+
Returns:
|
|
30
|
+
A dataframe with the aligned data (if the output option is used, the dataframe is saved to a file)
|
|
31
|
+
"""
|
|
32
|
+
aligned_data = align_data_vertically(gnps_file, sirius_file, isdb_file)
|
|
33
|
+
|
|
34
|
+
if output:
|
|
35
|
+
aligned_data.to_csv(output, index=False)
|
|
36
|
+
click.echo(f"Aligned data saved to {output}")
|
|
37
|
+
else:
|
|
38
|
+
click.echo(aligned_data)
|
|
39
|
+
|
|
40
|
+
|
|
41
|
+
@cli.command()
|
|
42
|
+
@click.option("--gnps-file", type=click.Path(exists=True), help="Path to GNPS output file.")
|
|
43
|
+
@click.option("--sirius-file", type=click.Path(exists=True), help="Path to Sirius output file.")
|
|
44
|
+
@click.option("--isdb-file", type=click.Path(exists=True), help="Path to ISDB output file.")
|
|
45
|
+
@click.option("--output", "-o", type=click.Path(), help="Output file to save the merged data.")
|
|
46
|
+
def align_horizontally(gnps_file: str, sirius_file: str, isdb_file: str, output: Optional[str] = None) -> None:
|
|
47
|
+
"""CLI tool to align and merge data from GNPS, Sirius, and ISDB horizontally.
|
|
48
|
+
|
|
49
|
+
Args:
|
|
50
|
+
gnps_file (str): Path to GNPS output file.
|
|
51
|
+
sirius_file (str): Path to Sirius output file.
|
|
52
|
+
isdb_file (str): Path to ISDB output file.
|
|
53
|
+
output (str, optional): Output file to save the merged data. Defaults to None.
|
|
54
|
+
|
|
55
|
+
Returns:
|
|
56
|
+
A dataframe with the aligned data (if the output option is used, the dataframe is saved to a file)
|
|
57
|
+
"""
|
|
58
|
+
aligned_data = align_data_horizontally(gnps_file, sirius_file, isdb_file)
|
|
59
|
+
|
|
60
|
+
if output:
|
|
61
|
+
aligned_data.to_csv(output, index=False)
|
|
62
|
+
click.echo(f"Aligned data saved to {output}")
|
|
63
|
+
else:
|
|
64
|
+
click.echo(aligned_data)
|
|
65
|
+
|
|
66
|
+
|
|
67
|
+
if __name__ == "__main__":
|
|
68
|
+
cli()
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
def foo() -> str:
|
|
2
|
+
"""Summary line.
|
|
3
|
+
|
|
4
|
+
Extended description of function.
|
|
5
|
+
|
|
6
|
+
Args:
|
|
7
|
+
foo (str): Description of arg1
|
|
8
|
+
|
|
9
|
+
Returns:
|
|
10
|
+
str: Description of return value
|
|
11
|
+
"""
|
|
12
|
+
|
|
13
|
+
return "foo"
|
|
14
|
+
|
|
15
|
+
|
|
16
|
+
if __name__ == "__main__": # pragma: no cover
|
|
17
|
+
pass
|
|
@@ -0,0 +1,118 @@
|
|
|
1
|
+
[tool.poetry]
|
|
2
|
+
name = "met-annot-unifier"
|
|
3
|
+
version = "0.0.1"
|
|
4
|
+
description = "A Python project to combine tabular outputs from GNPS, Sirius and ISDB"
|
|
5
|
+
authors = ["Pierre-Marie Allard <pierre-marie.allard@unifr.ch>"]
|
|
6
|
+
repository = "https://github.com/mapp-metabolomics-unit/met-annot-unifier"
|
|
7
|
+
documentation = "https://mapp-metabolomics-unit.github.io/met-annot-unifier/"
|
|
8
|
+
readme = "README.md"
|
|
9
|
+
packages = [
|
|
10
|
+
{include = "met_annot_unifier"}
|
|
11
|
+
]
|
|
12
|
+
|
|
13
|
+
[tool.poetry.dependencies]
|
|
14
|
+
python = ">=3.9,<4.0"
|
|
15
|
+
click = "^8.1.7"
|
|
16
|
+
pandas = "^2.2.0"
|
|
17
|
+
pyarrow = "^15.0.0"
|
|
18
|
+
|
|
19
|
+
[tool.poetry.group.dev.dependencies]
|
|
20
|
+
pytest = "^7.2.0"
|
|
21
|
+
pytest-cov = "^4.0.0"
|
|
22
|
+
deptry = "^0.12.0"
|
|
23
|
+
mypy = "^1.5.1"
|
|
24
|
+
pre-commit = "^3.4.0"
|
|
25
|
+
tox = "^4.11.1"
|
|
26
|
+
ipykernel = "^6.29.0"
|
|
27
|
+
pandas-stubs = "^2.1.4.231227"
|
|
28
|
+
pydantic = "^2.6.0"
|
|
29
|
+
pytest-click = "^1.1.0"
|
|
30
|
+
mkdocstrings = "^0.24.0"
|
|
31
|
+
|
|
32
|
+
[tool.poetry.group.docs.dependencies]
|
|
33
|
+
mkdocs = "^1.4.2"
|
|
34
|
+
mkdocs-material = "^9.2.7"
|
|
35
|
+
mkdocstrings = {extras = ["python"], version = "^0.24.0"}
|
|
36
|
+
|
|
37
|
+
[build-system]
|
|
38
|
+
requires = ["poetry-core>=1.0.0"]
|
|
39
|
+
build-backend = "poetry.core.masonry.api"
|
|
40
|
+
|
|
41
|
+
[tool.mypy]
|
|
42
|
+
files = ["met_annot_unifier"]
|
|
43
|
+
disallow_untyped_defs = "True"
|
|
44
|
+
disallow_any_unimported = "True"
|
|
45
|
+
no_implicit_optional = "True"
|
|
46
|
+
check_untyped_defs = "True"
|
|
47
|
+
warn_return_any = "True"
|
|
48
|
+
warn_unused_ignores = "True"
|
|
49
|
+
show_error_codes = "True"
|
|
50
|
+
|
|
51
|
+
[tool.pytest.ini_options]
|
|
52
|
+
testpaths = ["tests"]
|
|
53
|
+
|
|
54
|
+
[tool.ruff]
|
|
55
|
+
target-version = "py37"
|
|
56
|
+
line-length = 120
|
|
57
|
+
fix = true
|
|
58
|
+
select = [
|
|
59
|
+
# flake8-2020
|
|
60
|
+
"YTT",
|
|
61
|
+
# flake8-bandit
|
|
62
|
+
"S",
|
|
63
|
+
# flake8-bugbear
|
|
64
|
+
"B",
|
|
65
|
+
# flake8-builtins
|
|
66
|
+
"A",
|
|
67
|
+
# flake8-comprehensions
|
|
68
|
+
"C4",
|
|
69
|
+
# flake8-debugger
|
|
70
|
+
"T10",
|
|
71
|
+
# flake8-simplify
|
|
72
|
+
"SIM",
|
|
73
|
+
# isort
|
|
74
|
+
"I",
|
|
75
|
+
# mccabe
|
|
76
|
+
"C90",
|
|
77
|
+
# pycodestyle
|
|
78
|
+
"E", "W",
|
|
79
|
+
# pyflakes
|
|
80
|
+
"F",
|
|
81
|
+
# pygrep-hooks
|
|
82
|
+
"PGH",
|
|
83
|
+
# pyupgrade
|
|
84
|
+
"UP",
|
|
85
|
+
# ruff
|
|
86
|
+
"RUF",
|
|
87
|
+
# tryceratops
|
|
88
|
+
"TRY",
|
|
89
|
+
]
|
|
90
|
+
ignore = [
|
|
91
|
+
# LineTooLong
|
|
92
|
+
"E501",
|
|
93
|
+
# DoNotAssignLambda
|
|
94
|
+
"E731",
|
|
95
|
+
]
|
|
96
|
+
|
|
97
|
+
[tool.ruff.format]
|
|
98
|
+
preview = true
|
|
99
|
+
|
|
100
|
+
[tool.coverage.report]
|
|
101
|
+
skip_empty = true
|
|
102
|
+
|
|
103
|
+
[tool.coverage.run]
|
|
104
|
+
branch = true
|
|
105
|
+
source = ["met_annot_unifier"]
|
|
106
|
+
|
|
107
|
+
|
|
108
|
+
[tool.ruff.per-file-ignores]
|
|
109
|
+
"tests/*" = ["S101"]
|
|
110
|
+
|
|
111
|
+
[tool.poetry.scripts]
|
|
112
|
+
met_annot_unifier = "met_annot_unifier.__main__:main"
|
|
113
|
+
met-annot-unifier-cli = 'met_annot_unifier.cli:main'
|
|
114
|
+
|
|
115
|
+
# We delinberately ignore the following dependencies
|
|
116
|
+
|
|
117
|
+
[tool.deptry.per_rule_ignores]
|
|
118
|
+
DEP002 = ["pyarrow"]
|