uniprot

UniProt retrieval helpers plus mutation and comparison utilities for protein sequences.

UniProt Queries


source

get_uniprot_seq


def get_uniprot_seq(
    uniprot_id:str
)->str:

Queries the UniProt database to retrieve the protein sequence for a given UniProt ID.

get_uniprot_seq("P04626")[:60]

source

get_uniprot_features


def get_uniprot_features(
    uniprot_id:str
)->dict:

Given a UniProt ID, fetch the protein metadata and annotated features.

get_uniprot_features("P04626").keys()

source

get_uniprot_kd


def get_uniprot_kd(
    uniprot_id:str
)->list:

Query Domain: Protein kinase entries based on a UniProt ID.

get_uniprot_kd("P04626")

source

get_uniprot_type


def get_uniprot_type(
    uniprot_id:str, # UniProt accession to inspect
    type_:str='Signal', # feature type to filter for
)->list[dict[str, object]] | list[str]:

Get region sequences for a UniProt feature type.

get_uniprot_type("P04626", "Signal")[:1]

Sequence Mutation


source

apply_mut_single


def apply_mut_single(
    seq:str, # protein sequence to edit
    mutations:str, # point mutations such as E709A
    start_pos:int=1, # residue number of seq[0]
)->str:

Apply point mutations to a protein sequence.

apply_mut_single("MEEPQ", "M1A", "E2S")

source

apply_mut_complex


def apply_mut_complex(
    seq:str, # protein sequence to edit
    mut:str, # composite mutation such as G776delinsVC/S783C
    start_pos:int=1, # residue number of seq[0]
)->str:

Apply a composite mutation string to a protein sequence.

her2_seq = "LRKVKVLGSGAFGTVYKGIWIPDGENVKIPVAIKVLRENTSPKANKEILDEAYVMAGVGSPYVSRLLGICLTSTVQLVTQLMPYGCLLDHVRENRGRLGSQDLLNWCMQIAKGMSYLEDVRLVHRDLAARNVLVKSPNHVKITDFGLARLLDIDETEYHADGGKVPIKWMALESILRRRFTHQSDVWSYGVTVWELMTFGAKPYDGIPAREIPDLLEKGERLPQPPICTIDVYMIMVKCWMIDSECRPRFRELVSEFSRMARDPQRFV"
apply_mut_complex(her2_seq, "G776delinsVC/S783C", start_pos=720)[:25]

source

compare_seq


def compare_seq(
    seq1:str, # reference sequence
    seq2:str, # sequence to compare against seq1
    start_pos:int=1, # residue number of seq1[0]
    label1:str='Original', # label for the first sequence block
    label2:str='Mutant', # label for the second sequence block
    visualize:bool=True, # include block alignment output when True
    return_text:bool=False, # return the rendered text instead of None
)->str | None:

Align two protein sequences and summarize the differences.

print(compare_seq("MEEPQ", "MAEPQ", return_text=True))