PanGBank-api 0.1.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.
Files changed (33) hide show
  1. pangbank_api-0.1.1/PKG-INFO +211 -0
  2. pangbank_api-0.1.1/PanGBank_api.egg-info/PKG-INFO +211 -0
  3. pangbank_api-0.1.1/PanGBank_api.egg-info/SOURCES.txt +31 -0
  4. pangbank_api-0.1.1/PanGBank_api.egg-info/dependency_links.txt +1 -0
  5. pangbank_api-0.1.1/PanGBank_api.egg-info/entry_points.txt +2 -0
  6. pangbank_api-0.1.1/PanGBank_api.egg-info/requires.txt +13 -0
  7. pangbank_api-0.1.1/PanGBank_api.egg-info/top_level.txt +1 -0
  8. pangbank_api-0.1.1/README.md +191 -0
  9. pangbank_api-0.1.1/pangbank_api/__init__.py +0 -0
  10. pangbank_api-0.1.1/pangbank_api/config.py +21 -0
  11. pangbank_api-0.1.1/pangbank_api/crud/__init__.py +0 -0
  12. pangbank_api-0.1.1/pangbank_api/crud/collections.py +102 -0
  13. pangbank_api-0.1.1/pangbank_api/crud/common.py +75 -0
  14. pangbank_api-0.1.1/pangbank_api/crud/genomes.py +80 -0
  15. pangbank_api-0.1.1/pangbank_api/crud/pangenomes.py +222 -0
  16. pangbank_api-0.1.1/pangbank_api/database.py +13 -0
  17. pangbank_api-0.1.1/pangbank_api/dependencies.py +15 -0
  18. pangbank_api-0.1.1/pangbank_api/main.py +35 -0
  19. pangbank_api-0.1.1/pangbank_api/manage_db/__init__.py +0 -0
  20. pangbank_api-0.1.1/pangbank_api/manage_db/collections.py +605 -0
  21. pangbank_api-0.1.1/pangbank_api/manage_db/genome_metadata.py +460 -0
  22. pangbank_api-0.1.1/pangbank_api/manage_db/genomes.py +149 -0
  23. pangbank_api-0.1.1/pangbank_api/manage_db/input_models.py +35 -0
  24. pangbank_api-0.1.1/pangbank_api/manage_db/pangbank_db.py +205 -0
  25. pangbank_api-0.1.1/pangbank_api/manage_db/taxonomy.py +228 -0
  26. pangbank_api-0.1.1/pangbank_api/manage_db/utils.py +86 -0
  27. pangbank_api-0.1.1/pangbank_api/models.py +446 -0
  28. pangbank_api-0.1.1/pangbank_api/routers/__init__.py +0 -0
  29. pangbank_api-0.1.1/pangbank_api/routers/collections.py +64 -0
  30. pangbank_api-0.1.1/pangbank_api/routers/genomes.py +31 -0
  31. pangbank_api-0.1.1/pangbank_api/routers/pangenomes.py +172 -0
  32. pangbank_api-0.1.1/pyproject.toml +36 -0
  33. pangbank_api-0.1.1/setup.cfg +4 -0
@@ -0,0 +1,211 @@
1
+ Metadata-Version: 2.4
2
+ Name: PanGBank-api
3
+ Version: 0.1.1
4
+ Summary: Source code to PanGBank API
5
+ Author: Jean Mainguy
6
+ Requires-Python: <3.14,>=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fastapi[all]>=0.115.8
9
+ Requires-Dist: sqlmodel>=0.0.22
10
+ Requires-Dist: typer>=0.15.1
11
+ Requires-Dist: pyyaml>=6.0.2
12
+ Requires-Dist: packaging>=24
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8.3.4; extra == "dev"
15
+ Requires-Dist: requests>=2.32.3; extra == "dev"
16
+ Requires-Dist: httpx>=0.28.1; extra == "dev"
17
+ Requires-Dist: pytest-cov>=6.0.0; extra == "dev"
18
+ Requires-Dist: flake8>=7.1.2; extra == "dev"
19
+ Requires-Dist: alembic>=1.13.1; extra == "dev"
20
+
21
+ # PanGBank API
22
+
23
+ This repository contains the API used to manage the **PanGBank** database, which stores collections of pangenomes built with [**PPanGGOLiN**](https://github.com/labgem/PPanGGOLiN).
24
+
25
+ The API is built with [**FastAPI**](https://fastapi.tiangolo.com) and uses [**SQLModel**](https://sqlmodel.tiangolo.com) as its ORM.
26
+ It provides a RESTful interface for querying and exploring pangenome collections. Alongside the API, a command-line tool `pangbank_db` is included to manage the database.
27
+
28
+ ## 🚀 Installation
29
+
30
+ ### Local API Setup
31
+
32
+ 1. **Clone the repository**:
33
+
34
+ ```bash
35
+ git clone https://github.com/labgem/PanGBank-api.git
36
+ cd PanGBank-api
37
+ ```
38
+
39
+ 2. **Create a virtual environment and install dependencies**:
40
+
41
+ ```bash
42
+ python -m venv venv
43
+ source venv/bin/activate
44
+ pip install .
45
+ ```
46
+
47
+ 3. **Run the API in development mode**:
48
+
49
+ ```bash
50
+ export PANGBANK_DB_PATH="<path/to/database.sqlite>"
51
+ export PANGBANK_DATA_DIR="<path/to/pangenome_directory>"
52
+ fastapi dev pangbank_api/main.py
53
+ ```
54
+
55
+ > `PANGBANK_DB_PATH` is the path to your SQLite database file.
56
+ > `PANGBANK_DATA_DIR` is the root directory containing your pangenome data and mash files.
57
+
58
+
59
+ ## 🛠️ Managing the Database with `pangbank_db`
60
+
61
+ All CLI commands require the `PANGBANK_DB_PATH` environment variable to be set.
62
+
63
+ ```bash
64
+ export PANGBANK_DB_PATH="<path/to/database.sqlite>"
65
+ ```
66
+
67
+
68
+ ### Add a Collection Release
69
+
70
+ To add a new collection of pangenomes in the database, use:
71
+
72
+ ```bash
73
+ pangbank_db add-collection-release <collection_release.json>
74
+ ```
75
+ > [!NOTE]
76
+ > This command requires two environment variables:
77
+ >
78
+ > ```bash
79
+ > export PANGBANK_DB_PATH="<path/to/database.sqlite>"
80
+ > export PANGBANK_DATA_DIR="<root/path/serving/pangenomes>"
81
+ > ```
82
+
83
+
84
+ <details>
85
+
86
+
87
+ <summary>JSON Schema Example</summary>
88
+
89
+
90
+
91
+ ```jsonc
92
+ {
93
+ "collection": {
94
+ "name": "GTDB_all_sampled",
95
+ "description": "GTDB all is a collection of pangenomes made of GTDB species that have at least 15 genomes."
96
+ },
97
+ "release": {
98
+ "version": "1.0.0",
99
+ "ppanggolin_version": "2.2.4",
100
+ "pangbank_wf_version": "0.0.2",
101
+ "pangenomes_directory": "GTDB_refseq/release_v1.0.0/data/pangenomes/", // relative to PANGBANK_DATA_DIR
102
+ "release_note": "",
103
+ "date": "2025-07-10",
104
+ "mash_sketch": "GTDB_refseq/release_v1.0.0/data/mash_sketch/families_persistent_all.msh", // relative to PANGBANK_DATA_DIR
105
+ "mash_version": "2.3"
106
+ },
107
+ "taxonomy": {
108
+ "name": "GTDB",
109
+ "version": "10-RS226",
110
+ "ranks": "Domain; Phylum; Class; Order; Family; Genus; Species",
111
+ "file": "/absolute/path/to/taxonomy.tsv"
112
+ },
113
+ "genome_sources": [
114
+ {
115
+ "name": "RefSeq",
116
+ "file": "/absolute/path/to/genomes.tsv",
117
+ "version": "",
118
+ "description": "",
119
+ "source": "",
120
+ "url": ""
121
+ }
122
+ ],
123
+ "genome_metadata_sources": [
124
+ {
125
+ "name": "GTDB 10-RS226 metadata",
126
+ "description": "Metadata collected from GTDB. Some columns have been filtered out.",
127
+ "url": "https://data.ace.uq.edu.au/public/gtdb/data/releases/release226/226.0/",
128
+ "strain_attribute": "ncbi_strain_identifiers",
129
+ "organism_name_attribute": "ncbi_organism_name",
130
+ "file": "/absolute/path/to/metadata.tsv"
131
+ }
132
+ ]
133
+ }
134
+ ```
135
+
136
+ #### Note
137
+ * Paths for `pangenomes_directory` and `mash_sketch` must be **relative to `PANGBANK_DATA_DIR`**.
138
+ * Paths for `taxonomy.file`, `genome_sources[*].file`, and `genome_metadata_sources[*].file` must be **absolute file paths**.
139
+
140
+ </details>
141
+
142
+
143
+ ### List Existing Collections
144
+
145
+ ```bash
146
+ pangbank_db list-collection
147
+ ```
148
+
149
+ ### Delete a Collection Release
150
+
151
+ ```bash
152
+ pangbank_db delete-collection <collection_name> --release-version <version>
153
+ ```
154
+
155
+
156
+ ## 🗃️ Database Migrations with Alembic
157
+
158
+ We use [Alembic](https://alembic.sqlalchemy.org/) to manage schema changes in the PanGBank database.
159
+
160
+
161
+ #### Create a new migration
162
+
163
+ Generate a migration after updating your SQLModel models (e.g., adding or changing columns):
164
+
165
+ ```bash
166
+ alembic revision --autogenerate -m "Describe your change here"
167
+ ```
168
+
169
+ #### Apply migrations to the database
170
+
171
+ This applies all pending migrations:
172
+
173
+ ```bash
174
+ alembic upgrade head
175
+ ```
176
+
177
+ #### Roll back the last migration (use with caution)
178
+
179
+ If something went wrong, you can revert the last migration:
180
+
181
+ ```bash
182
+ alembic downgrade -1
183
+ ```
184
+
185
+ Or go back to the base (empty schema):
186
+
187
+ ```bash
188
+ alembic downgrade base
189
+ ```
190
+
191
+ > [!NOTE]
192
+ > * The SQLite database path is defined in `config.py` via the `pangbank_db_path` setting (`PANGBANK_DB_PATH` env var).
193
+ >* Alembic is configured to read this dynamically, so no need to change `alembic.ini`.
194
+
195
+
196
+
197
+ ## Contributing
198
+
199
+ 1. Fork the repository.
200
+ 2. Create a feature branch (`git checkout -b feature-name`).
201
+ 3. Commit your changes (`git commit -m 'Add new feature'`).
202
+ 4. Push to the branch (`git push origin feature-name`).
203
+ 5. Open a pull request.
204
+
205
+ ## License
206
+
207
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
208
+
209
+ ## Contact
210
+
211
+ For any inquiries or issues, open an issue on the [GitHub repository](https://github.com/labgem/PanGBank-API/issues).
@@ -0,0 +1,211 @@
1
+ Metadata-Version: 2.4
2
+ Name: PanGBank-api
3
+ Version: 0.1.1
4
+ Summary: Source code to PanGBank API
5
+ Author: Jean Mainguy
6
+ Requires-Python: <3.14,>=3.10
7
+ Description-Content-Type: text/markdown
8
+ Requires-Dist: fastapi[all]>=0.115.8
9
+ Requires-Dist: sqlmodel>=0.0.22
10
+ Requires-Dist: typer>=0.15.1
11
+ Requires-Dist: pyyaml>=6.0.2
12
+ Requires-Dist: packaging>=24
13
+ Provides-Extra: dev
14
+ Requires-Dist: pytest>=8.3.4; extra == "dev"
15
+ Requires-Dist: requests>=2.32.3; extra == "dev"
16
+ Requires-Dist: httpx>=0.28.1; extra == "dev"
17
+ Requires-Dist: pytest-cov>=6.0.0; extra == "dev"
18
+ Requires-Dist: flake8>=7.1.2; extra == "dev"
19
+ Requires-Dist: alembic>=1.13.1; extra == "dev"
20
+
21
+ # PanGBank API
22
+
23
+ This repository contains the API used to manage the **PanGBank** database, which stores collections of pangenomes built with [**PPanGGOLiN**](https://github.com/labgem/PPanGGOLiN).
24
+
25
+ The API is built with [**FastAPI**](https://fastapi.tiangolo.com) and uses [**SQLModel**](https://sqlmodel.tiangolo.com) as its ORM.
26
+ It provides a RESTful interface for querying and exploring pangenome collections. Alongside the API, a command-line tool `pangbank_db` is included to manage the database.
27
+
28
+ ## 🚀 Installation
29
+
30
+ ### Local API Setup
31
+
32
+ 1. **Clone the repository**:
33
+
34
+ ```bash
35
+ git clone https://github.com/labgem/PanGBank-api.git
36
+ cd PanGBank-api
37
+ ```
38
+
39
+ 2. **Create a virtual environment and install dependencies**:
40
+
41
+ ```bash
42
+ python -m venv venv
43
+ source venv/bin/activate
44
+ pip install .
45
+ ```
46
+
47
+ 3. **Run the API in development mode**:
48
+
49
+ ```bash
50
+ export PANGBANK_DB_PATH="<path/to/database.sqlite>"
51
+ export PANGBANK_DATA_DIR="<path/to/pangenome_directory>"
52
+ fastapi dev pangbank_api/main.py
53
+ ```
54
+
55
+ > `PANGBANK_DB_PATH` is the path to your SQLite database file.
56
+ > `PANGBANK_DATA_DIR` is the root directory containing your pangenome data and mash files.
57
+
58
+
59
+ ## 🛠️ Managing the Database with `pangbank_db`
60
+
61
+ All CLI commands require the `PANGBANK_DB_PATH` environment variable to be set.
62
+
63
+ ```bash
64
+ export PANGBANK_DB_PATH="<path/to/database.sqlite>"
65
+ ```
66
+
67
+
68
+ ### Add a Collection Release
69
+
70
+ To add a new collection of pangenomes in the database, use:
71
+
72
+ ```bash
73
+ pangbank_db add-collection-release <collection_release.json>
74
+ ```
75
+ > [!NOTE]
76
+ > This command requires two environment variables:
77
+ >
78
+ > ```bash
79
+ > export PANGBANK_DB_PATH="<path/to/database.sqlite>"
80
+ > export PANGBANK_DATA_DIR="<root/path/serving/pangenomes>"
81
+ > ```
82
+
83
+
84
+ <details>
85
+
86
+
87
+ <summary>JSON Schema Example</summary>
88
+
89
+
90
+
91
+ ```jsonc
92
+ {
93
+ "collection": {
94
+ "name": "GTDB_all_sampled",
95
+ "description": "GTDB all is a collection of pangenomes made of GTDB species that have at least 15 genomes."
96
+ },
97
+ "release": {
98
+ "version": "1.0.0",
99
+ "ppanggolin_version": "2.2.4",
100
+ "pangbank_wf_version": "0.0.2",
101
+ "pangenomes_directory": "GTDB_refseq/release_v1.0.0/data/pangenomes/", // relative to PANGBANK_DATA_DIR
102
+ "release_note": "",
103
+ "date": "2025-07-10",
104
+ "mash_sketch": "GTDB_refseq/release_v1.0.0/data/mash_sketch/families_persistent_all.msh", // relative to PANGBANK_DATA_DIR
105
+ "mash_version": "2.3"
106
+ },
107
+ "taxonomy": {
108
+ "name": "GTDB",
109
+ "version": "10-RS226",
110
+ "ranks": "Domain; Phylum; Class; Order; Family; Genus; Species",
111
+ "file": "/absolute/path/to/taxonomy.tsv"
112
+ },
113
+ "genome_sources": [
114
+ {
115
+ "name": "RefSeq",
116
+ "file": "/absolute/path/to/genomes.tsv",
117
+ "version": "",
118
+ "description": "",
119
+ "source": "",
120
+ "url": ""
121
+ }
122
+ ],
123
+ "genome_metadata_sources": [
124
+ {
125
+ "name": "GTDB 10-RS226 metadata",
126
+ "description": "Metadata collected from GTDB. Some columns have been filtered out.",
127
+ "url": "https://data.ace.uq.edu.au/public/gtdb/data/releases/release226/226.0/",
128
+ "strain_attribute": "ncbi_strain_identifiers",
129
+ "organism_name_attribute": "ncbi_organism_name",
130
+ "file": "/absolute/path/to/metadata.tsv"
131
+ }
132
+ ]
133
+ }
134
+ ```
135
+
136
+ #### Note
137
+ * Paths for `pangenomes_directory` and `mash_sketch` must be **relative to `PANGBANK_DATA_DIR`**.
138
+ * Paths for `taxonomy.file`, `genome_sources[*].file`, and `genome_metadata_sources[*].file` must be **absolute file paths**.
139
+
140
+ </details>
141
+
142
+
143
+ ### List Existing Collections
144
+
145
+ ```bash
146
+ pangbank_db list-collection
147
+ ```
148
+
149
+ ### Delete a Collection Release
150
+
151
+ ```bash
152
+ pangbank_db delete-collection <collection_name> --release-version <version>
153
+ ```
154
+
155
+
156
+ ## 🗃️ Database Migrations with Alembic
157
+
158
+ We use [Alembic](https://alembic.sqlalchemy.org/) to manage schema changes in the PanGBank database.
159
+
160
+
161
+ #### Create a new migration
162
+
163
+ Generate a migration after updating your SQLModel models (e.g., adding or changing columns):
164
+
165
+ ```bash
166
+ alembic revision --autogenerate -m "Describe your change here"
167
+ ```
168
+
169
+ #### Apply migrations to the database
170
+
171
+ This applies all pending migrations:
172
+
173
+ ```bash
174
+ alembic upgrade head
175
+ ```
176
+
177
+ #### Roll back the last migration (use with caution)
178
+
179
+ If something went wrong, you can revert the last migration:
180
+
181
+ ```bash
182
+ alembic downgrade -1
183
+ ```
184
+
185
+ Or go back to the base (empty schema):
186
+
187
+ ```bash
188
+ alembic downgrade base
189
+ ```
190
+
191
+ > [!NOTE]
192
+ > * The SQLite database path is defined in `config.py` via the `pangbank_db_path` setting (`PANGBANK_DB_PATH` env var).
193
+ >* Alembic is configured to read this dynamically, so no need to change `alembic.ini`.
194
+
195
+
196
+
197
+ ## Contributing
198
+
199
+ 1. Fork the repository.
200
+ 2. Create a feature branch (`git checkout -b feature-name`).
201
+ 3. Commit your changes (`git commit -m 'Add new feature'`).
202
+ 4. Push to the branch (`git push origin feature-name`).
203
+ 5. Open a pull request.
204
+
205
+ ## License
206
+
207
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
208
+
209
+ ## Contact
210
+
211
+ For any inquiries or issues, open an issue on the [GitHub repository](https://github.com/labgem/PanGBank-API/issues).
@@ -0,0 +1,31 @@
1
+ README.md
2
+ pyproject.toml
3
+ PanGBank_api.egg-info/PKG-INFO
4
+ PanGBank_api.egg-info/SOURCES.txt
5
+ PanGBank_api.egg-info/dependency_links.txt
6
+ PanGBank_api.egg-info/entry_points.txt
7
+ PanGBank_api.egg-info/requires.txt
8
+ PanGBank_api.egg-info/top_level.txt
9
+ pangbank_api/__init__.py
10
+ pangbank_api/config.py
11
+ pangbank_api/database.py
12
+ pangbank_api/dependencies.py
13
+ pangbank_api/main.py
14
+ pangbank_api/models.py
15
+ pangbank_api/crud/__init__.py
16
+ pangbank_api/crud/collections.py
17
+ pangbank_api/crud/common.py
18
+ pangbank_api/crud/genomes.py
19
+ pangbank_api/crud/pangenomes.py
20
+ pangbank_api/manage_db/__init__.py
21
+ pangbank_api/manage_db/collections.py
22
+ pangbank_api/manage_db/genome_metadata.py
23
+ pangbank_api/manage_db/genomes.py
24
+ pangbank_api/manage_db/input_models.py
25
+ pangbank_api/manage_db/pangbank_db.py
26
+ pangbank_api/manage_db/taxonomy.py
27
+ pangbank_api/manage_db/utils.py
28
+ pangbank_api/routers/__init__.py
29
+ pangbank_api/routers/collections.py
30
+ pangbank_api/routers/genomes.py
31
+ pangbank_api/routers/pangenomes.py
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ pangbank_db = pangbank_api.manage_db.pangbank_db:cli
@@ -0,0 +1,13 @@
1
+ fastapi[all]>=0.115.8
2
+ sqlmodel>=0.0.22
3
+ typer>=0.15.1
4
+ pyyaml>=6.0.2
5
+ packaging>=24
6
+
7
+ [dev]
8
+ pytest>=8.3.4
9
+ requests>=2.32.3
10
+ httpx>=0.28.1
11
+ pytest-cov>=6.0.0
12
+ flake8>=7.1.2
13
+ alembic>=1.13.1
@@ -0,0 +1 @@
1
+ pangbank_api
@@ -0,0 +1,191 @@
1
+ # PanGBank API
2
+
3
+ This repository contains the API used to manage the **PanGBank** database, which stores collections of pangenomes built with [**PPanGGOLiN**](https://github.com/labgem/PPanGGOLiN).
4
+
5
+ The API is built with [**FastAPI**](https://fastapi.tiangolo.com) and uses [**SQLModel**](https://sqlmodel.tiangolo.com) as its ORM.
6
+ It provides a RESTful interface for querying and exploring pangenome collections. Alongside the API, a command-line tool `pangbank_db` is included to manage the database.
7
+
8
+ ## 🚀 Installation
9
+
10
+ ### Local API Setup
11
+
12
+ 1. **Clone the repository**:
13
+
14
+ ```bash
15
+ git clone https://github.com/labgem/PanGBank-api.git
16
+ cd PanGBank-api
17
+ ```
18
+
19
+ 2. **Create a virtual environment and install dependencies**:
20
+
21
+ ```bash
22
+ python -m venv venv
23
+ source venv/bin/activate
24
+ pip install .
25
+ ```
26
+
27
+ 3. **Run the API in development mode**:
28
+
29
+ ```bash
30
+ export PANGBANK_DB_PATH="<path/to/database.sqlite>"
31
+ export PANGBANK_DATA_DIR="<path/to/pangenome_directory>"
32
+ fastapi dev pangbank_api/main.py
33
+ ```
34
+
35
+ > `PANGBANK_DB_PATH` is the path to your SQLite database file.
36
+ > `PANGBANK_DATA_DIR` is the root directory containing your pangenome data and mash files.
37
+
38
+
39
+ ## 🛠️ Managing the Database with `pangbank_db`
40
+
41
+ All CLI commands require the `PANGBANK_DB_PATH` environment variable to be set.
42
+
43
+ ```bash
44
+ export PANGBANK_DB_PATH="<path/to/database.sqlite>"
45
+ ```
46
+
47
+
48
+ ### Add a Collection Release
49
+
50
+ To add a new collection of pangenomes in the database, use:
51
+
52
+ ```bash
53
+ pangbank_db add-collection-release <collection_release.json>
54
+ ```
55
+ > [!NOTE]
56
+ > This command requires two environment variables:
57
+ >
58
+ > ```bash
59
+ > export PANGBANK_DB_PATH="<path/to/database.sqlite>"
60
+ > export PANGBANK_DATA_DIR="<root/path/serving/pangenomes>"
61
+ > ```
62
+
63
+
64
+ <details>
65
+
66
+
67
+ <summary>JSON Schema Example</summary>
68
+
69
+
70
+
71
+ ```jsonc
72
+ {
73
+ "collection": {
74
+ "name": "GTDB_all_sampled",
75
+ "description": "GTDB all is a collection of pangenomes made of GTDB species that have at least 15 genomes."
76
+ },
77
+ "release": {
78
+ "version": "1.0.0",
79
+ "ppanggolin_version": "2.2.4",
80
+ "pangbank_wf_version": "0.0.2",
81
+ "pangenomes_directory": "GTDB_refseq/release_v1.0.0/data/pangenomes/", // relative to PANGBANK_DATA_DIR
82
+ "release_note": "",
83
+ "date": "2025-07-10",
84
+ "mash_sketch": "GTDB_refseq/release_v1.0.0/data/mash_sketch/families_persistent_all.msh", // relative to PANGBANK_DATA_DIR
85
+ "mash_version": "2.3"
86
+ },
87
+ "taxonomy": {
88
+ "name": "GTDB",
89
+ "version": "10-RS226",
90
+ "ranks": "Domain; Phylum; Class; Order; Family; Genus; Species",
91
+ "file": "/absolute/path/to/taxonomy.tsv"
92
+ },
93
+ "genome_sources": [
94
+ {
95
+ "name": "RefSeq",
96
+ "file": "/absolute/path/to/genomes.tsv",
97
+ "version": "",
98
+ "description": "",
99
+ "source": "",
100
+ "url": ""
101
+ }
102
+ ],
103
+ "genome_metadata_sources": [
104
+ {
105
+ "name": "GTDB 10-RS226 metadata",
106
+ "description": "Metadata collected from GTDB. Some columns have been filtered out.",
107
+ "url": "https://data.ace.uq.edu.au/public/gtdb/data/releases/release226/226.0/",
108
+ "strain_attribute": "ncbi_strain_identifiers",
109
+ "organism_name_attribute": "ncbi_organism_name",
110
+ "file": "/absolute/path/to/metadata.tsv"
111
+ }
112
+ ]
113
+ }
114
+ ```
115
+
116
+ #### Note
117
+ * Paths for `pangenomes_directory` and `mash_sketch` must be **relative to `PANGBANK_DATA_DIR`**.
118
+ * Paths for `taxonomy.file`, `genome_sources[*].file`, and `genome_metadata_sources[*].file` must be **absolute file paths**.
119
+
120
+ </details>
121
+
122
+
123
+ ### List Existing Collections
124
+
125
+ ```bash
126
+ pangbank_db list-collection
127
+ ```
128
+
129
+ ### Delete a Collection Release
130
+
131
+ ```bash
132
+ pangbank_db delete-collection <collection_name> --release-version <version>
133
+ ```
134
+
135
+
136
+ ## 🗃️ Database Migrations with Alembic
137
+
138
+ We use [Alembic](https://alembic.sqlalchemy.org/) to manage schema changes in the PanGBank database.
139
+
140
+
141
+ #### Create a new migration
142
+
143
+ Generate a migration after updating your SQLModel models (e.g., adding or changing columns):
144
+
145
+ ```bash
146
+ alembic revision --autogenerate -m "Describe your change here"
147
+ ```
148
+
149
+ #### Apply migrations to the database
150
+
151
+ This applies all pending migrations:
152
+
153
+ ```bash
154
+ alembic upgrade head
155
+ ```
156
+
157
+ #### Roll back the last migration (use with caution)
158
+
159
+ If something went wrong, you can revert the last migration:
160
+
161
+ ```bash
162
+ alembic downgrade -1
163
+ ```
164
+
165
+ Or go back to the base (empty schema):
166
+
167
+ ```bash
168
+ alembic downgrade base
169
+ ```
170
+
171
+ > [!NOTE]
172
+ > * The SQLite database path is defined in `config.py` via the `pangbank_db_path` setting (`PANGBANK_DB_PATH` env var).
173
+ >* Alembic is configured to read this dynamically, so no need to change `alembic.ini`.
174
+
175
+
176
+
177
+ ## Contributing
178
+
179
+ 1. Fork the repository.
180
+ 2. Create a feature branch (`git checkout -b feature-name`).
181
+ 3. Commit your changes (`git commit -m 'Add new feature'`).
182
+ 4. Push to the branch (`git push origin feature-name`).
183
+ 5. Open a pull request.
184
+
185
+ ## License
186
+
187
+ This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for details.
188
+
189
+ ## Contact
190
+
191
+ For any inquiries or issues, open an issue on the [GitHub repository](https://github.com/labgem/PanGBank-API/issues).
File without changes
@@ -0,0 +1,21 @@
1
+ from pydantic_settings import BaseSettings
2
+ from functools import lru_cache
3
+ from pathlib import Path
4
+ from typing import Annotated
5
+ from fastapi import Depends
6
+
7
+
8
+ class Settings(BaseSettings):
9
+ pangbank_db_path: Path = Path("database/database.db")
10
+ pangbank_data_dir: Path = Path("data/")
11
+ pangbank_origins: str = (
12
+ "http://localhost:3000" # list of origins separated by semicolon
13
+ )
14
+
15
+
16
+ @lru_cache
17
+ def get_settings():
18
+ return Settings()
19
+
20
+
21
+ SettingsDep = Annotated[Settings, Depends(get_settings)]
File without changes