<jupyter_start><jupyter_text>Example usage of PyPresent code Move into the PyPresent directory<jupyter_code>import sys
sys.path.append('/home/wsx/projects/pypresent/')<jupyter_output><empty_output><jupyter_text>Import the necessary modules<jupyter_code>from mutation import Mutation
from allele import Allele
from patient import Patient
from config import check<jupyter_output><empty_output><jupyter_text>Create a mutation object This object represents the mutated residue that could be presented. There are **two** ways to import the sequence: **Example mutation:*** Gene: OR5AC1 * Mutated position: 20 * Native amino acid: X * New amino acid: 'K'<jupyter_code># 1. Fasta file
mut = Mutation(20, 'K', from_file=True, gene_fasta_file='./data/protein.fa', id='OR5AC1_X20K')
# 2. Directly with a string
#from Bio import SeqIO
#with open('./data/protein.fa', 'r') as handle:
#    fasta_sequences = next(SeqIO.parse(handle,'fasta'))
#sequence = str(fasta_sequences.seq)
#mut = Mutation(21, 'K', from_file=False, gene_sequence=sequence, native_aa='P', id='OR5AC1_P21K')
# 1. Fasta file
mut = Mutation(20, 'H', from_file=True, 
               gene_fasta_file='./data/protein.fa', id='OR5AC1_X20K',
               native_aa='H')<jupyter_output>9 30
5 34<jupyter_text>Create an allele object This object represents a single MHC-I or MHC-II allele. Only create an allele object if you want a single-allelic score.<jupyter_code>aI = Allele('HLA-A01:01', mhc_class='I')
aII = Allele('DRB1_1114', mhc_class='II')<jupyter_output><empty_output><jupyter_text>Call single-allelic score<jupyter_code>check(aI)
check(mut)
aI.allele_score(mut, verbose = True)
aII.allele_score(mut, verbose = True)
# See command behind the python scripts
aI.allele_score(mut, verbose=True)<jupyter_output>Running command:  /public/tools/netMHC/netMHCpan-4.0/netMHCpan -a HLA-A01:01 -f /home/wsx/tmp/netMHC/OR5AC1_X20K_1569581656 -xls -xlsfile /home/wsx/tmp/netMHC/raw_affinities.OR5AC1_X20K_OV4EC2 > /home/wsx/tmp/netMHC/trash.OR5AC1_X20K_OV4EC2<jupyter_text>Create a patient object This object represents a patient and is defined by all of their MHC-I and/or MHC-II alleles..<jupyter_code>allelesI = ['HLA-A11:01', 'HLA-A31:35', 'HLA-B07:02', 'HLA-B40:30', 'HLA-C06:19', 'HLA-C07:07']
allelesII = ['DRB1_1114', 'DRB1_1301', 'DRB1_1114', 'DRB1_1301', \
             'HLA-DQA10511-DQB10308', 'HLA-DQA10509-DQB10628', \
             'HLA-DQA10511-DQB10628', 'HLA-DQA10509-DQB10308', \
             'HLA-DPA10301-DPB19201', 'HLA-DPA10103-DPB13401', \
             'HLA-DPA10301-DPB13401', 'HLA-DPA10103-DPB19201']
p = Patient(allelesI, allelesII)<jupyter_output><empty_output><jupyter_text>Call multi-allelic score<jupyter_code>p.patient_score(mut, mhc_class='I')
p.patient_score(mut, mhc_class='II')
# Only input MHC I
allelesI = ['HLA-A11:01', 'HLA-A31:35', 'HLA-B07:02', 'HLA-B40:30', 'HLA-C06:19', 'HLA-C07:07']

p = Patient(allelesI, [])

p.patient_score(mut, mhc_class='I')<jupyter_output><empty_output><jupyter_text>Warning: netMHCpan/netMHCIIpan leave residual files. Be sure to delete your temparary directory after running.<jupyter_code># add removal statement
# ! rm /cellar/users/ramarty/Data/pypresent/tmp/*<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.13858611024602926, 'fraction_numerical': 0.06851448146994706, 'mean_word_length': 5.6777546777546775, 'pattern_counts': {'":': 0, '<': 31, '<?xml version=': 0, '>': 32, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '8', 'dir': 'jupyter-structured-clean-dedup', 'id': '55686', 'license': 'MIT', 'n_tokens_mistral': 1422, 'n_tokens_neox': 1260, 'n_words': 247, 'path': 'example_usage.ipynb', 'repo_name': 'XSLiuLab/pypresent', 'size': '3211'}