seroref.db¶
Data-oriented species specifications (BacterialSpecies, SpeciesSpec, SpeciesSpecs), deduplicated reference strain isolates (ReferenceStrain, ReferenceStrains), and relational Structure-of-Arrays (SoA) locus records (SeroRefRecord, SeroRefRecords).
Species Specifications & Serotype Rules (seroref.db.species)¶
species
¶
Data-oriented bacterial species ontology, serotype grammars, and SoA SpeciesSpecs container.
Classes:
| Name | Description |
|---|---|
GramStain |
Cell-envelope Gram stain classification ( |
SerotypeRule |
Declarative rule mapping a serotype token prefix to its |
SpeciesSpec |
Immutable biological specification for a canonical |
SpeciesSpecs |
Ragged Structure-of-Arrays (SoA) batch container over |
BacterialSpecies |
Canonical bacterial species ontology ( |
Functions:
| Name | Description |
|---|---|
archetypes_to_mask |
Pack a collection of |
mask_to_archetypes |
Unpack a 32-bit integer presence bitmask into a sorted tuple of |
GramStain
¶
Bases: IntEnum
Cell-envelope Gram stain classification (0..3) for bacterial species.
Methods:
| Name | Description |
|---|---|
from_name |
Resolve a |
resolve |
Resolve a |
Attributes:
| Name | Type | Description |
|---|---|---|
label |
bytes
|
Canonical ASCII byte-string label for this Gram stain class. |
label_str |
str
|
Canonical UTF-8 string label for this Gram stain class. |
Source code in src/seroref/db/species.py
from_name
classmethod
¶
Resolve a GramStain by enum ID, enum name, or label.
Source code in src/seroref/db/species.py
resolve
classmethod
¶
Resolve a GramStain identifier, falling back to default (or GramStain.UNKNOWN).
Source code in src/seroref/db/species.py
SerotypeRule
dataclass
¶
Bases: ScalarView
Declarative rule mapping a serotype token prefix to its ArchetypeCategory and canonical prefix.
Source code in src/seroref/db/species.py
SpeciesSpec
dataclass
¶
Bases: ScalarView
Immutable biological specification for a canonical BacterialSpecies.
Encapsulates taxonomic identity, cell-envelope architecture, expected LocusArchetype bitmask,
declarative serotype formula rules, serovar-to-O-group mappings, and landmark BGC accession series.
Methods:
| Name | Description |
|---|---|
supports_archetype |
Return |
is_strain_or_mutant_token |
Return |
canonicalize_token |
Normalize a single serotype token into |
parse_serotype |
Parse a single or multi-antigen serotype formula (e.g. |
normalize_strain |
Normalize a strain isolate designation, rescuing strain/serovar tokens from |
Attributes:
| Name | Type | Description |
|---|---|---|
scientific_name |
bytes
|
Canonical scientific name as ASCII bytes (alias for |
synonyms |
tuple[bytes, ...]
|
Taxonomic synonyms and genus aliases as ASCII bytes (alias for |
name_str |
str
|
UTF-8 scientific name of this bacterial species. |
scientific_name_str |
str
|
UTF-8 scientific name of this bacterial species. |
genus |
bytes
|
Genus byte string extracted from |
archetypes |
tuple[LocusArchetype, ...]
|
Sorted tuple of |
Source code in src/seroref/db/species.py
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 | |
scientific_name
property
¶
Canonical scientific name as ASCII bytes (alias for self.name).
synonyms
property
¶
Taxonomic synonyms and genus aliases as ASCII bytes (alias for self.aliases).
scientific_name_str
property
¶
UTF-8 scientific name of this bacterial species.
archetypes
property
¶
archetypes: tuple[LocusArchetype, ...]
Sorted tuple of LocusArchetypes compatible with this species.
supports_archetype
¶
supports_archetype(archetype: LocusArchetype) -> bool
Return True if archetype is enabled in self.archetype_mask.
is_strain_or_mutant_token
¶
Return True if token is a laboratory strain, culture-collection ID, or genetic mutant.
Source code in src/seroref/db/species.py
canonicalize_token
¶
canonicalize_token(
raw_token: str | bytes,
*,
archetype: LocusArchetype | None = None,
) -> tuple[ArchetypeCategory, bytes] | None
Normalize a single serotype token into (ArchetypeCategory, canonical_bytes) or None.
Source code in src/seroref/db/species.py
parse_serotype
¶
parse_serotype(
raw: str | bytes,
*,
archetype: LocusArchetype | None = None,
) -> tuple[tuple[ArchetypeCategory, bytes], ...]
Parse a single or multi-antigen serotype formula (e.g. b"O1:K1(L1):H7") into typed tokens.
Source code in src/seroref/db/species.py
normalize_strain
¶
Normalize a strain isolate designation, rescuing strain/serovar tokens from raw_serotype when needed.
Source code in src/seroref/db/species.py
SpeciesSpecs
dataclass
¶
Bases: RaggedArrayContainer[SpeciesSpec, 'SpeciesSpecs']
Ragged Structure-of-Arrays (SoA) batch container over SpeciesSpec specifications.
All 1D fields share leading dimension len(self) (52 for the canonical BacterialSpecies ontology).
Variable-length per-species metadata (aliases, serotype_rules, serovar_map, landmark_accessions,
and known_serotypes) are CSR-packed into contiguous NumPy arrays without Python object tuples.
Methods:
| Name | Description |
|---|---|
empty |
Create an empty 0-length |
from_list |
Compile a sequence of |
concat |
Concatenate multiple |
Attributes:
| Name | Type | Description |
|---|---|---|
scientific_names |
ndarray[tuple[int], dtype[bytes_]]
|
1D byte-string array of canonical scientific names (alias for |
alias_offsets |
ndarray[tuple[int], dtype[int32]]
|
Alias for |
alias_lengths |
ndarray[tuple[int], dtype[int32]]
|
Alias for |
Source code in src/seroref/db/species.py
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 | |
scientific_names
property
¶
1D byte-string array of canonical scientific names (alias for self.names).
alias_offsets
property
¶
Alias for self.offsets (starting indices into self.alias_values).
alias_lengths
property
¶
Alias for self.lengths (number of taxonomic aliases per species).
empty
classmethod
¶
Create an empty 0-length SpeciesSpecs container.
Source code in src/seroref/db/species.py
from_list
classmethod
¶
from_list(specs: Sequence[SpeciesSpec]) -> Self
Compile a sequence of SpeciesSpec scalar views into a SpeciesSpecs SoA container.
Source code in src/seroref/db/species.py
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 | |
concat
classmethod
¶
Concatenate multiple SpeciesSpecs containers.
BacterialSpecies
¶
Bases: IntEnum
Canonical bacterial species ontology (0..51) for SeroRef reference loci and strains.
Follows the same data-oriented IntEnum + frozen SpeciesSpec + SpeciesSpecs pattern as
LocusArchetype and GeneRole.
Methods:
| Name | Description |
|---|---|
parse_serotype |
Parse and normalize a single or multi-antigen serotype formula using this species' grammar. |
normalize_strain |
Normalize a strain isolate designation for this species. |
from_name |
Resolve a |
resolve |
Resolve a species identifier, falling back to |
from_taxid |
Resolve a |
specs |
Return the cached singleton |
Attributes:
| Name | Type | Description |
|---|---|---|
spec |
SpeciesSpec
|
Return the immutable |
name_bytes |
bytes
|
Canonical scientific name as ASCII bytes (e.g. |
scientific_name |
bytes
|
Canonical scientific name as ASCII bytes (e.g. |
name_str |
str
|
Canonical scientific name as UTF-8 |
scientific_name_str |
str
|
Canonical scientific name as UTF-8 |
ncbi_taxid |
int
|
Species-level NCBI Taxonomy ID. |
gram_stain |
GramStain
|
Gram stain classification ( |
default_category |
ArchetypeCategory
|
Default surface polysaccharide |
archetype_mask |
int
|
32-bit bitmask of |
aliases |
tuple[bytes, ...]
|
Taxonomic synonyms and genus aliases for this species. |
synonyms |
tuple[bytes, ...]
|
Taxonomic synonyms and genus aliases for this species (alias for |
landmark_accessions |
tuple[tuple[bytes, bytes], ...]
|
Landmark INSDC BGC accession intervals for this species. |
Source code in src/seroref/db/species.py
797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 | |
name_bytes
property
¶
Canonical scientific name as ASCII bytes (e.g. b"Escherichia coli").
scientific_name
property
¶
Canonical scientific name as ASCII bytes (e.g. b"Escherichia coli").
gram_stain
property
¶
gram_stain: GramStain
Gram stain classification (GramStain.NEGATIVE or GramStain.POSITIVE).
default_category
property
¶
default_category: ArchetypeCategory
Default surface polysaccharide ArchetypeCategory when serotype tokens lack an explicit prefix.
archetype_mask
property
¶
32-bit bitmask of LocusArchetypes compatible with this species.
aliases
property
¶
Taxonomic synonyms and genus aliases for this species.
synonyms
property
¶
Taxonomic synonyms and genus aliases for this species (alias for self.aliases).
landmark_accessions
property
¶
Landmark INSDC BGC accession intervals for this species.
parse_serotype
¶
parse_serotype(
raw: str | bytes,
*,
archetype: LocusArchetype | None = None,
) -> tuple[tuple[ArchetypeCategory, bytes], ...]
Parse and normalize a single or multi-antigen serotype formula using this species' grammar.
Source code in src/seroref/db/species.py
normalize_strain
¶
Normalize a strain isolate designation for this species.
from_name
classmethod
¶
from_name(
key: str | bytes | int | BacterialSpecies,
) -> BacterialSpecies
Resolve a BacterialSpecies by enum ID, scientific name, enum name, or taxonomic alias.
Source code in src/seroref/db/species.py
resolve
classmethod
¶
resolve(
key: str | bytes | int | BacterialSpecies,
default: BacterialSpecies | None = None,
) -> BacterialSpecies
Resolve a species identifier, falling back to default (or BacterialSpecies.UNKNOWN).
Source code in src/seroref/db/species.py
from_taxid
classmethod
¶
from_taxid(taxid: int) -> BacterialSpecies
Resolve a BacterialSpecies from an NCBI Taxonomy ID, or BacterialSpecies.UNKNOWN.
specs
classmethod
¶
specs() -> SpeciesSpecs
Return the cached singleton SpeciesSpecs SoA container over all BacterialSpecies.
archetypes_to_mask
¶
archetypes_to_mask(
archetypes: Iterable[int | LocusArchetype],
) -> int
Pack a collection of LocusArchetype values into a 32-bit integer presence bitmask.
Source code in src/seroref/db/species.py
mask_to_archetypes
¶
mask_to_archetypes(mask: int) -> tuple[LocusArchetype, ...]
Unpack a 32-bit integer presence bitmask into a sorted tuple of LocusArchetype enums.
Scalar Views (seroref.db.models)¶
models
¶
OOP scalar data models for ReferenceStrain and SeroRefRecord.
Classes:
| Name | Description |
|---|---|
ReferenceStrain |
Immutable scalar view of a reference bacterial strain isolate and genome assembly. |
SeroRefRecord |
Immutable scalar view of a reference bacterial antigen locus record in |
Functions:
| Name | Description |
|---|---|
archetype_to_antigen_type |
Map a |
ReferenceStrain
dataclass
¶
Bases: ScalarView
Immutable scalar view of a reference bacterial strain isolate and genome assembly.
Attributes:
| Name | Type | Description |
|---|---|---|
species |
BacterialSpecies
|
Canonical |
name |
bytes
|
Normalized primary reference strain designation (e.g. |
synonyms |
tuple[bytes, ...]
|
Culture-collection and laboratory strain equivalence clique from DSMZ StrainInfo v2. |
assembly_id |
bytes
|
INSDC genome assembly or nucleotide accession (e.g. |
ncbi_taxid |
int
|
Strain-specific or species-level NCBI Taxonomy ID integer. |
straininfo_id |
int
|
DSMZ StrainInfo |
bacdive_id |
int
|
DSMZ BacDive ID integer, or |
pmids |
tuple[int, ...]
|
Tuple of PubMed IDs associated with this reference strain or assembly. |
Methods:
| Name | Description |
|---|---|
from_raw |
Construct a normalized |
with_passport |
Enrich this |
merge |
Merge metadata from another |
bind_loci |
Bind a batch of predicted |
Source code in src/seroref/db/models.py
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 | |
effective_taxid
property
¶
Resolved NCBI Taxonomy ID, falling back to self.species.ncbi_taxid when self.ncbi_taxid == 0.
compound_key
property
¶
Unique composite strain-assembly key b"<organism>|<name>|<assembly_id>".
from_raw
classmethod
¶
from_raw(
organism: str | bytes | int | BacterialSpecies,
strain: str | bytes = b"",
*,
raw_serotype: str | bytes = b"",
synonyms: Sequence[bytes | str] = (),
assembly_id: bytes | str = b"",
ncbi_taxid: int = 0,
straininfo_id: int = 0,
bacdive_id: int = 0,
pmids: Sequence[int] = (),
) -> Self
Construct a normalized ReferenceStrain using BacterialSpecies rules.
Source code in src/seroref/db/models.py
with_passport
¶
Enrich this ReferenceStrain with culture-collection synonyms and IDs from a StrainPassport.
Source code in src/seroref/db/models.py
merge
¶
merge(other: ReferenceStrain) -> Self
Merge metadata from another ReferenceStrain describing the same isolate or assembly.
Source code in src/seroref/db/models.py
bind_loci
¶
bind_loci(
loci: Loci, raw_serotype: str | bytes = b""
) -> list[SeroRefRecord]
Bind a batch of predicted Loci on this reference assembly into SeroRefRecord rows.
Splits multi-antigen formulas (e.g. 'O1:K1(L1):H7') across predicted ArchetypeCategory
groups (O-Antigen, Capsule, Exopolysaccharide, Other), assigns invariant glycan names
(Pel, PNAG, Alginate, Cellulose) to exopolysaccharide archetypes, and synchronizes
locus.name with the resolved serotype.
Source code in src/seroref/db/models.py
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 | |
SeroRefRecord
dataclass
¶
Bases: ScalarView
Immutable scalar view of a reference bacterial antigen locus record in SeroRefRecords.
Attributes:
| Name | Type | Description |
|---|---|---|
strain_record |
ReferenceStrain
|
Parent |
serotype |
bytes
|
Canonical serotype or glycan name (e.g. |
locus |
Locus | None
|
Predicted |
Methods:
| Name | Description |
|---|---|
from_fields |
Construct a |
merge |
Merge metadata from another |
Source code in src/seroref/db/models.py
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 | |
strain_synonyms
property
¶
All equivalent culture-collection and lab designations from DSMZ StrainInfo v2.
assembly_id
property
¶
INSDC genome assembly or nucleotide accession (e.g. b"GCA_900706755.1").
pmids
property
¶
Tuple of PubMed IDs associated with this reference strain or locus.
archetype
property
¶
archetype: LocusArchetype
Return the LocusArchetype of the reference locus, or LocusArchetype.UNKNOWN.
category
property
¶
category: ArchetypeCategory
Return the high-level ArchetypeCategory of the reference locus.
antigen_type
property
¶
Surface polysaccharide antigen class (b"CPS", b"O-antigen", b"EPS", b"WTA") derived from archetype.
compound_key
property
¶
Unique composite reference key b"<organism>|<antigen_type>|<serotype>|<assembly_id>".
from_fields
classmethod
¶
from_fields(
organism: str | bytes | int | BacterialSpecies,
*,
serotype: str | bytes = b"",
strain: str | bytes = b"",
strain_synonyms: Sequence[bytes | str] = (),
assembly_id: bytes | str = b"",
locus: Locus | None = None,
ncbi_taxid: int = 0,
straininfo_id: int = 0,
bacdive_id: int = 0,
pmids: Sequence[int] = (),
) -> Self
Construct a SeroRefRecord from flat organism, strain, serotype, and locus fields.
Source code in src/seroref/db/models.py
merge
¶
merge(other: SeroRefRecord) -> Self
Merge metadata from another SeroRefRecord describing the same physical locus.
Source code in src/seroref/db/models.py
archetype_to_antigen_type
¶
archetype_to_antigen_type(
archetype: LocusArchetype,
) -> bytes
Map a LocusArchetype to its canonical surface polysaccharide antigen class (CPS, O-antigen, EPS, WTA).
Source code in src/seroref/db/models.py
Batched Reference Database Containers (seroref.db.records)¶
records
¶
Structure-of-Arrays (SoA) batch containers for ReferenceStrain and SeroRefRecord.
Classes:
| Name | Description |
|---|---|
ReferenceStrains |
Ragged Structure-of-Arrays (SoA) container for deduplicated |
SeroRefRecords |
Normalized relational Structure-of-Arrays (SoA) container for |
Functions:
| Name | Description |
|---|---|
loci_to_npz_dict |
Serialize a |
loci_from_npz_dict |
Deserialize a |
load_seroref_records |
Load curated |
ReferenceStrains
dataclass
¶
Bases: RaggedArrayContainer[ReferenceStrain, 'ReferenceStrains']
Ragged Structure-of-Arrays (SoA) container for deduplicated ReferenceStrain records.
Stores per-strain species IDs, primary strain names, INSDC assembly accessions, taxonomy/culture
collection IDs, and CSR-packed ragged arrays for culture-collection synonym_values (offsets,
lengths) and literature pmid_values (pmid_offsets, pmid_lengths).
Methods:
| Name | Description |
|---|---|
empty |
Create an empty 0-length |
from_list |
Compile a sequence of |
concat |
Concatenate multiple |
where_species |
Filter strains by canonical |
where_assembly_id |
Filter strains by INSDC |
equivalence_csr |
Build the |
merge_cliques |
Resolve transitive |
to_npz_dict |
Serialize this |
from_npz_dict |
Deserialize a |
Attributes:
| Name | Type | Description |
|---|---|---|
organisms |
ndarray[tuple[int], dtype[bytes_]]
|
Vectorized 1D array of canonical scientific names resolved from |
synonym_offsets |
ndarray[tuple[int], dtype[int32]]
|
Alias for |
synonym_lengths |
ndarray[tuple[int], dtype[int32]]
|
Alias for |
Source code in src/seroref/db/records.py
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 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 | |
organisms
property
¶
Vectorized 1D array of canonical scientific names resolved from self.species_ids.
synonym_offsets
property
¶
Alias for self.offsets (starting indices into self.synonym_values).
synonym_lengths
property
¶
Alias for self.lengths (number of synonyms per strain record).
empty
classmethod
¶
Create an empty 0-length ReferenceStrains container.
Source code in src/seroref/db/records.py
from_list
classmethod
¶
from_list(strains: Sequence[ReferenceStrain]) -> Self
Compile a sequence of ReferenceStrain scalar views into a ReferenceStrains SoA container.
Source code in src/seroref/db/records.py
concat
classmethod
¶
Concatenate multiple ReferenceStrains containers.
where_species
¶
where_species(
species: str | bytes | int | BacterialSpecies,
) -> Self
Filter strains by canonical BacterialSpecies.
where_assembly_id
¶
Filter strains by INSDC assembly_id.
equivalence_csr
¶
Build the (M, M) symmetric CSR adjacency matrix of ReferenceStrain equivalence cliques.
Source code in src/seroref/db/records.py
merge_cliques
¶
Resolve transitive ReferenceStrain equivalence cliques via CSR.connected_components_from_edges (seroverse.core.graph.csr.CSR).
Returns:
| Type | Description |
|---|---|
Self
|
tuple[ReferenceStrains, np.ndarray]: |
ndarray[tuple[int], dtype[int32]]
|
is a 1D |
Source code in src/seroref/db/records.py
to_npz_dict
¶
Serialize this ReferenceStrains container into a flat .npz-ready dictionary.
Source code in src/seroref/db/records.py
from_npz_dict
classmethod
¶
Deserialize a ReferenceStrains container from a flat .npz archive dictionary.
Source code in src/seroref/db/records.py
SeroRefRecords
dataclass
¶
Bases: BatchedContainer[SeroRefRecord, 'SeroRefRecords']
Normalized relational Structure-of-Arrays (SoA) container for SeroRefRecord loci.
Deduplicates reference isolates and genome assemblies into self.strains (ReferenceStrains, length M)
and links each of the N predicted surface polysaccharide loci (self.loci, self.serotypes) to its parent
strain via self.strain_indices (int32[N], analogous to Genes.contig_indices).
Methods:
| Name | Description |
|---|---|
empty |
Create an empty 0-length |
from_list |
Compile a sequence of |
concat |
Concatenate and normalize multiple |
where_species |
Filter records by canonical |
where_organism |
Filter records by organism name or |
where_serotype |
Filter records by canonical |
where_antigen_type |
Filter records by derived surface polysaccharide |
where_assembly_id |
Filter records by INSDC genome or locus |
where_archetype |
Filter records by |
save |
Atomically serialize this |
load |
Load a |
Attributes:
| Name | Type | Description |
|---|---|---|
species_ids |
ndarray[tuple[int], dtype[int16]]
|
1D |
organisms |
ndarray[tuple[int], dtype[bytes_]]
|
1D byte-string array ( |
strain_names |
ndarray[tuple[int], dtype[bytes_]]
|
1D byte-string array ( |
assembly_ids |
ndarray[tuple[int], dtype[bytes_]]
|
1D byte-string array ( |
ncbi_taxids |
ndarray[tuple[int], dtype[int32]]
|
1D |
straininfo_ids |
ndarray[tuple[int], dtype[int32]]
|
1D |
bacdive_ids |
ndarray[tuple[int], dtype[int32]]
|
1D |
archetypes |
ndarray[tuple[int], dtype[int8]]
|
1D |
antigen_types |
ndarray[tuple[int], dtype[bytes_]]
|
1D byte-string array ( |
strain_locus_csr |
CSR
|
Sparse |
species_locus_csr |
CSR
|
Sparse |
species_strain_csr |
CSR
|
Sparse |
Source code in src/seroref/db/records.py
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 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 | |
species_ids
property
¶
1D int16 array ((N,)) of BacterialSpecies IDs for each locus record.
organisms
property
¶
1D byte-string array ((N,)) of canonical species names for each locus record.
strain_names
property
¶
1D byte-string array ((N,)) of primary reference strain designations for each locus record.
assembly_ids
property
¶
1D byte-string array ((N,)) of INSDC assembly/nucleotide accessions for each locus record.
ncbi_taxids
property
¶
1D int32 array ((N,)) of NCBI Taxonomy IDs for each locus record.
straininfo_ids
property
¶
1D int32 array ((N,)) of DSMZ StrainInfo IDs for each locus record.
bacdive_ids
property
¶
1D int32 array ((N,)) of DSMZ BacDive IDs for each locus record.
archetypes
property
¶
1D int8 array ((N,)) of LocusArchetype integer IDs across all records in the batch.
antigen_types
property
¶
1D byte-string array ((N,)) of surface antigen classes (b"CPS", b"O-antigen", b"EPS", b"WTA").
strain_locus_csr
property
¶
Sparse (M, N) CSR (seroverse.core.graph.csr.CSR) incidence matrix mapping ReferenceStrains to Loci.
species_locus_csr
property
¶
Sparse (S, N) CSR (seroverse.core.graph.csr.CSR) incidence matrix mapping BacterialSpecies to Loci.
species_strain_csr
property
¶
Sparse (S, M) CSR (seroverse.core.graph.csr.CSR) incidence matrix mapping BacterialSpecies to ReferenceStrains.
empty
classmethod
¶
Create an empty 0-length SeroRefRecords container.
Source code in src/seroref/db/records.py
from_list
classmethod
¶
from_list(
records: Sequence[SeroRefRecord],
*,
deduplicate: bool = True,
) -> Self
Compile a sequence of SeroRefRecord scalar views into a normalized SeroRefRecords container.
Deduplicates ReferenceStrain entries into self.strains, merges untyped/typed duplicate
physical loci when deduplicate=True, and synchronizes Loci.names with self.serotypes.
Source code in src/seroref/db/records.py
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 | |
concat
classmethod
¶
Concatenate and normalize multiple SeroRefRecords batches.
where_species
¶
where_species(
species: str | bytes | int | BacterialSpecies,
) -> Self
Filter records by canonical BacterialSpecies.
where_organism
¶
where_organism(
organism: bytes | str | BacterialSpecies,
) -> Self
Filter records by organism name or BacterialSpecies.
Source code in src/seroref/db/records.py
where_serotype
¶
Filter records by canonical serotype byte string.
where_antigen_type
¶
Filter records by derived surface polysaccharide antigen_type (CPS, O-antigen, EPS, WTA).
Source code in src/seroref/db/records.py
where_assembly_id
¶
Filter records by INSDC genome or locus assembly_id.
Source code in src/seroref/db/records.py
where_archetype
¶
where_archetype(
archetype: LocusArchetype | int | str | bytes,
) -> Self
Filter records by LocusArchetype.
save
¶
Atomically serialize this SeroRefRecords container to a compressed .npz archive.
Source code in src/seroref/db/records.py
load
classmethod
¶
Load a SeroRefRecords container from .npz (supporting both relational and legacy flat schemas).
Source code in src/seroref/db/records.py
loci_to_npz_dict
¶
loci_to_npz_dict(
loci: Loci, prefix: str = "locus_"
) -> dict[str, Any]
Serialize a Loci SoA batch (and its embedded Genes) into a flat .npz-ready dictionary.
Source code in src/seroref/db/records.py
loci_from_npz_dict
¶
loci_from_npz_dict(
data: Any, prefix: str = "locus_"
) -> Loci
Deserialize a Loci SoA batch from a flat .npz archive dictionary.
Source code in src/seroref/db/records.py
load_seroref_records
¶
load_seroref_records(
path: Path = DEFAULT_SEROREF_DB_PATH,
) -> SeroRefRecords