genos.api
Genos API subpackage.
This package contains modules that wrap individual Genos API endpoints: - HealthAPI: /health endpoint - VariantPredictorAPI: /predict endpoint
- class HealthAPI(session: Session, base_url: str, timeout: int = 30)
Bases:
BaseAPIWrapper class for the Health Check API endpoint.
This class handles requests to the /health endpoint, allowing clients to verify that the Genos service is running and responsive.
- check() dict
Perform a health check request.
- Returns:
- JSON response from the health endpoint, typically containing:
”status”: “healthy” or “unhealthy”
”message”: optional status message
- Return type:
dict
- Raises:
APIRequestError – If the request fails or the server is unreachable.
- class VariantPredictorAPI(session: Session, base_url: str, timeout: int = 30)
Bases:
BaseAPIWrapper class for the Variant Prediction API endpoint.
This class handles requests to the /predict endpoint for variant pathogenicity prediction. It validates input and raises structured SDK exceptions on errors.
- predict(assembly: str, chrom: str, pos: int, ref: str, alt: str) dict
Predict the pathogenicity of a genetic variant.
- Parameters:
assembly (str) – Reference genome version, allowed values: ‘hg38’ or ‘hg19’.
chrom (str) – Chromosome, e.g., ‘chr6’.
pos (int) – Position, 1-based coordinate.
ref (str) – Reference allele, single letter or sequence.
alt (str) – Alternate allele, single letter or sequence.
- Returns:
- Prediction result, typically containing:
”variant”: input variant
”prediction”: “Pathogenic” or “Benign”
”score_Benign”: float
”score_Pathogenic”: float
- Return type:
dict
- Raises:
ValueError – If any argument is invalid.
APIRequestError – If the API request fails or the server returns an error.
- class EmbeddingExtractorAPI(session: Session, base_url: str, timeout: int = 30, config=None)
Bases:
BaseAPIWrapper class for the Embedding Extraction API endpoints.
This class handles requests to the embedding extraction endpoints, including single sequence and batch processing.
- extract(sequence: str, model_name: str = 'Genos-1.2B', pooling_method: str = 'mean') dict | List[dict]
Extracts a numerical embedding representation for a given nucleotide sequence.
- Parameters:
sequence (str) – DNA sequence string .
model_name (str, optional) – Model name to use. Default is “Genos-1.2B”. Options: “Genos-1.2B”, “Genos-10B”
pooling_method (str, optional) – Pooling method. Default is “mean”. Options: “mean”, “max”, “last”, “none”
- Returns:
“token_count”: number of tokens
”embedding_shape”: shape of embedding array
”embedding_dim”: dimension of embedding
”embedding”: embedding array (list)
- Return type:
dict
- Raises:
ValueError – If sequence is not a valid string or list.
ValidationError – If parameters are invalid.
APIRequestError – If the API request fails.
Examples
>>> # Single sequence >>> result = embedding_api.extract("ATCGATCGATCG") >>> print(result['embedding_dim']) 4096
- class RNASeqCoverageTrackPredictionAPI(session: Session, base_url: str, timeout: int = 30)
Bases:
BaseAPIClient for the RNA-seq Coverage Track Prediction service in GeneOS.
This class provides access to RNA-seq Coverage Track Prediction models, allowing users to predict the coverage track of an RNA-seq experiment based on the genomic coordinates.
- predict(chrom: str, start_pos: int) dict
Predict the coverage track of an RNA-seq experiment based on the genomic coordinates.
- Parameters:
chrom (str) – Chromosome name.
start_pos (int) – Start position.
- Returns:
A JSON response from the RNA-seq Coverage Track Prediction model containing the predicted coverage track.
- Return type:
dict
- Raises:
ValueError – If the parameters are invalid.
APIRequestError – If the API request fails.
Modules