genebe package
Submodules
genebe.client module
- exception genebe.client.TooManyRequestsError
Bases:
Exception
- exception genebe.client.WrongServerResponseError
Bases:
Exception
- genebe.client.annotate_variants_list(variants: List[str], genome: str = 'hg38', use_ensembl: bool = True, use_refseq: bool = True, flatten_consequences: bool = True, batch_size: int = 500, username: str = None, api_key: str = None, use_netrc: bool = True, endpoint_url: str = 'https://api.genebe.net/cloud/api-public/v1/variants', progress_bar: bool = True, omit_acmg: bool = False, omit_csq: bool = False, omit_basic: bool = False, omit_advanced: bool = False, omit_normalization: bool = False, annotator: str = 'snpeff') List[Dict[str, object]]
Annotates a list of genetic variants.
- Args:
- variants (List[str]): A list of genetic variants to be annotated.
Format: chr-pos-ref-alt. Look at examples below.
- use_ensembl (bool, optional): Whether to use Ensembl for annotation.
Defaults to True.
- use_refseq (bool, optional): Whether to use RefSeq for annotation.
Defaults to True.
- genome (str, optional): The genome version for annotation (e.g., ‘hg38’).
Defaults to ‘hg38’.
- flatten_consequences (bool, optional): If set to False, return consequences as a list of objects.
If set to True, only the most important consequence is returned in a flat form. Defaults to True.
- batch_size (int, optional): The size of each batch for processing variants.
Defaults to 100. Must be smaller or equal 1000.
- username (str, optional): The username for authentication.
Defaults to None.
- api_key (str, optional): The API key for authentication.
Defaults to None.
- use_netrc (bool, optional): Whether to use credentials from the user’s
.netrc file for authentication. Defaults to True.
- endpoint_url (str, optional): The API endpoint for variant annotation.
Defaults to ‘https://api.genebe.net/cloud/api-public/v1/variants’.
- progress_bar (bool, optional): Show progress bar.
Defaults to True.
omit_acmg (bool, optional): Don’t add ACMG scores in the output. Defaults to False. omit_csq (bool, optional): Don’t add consequences in the output. Defaults to False. omit_basic (bool, optional): Don’t add basic annotations (GnomAD frequencies etc) in the output. Defaults to False. omit_advanced (bool, optional): Don’t add advanced annotations (ClinVar etc) in the output. Defaults to False. omit_normalization (bool, optional): Don’t normalize variants. Use only if you are sure they are normalized already. Defaults to False. annotator (str, optional): Which VEP implementation to use.
Defaults to snpeff.
- Returns:
List[Dict[str, object]]: A list of dictionaries containing annotation information for each variant. The dictionary structure may vary. Check the current documentation on https://genebe.net/about/api
- Example:
>>> variants = ["7-69599651-A-G", "6-160585140-T-G"] >>> annotations = annotate_variants_list(variants, use_ensembl=True, ... use_refseq=False, genome='hg38', ... batch_size=500, username="user123@example.com", ... api_key="apikey456", use_netrc=False, ... endpoint_url='https://api.genebe.net/cloud/api-public/v1/variants') >>> print(annotations) [{'chr': '7', 'pos':69599651 (...) }]
- Note:
The number of the elements in returned list is always equal to the number of queries.
- genebe.client.annotate_variants_list_to_dataframe(variants: List[str], use_ensembl: bool = True, use_refseq: bool = True, genome: str = 'hg38', batch_size: int = 100, flatten_consequences: bool = True, username: str = None, api_key: str = None, use_netrc: bool = True, endpoint_url: str = 'https://api.genebe.net/cloud/api-public/v1/variants') DataFrame
- genebe.client.parse_hgvs(hgvs: List[str], batch_size: int = 500, username: str = None, api_key: str = None, use_netrc: bool = True, endpoint_url: str = 'https://api.genebe.net/cloud/api-public/v1/hgvs') List[str]
Parses a list of genetic variants encoded in HGVS.
- Args:
- hgvs (List[str]): A list of genetic variants in hgvs format.
Supports .n:, .c:, .g: and .m:. Look at examples below.
- batch_size (int, optional): The size of each batch for processing variants.
Defaults to 500. Must be smaller or equal 1000.
- username (str, optional): The username for authentication.
Defaults to None.
- api_key (str, optional): The API key for authentication.
Defaults to None.
- use_netrc (bool, optional): Whether to use credentials from the user’s
.netrc file for authentication. Defaults to True.
- endpoint_url (str, optional): The API endpoint for parsing hgvs.
Defaults to ‘https://api.genebe.net/cloud/api-public/v1/hgvs’.
- Returns:
List[str]: A list of dictionaries containing annotation information for each variant. Check the current documentation on https://genebe.net/about/api
- Example:
>>> hgvs_variants = ["'NM_000277.2:c.1A>G"] >>> variants = parse_hgvs(hgvs_variants) >>> print(variants) ['12-102917129-AT-AC', '12-102852850-GA-G']
- Note:
The number of the elements in returned list is always equal to the number of queries.
If some position cannot be parsed, an empty string is returned.
- genebe.client.whoami(username: str = None, api_key: str = None, use_netrc: bool = True, endpoint_url: str = 'https://api.genebe.net/cloud/api-public/v1/whoami') List[str]
Information about me: usage statistics, limits etc.
- Args:
- username (str, optional): The username for authentication.
Defaults to None.
- api_key (str, optional): The API key for authentication.
Defaults to None.
- use_netrc (bool, optional): Whether to use credentials from the user’s
.netrc file for authentication. Defaults to True.
- endpoint_url (str, optional): The API endpoint to use.
Defaults to ‘https://api.genebe.net/cloud/api-public/v1/whoami’.
- Returns:
An object. Check the current documentation on https://genebe.net/about/api
genebe.entrypoint module
- genebe.entrypoint.account_command(args)
- genebe.entrypoint.main()
genebe.gbid module
- exception genebe.gbid.InvalidPositionException(message)
Bases:
Exception
- class genebe.gbid.PositionEncoder
Bases:
object
- CHR_NOT_SUPPORTED = -1
- ERROR_WRONG_CHR_POSITION = -2
- encode(chromosome: str, position: int)
- encode_1_based_without_throw(chromosome, position)
- class genebe.gbid.VariantIdEncoder
Bases:
object
- BASES = ['A', 'C', 'G', 'T']
- MASK_CHANGE_HASH_VALUE = 536870911
- MASK_C_HASH = 536870912
- MASK_DEL = 33292288
- MASK_HASH = 9223372036854775808
- MASK_INS = 262143
- MASK_INS_LEN = 503316480
- MASK_NULL = 4611686018427387904
- MASK_POS = 4611686017353646080
- MAX_DEL_LENGTH = 127
- MAX_INS_LENGTH = 9
- RADIX = 36
- change_hash(del_length, alt)
- encode1based(chromosome, position, ref, alt)
- encode_bases(alt)
- hash(chromosome, position, del_length, alt)
- positionEncoder = <genebe.gbid.PositionEncoder object>
- set_value(input, mask, value)
genebe.json_simple_annotator module
- genebe.json_simple_annotator.annotate_json(input_json_path: str, output_json_path: str, genome: str = 'hg38', use_ensembl: bool = True, use_refseq: bool = True, flatten_consequences: bool = True, batch_size: int = 500, username: str | None = None, api_key: str | None = None, use_netrc: bool = True, endpoint_url: str = 'https://api.genebe.net/cloud/api-public/v1/variants', omit_acmg: bool = False, omit_csq: bool = False, omit_basic: bool = False, omit_advanced: bool = False, omit_normalization: bool = False, progress: bool = False)
Annotates a JSON file using the annotate_variants_list function.
- Args:
input_json_path (str): Path to the input json lines file. output_json_path (str): Path to the output annotated json lines file. genome (str, optional): The genome version for annotation (e.g., ‘hg38’).
Defaults to ‘hg38’.
- use_ensembl (bool, optional): Whether to use Ensembl for annotation.
Defaults to True.
- use_refseq (bool, optional): Whether to use RefSeq for annotation.
Defaults to True.
- flatten_consequences (bool, optional): If set to False, return consequences as a list of objects.
If set to True, only the most important consequence is returned in a flat form. Defaults to True.
- batch_size (int, optional): The size of each batch for processing variants.
Defaults to 100. Must be smaller or equal 1000.
- username (str, optional): The username for authentication.
Defaults to None.
- api_key (str, optional): The API key for authentication.
Defaults to None.
- use_netrc (bool, optional): Whether to use credentials from the user’s
.netrc file for authentication. Defaults to True.
- endpoint_url (str, optional): The API endpoint for variant annotation.
Defaults to ‘https://api.genebe.net/cloud/api-public/v1/variants’.
omit_acmg (bool, optional): Don’t add ACMG scores in the output. Defaults to False. omit_csq (bool, optional): Don’t add consequences in the output. Defaults to False. omit_basic (bool, optional): Don’t add basic annotations (GnomAD frequencies etc) in the output. Defaults to False. omit_advanced (bool, optional): Don’t add advanced annotations (ClinVar etc) in the output. Defaults to False. omit_normalization (bool, optional): Don’t normalize variants. Use only if you are sure they are normalized already. Defaults to False. progress (bool, optional): Show progress bar
genebe.vcf_simple_annotator module
- genebe.vcf_simple_annotator.annotate_vcf(input_vcf_path: str, output_vcf_path: str, genome: str = 'hg38', use_ensembl: bool = True, use_refseq: bool = True, flatten_consequences: bool = True, batch_size: int = 500, username: str | None = None, api_key: str | None = None, use_netrc: bool = True, endpoint_url: str = 'https://api.genebe.net/cloud/api-public/v1/variants', omit_acmg: bool = False, omit_csq: bool = False, omit_basic: bool = False, omit_advanced: bool = False, omit_normalization: bool = False, progress: bool = False)
Annotates a VCF file using the annotate_variants_list function.
- Args:
input_vcf_path (str): Path to the input VCF file. output_vcf_path (str): Path to the output annotated VCF file. genome (str, optional): The genome version for annotation (e.g., ‘hg38’).
Defaults to ‘hg38’.
- use_ensembl (bool, optional): Whether to use Ensembl for annotation.
Defaults to True.
- use_refseq (bool, optional): Whether to use RefSeq for annotation.
Defaults to True.
- flatten_consequences (bool, optional): If set to False, return consequences as a list of objects.
If set to True, only the most important consequence is returned in a flat form. Defaults to True.
- batch_size (int, optional): The size of each batch for processing variants.
Defaults to 100. Must be smaller or equal 1000.
- username (str, optional): The username for authentication.
Defaults to None.
- api_key (str, optional): The API key for authentication.
Defaults to None.
- use_netrc (bool, optional): Whether to use credentials from the user’s
.netrc file for authentication. Defaults to True.
- endpoint_url (str, optional): The API endpoint for variant annotation.
Defaults to ‘https://api.genebe.net/cloud/api-public/v1/variants’.
omit_acmg (bool, optional): Don’t add ACMG scores in the output. Defaults to False. omit_csq (bool, optional): Don’t add consequences in the output. Defaults to False. omit_basic (bool, optional): Don’t add basic annotations (GnomAD frequencies etc) in the output. Defaults to False. omit_advanced (bool, optional): Don’t add advanced annotations (ClinVar etc) in the output. Defaults to False. omit_normalization (bool, optional): Don’t normalize variants. Use only if you are sure they are normalized already. Defaults to False. progress (bool, optional): Show progress bar