anyvar.storage.orm
SQLAlchemy ORM models for AnyVar database schema.
- class anyvar.storage.orm.Allele(**kwargs)[source]
AnyVar ORM model for Alleles
- __init__(**kwargs)[source]
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class anyvar.storage.orm.Base(**kwargs)[source]
Base class for all AnyVar ORM models.
- __init__(**kwargs)[source]
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- disassemble()[source]
Returns a dict containing this entity + all of its constituent ORM objects, keyed by type. If there are no constituent ORM objects, dict will just contain a single entry referring to this entity.
Example: >>> sequence_reference = orm.SequenceReference( … id=”SQ.Ya6Rs7DHhDeg7YaOSg1EoNi3U_nQ9SvO”, … # etc… … ) >>> location = orm.Location( … id=”ga4gh:SL.U8b3eMCw6QjGA9cnDx_KYxqbol0UrEKx”, … sequence_reference_id=sequence_reference.id, … sequence_reference=sequence_reference, … # etc… … ) >>> allele = orm.Allele( … id=”ga4gh:VA.uR23Z7AAFaLHhPUymUEYNG4o2CCE560T”, … location_id=location.id, … location=location, … # etc… … ) >>> disassembled_allele = allele.disassemble() >>> print(disassembled_allele) {‘Allele’: <anyvar.storage.orm.Allele object at 0x108dfa780>, ‘Location’: <anyvar.storage.orm.Location object at 0x101416db0>, ‘SequenceReference’: <anyvar.storage.orm.SequenceReference object at 0x100af5250>}
- Return type:
dict[str,Base]
- get_disassembler()[source]
Yields an Iterator that recursively disassembles this entity into itself + its constituent ORM objects. Will simply yield self if object contains no other entities.
- Return type:
Iterator[Base]- Returns:
An Iterator yielding this entity + its constituent ORM objects
- class anyvar.storage.orm.CanonicalAllele(**kwargs)[source]
AnyVar ORM model for canonical allele variants
- __init__(**kwargs)[source]
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class anyvar.storage.orm.Extension(**kwargs)[source]
AnyVar ORM model for extensions table.
- __init__(**kwargs)[source]
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class anyvar.storage.orm.Location(**kwargs)[source]
AnyVar ORM model for Locations
- __init__(**kwargs)[source]
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- get_disassembler()[source]
Recursively disassemble to yield self + constituent SequenceReference object
- Return type:
Iterator[Base]
-
sequence_reference:
Mapped[SequenceReference][source]
- class anyvar.storage.orm.ProteinSequenceConsequence(**kwargs)[source]
AnyVar ORM model for canonical allele variants
- __init__(**kwargs)[source]
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class anyvar.storage.orm.SequenceReference(**kwargs)[source]
AnyVar ORM model for SequenceReferences
- __init__(**kwargs)[source]
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class anyvar.storage.orm.VariationMapping(**kwargs)[source]
AnyVar ORM model for variation-to-variation mapping
- __init__(**kwargs)[source]
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- class anyvar.storage.orm.VrsObject(**kwargs)[source]
AnyVar ORM model for vrs_objects table.
- __init__(**kwargs)[source]
A simple constructor that allows initialization from kwargs.
Sets attributes on the constructed instance using the names and values in
kwargs.Only keys that are present as attributes of the instance’s class are allowed. These could be, for example, any mapped columns or relationships.
- anyvar.storage.orm.create_tables(db_url)[source]
Create all tables in the database.
- Parameters:
db_url (
str) – Database connection URL (e.g., postgresql://user:pass@host:port/db)- Return type:
None
- anyvar.storage.orm.session_factory(db_url)[source]
Create a SQLAlchemy session factory.
Returns a sessionmaker factory that should be used to create sessions. Follows SQLAlchemy 2.0 recommended semantics where the session lifecycle is managed externally using context managers.
Example usage:
>>> sf = session_factory(db_url) >>> with sf() as session: ... with session.begin(): # Perform database operations ... session.add(some_object) ... session.execute(some_query) >>> # Transaction from session.begin() automatically commits if no exceptions occur >>> # Session automatically closes
See: https://docs.sqlalchemy.org/en/20/orm/session_basics.html#using-a-sessionmaker
- Parameters:
db_url (
str) – Database connection URL (e.g., postgresql://user:pass@host:port/db)- Return type:
sessionmaker- Returns:
SQLAlchemy sessionmaker factory