uniprot_extraction
UniProt extraction and mapping helpers for structures.
ChainUniprotPair = namedtuple('ChainUniprotPair', ['chain_id', 'uniprot_accession'])
module-attribute
¶
Pair of chain id and UniProt accession for mapping purposes.
UniprotSource = Literal['both', 'sifts', 'struct_ref_seq', 'fallback']
module-attribute
¶
From which source to extract UniProt accessions from a structure.
FlattenedUniprotChainMapping
dataclass
¶
Collapsed _struct_ref_seq like alignment information for one chain.
Attributes:
uniprot_accession: The UniProt accession.
uniprot_start: The start position of the alignment on the UniProt sequence.
uniprot_end: The end position of the alignment on the UniProt sequence.
chain_id: The chain ID in the 'auth' [chain ID system][protein_quest.structure.chains.ChainIdSystem].
sequence_identity: The sequence identity of the alignment.
aligned_residue_count: The number of aligned residues in the alignment.
flatten_uniprot_chain_mappings(mappings)
¶
Flatten a set of UniprotChainMapping.
Each (accession, chain) group is collapsed into one record with merged start/end
and aligned_residue_count summed across all ranges.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
mappings
|
UniprotChainMappings
|
Set of UniprotChainMapping. |
required |
Returns:
| Type | Description |
|---|---|
set[FlattenedUniprotChainMapping]
|
Set of flattened per-(accession, chain) records with merged start/end, |
set[FlattenedUniprotChainMapping]
|
summed aligned residue counts, and computed sequence identity. |
structure2uniprot_accessions(structure_file)
¶
Extract UniProt accessions from a structure file.
Logs a warning and returns an empty set if no accessions are found in structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure_file
|
Path
|
Source mmCIF path to preserve raw SIFTS segment data. |
required |
Returns:
| Type | Description |
|---|---|
set[str]
|
A set of UniProt accessions found in the structure. |
structure_to_uniprot(structure_file, source='both', one_uniprot_per_chain=True, structure=None)
¶
Extract UniProt chain mappings from a structure.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure_file
|
Path
|
Source mmCIF path. When provided for |
required |
source
|
UniprotSource
|
UniProt source to read from.
|
'both'
|
one_uniprot_per_chain
|
bool
|
If True, return only the best UniProt per chain, based on highest aligned residue count, with ties broken alphabetically by accession. Otherwise, return all UniProt mappings for each chain. |
True
|
structure
|
Structure | None
|
The structure containing SIFTS and/or |
None
|
Returns:
| Type | Description |
|---|---|
set[FlattenedUniprotChainMapping]
|
Set of flattened per-(accession, chain) records with merged start/end, |
set[FlattenedUniprotChainMapping]
|
summed aligned residue counts, and computed sequence identity. |
uniprot_chain_mappings_from_struct_ref_seq(structure)
¶
Extract UniProt chain mappings from _struct_ref_seq rows.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
structure
|
Structure
|
The structure containing |
required |
Returns:
| Type | Description |
|---|---|
UniprotChainMappings
|
Set of UniProt chain mappings with ranges per chain. Empty if no UNP data found. |