plasrisk 1.0.0__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.
plasrisk-1.0.0/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2025 PlasRisk Team
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,11 @@
1
+ include README.md
2
+ include LICENSE
3
+ include pyproject.toml
4
+ include setup.py
5
+ include MANIFEST.in
6
+ recursive-include plasrisk/data *.csv
7
+ recursive-include tests *.py *.fasta
8
+ recursive-include docs *.html *.svg
9
+ prune .github
10
+ prune bioconda
11
+ prune conda
@@ -0,0 +1,415 @@
1
+ Metadata-Version: 2.4
2
+ Name: plasrisk
3
+ Version: 1.0.0
4
+ Summary: PlasRisk: ten-dimension data-driven weighted risk assessment for bacterial plasmids from FASTA sequences
5
+ Author: PlasRisk Team
6
+ Maintainer: PlasRisk Team
7
+ License-Expression: MIT
8
+ Project-URL: Homepage, https://github.com/LLQ95/PlasRisk
9
+ Project-URL: Repository, https://github.com/LLQ95/PlasRisk
10
+ Project-URL: Issues, https://github.com/LLQ95/PlasRisk/issues
11
+ Project-URL: Documentation, https://github.com/LLQ95/PlasRisk#readme
12
+ Project-URL: Changelog, https://github.com/LLQ95/PlasRisk/releases
13
+ Keywords: bioinformatics,plasmid,antimicrobial resistance,AMR,risk assessment,microbial genomics,One Health,biocide resistance,co-selection,horizontal gene transfer
14
+ Classifier: Development Status :: 4 - Beta
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Scientific/Engineering :: Bio-Informatics
17
+ Classifier: Programming Language :: Python :: 3
18
+ Classifier: Programming Language :: Python :: 3.8
19
+ Classifier: Programming Language :: Python :: 3.9
20
+ Classifier: Programming Language :: Python :: 3.10
21
+ Classifier: Programming Language :: Python :: 3.11
22
+ Classifier: Programming Language :: Python :: 3.12
23
+ Classifier: Operating System :: OS Independent
24
+ Classifier: Environment :: Console
25
+ Requires-Python: >=3.8
26
+ Description-Content-Type: text/markdown
27
+ License-File: LICENSE
28
+ Requires-Dist: pandas>=1.3
29
+ Requires-Dist: numpy>=1.20
30
+ Provides-Extra: dev
31
+ Requires-Dist: pytest>=7.0; extra == "dev"
32
+ Requires-Dist: pytest-cov; extra == "dev"
33
+ Requires-Dist: build; extra == "dev"
34
+ Requires-Dist: twine; extra == "dev"
35
+ Provides-Extra: full
36
+ Requires-Dist: biopython>=1.79; extra == "full"
37
+ Dynamic: license-file
38
+
39
+ # PlasRisk
40
+
41
+ **10-dimension data-driven weighted risk assessment for bacterial plasmids from FASTA sequences**
42
+
43
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
44
+ [![Python](https://img.shields.io/badge/python-3.8+-blue.svg)](https://python.org)
45
+
46
+ PlasRisk computes a composite risk score for bacterial plasmids based on ten
47
+ data-driven weighted dimensions: antimicrobial resistance gene (ARG) burden,
48
+ virulence factors (VFs), mobility/conjugation potential, host range, replicon
49
+ type, plasmid size, biocide/metal resistance (BMRG), geographic spread, habitat
50
+ breadth, and temporal growth rate. It accepts plasmid FASTA sequences and
51
+ automatically annotates them using [abricate](https://github.com/tseemann/abricate).
52
+
53
+ ```
54
+ S = 0.245*S_ARG + 0.110*S_VF + 0.204*S_MOB + 0.028*S_HOST
55
+ + 0.003*S_REP + 0.181*S_SIZE + 0.211*S_BM
56
+ + 0.002*S_GEO + 0.002*S_HAB + 0.015*S_GROW
57
+
58
+ Weights derived by data-driven consensus (Random Forest MDG, LASSO, and
59
+ grid-search optimization) on 792,964 PIPdb PSCs; sum ≈ 1.0.
60
+ ```
61
+
62
+ Risk grades: **A** (Very High, S >= 0.60), **B** (High, >= 0.45),
63
+ **C** (Moderate, >= 0.30), **D** (Low, >= 0.15), **E** (Minimal, < 0.15).
64
+
65
+ ---
66
+
67
+ ## Installation
68
+
69
+ ### Option 1: conda (recommended)
70
+
71
+ ```bash
72
+ # Create a dedicated environment
73
+ conda create -n plasrisk -c bioconda -c conda-forge plasrisk
74
+ conda activate plasrisk
75
+
76
+ # Optional: install abricate and blast for full annotation capability
77
+ conda install -c bioconda -c conda-forge abricate blast
78
+ ```
79
+
80
+ PlasRisk can run without abricate in sequence-only mode (`--no-abricate`),
81
+ scoring based on plasmid length and replicon lookup priors.
82
+
83
+ ### Option 2: pip + manual abricate
84
+
85
+ ```bash
86
+ pip install plasrisk
87
+
88
+ # Install abricate separately for full annotation
89
+ conda install -c bioconda abricate
90
+ # or on Debian/Ubuntu: apt-get install abricate
91
+ ```
92
+
93
+ ### Option 3: from source
94
+
95
+ ```bash
96
+ git clone https://github.com/LLQ95/PlasRisk.git
97
+ cd PlasRisk
98
+ pip install .
99
+
100
+ # Install annotation dependencies (optional)
101
+ conda install -c bioconda abricate blast
102
+ ```
103
+
104
+ ### Set up abricate databases
105
+
106
+ After installing abricate, download the databases you need:
107
+
108
+ ```bash
109
+ # Download/update all default databases
110
+ abricate-get_db --db card --force
111
+ abricate-get_db --db vfdb --force
112
+ abricate-get_db --db plasmidfinder --force
113
+ abricate-get_db --db resfinder --force
114
+ abricate-get_db --db ncbi --force
115
+
116
+ # Verify
117
+ abricate --list
118
+ ```
119
+
120
+ For BacMet (biocide/metal resistance) database, see:
121
+ https://github.com/tseemann/abricate#making-your-own-database
122
+
123
+ ---
124
+
125
+ ## Quick start
126
+
127
+ ```bash
128
+ # Score a single plasmid
129
+ plasrisk plasmid.fasta
130
+
131
+ # Score multiple plasmids
132
+ plasrisk *.fasta
133
+
134
+ # Score all FASTA files in a directory
135
+ plasrisk /path/to/plasmids/
136
+
137
+ # Specify output directory
138
+ plasrisk -o results *.fasta
139
+
140
+ # Use specific abricate databases
141
+ plasrisk --db card,vfdb,plasmidfinder,bacmet plasmid.fasta
142
+
143
+ # Sequence-only mode (no abricate needed; scores based on length + replicon lookup)
144
+ plasrisk --no-abricate contigs.fasta
145
+
146
+ # JSON output
147
+ plasrisk --json -o results plasmid.fasta
148
+ ```
149
+
150
+ ### Example output
151
+
152
+ ```
153
+ Grade A: 3 ( 3.2%) ######
154
+ Grade B: 12 ( 12.9%) ##########################
155
+ Grade C: 28 ( 30.1%) ############################################################
156
+ Grade D: 35 ( 37.6%) ############################################################################
157
+ Grade E: 15 ( 16.1%) ################################
158
+
159
+ Top 10 highest-risk plasmids:
160
+ pNDM-1_260kb S=0.712 grade A 8 ARG IncX3 [blaNDM]
161
+ pMCR-1_33kb S=0.581 grade B 4 ARG IncX4 [mcr]
162
+ pKPC-2_110kb S=0.534 grade B 6 ARG IncFII(K) [blaKPC]
163
+ ```
164
+
165
+ ### Output files
166
+
167
+ | File | Description |
168
+ |------|-------------|
169
+ | `plasrisk_results.tsv` | Per-sequence scores: all 10 components, S_total, S_norm, grade, gene lists |
170
+ | `plasrisk_summary.tsv` | Per-file summary: counts, grade distribution, mean/max scores |
171
+ | `plasrisk_results.json` | JSON format (with `--json`) |
172
+
173
+ ---
174
+
175
+ ## Python API
176
+
177
+ ```python
178
+ from plasrisk import PlasRiskScorer, PlasmidFeatures, annotate_fasta, load_replicon_lookup
179
+
180
+ # Option A: annotate a FASTA file directly
181
+ lookup = load_replicon_lookup()
182
+ result = annotate_fasta("plasmid.fasta", lookup=lookup)
183
+ scorer = PlasRiskScorer(replicon_lookup=lookup)
184
+ df = scorer.score_dataframe(result.features)
185
+ print(df[["seq_id", "S_norm", "grade", "high_risk_genes"]])
186
+
187
+ # Option B: construct features manually
188
+ feat = PlasmidFeatures(
189
+ seq_id="pExample",
190
+ length_bp=85000,
191
+ arg_names=["NDM-1", "CTX-M-15", "TEM-1"],
192
+ vf_names=["aerobactin"],
193
+ vf_categories=["Nutritional/Metabolic factor"],
194
+ bm_gene_names=["merA", "qacEdelta1"],
195
+ replicon="IncX3",
196
+ has_t4cp=True,
197
+ has_relaxase=True,
198
+ has_oriT=True,
199
+ has_auxiliary=True,
200
+ )
201
+ scores = scorer.score(feat)
202
+ print(f"S_norm = {scores['S_norm']:.3f}, grade = {scores['grade']}")
203
+ ```
204
+
205
+ ---
206
+
207
+ ## The 10 risk dimensions
208
+
209
+ | Component | Weight | What it measures | Scoring basis |
210
+ |-----------|--------|------------------|---------------|
211
+ | **S_ARG** | 0.245 | ARG count, WHO-priority genes, high-risk genes (mcr, NDM, KPC, CTX-M, tetX, etc.) | Base + per-gene + high-risk bonuses |
212
+ | **S_BM** | 0.211 | Biocide/metal resistance (mer, qac, ars/cop/sil) — co-selection potential | Base + per-gene + family bonuses |
213
+ | **S_MOB** | 0.204 | T4CP, relaxase, oriT, auxiliary transfer proteins | Element-based additive score |
214
+ | **S_SIZE** | 0.181 | Plasmid length (cargo capacity) | Sigmoid: midpoint 30 kb |
215
+ | **S_VF** | 0.110 | VF count, exotoxins, secretion systems (T3SS/T4SS) | Base + per-gene + category bonuses |
216
+ | **S_HOST** | 0.028 | Number of host genera / replicon prior | Empirical host range or lookup |
217
+ | **S_GROW** | 0.015 | Annual growth rate of the replicon | PIPdb-derived lookup |
218
+ | **S_REP** | 0.003 | Replicon backbone risk (IncX3, IncN, ColKP3 high; ColpVC low) | PIPdb-derived lookup table |
219
+ | **S_HAB** | 0.002 | Habitat breadth (human/animal/environment) | PIPdb-derived lookup |
220
+ | **S_GEO** | 0.002 | Number of countries observed | PIPdb-derived lookup |
221
+
222
+ ---
223
+
224
+ ## Command-line options
225
+
226
+ ```
227
+ plasrisk [options] <fasta1> [fasta2 ...]
228
+
229
+ positional arguments:
230
+ FASTA FASTA file(s) or directory
231
+
232
+ options:
233
+ -o, --output DIR Output directory (default: ./plasrisk_output)
234
+ -t, --threads N Number of abricate threads (default: 4)
235
+ --min-id FLOAT Minimum abricate identity % (default: 75)
236
+ --min-cov FLOAT Minimum abricate coverage % (default: 50)
237
+ --no-abricate Skip abricate; sequence-only scoring
238
+ --db LIST Comma-separated abricate databases (default: auto)
239
+ --json Also write JSON output
240
+ -q, --quiet Suppress progress messages
241
+ -v, --version Show version
242
+ -h, --help Show help
243
+ ```
244
+
245
+ ---
246
+
247
+ ## Model validation
248
+
249
+ The PlasRisk model was developed and validated using 792,964 plasmid sequence
250
+ clusters from PIPdb (Zhu et al., *Nucleic Acids Res.*, 2025). Validation
251
+ included:
252
+
253
+ - **Quartile stratification**: Q1 (highest risk) plasmids had 92.3% ARG prevalence,
254
+ 28.2% high-risk ARG rate, 17.5% conjugative rate (vs. 0% in Q4).
255
+ - **Data-driven weights**: RF-MDG, LASSO, and grid-search optimization across four
256
+ outcomes (high-risk ARG, MDR-VF fusion, conjugative capacity, BMRG carriage)
257
+ converged on S_ARG (0.245), S_BM (0.211), S_MOB (0.204), and S_SIZE (0.181)
258
+ as dominant predictors.
259
+ - **AUC validation**: Final weights achieved AUC 0.956 (high-risk ARG), 0.961
260
+ (MDR-VF fusion), 0.856 (conjugation), 0.902 (BMRG); mean 0.919.
261
+ - **Leave-one-replicon-out CV**: mean AUC = 0.962 across 40 replicons.
262
+ - **Weight perturbation sensitivity** (100 iterations, +/-30%): mean Spearman
263
+ rho = 0.994, mean top-10 overlap = 9.2/10.
264
+ - **External validation**: 40 independent NCBI plasmids correctly classified
265
+ (18/20 high-risk Grade A, 19/20 low-risk Grade D/E).
266
+
267
+ ---
268
+
269
+ ## Uploading to conda (bioconda)
270
+
271
+ To make PlasRisk installable via `conda install -c bioconda plasrisk`:
272
+
273
+ ### Step 1: Upload to PyPI
274
+
275
+ ```bash
276
+ # Install build tools
277
+ pip install build twine
278
+
279
+ # Build distributions
280
+ python -m build
281
+
282
+ # Upload to PyPI
283
+ twine upload dist/*
284
+ ```
285
+
286
+ ### Step 2: Fork and clone bioconda-recipes
287
+
288
+ ```bash
289
+ git clone https://github.com/bioconda/bioconda-recipes.git
290
+ cd bioconda-recipes
291
+ ```
292
+
293
+ ### Step 3: Create the recipe
294
+
295
+ ```bash
296
+ # Create recipe directory
297
+ mkdir -p recipes/plasrisk
298
+ ```
299
+
300
+ Create `recipes/plasrisk/meta.yaml`:
301
+
302
+ ```yaml
303
+ {% set version = "1.0.0" %}
304
+
305
+ package:
306
+ name: plasrisk
307
+ version: {{ version }}
308
+
309
+ source:
310
+ url: https://pypi.io/packages/source/p/plasrisk/plasrisk-{{ version }}.tar.gz
311
+ sha256: <SHA256 from PyPI>
312
+
313
+ build:
314
+ number: 0
315
+ noarch: python
316
+ entry_points:
317
+ - plasrisk = plasrisk.cli:main
318
+ script: "{{ PYTHON }} -m pip install . --no-deps --ignore-installed -vv"
319
+
320
+ requirements:
321
+ host:
322
+ - python >=3.8
323
+ - pip
324
+ - setuptools >=61.0
325
+ - wheel
326
+ run:
327
+ - python >=3.8
328
+ - pandas >=1.3
329
+ - numpy >=1.20
330
+ # abricate/blast optional; CLI falls back to --no-abricate mode
331
+
332
+ test:
333
+ imports:
334
+ - plasrisk
335
+ commands:
336
+ - plasrisk --help
337
+ - plasrisk --version
338
+
339
+ about:
340
+ home: https://github.com/LLQ95/PlasRisk
341
+ license: MIT
342
+ license_file: LICENSE
343
+ summary: "Ten-dimension data-driven weighted risk assessment for bacterial plasmids"
344
+ ```
345
+
346
+ > **Note:** The complete, ready-to-submit recipe is in the `bioconda/` directory.
347
+ > See `UPLOAD_GUIDE.md` for the full step-by-step release process.
348
+
349
+ ### Step 4: Test locally
350
+
351
+ ```bash
352
+ # Install bioconda-utils
353
+ conda install -c bioconda bioconda-utils
354
+
355
+ # Test the recipe
356
+ bioconda-utils build recipes/plasrisk --docker
357
+ ```
358
+
359
+ ### Step 5: Submit a pull request
360
+
361
+ ```bash
362
+ git checkout -b plasrisk
363
+ git add recipes/plasrisk/
364
+ git commit -m "Add plasrisk recipe"
365
+ git push origin plasrisk
366
+ # Open PR at https://github.com/bioconda/bioconda-recipes
367
+ ```
368
+
369
+ Once the PR is merged and CI passes, PlasRisk will be installable via:
370
+
371
+ ```bash
372
+ conda install -c bioconda plasrisk
373
+ ```
374
+
375
+ ### Local conda build (without bioconda)
376
+
377
+ ```bash
378
+ # Build from the conda/ directory in this repo
379
+ conda build conda/
380
+
381
+ # Install locally
382
+ conda install --use-local plasrisk
383
+ ```
384
+
385
+ ---
386
+
387
+ ## Running tests
388
+
389
+ ```bash
390
+ cd PlasRisk
391
+ python -m pytest tests/ -v
392
+ # or
393
+ python tests/test_scoring.py
394
+ ```
395
+
396
+ ---
397
+
398
+ ## Citation
399
+
400
+ If you use PlasRisk, please cite:
401
+
402
+ > [Authors]. PlasRisk: a ten-dimension data-driven weighted risk assessment
403
+ > framework for bacterial plasmids. *Journal*, 2025. doi: [to be added]
404
+
405
+ The model is based on data from:
406
+ > Zhu Q, Chen Q, Lu X, et al. PIPdb: a comprehensive plasmid sequence resource
407
+ > for tracking the horizontal transfer of pathogenic factors and antimicrobial
408
+ > resistance genes. *Nucleic Acids Research*, 2025, 53(D1):D169-D178.
409
+ > doi:10.1093/nar/gkae952
410
+
411
+ ---
412
+
413
+ ## License
414
+
415
+ MIT License - see [LICENSE](LICENSE) for details.