tcrpmhcdataset.TCR

The purpose of this python3 script is to implement the TCR dataclass.

@dataclass(frozen=True)
class TCR:

Define a Meaningful TCR Object that is used to store TCR information in the context of paired immmunogenicity data. Implemented as a frozen dataclass to ensure that TCR data does not change during processing. Standardization is performed using the 'tidytcells' package authored by Yuta Nagano.

Attributes:

  • cdr3b (str, required): The CDR3 beta sequence.
  • trbv (str, required): The TRBV gene in IMGT format.
  • trbj (str, required): The TRBJ gene in IMGT format
  • trbd (str, optional): The TRBD gene in IMGT format. Defaults to None.
  • tcrb_full (str, optional): The full beta TCR sequence. Defaults to None.
  • cdr3a (str, optional): The CDR3 alpha sequence. Defaults to None.
  • trav (str, optional): The TRAV gene in IMGT format. Defaults to None.
  • traj (str, optional): The TRAJ gene in IMGT format. Defaults to None.
  • trad (str, optional): The TRAD gene in IMGT format. Defaults to None.
  • tcra_full (str, optional): The full alpha TCR sequence. Defaults to None.
  • pMHC (pMHC, optional): The pMHC object recognized by this TCR. Defaults to None.
  • reference (str, optional): The reference for this TCR. Defaults to None.

Implements:

  • __init__: Initialize the TCR object
  • __post_init__: Standardize the input fields using IMGT format and check for minimum required inputs.
  • __repr__: Return a uniquely identifiable representation of the TCR object.
  • __str__: Return an string representation of the TCR object for user interaction.
  • __eq__: Check if two TCR objects are functionally equivalent. As such it does not check for equality across all the possible fields of the TCR but checks for the CDR3 regions as well as the TRBV and TRBJ genes.
  • __hash__: Hash the TCR object
  • add_pMHC: Add a pMHC to the set of cognate pMHCs recognized by this TCR
  • add_reference: Add a reference to the set of references for this TCR
  • get_pMHCs: Get the set of pMHCs recognized by this TCR
  • get_references: Get the set of references for this TCR

Returns:

  • TCR Object: A TCR dataclass object that can be used to store TCR information
TCR( cdr3b: str, trbv: str, trbj: str, trbd: Optional[str] = None, tcrb_full: Optional[str] = None, cdr3a: Optional[str] = None, trav: Optional[str] = None, traj: Optional[str] = None, trad: Optional[str] = None, tcra_full: Optional[str] = None, use_cdr3b: bool = True, use_cdr3a: bool = False, use_trb: bool = False, use_tra: bool = False, pMHC: Optional[object] = None, reference: Optional[str] = None, pMHCs: Set[NoneType] = <factory>, references: Set[str] = <factory>)
cdr3b: str
trbv: str
trbj: str
trbd: Optional[str] = None
tcrb_full: Optional[str] = None
cdr3a: Optional[str] = None
trav: Optional[str] = None
traj: Optional[str] = None
trad: Optional[str] = None
tcra_full: Optional[str] = None
use_cdr3b: bool = True
use_cdr3a: bool = False
use_trb: bool = False
use_tra: bool = False
pMHC: Optional[object] = None
reference: Optional[str] = None
pMHCs: Set[NoneType]
references: Set[str]
def add_pMHC(self, pMHC):

Add a pMHC to the set of cognate pMHCs recognized by this TCR

Args:

  • pMHC (pMHC Object): The pMHC to add.

Returns:

  • None
def add_reference(self, reference):

Add a supporting reference to the set of references for this TCR

Args:

  • reference (str): The reference to add

Returns:

  • None
def get_pMHCs(self):

Get the set of pMHCs recognized by this TCR

Returns:

  • pmhcs: The set of pMHCs recognized by this TCR
def get_references(self):

Get the set of references for this TCR

Returns:

  • references: The set of references for this TCR