mkt.databases.datasets.discoverx.DiscoverXInfo

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.

__init__(**data: Any) None

Create a new model by parsing and validating input data from keyword arguments.

Raises [ValidationError][pydantic_core.ValidationError] if the input data cannot be validated to form a valid model.

self is explicitly positional-only to allow self as a field name.

Methods

check_construct_boundaries(str_seq, int_idx, ...)

Raise error if construct boundaries do not match sequence.

check_deletion_boundaries(str_seq, int_idx, ...)

Raise error if deletion boundaries do not match sequence.

check_region_of_mutation(idx_start, idx_end, ...)

Check if mutation falls within kinase domain or KLIFS region.

convert_refseq2uniprot_mutations(idx_refseq)

Convert RefSeq mutation index to UniProt mutation index.

convert_uniprot2refseq_klifs_residues()

Convert KLIFS residues from UniProt to RefSeq indices.

extract_region_indices([bool_kd])

Extract kinase domain or KLIFS region indices from DICT_KINASE.

find_closest_mapping(idx_in[, iter_idx, ...])

Find closest mapping index if direct mapping is not available.

find_intra_gaps(dict_in[, bool_bl])

Find intra-pocket gaps in KLIFS pocket region.

generate_KLIFS2RefSeqIdx()

Generate mapping from KLIFS residue numbers to RefSeq indices.

generate_alignment_dict_including_gaps()

Return fully aligned KLIFS pocket.

generate_construct_dictionary()

Generate dictionary representation of the DiscoverXInfo object.

generate_construct_sequence_dict()

Generate dictionary of construct regions and their sequences.

generate_klifs_region_seq_list_from_dict_idx()

Generate mapping from RefSeq indices to KLIFS residue numbers.

get_boundaries_in_key([bool_klifs])

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

get_inter_region()

Get inter-region sequences.

get_intra_region()

Get intra-region sequences.

model_post_init(_DiscoverXInfo__context)

Post-initialization processing to populate additional fields.

recursive_idx_search(idx, in_dict, decreasing)

Recursively search for index in dictionary.

replace_mutations_in_sequences()

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

return_index(idx_in)

Return adjusted index based on offset setting.

return_intra_gap_substr(bl_bool)

Return intra-region gap substring.

return_refseq2uniprot_mapping()

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

validate_construct_boundaries(data)

validate_deletions(data)

validate_missense_mutations(data)

Attributes

discoverx_gene_symbol

DiscoverX gene symbol.

key

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

accession

DiscoverX accession of the kinase construct.

uniprot_id

UniProt accession of the kinase.

str_start

Amino acid at the start of the construct.

idx_start

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

str_stop

Amino acid at the stop of the construct.

idx_stop

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

seq_refseq

RefSeq sequence with deletions allowed.

seq_uniprot

UniProt canonical sequence with deletions allowed.

bool_wt

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

list_missense_mutations

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

list_deletion_mutations

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

list_uniprot2refseq

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

list_refseq2uniprot

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

bool_has_kd

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

bool_has_klifs

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

bool_mutations_in_kd_region

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

bool_mutations_in_klifs_region

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

bool_mutations_in_klifs_residues

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

dict_refseq_indices

Dictionary with 'start' and 'stop' indices for RefSeq sequence.

KLIFS2RefSeqIdx

Dictionary mapping KLIFS residue numbers to RefSeq indices.

KLIFS2RefSeqSeq

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

dict_construct_sequences

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

bool_offset

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

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]