seroverse.client¶
Asynchronous, token-bucket rate-limited HTTP clients and msgspec msgpack cassette utilities for querying NCBI, ENA, DSMZ BacDive, StrainInfo, and Pathogenwatch.
Base Client & Msgpack Cassettes (seroverse.client.base)¶
base
¶
Unified asynchronous HTTP client and msgspec serialization helpers for SeroVerse.
Classes:
| Name | Description |
|---|---|
Client |
High-performance asynchronous HTTP client powered by |
Client
¶
High-performance asynchronous HTTP client powered by aiohttp and msgspec.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
base_url
|
str
|
Base endpoint URL. |
required |
api_key_header
|
str | None
|
Optional HTTP header key for API authorization. |
None
|
api_key
|
str | None
|
Optional API key string. |
None
|
user_agent
|
str
|
User-Agent header value. |
'seroverse-client/0.1'
|
timeout
|
float
|
Total request timeout in seconds. |
30.0
|
max_concurrency
|
int
|
Maximum concurrent in-flight requests per event loop. |
5
|
polite_delay
|
float
|
Optional minimum delay (in seconds) after live network requests. |
0.0
|
recorder
|
Any | None
|
Optional |
None
|
Methods:
| Name | Description |
|---|---|
encode_msgpack |
Serialize an object or dataclass tree into compact MessagePack bytes. |
decode_msgpack |
Deserialize MessagePack bytes directly into a typed |
save_msgpack |
Atomically persist |
load_msgpack |
Load and decode a binary MessagePack file into |
polite_sleep |
Sleep politely after a live network request, skipping sleep on fast cassette replays. |
get_session |
Retrieve or instantiate the underlying |
close |
Close the underlying |
close_sync |
Close the underlying |
request |
Send an async HTTP request and return decoded JSON (via |
get |
Perform an async HTTP GET request. |
post |
Perform an async HTTP POST request. |
delete |
Perform an async HTTP DELETE request. |
stream_bytes |
Send an async HTTP request and read raw response bytes. |
get_json |
Fetch |
post_json |
Fetch |
stream_buffer |
Send an async HTTP request and return an in-memory |
stream_chunks |
Stream response bytes in chunks as an async generator, emitting progress when |
run_sync |
Execute a coroutine synchronously and close any session bound to the temporary event loop. |
Attributes:
| Name | Type | Description |
|---|---|---|
api_key |
str | None
|
Return the configured API key string, or |
Source code in src/seroverse/client/base.py
20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 | |
encode_msgpack
staticmethod
¶
decode_msgpack
staticmethod
¶
Deserialize MessagePack bytes directly into a typed @dataclass(frozen=True, slots=True) structure.
save_msgpack
staticmethod
¶
Atomically persist obj to path as binary MessagePack.
Source code in src/seroverse/client/base.py
load_msgpack
staticmethod
¶
polite_sleep
async
¶
Sleep politely after a live network request, skipping sleep on fast cassette replays.
Source code in src/seroverse/client/base.py
get_session
async
¶
Retrieve or instantiate the underlying aiohttp.ClientSession for the active event loop.
Source code in src/seroverse/client/base.py
close
async
¶
Close the underlying aiohttp.ClientSession if open.
Source code in src/seroverse/client/base.py
close_sync
¶
Close the underlying aiohttp.ClientSession synchronously.
Source code in src/seroverse/client/base.py
request
async
¶
Send an async HTTP request and return decoded JSON (via msgspec) or text.
Source code in src/seroverse/client/base.py
get
async
¶
post
async
¶
delete
async
¶
stream_bytes
async
¶
Send an async HTTP request and read raw response bytes.
Source code in src/seroverse/client/base.py
get_json
async
¶
Fetch endpoint via GET and decode JSON directly into type_ using msgspec.
Source code in src/seroverse/client/base.py
post_json
async
¶
Fetch endpoint via POST and decode JSON directly into type_ using msgspec.
Source code in src/seroverse/client/base.py
stream_buffer
async
¶
Send an async HTTP request and return an in-memory BytesIO stream.
stream_chunks
async
¶
stream_chunks(
method: str,
endpoint: str,
chunk_size: int = 65536,
**kwargs: Any,
) -> AsyncIterator[bytes]
Stream response bytes in chunks as an async generator, emitting progress when Content-Length is known.
Source code in src/seroverse/client/base.py
run_sync
¶
Execute a coroutine synchronously and close any session bound to the temporary event loop.
Source code in src/seroverse/client/base.py
NCBI Entrez & Datasets (seroverse.client.ncbi)¶
ncbi
¶
NCBI Entrez E-Utilities and NCBI Datasets v2 REST API client and models.
Classes:
| Name | Description |
|---|---|
NuccoreSummary |
Immutable NCBI |
PubMedArticleId |
Article identifier entry inside a PubMed |
PubMedSummary |
Immutable PubMed |
DatasetAssemblyReport |
Immutable NCBI Datasets v2 genome assembly report summary. |
NCBIClient |
Asynchronous client for NCBI Entrez E-Utilities and NCBI Datasets v2. |
NuccoreSummary
dataclass
¶
Immutable NCBI nuccore esummary record.
Source code in src/seroverse/client/ncbi.py
PubMedArticleId
dataclass
¶
PubMedSummary
dataclass
¶
Immutable PubMed esummary record.
Source code in src/seroverse/client/ncbi.py
DatasetAssemblyReport
dataclass
¶
Immutable NCBI Datasets v2 genome assembly report summary.
Source code in src/seroverse/client/ncbi.py
NCBIClient
¶
Bases: Client
Asynchronous client for NCBI Entrez E-Utilities and NCBI Datasets v2.
Methods:
| Name | Description |
|---|---|
esearch |
Run rate-limited |
esummary |
Run batched |
fetch_nuccore_summaries |
Fetch |
fetch_pubmed_summaries |
Fetch |
elink_pubmed_to_nuccore |
Map PubMed IDs to linked |
efetch_fasta |
Download multi-FASTA bytes for |
fetch_taxon_assemblies |
Query NCBI Datasets v2 |
download_assembly_fasta |
Download genome FASTA bytes for |
Source code in src/seroverse/client/ncbi.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
esearch
async
¶
Run rate-limited esearch.fcgi and return matching UID strings.
Source code in src/seroverse/client/ncbi.py
esummary
async
¶
Run batched esummary.fcgi POST requests and return {uid: info_dict}.
Source code in src/seroverse/client/ncbi.py
fetch_nuccore_summaries
async
¶
fetch_nuccore_summaries(
uids: Sequence[str],
*,
slen_range: tuple[int, int] | None = None,
chunk_size: int = 200,
) -> dict[str, NuccoreSummary]
Fetch NuccoreSummary records for uids, optionally filtering by sequence length slen_range.
Source code in src/seroverse/client/ncbi.py
fetch_pubmed_summaries
async
¶
fetch_pubmed_summaries(
pmids: Sequence[int | str], chunk_size: int = 150
) -> dict[int, PubMedSummary]
Fetch PubMedSummary records (including DOIs) for pmids.
Source code in src/seroverse/client/ncbi.py
elink_pubmed_to_nuccore
async
¶
Map PubMed IDs to linked nuccore UIDs via elink.fcgi (pubmed_nuccore).
Source code in src/seroverse/client/ncbi.py
efetch_fasta
async
¶
Download multi-FASTA bytes for uids via efetch.fcgi.
Source code in src/seroverse/client/ncbi.py
fetch_taxon_assemblies
async
¶
fetch_taxon_assemblies(
taxon: str, page_size: int = 1000
) -> list[DatasetAssemblyReport]
Query NCBI Datasets v2 genome/taxon/{taxon}/dataset_report and return assembly reports.
Source code in src/seroverse/client/ncbi.py
download_assembly_fasta
async
¶
Download genome FASTA bytes for accession via NCBI Datasets v2 archive endpoint.
Source code in src/seroverse/client/ncbi.py
ENA Portal & Browser (seroverse.client.ena)¶
ena
¶
Asynchronous client for the EMBL-EBI ENA Portal REST API.
Classes:
| Name | Description |
|---|---|
ENASampleRecord |
Immutable ENA Portal |
ENAAssemblyRecord |
Immutable ENA Portal |
ENAClient |
Asynchronous client for the EMBL-EBI ENA Portal API. |
ENASampleRecord
dataclass
¶
Immutable ENA Portal sample record decoded via msgspec.
Source code in src/seroverse/client/ena.py
ENAAssemblyRecord
dataclass
¶
Immutable ENA Portal assembly record decoded via msgspec.
Source code in src/seroverse/client/ena.py
ENAClient
¶
Bases: Client
Asynchronous client for the EMBL-EBI ENA Portal API.
Methods:
| Name | Description |
|---|---|
search_samples |
Query |
search_assemblies |
Query |
Source code in src/seroverse/client/ena.py
search_samples
async
¶
search_samples(
query: str,
fields: Sequence[str] = (
"sample_accession",
"scientific_name",
"strain",
"serotype",
"serovar",
"tax_id",
),
limit: int = 0,
) -> list[ENASampleRecord]
Query search?result=sample and decode directly into list[ENASampleRecord].
Source code in src/seroverse/client/ena.py
search_assemblies
async
¶
search_assemblies(
query: str,
fields: Sequence[str] = (
"accession",
"sample_accession",
"scientific_name",
"strain",
"tax_id",
),
limit: int = 0,
) -> list[ENAAssemblyRecord]
Query search?result=assembly and decode directly into list[ENAAssemblyRecord].
Source code in src/seroverse/client/ena.py
DSMZ BacDive & StrainInfo (seroverse.client.dsmz)¶
dsmz
¶
DSMZ StrainInfo v2 and BacDive v2 REST API clients and culture-collection models.
Classes:
| Name | Description |
|---|---|
StrainLiterature |
Immutable bibliographic entry linked to a StrainInfo culture deposit. |
StrainPassport |
Consolidated DSMZ StrainInfo v2 passport with culture-collection synonyms, PMIDs, and INSDC accessions. |
StrainInfoClient |
Asynchronous client for the public DSMZ StrainInfo v2 REST API. |
BacDiveClient |
Asynchronous client for the DSMZ BacDive v2 REST API. |
StrainLiterature
dataclass
¶
Immutable bibliographic entry linked to a StrainInfo culture deposit.
Source code in src/seroverse/client/dsmz.py
StrainPassport
dataclass
¶
Consolidated DSMZ StrainInfo v2 passport with culture-collection synonyms, PMIDs, and INSDC accessions.
Methods:
| Name | Description |
|---|---|
from_raw_dict |
Parse a raw StrainInfo |
Source code in src/seroverse/client/dsmz.py
from_raw_dict
classmethod
¶
from_raw_dict(raw: dict[str, Any]) -> StrainPassport | None
Parse a raw StrainInfo /v2/data/strain/max/ JSON object into a StrainPassport.
Source code in src/seroverse/client/dsmz.py
StrainInfoClient
¶
Bases: Client
Asynchronous client for the public DSMZ StrainInfo v2 REST API.
Methods:
| Name | Description |
|---|---|
search_by_taxon |
Return all StrainInfo IDs ( |
search_by_cc_no |
Return matching |
search_by_designation |
Return matching |
search_by_collection |
Return all |
fetch_passports |
Batch-fetch |
fetch_taxon_passports |
Search all strains for |
Source code in src/seroverse/client/dsmz.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 | |
search_by_taxon
async
¶
Return all StrainInfo IDs (SI-IDs) for a species or genus name.
search_by_cc_no
async
¶
Return matching SI-IDs for a culture collection number (e.g. ATCC 25238, NCTC 9001).
search_by_designation
async
¶
Return matching SI-IDs for an arbitrary strain designation (e.g. Prague 1550/57).
Source code in src/seroverse/client/dsmz.py
search_by_collection
async
¶
Return all SI-IDs deposited in a culture collection (e.g. CNCTC, NCTC, ATCC).
Source code in src/seroverse/client/dsmz.py
fetch_passports
async
¶
fetch_passports(
si_ids: Sequence[int], batch_size: int = 50
) -> list[StrainPassport]
Batch-fetch StrainPassport records for si_ids via /v2/data/strain/max/{ids}.
Source code in src/seroverse/client/dsmz.py
fetch_taxon_passports
async
¶
fetch_taxon_passports(
taxon_name: str, batch_size: int = 50
) -> list[StrainPassport]
Search all strains for taxon_name and batch-fetch their complete StrainPassport records.
Source code in src/seroverse/client/dsmz.py
BacDiveClient
¶
Bases: Client
Asynchronous client for the DSMZ BacDive v2 REST API.
Methods:
| Name | Description |
|---|---|
fetch_strain |
Fetch a BacDive strain record by its integer |
Source code in src/seroverse/client/dsmz.py
fetch_strain
async
¶
Fetch a BacDive strain record by its integer bacdive_id.
Source code in src/seroverse/client/dsmz.py
Pathogenwatch Collections (seroverse.client.pathogenwatch)¶
pathogenwatch
¶
Pathogenwatch REST API client and collection metadata models.
Classes:
| Name | Description |
|---|---|
PathogenwatchCollection |
Dataclass representing a Pathogenwatch collection metadata object. |
PathogenwatchCollectionBundle |
In-memory collection download bundle from Pathogenwatch. |
PathogenwatchClient |
Asynchronous and synchronous client for interacting with the Pathogenwatch REST API. |
PathogenwatchCollection
dataclass
¶
Dataclass representing a Pathogenwatch collection metadata object.
Attributes:
| Name | Type | Description |
|---|---|---|
uuid |
str
|
Short UUID identifier of the collection. |
name |
str
|
Human-readable title of the collection. |
id |
int | str | None
|
Optional numeric or string internal Pathogenwatch collection ID. |
description |
str | None
|
Optional collection description text. |
size |
int | None
|
Total number of genomes in the collection, or |
organism_id |
str | None
|
Taxonomic organism identifier. |
organism_name |
str | None
|
Human-readable species/organism name. |
owner |
str | None
|
Ownership tag (e.g., |
access |
str | None
|
Visibility/access level (e.g., |
binned |
bool | None
|
Whether the collection is binned/archived. |
created_at |
str | None
|
ISO timestamp string when the collection was created. |
Methods:
| Name | Description |
|---|---|
from_dict |
Instantiates a |
group_choices |
Builds grouped selectize choices organized by species/organism (with owned collections first). |
Source code in src/seroverse/client/pathogenwatch.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 | |
organism_label
property
¶
Returns the resolved human-readable species/organism label for grouping, or None.
is_owned
property
¶
Returns whether this collection belongs to the authenticated user ("me").
display_label
property
¶
Returns a human-readable selector label including genome count when available.
from_dict
classmethod
¶
from_dict(data: dict[str, Any]) -> PathogenwatchCollection
Instantiates a PathogenwatchCollection from a raw API dictionary payload.
Source code in src/seroverse/client/pathogenwatch.py
group_choices
staticmethod
¶
group_choices(
collections: Sequence[PathogenwatchCollection],
) -> dict[str, Any]
Builds grouped selectize choices organized by species/organism (with owned collections first).
Source code in src/seroverse/client/pathogenwatch.py
PathogenwatchCollectionBundle
dataclass
¶
In-memory collection download bundle from Pathogenwatch.
Attributes:
| Name | Type | Description |
|---|---|---|
uuid |
str
|
Short UUID identifier of the collection. |
name |
str
|
Resolved collection name. |
details |
dict[str, Any]
|
Raw collection details dictionary ( |
records |
tuple[dict[str, Any], ...]
|
Paginated genome records tuple. |
analyses |
tuple[tuple[str, bytes], ...]
|
Tuple of |
metadata_csv |
bytes | None
|
Downloaded isolate metadata CSV bytes, or |
matrix_csv |
bytes | None
|
Downloaded pairwise distance matrix CSV bytes, or |
fallback_newick |
bytes
|
First tree Newick byte string from |
Source code in src/seroverse/client/pathogenwatch.py
PathogenwatchClient
¶
Bases: Client
Asynchronous and synchronous client for interacting with the Pathogenwatch REST API.
Methods:
| Name | Description |
|---|---|
get_collections |
Fetches collections available to the authenticated account or public collections. |
get_collection |
Fetches complete metadata and analysis jobs for a specific collection. |
get_collection_genomes |
Fetches genome analysis records for a collection. |
download_distance_matrix |
Downloads pairwise genomic distance matrix CSV bytes for a collection. |
download_analysis |
Downloads discrete analysis CSV bytes (e.g. Kleborate, Kaptive) for a collection. |
download_kleborate |
Downloads Kleborate analysis CSV bytes for a collection. |
download_kaptive |
Downloads Kaptive analysis CSV bytes for a collection. |
download_metadata |
Downloads isolate metadata CSV bytes for a collection. |
download_summary |
Downloads summary CSV bytes for a collection. |
fetch_collection_bundle |
Downloads collection details, genomes, analyses, metadata, and distance matrix in memory. |
download_collection_files |
Downloads discrete collection files to an output directory on disk. |
default_analysis_types |
Selects the default genotype analysis types from a collection's |
get_collections_sync |
Synchronously fetches collections available to the authenticated account or public collections. |
get_collection_sync |
Synchronously fetches complete metadata and analysis jobs for a collection. |
get_collection_genomes_sync |
Synchronously fetches genome analysis records for a collection. |
download_distance_matrix_sync |
Synchronously downloads the pairwise genomic distance matrix CSV bytes for a collection. |
download_analysis_sync |
Synchronously downloads discrete analysis CSV bytes for a collection. |
download_kleborate_sync |
Synchronously downloads Kleborate analysis CSV bytes for a collection. |
download_kaptive_sync |
Synchronously downloads Kaptive analysis CSV bytes for a collection. |
download_metadata_sync |
Synchronously downloads isolate metadata CSV bytes for a collection. |
download_summary_sync |
Synchronously downloads summary CSV bytes for a collection. |
download_collection_files_sync |
Synchronously downloads collection CSV files to disk. |
fetch_collection_bundle_sync |
Synchronously downloads a collection bundle in memory. |
Source code in src/seroverse/client/pathogenwatch.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 | |
get_collections
async
¶
get_collections(
owner: str | None = None,
exclude: str | None = None,
binned: bool | None = None,
limit: int | None = None,
) -> list[PathogenwatchCollection]
Fetches collections available to the authenticated account or public collections.
Source code in src/seroverse/client/pathogenwatch.py
get_collection
async
¶
Fetches complete metadata and analysis jobs for a specific collection.
Source code in src/seroverse/client/pathogenwatch.py
get_collection_genomes
async
¶
get_collection_genomes(
uuid: str,
share_id: str | None = None,
page: int = 1,
all_pages: bool = True,
) -> list[dict[str, Any]]
Fetches genome analysis records for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_distance_matrix
async
¶
Downloads pairwise genomic distance matrix CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_analysis
async
¶
download_analysis(
uuid: str,
download_type: str,
job: str | None = None,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Downloads discrete analysis CSV bytes (e.g. Kleborate, Kaptive) for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_kleborate
async
¶
download_kleborate(
uuid: str,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Downloads Kleborate analysis CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_kaptive
async
¶
download_kaptive(
uuid: str,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Downloads Kaptive analysis CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_metadata
async
¶
download_metadata(
uuid: str,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Downloads isolate metadata CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_summary
async
¶
download_summary(
uuid: str,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Downloads summary CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
fetch_collection_bundle
async
¶
fetch_collection_bundle(
uuid: str,
*,
with_distances: bool = True,
with_metadata: bool = True,
matrix_type: str = "difference",
dataset_name: str | None = None,
strict_distances: bool = False,
analysis_types: Sequence[str] | str | None = None,
) -> PathogenwatchCollectionBundle
Downloads collection details, genomes, analyses, metadata, and distance matrix in memory.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uuid
|
str
|
Short UUID of the collection. |
required |
with_distances
|
bool
|
Whether to download the pairwise distance matrix CSV. |
True
|
with_metadata
|
bool
|
Whether to download spatiotemporal isolate metadata CSV. |
True
|
matrix_type
|
str
|
Distance matrix type ( |
'difference'
|
dataset_name
|
str | None
|
Optional custom name override. Defaults to the collection title. |
None
|
strict_distances
|
bool
|
If |
False
|
analysis_types
|
Sequence[str] | str | None
|
Optional analysis name or sequence of analysis names to fetch.
When |
None
|
Returns:
| Type | Description |
|---|---|
PathogenwatchCollectionBundle
|
In-memory |
Source code in src/seroverse/client/pathogenwatch.py
409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 | |
download_collection_files
async
¶
download_collection_files(
uuid: str,
output_dir: str | Path,
analysis_types: Sequence[str] = (
"kleborate",
"kaptive",
),
include_metadata: bool = True,
include_matrix: bool = True,
matrix_type: str = "difference",
prefix: str | None = None,
) -> dict[str, Path]
Downloads discrete collection files to an output directory on disk.
Source code in src/seroverse/client/pathogenwatch.py
default_analysis_types
staticmethod
¶
Selects the default genotype analysis types from a collection's downloads list.
Source code in src/seroverse/client/pathogenwatch.py
get_collections_sync
¶
get_collections_sync(
owner: str | None = None,
exclude: str | None = None,
binned: bool | None = None,
limit: int | None = None,
) -> list[PathogenwatchCollection]
Synchronously fetches collections available to the authenticated account or public collections.
Source code in src/seroverse/client/pathogenwatch.py
get_collection_sync
¶
Synchronously fetches complete metadata and analysis jobs for a collection.
get_collection_genomes_sync
¶
get_collection_genomes_sync(
uuid: str,
share_id: str | None = None,
page: int = 1,
all_pages: bool = True,
) -> list[dict[str, Any]]
Synchronously fetches genome analysis records for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_distance_matrix_sync
¶
Synchronously downloads the pairwise genomic distance matrix CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_analysis_sync
¶
download_analysis_sync(
uuid: str,
download_type: str,
job: str | None = None,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Synchronously downloads discrete analysis CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_kleborate_sync
¶
download_kleborate_sync(
uuid: str,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Synchronously downloads Kleborate analysis CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_kaptive_sync
¶
download_kaptive_sync(
uuid: str,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Synchronously downloads Kaptive analysis CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_metadata_sync
¶
download_metadata_sync(
uuid: str,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Synchronously downloads isolate metadata CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_summary_sync
¶
download_summary_sync(
uuid: str,
genome_ids: Sequence[str] | None = None,
prefix: str | None = None,
) -> bytes
Synchronously downloads summary CSV bytes for a collection.
Source code in src/seroverse/client/pathogenwatch.py
download_collection_files_sync
¶
download_collection_files_sync(
uuid: str,
output_dir: str | Path,
analysis_types: Sequence[str] = (
"kleborate",
"kaptive",
),
include_metadata: bool = True,
include_matrix: bool = True,
matrix_type: str = "difference",
prefix: str | None = None,
) -> dict[str, Path]
Synchronously downloads collection CSV files to disk.
Source code in src/seroverse/client/pathogenwatch.py
fetch_collection_bundle_sync
¶
fetch_collection_bundle_sync(
uuid: str,
*,
with_distances: bool = True,
with_metadata: bool = True,
matrix_type: str = "difference",
dataset_name: str | None = None,
strict_distances: bool = False,
analysis_types: Sequence[str] | str | None = None,
) -> PathogenwatchCollectionBundle
Synchronously downloads a collection bundle in memory.