Spaces:
Sleeping
Sleeping
| """ | |
| state.py β shared mutable state passed to every parser module. | |
| Holds auto-increment counters and deduplication look-up tables. | |
| """ | |
| class ParserState: | |
| def __init__(self): | |
| # ββ References ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Maps dedup key -> ref_pk (int) | |
| # key = ("article", pubmed_id_or_citation) | ("textbook", ...) | ... | |
| self.refs_seen: dict = {} | |
| self.ref_counter: int = 0 | |
| # ββ Categories ββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Maps (category_name_lower, mesh_id) -> category_id (int) | |
| self.cats_seen: dict = {} | |
| self.cat_counter: int = 0 | |
| # ββ Pathways ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Set of smpdb_ids already written to pathways.csv | |
| self.pathways_seen: set = set() | |
| # ββ Polypeptides ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Set of polypeptide_ids (UniProt) already written to polypeptides.csv | |
| self.polypeptides_seen: set = set() | |
| # ββ Interactants ββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| # Set of interactant_ids (BE-IDs) already written to interactants.csv | |
| self.interactants_seen: set = set() | |
| # ββ Reactions βββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| self.reaction_counter: int = 0 | |
| # ββ Products ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ | |
| self.product_counter: int = 0 | |
| # ββ Drug counter (for progress reporting) βββββββββββββββββββββββββββββ | |
| self.drug_count: int = 0 | |