Module phc.easy.omics.options.genomic_expression
Expand source code
from enum import Enum
from typing import List, Optional, Union
from pydantic import Field, constr
from phc.easy.abstract.paging_api_item import PagingApiOptions
from phc.easy.omics.options.common import GenomicVariantInclude
EXPRESSION = constr(
regex=r"^(\d+(\.\d+)?\-\d+(\.\d+)?|[\>\<]\=\s?\d+(\.\d+)?|\d+(\.\d+)?:(lte|gte))$"
)
ORDER_BY = constr(regex=r"^expression(:desc)?$")
MAPPINGS = {
"variant_set_ids": "rnaQuantificationSetIds",
"outlier_std_dev": "outlierStdDev",
"in_ckb": "drugAssociations",
"order_by": "orderBy",
}
class GenomicExpressionOptions(PagingApiOptions):
"""Options to pass to `/v1/genomics/expressions`"""
variant_set_ids: List[str] = Field(..., min_items=1)
include: List[GenomicVariantInclude] = []
gene: List[str] = []
expression: Optional[EXPRESSION] = None
order_by: Optional[ORDER_BY] = None
in_ckb: Optional[bool] = None
# TODO: Fill out allowed options for this parameter
outlier_std_dev: Optional[str] = None
@staticmethod
def transform(key, value):
if key == "expression" and value is not None:
value = GenomicExpressionOptions.transform_expression(value)
if isinstance(value, list):
value = ",".join(
[elem if isinstance(elem, str) else str(elem) for elem in value]
)
elif isinstance(value, bool):
value = "true" if value else None
return (MAPPINGS.get(key, key), value)
@staticmethod
def transform_expression(value: str):
value = value.replace(" ", "")
if ">=" in value:
return value.replace(">=", "") + ":gte"
if "<=" in value:
return value.replace("<=", "") + ":lte"
return value
Classes
class EXPRESSION (...)
-
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
Ancestors
- pydantic.types.ConstrainedStr
- builtins.str
Class variables
var curtail_length
var max_length
var min_length
var regex
var strict
var strip_whitespace
var to_lower
var to_upper
class ORDER_BY (...)
-
str(object='') -> str str(bytes_or_buffer[, encoding[, errors]]) -> str
Create a new string object from the given object. If encoding or errors is specified, then the object must expose a data buffer that will be decoded using the given encoding and error handler. Otherwise, returns the result of object.str() (if defined) or repr(object). encoding defaults to sys.getdefaultencoding(). errors defaults to 'strict'.
Ancestors
- pydantic.types.ConstrainedStr
- builtins.str
Class variables
var curtail_length
var max_length
var min_length
var regex
var strict
var strip_whitespace
var to_lower
var to_upper
class GenomicExpressionOptions (**data: Any)
-
Options to pass to
/v1/genomics/expressions
Create a new model by parsing and validating input data from keyword arguments.
Raises ValidationError if the input data cannot be parsed to form a valid model.
Expand source code
class GenomicExpressionOptions(PagingApiOptions): """Options to pass to `/v1/genomics/expressions`""" variant_set_ids: List[str] = Field(..., min_items=1) include: List[GenomicVariantInclude] = [] gene: List[str] = [] expression: Optional[EXPRESSION] = None order_by: Optional[ORDER_BY] = None in_ckb: Optional[bool] = None # TODO: Fill out allowed options for this parameter outlier_std_dev: Optional[str] = None @staticmethod def transform(key, value): if key == "expression" and value is not None: value = GenomicExpressionOptions.transform_expression(value) if isinstance(value, list): value = ",".join( [elem if isinstance(elem, str) else str(elem) for elem in value] ) elif isinstance(value, bool): value = "true" if value else None return (MAPPINGS.get(key, key), value) @staticmethod def transform_expression(value: str): value = value.replace(" ", "") if ">=" in value: return value.replace(">=", "") + ":gte" if "<=" in value: return value.replace("<=", "") + ":lte" return value
Ancestors
- PagingApiOptions
- pydantic.main.BaseModel
- pydantic.utils.Representation
Class variables
var expression : Optional[ConstrainedStrValue]
var gene : List[str]
var in_ckb : Optional[bool]
var include : List[GenomicVariantInclude]
var order_by : Optional[ConstrainedStrValue]
var outlier_std_dev : Optional[str]
var variant_set_ids : List[str]
Static methods
def transform(key, value)
-
Expand source code
@staticmethod def transform(key, value): if key == "expression" and value is not None: value = GenomicExpressionOptions.transform_expression(value) if isinstance(value, list): value = ",".join( [elem if isinstance(elem, str) else str(elem) for elem in value] ) elif isinstance(value, bool): value = "true" if value else None return (MAPPINGS.get(key, key), value)
def transform_expression(value: str)
-
Expand source code
@staticmethod def transform_expression(value: str): value = value.replace(" ", "") if ">=" in value: return value.replace(">=", "") + ":gte" if "<=" in value: return value.replace("<=", "") + ":lte" return value
Methods
def dict(self)
-
Inherited from:
PagingApiOptions
.dict
Generate a dictionary representation of the model, optionally specifying which fields to include or exclude.