mkt.databases.datasets.discoverx

DiscoverX kinase panel metadata model and generator.

Provides the DiscoverXInfo model and DiscoverXInfoGenerator for representing and building DiscoverX/scanMAX kinase panel metadata.

Module Attributes

DICT_DAVIS_DROP

terms to drop where key is colname and value is list of terms.

DICT_DAVIS_MERGE_FIX

{column name : replacement string}} to fix entries in the Davis DiscoverX dataset.

Classes

DiscoverXInfo(*, discoverx_gene_symbol, key, ...)

DiscoverX dataset processing class.

DiscoverXInfoGenerator([str_url, ...])

Class to generate DiscoverXInfo objects from DiscoverX kinase construct information CSV.

mkt.databases.datasets.discoverx.DICT_DAVIS_DROP = {'Construct Description': ['(L747-T751del,Sins)', '(ITD'], 'DiscoverX Gene Symbol': ['-phosphorylated', '-cyclin', '-autoinhibited', 'ALK(1151Tins)'], 'Species': ['P.falciparum', 'M.tuberculosis']}

terms to drop where key is colname and value is list of terms.

Type:

Dict[str, list[str]]

mkt.databases.datasets.discoverx.DICT_DAVIS_MERGE_FIX = {'EGFR(E746-A750del)': {'AA Start/Stop': 'R669/V1011'}, 'EGFR(L747-E749del, A750P)': {'AA Start/Stop': 'R669/V1011'}, 'EGFR(L747-S752del, P753S)': {'AA Start/Stop': 'R669/V1011'}, 'EGFR(S752-I759del)': {'AA Start/Stop': 'R669/V1011'}, 'GCN2(Kin.Dom.2,S808G)': {'Construct Description': 'Mutation (S808G)'}, 'RPS6KA4(Kin.Dom.1-N-terminal)': {'AA Start/Stop': 'M1/V374'}, 'RPS6KA5(Kin.Dom.1-N-terminal)': {'AA Start/Stop': 'M1/A389'}}

{column name : replacement string}} to fix entries in the Davis DiscoverX dataset.

Type:

Dictionary of {DiscoverX Gene Symbol

class mkt.databases.datasets.discoverx.DiscoverXInfo(*, discoverx_gene_symbol: str, key: str | None, accession: str, uniprot_id: str, str_start: ~typing.Annotated[str, ~pydantic.types.StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=^[ACDEFGHIKLMNPQRSTVWY]{1}$)] | None, idx_start: int | None, str_stop: ~typing.Annotated[str, ~pydantic.types.StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=^[ACDEFGHIKLMNPQRSTVWY]{1}$)] | None, idx_stop: int | None, seq_refseq: ~typing.Annotated[str, ~pydantic.types.StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=^[ACDEFGHIKLMNPQRSTVWXY\-]+$)] | None, seq_uniprot: ~typing.Annotated[str, ~pydantic.types.StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=^[ACDEFGHIKLMNPQRSTVWXY\-]+$)] | None = None, bool_wt: bool, list_missense_mutations: list[tuple[str, int, str]] | None = None, list_deletion_mutations: list[tuple[str, list[int], str]] | None = None, list_uniprot2refseq: list[int | None] | None = None, list_refseq2uniprot: list[int | None] | None = None, bool_has_kd: bool | None = None, bool_has_klifs: bool | None = None, bool_mutations_in_kd_region: bool | None = None, bool_mutations_in_klifs_region: bool | None = None, bool_mutations_in_klifs_residues: bool | None = None, dict_refseq_indices: dict[int, str | None] | None = None, KLIFS2RefSeqIdx: dict[int, int] | None = None, KLIFS2RefSeqSeq: dict[str, str] | None = None, dict_construct_sequences: dict[str, str | None] | None = None, bool_offset: bool = True)[source]

Bases: BaseModel

DiscoverX dataset processing class.

KLIFS2RefSeqIdx: dict[int, int] | None

Dictionary mapping KLIFS residue numbers to RefSeq indices.

Type:

dict[int, int] | None

KLIFS2RefSeqSeq: dict[str, str] | None

Dictionary mapping KLIFS region names (including intra/inter) to RefSeq sequences.

Type:

dict[str, str] | None

accession: str

DiscoverX accession of the kinase construct.

Type:

str

bool_has_kd: bool | None

Whether the kinase has a kinase domain defined in DICT_KINASE (True), not defined (False), or key not in DICT_KINASE (None).

Type:

bool | None

bool_has_klifs: bool | None

Whether the kinase has KLIFS residues defined in DICT_KINASE (True), not defined (False), or key not in DICT_KINASE (None).

Type:

bool | None

bool_mutations_in_kd_region: bool | None

Whether all mutations fall within the kinase domain (True), outside (False), or no mutations/kinase domain/DICT_KINASE (None).

Type:

bool | None

bool_mutations_in_klifs_region: bool | None

Whether all mutations fall within the span of the KLIFS region (True), outside (False), or no mutations/KLIFS region/DICT_KINASE (None).

Type:

bool | None

bool_mutations_in_klifs_residues: bool | None

Whether all mutations fall within a KLIFS residue (True), outside (False), or no mutations/KLIFS residue/DICT_KINASE (None).

Type:

bool | None

bool_offset: bool

Whether to use 1-based indexing (True) or 0-based indexing (False). Default is True.

Type:

bool

bool_wt: bool

Whether the construct is wild-type (True) or mutant (False).

Type:

bool

static check_construct_boundaries(str_seq: str, int_idx: int, int_offset: int, str_aa: str, str_id: str, bool_start: bool = True) None[source]

Raise error if construct boundaries do not match sequence.

Parameters:
  • str_seq (str) – Amino acid sequence.

  • int_idx (int) – Index of the amino acid in the sequence.

  • str_aa (str) – Amino acid expected at the index.

Raises:

ValueError – If the amino acid at the index does not match the expected amino acid.

static check_deletion_boundaries(str_seq: str, int_idx: int, int_offset: int, str_check: str, str_id: str, bool_start: bool = True) None[source]

Raise error if deletion boundaries do not match sequence.

Parameters:
  • str_seq (str) – Amino acid sequence.

  • int_idx (int) – Index of the amino acid deleted in the sequence.

  • int_offset (int) – Offset to apply to the index.

  • str_check (str) – Amino acid expected at the index.

  • str_id (str) – Identifier for logging.

  • bool_start (bool, optional) – Whether checking start (True) or stop (False) of deletion; defaults to True.

Raises:

ValueError – If the amino acid at the index does not match the expected amino acid.

check_region_of_mutation(idx_start: int | None, idx_end: int | None, list_codons: int | list[int], bool_kd: bool = True) bool[source]

Check if mutation falls within kinase domain or KLIFS region.

Parameters:

idx_startint | None

Start index of the region.

idx_endint | None

End index of the region.

idx_codonint

Index of the mutation codon.

bool_kdbool

Whether to check kinase domain (True) or KLIFS region (False); default is True.

Returns:

bool

Updated bool indicating if mutation falls within region.

convert_refseq2uniprot_mutations(idx_refseq: int | list[int]) int | list[int][source]

Convert RefSeq mutation index to UniProt mutation index.

Parameters:

idx_refseqint | list[int]

Index or list of indices of the mutation in the RefSeq sequence.

Returns:

str

UniProt sequence with the mutation replaced - need to run return_index() before using.

convert_uniprot2refseq_klifs_residues() list[int] | None[source]

Convert KLIFS residues from UniProt to RefSeq indices.

Parameters:

None

Returns:

list[int | None]

List of RefSeq indices corresponding to KLIFS residues or None if not available.

dict_construct_sequences: dict[str, str | None] | None

Dictionary with keys as region names and values as sequences or None.

Type:

dict[str, str | None] | None

dict_refseq_indices: dict[int, str | None] | None

Dictionary with ‘start’ and ‘stop’ indices for RefSeq sequence.

Type:

dict[int, str | None]

discoverx_gene_symbol: str

DiscoverX gene symbol.

extract_region_indices(bool_kd: bool = True) tuple[int, int][source]

Extract kinase domain or KLIFS region indices from DICT_KINASE.

Parameters:

bool_kdbool

Whether to check kinase domain (True) or KLIFS region (False); default is True.

Returns:

tuple[int, int]

Tuple of (start index, end index).

find_closest_mapping(idx_in: int, iter_idx: Iterable | None = None, bool_refseq2uniprot: bool = True) int | None[source]

Find closest mapping index if direct mapping is not available.

Parameters:

idx_inint

Input index to map.

iter_idxIterable | None

Iterable of valid indices to consider for mapping; default is None.

bool_refseq2uniprotbool

Whether to map from RefSeq to UniProt (True) or UniProt to RefSeq (False); default is True.

Returns:

int | None

Closest mapping index or None if no mapping found.

find_intra_gaps(dict_in: dict[str, int], bool_bl: bool = True) tuple[int, str] | None[source]

Find intra-pocket gaps in KLIFS pocket region.

Parameters:
  • dict_in (dict[str, int]) – Dictionary of KLIFS regions and their corresponding indices

  • bool_bl (bool) – If True, find intra-region gaps for b.l region; if False, find intra-region gaps for linker region

Returns:

Tuple of intra-region gaps

Return type:

tuple[str, str] | None

generate_KLIFS2RefSeqIdx() dict[str, int | None][source]

Generate mapping from KLIFS residue numbers to RefSeq indices.

generate_alignment_dict_including_gaps()[source]

Return fully aligned KLIFS pocket.

generate_construct_dictionary() dict | None[source]

Generate dictionary representation of the DiscoverXInfo object.

Returns:

dict | None
Dictionary of length == construct where keys are RefSeq indices and values are properties

(e.g., KD start/end, KLIFS residues).

generate_construct_sequence_dict() dict[str, str | None] | None[source]

Generate dictionary of construct regions and their sequences.

Returns:

dict[str, str | None]
Dictionary with keys as region names and values as sequences or None.
  • KLIFS + KD: kd_pre, kd_start, klifs, kd_end, kd_post

  • KD only: kd_pre, kd, kd_post

  • KLIFS only: construct_pre, klifs, construct_post

  • Neither: construct

generate_klifs_region_seq_list_from_dict_idx() dict[str, str | None][source]

Generate mapping from RefSeq indices to KLIFS residue numbers.

get_boundaries_in_key(bool_klifs: bool = True) tuple[int, int][source]

Get start and end indices of kinase domain or KLIFS region in dict_refseq_indices.

bool_klifsbool
If True, get KLIFS region boundaries;

if False, get kinase domain boundaries; default is True.

Returns:

tuple[int, int]

Tuple of (start index, end index) within dict_refseq_indices.

get_inter_region() dict[str, str | None][source]

Get inter-region sequences.

get_intra_region()[source]

Get intra-region sequences.

idx_start: int | None

Position of the start of the construct in the RefSeq sequence.

Type:

int

idx_stop: int | None

Position of the stop of the construct in the RefSeq sequence.

Type:

int

key: str | None

Dictionary key for the kinase; HGNC name + ‘_1/2’ for multi-mapping.

list_deletion_mutations: list[tuple[str, list[int], str]] | None

List of deletion mutations as tuples of (start WT amino acid, list of positions deleted, end WT amino acid).

Type:

list[tuple[str, list[int], str] | None]

list_missense_mutations: list[tuple[str, int, str]] | None

List of missense mutations as tuples of (wild-type amino acid, position, mutant amino acid).

Type:

list[tuple[str, int, str] | None]

list_refseq2uniprot: list[int | None] | None

List mapping RefSeq sequence indices to UniProt sequence indices length must match the length of the RefSeq sequence and entries correspond to UniProt.

Type:

list[int | None]

list_uniprot2refseq: list[int | None] | None

List mapping UniProt sequence indices to RefSeq sequence indices; length must match the length of the UniProt sequence and entries correspond to RefSeq.

Type:

list[int | None]

model_post_init(_DiscoverXInfo__context: any) None[source]

Post-initialization processing to populate additional fields.

Recursively search for index in dictionary.

Parameters:
  • idx (int) – Index to start search

  • in_dict (dict[str, int]) – Dictionary to search

  • decreasing (bool) – If True, search in decreasing order; if False, search in increasing order

Returns:

idx – Index in dictionary

Return type:

int

replace_mutations_in_sequences() tuple[str | None, str | None, bool | None, bool | None, bool | None][source]

Replace mutations in RefSeq and UniProt full sequences in the Davis dataset.

Parameters:

df_inpd.DataFrame

Input DataFrame.

Returns:

pd.DataFrame

DataFrame with mutations replaced in RefSeq and UniProt full sequences.

list[tuple]

Tuple of (RefSeq sequence, UniProt sequence, bool mutation in KD, bool mutation in KLIFS region, bool mutation in KLIFS residues).

return_index(idx_in: int) int[source]

Return adjusted index based on offset setting.

Parameters:

idx_inint

Input index.

Returns:

int

Adjusted index.

return_intra_gap_substr(bl_bool) str | None[source]

Return intra-region gap substring.

Parameters:

bl_bool (bool) – If True, find intra-region gaps for b.l region; if False, find intra-region gaps for linker region

Returns:

Intra-region gap substring

Return type:

str | None

return_refseq2uniprot_mapping() tuple[list[int | None] | None, list[int | None] | None][source]

Return mapping of RefSeq to UniProt indices (and visa versa) using global alignment.

Parameters:

str_refseqstr

RefSeq sequence string.

str_uniprotstr

UniProt sequence string.

Returns:

list[int], list[int]
Two lists mapping RefSeq to UniProt indices and vice versa;

index in initial string given by position in list.

seq_refseq: StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=^[ACDEFGHIKLMNPQRSTVWXY\-]+$)] | None

RefSeq sequence with deletions allowed.

Type:

SequenceDEL

seq_uniprot: StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=^[ACDEFGHIKLMNPQRSTVWXY\-]+$)] | None

UniProt canonical sequence with deletions allowed.

Type:

SequenceDEL

str_start: StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=^[ACDEFGHIKLMNPQRSTVWY]{1}$)] | None

Amino acid at the start of the construct.

Type:

SeqStartStop

str_stop: StringConstraints(strip_whitespace=None, to_upper=None, to_lower=None, strict=None, min_length=None, max_length=None, pattern=^[ACDEFGHIKLMNPQRSTVWY]{1}$)] | None

Amino acid at the stop of the construct.

Type:

SeqStartStop

uniprot_id: str

UniProt accession of the kinase.

Type:

str | None

classmethod validate_construct_boundaries(data: dict) dict[source]
classmethod validate_deletions(data: dict) dict[source]
classmethod validate_missense_mutations(data: dict) dict[source]
class mkt.databases.datasets.discoverx.DiscoverXInfoGenerator(str_url: str = 'https://raw.githubusercontent.com/openkinome/kinoml/refs/heads/master/kinoml/data/kinomescan/DiscoverX_489_Kinase_Assay_Construct_Information.csv', bool_offset: bool = True, df: DataFrame | None = None, df_id: DataFrame | None = None, dict_discoverx_info: dict[str, DiscoverXInfo] = FieldInfo(annotation=NoneType, required=False, default_factory=dict, json_schema_extra={'initialize': False}))[source]

Bases: object

Class to generate DiscoverXInfo objects from DiscoverX kinase construct information CSV.

__init__(str_url: str = 'https://raw.githubusercontent.com/openkinome/kinoml/refs/heads/master/kinoml/data/kinomescan/DiscoverX_489_Kinase_Assay_Construct_Information.csv', bool_offset: bool = True, df: DataFrame | None = None, df_id: DataFrame | None = None, dict_discoverx_info: dict[str, DiscoverXInfo] = FieldInfo(annotation=NoneType, required=False, default_factory=dict, json_schema_extra={'initialize': False})) None
bool_offset: bool = True

Whether to use 1-based indexing (True) or 0-based indexing (False). Default is True.

Type:

bool

check_multimatch_str(list_in: list[tuple[int, str]]) list[str][source]

Check which multi-mapping kinase IDs correspond to a given region.

Parameters:

list_in (list[tuple[int, str]]) – List of tuples of (row index, kinase ID) for multi-mapping kinase IDs.

Returns:

List of strings containing the resolved kinase IDs.

Return type:

list[str]

df: DataFrame | None = None

DataFrame of the DiscoverX kinase construct information CSV.

Type:

pd.DataFrame

df_id: DataFrame | None = None

DataFrame of the UniProt ID mapping results.

Type:

pd.DataFrame

generate_dataframes() tuple[DataFrame, DataFrame][source]

Generate DataFrame of DiscoverX kinase construct information with UniProt mapping.

Returns:

dfpd.DataFrame

DataFrame of the DiscoverX kinase construct information.

df_idpd.DataFrame

DataFrame of the UniProt ID mapping results.

generate_discoverx_info_dict() dict[str, DiscoverXInfo][source]

Generate dictionary of DiscoverXInfo objects from the DataFrame.

Returns:

dict[str, DiscoverXInfo]

Dictionary of DiscoverXInfo objects keyed by DiscoverX gene symbol.

parse_mutation_info(str_mut: str) tuple[bool, dict[str, list | None]][source]

Parse mutation information from a mutation string.

Parameters:

str_mutstr

Mutation string in the format “A123B” (missense) or “A123-B” (deletion).

Returns:

tuple[bool, dict[str, list | None]]
Tuple of (is_wild_type, dict of mutations) where dict contains:
  • “missense”: list of missense mutations as tuples (wt_aa, position, mut_aa)

  • “deletion”: list of deletion mutations as tuples (wt_aa, list of positions, mut_aa or ‘-‘)

If wild-type, returns (True, {“missense”: None, “deletion”: None}). If mutations are present, returns (False, {“missense”: […], “deletion”: […]}). Missense mutations are represented as tuples of (WT AA, position, mutant AA). Deletion mutations are represented as tuples of (WT start AA, list of positions, WT end AA).

replace_multi_mapping_keys() list[str | None][source]

Combine mono- and multi-mapping UniProt ID lists into a single list.

Returns:

list[str | None]

Combined list of UniProt IDs.

static return_construct_boundaries(str_in: str) tuple[str | None, int | None, str | None, int | None][source]

Return the start and end indices of the kinase construct from the construct description.

Parameters:

str_instr

“AA Start/Stop” string.

Returns:

tuple[str | None, int | None, str | None, int | None]

Tuple of (str_start, idx_start, str_end, idx_end).

static return_deletion_mutation(str_in: str) tuple[str, list[int], str][source]

Return the start residue, list of codon indices, and end residue from a deletion

Parameters:

str_instr

Deletion mutation string (e.g., “A123-125del”).

Returns:

tuple[str, list[int], str]

Tuple of (str_start, list_idx_del, str_end).

static return_missense_mutation(str_in: str) tuple[str, int, str][source]

Return the wild-type residue, codon index, and mutant residue from a missense mutation string.

Parameters:

str_instr

Missense mutation string (e.g., “A123T”).

Returns:

tuple[str, int, str]

Tuple of (str_wt, idx_codon, str_mut).

str_url: str = 'https://raw.githubusercontent.com/openkinome/kinoml/refs/heads/master/kinoml/data/kinomescan/DiscoverX_489_Kinase_Assay_Construct_Information.csv'

URL to the DiscoverX kinase construct information CSV.

Type:

str