@@ -1631,15 +1631,15 @@ def get_sequence_for_fasta(template, MHC_class, chain):
16311631
16321632
16331633def generate_mhcseq_database (data_dir = PANDORA .PANDORA_data + '/mhcseqs' ,
1634- HLA_out = 'Human_MHC_data .fasta' ,
1635- nonHLA_out = 'NonHuman_MHC_data .fasta' ):
1636- """generate_mhcseq_database(data_dir=PANDORA.PANDORA_data, HLA_out='Human_MHC_data .fasta', nonHLA_out='NonHuman_MHC_data .fasta')
1634+ HLA_out = 'HLA_cleaned .fasta' ,
1635+ nonHLA_out = 'MHC_cleaned .fasta' ):
1636+ """generate_mhcseq_database(data_dir=PANDORA.PANDORA_data, HLA_out='HLA_cleaned .fasta', nonHLA_out='MHC_cleaned .fasta')
16371637 Downloads and parse HLA and other MHC sequences to compile reference fastas
16381638
16391639 Args:
16401640 data_dir (str, optional): Data directory. Defaults to PANDORA.PANDORA_data.
1641- HLA_out (str, optional): Output file for HLA sequences. Defaults to 'Human_MHC_data .fasta'.
1642- nonHLA_out (str, optional): Output file for non human MHCs. Defaults to 'NonHuman_MHC_data .fasta'.
1641+ HLA_out (str, optional): Output file for HLA sequences. Defaults to 'HLA_cleaned .fasta'.
1642+ nonHLA_out (str, optional): Output file for non human MHCs. Defaults to 'MHC_cleaned .fasta'.
16431643
16441644 Returns:
16451645 None.
@@ -1665,12 +1665,12 @@ def generate_mhcseq_database(data_dir = PANDORA.PANDORA_data + '/mhcseqs',
16651665 return ref_MHCI_sequences
16661666
16671667
1668- def generate_hla_database (data_dir , HLA_out = 'Human_MHC_data .fasta' ):
1668+ def generate_hla_database (data_dir , HLA_out = 'HLA_cleaned .fasta' ):
16691669 """
16701670 Downloads and parse HLA sequences
16711671
16721672 Args:
1673- HLA_out (str, optional): Output file for HLA sequences. Defaults to 'Human_MHC_data .fasta'.
1673+ HLA_out (str, optional): Output file for HLA sequences. Defaults to 'HLA_cleaned .fasta'.
16741674
16751675 Returns:
16761676 None.
@@ -1681,21 +1681,21 @@ def generate_hla_database(data_dir, HLA_out = 'Human_MHC_data.fasta'):
16811681 ###
16821682 # Rename pre-existing raw file
16831683 try :
1684- os .system ('mv %s/hla_prot .fasta %s/OLD_hla_prot .fasta' % (data_dir , data_dir ))
1684+ os .system ('mv %s/HLA_raw .fasta %s/OLD_HLA_raw .fasta' % (data_dir , data_dir ))
16851685 except :
16861686 pass
16871687
16881688 # Download Human data
16891689 url = 'https://raw.githubusercontent.com/ANHIG/IMGTHLA/Latest/hla_prot.fasta'
1690- command = (' ' ).join (['wget' , url , '-P ' , data_dir ])
1690+ command = (' ' ).join (['wget' , url , '-O ' , f' { data_dir } /HLA_raw.fasta' ])
16911691 proc = subprocess .Popen (command , executable = '/bin/bash' ,
16921692 shell = True , stdout = subprocess .PIPE )
16931693 print (proc .stdout .read ())
16941694
16951695 HLAs = {}
16961696 to_write = {}
16971697 #Parse the fasta files
1698- for seq_record in SeqIO .parse (data_dir + '/hla_prot .fasta' , "fasta" ):
1698+ for seq_record in SeqIO .parse (f' { data_dir } /HLA_raw .fasta' , "fasta" ):
16991699 allele_fullname = seq_record .description .split (' ' )[1 ]
17001700 #allele_significant = allele_fullname[:8]
17011701 #Take only up to the allele identifyer, ignore the silent mutations
@@ -1743,18 +1743,18 @@ def generate_hla_database(data_dir, HLA_out = 'Human_MHC_data.fasta'):
17431743
17441744 # Remove pre-existing raw file
17451745 try :
1746- os .system ('rm %s/OLD_hla_prot .fasta' % data_dir )
1746+ os .system (f 'rm { data_dir } /OLD_HLA_raw .fasta' )
17471747 except :
17481748 pass
17491749
17501750 return to_write
17511751
1752- def generate_nonhla_database (data_dir , nonHLA_out = 'NonHuman_MHC_data .fasta' ):
1752+ def generate_nonhla_database (data_dir , nonHLA_out = 'MHC_cleaned .fasta' ):
17531753 """
17541754 Downloads and parse non human MHC sequences
17551755
17561756 Args:
1757- nonHLA_out (str, optional): Output file for non human MHCs. Defaults to 'NonHuman_MHC_data .fasta'.
1757+ nonHLA_out (str, optional): Output file for non human MHCs. Defaults to 'MHC_cleaned .fasta'.
17581758
17591759 Returns:
17601760 None.
@@ -1765,22 +1765,22 @@ def generate_nonhla_database(data_dir, nonHLA_out = 'NonHuman_MHC_data.fasta'):
17651765 ###
17661766 # Rename pre-existing raw file
17671767 try :
1768- os .system ('mv %s/MHC_prot .fasta %s/OLD_MHC_prot .fasta' % ( data_dir , data_dir ) )
1768+ os .system (f 'mv { data_dir } /MHC_raw .fasta { data_dir } /OLD_MHC_raw .fasta' )
17691769 except :
17701770 pass
17711771
17721772 # Download other animlas data
17731773 #os.system('wget https://raw.githubusercontent.com/ANHIG/IPDMHC/Latest/MHC_prot.fasta')
17741774 url = 'https://raw.githubusercontent.com/ANHIG/IPDMHC/Latest/MHC_prot.fasta'
1775- command = (' ' ).join (['wget' , url , '-P ' , data_dir ])
1775+ command = (' ' ).join (['wget' , url , '-O ' , f' { data_dir } /MHC_raw.fasta' ])
17761776 proc = subprocess .Popen (command , executable = '/bin/bash' ,
17771777 shell = True , stdout = subprocess .PIPE )
17781778 print (proc .stdout .read ())
17791779
17801780 MHCs = {}
17811781 to_write = {}
17821782 #Parse the fasta file
1783- fasta = f'{ data_dir } /MHC_prot .fasta'
1783+ fasta = f'{ data_dir } /MHC_raw .fasta'
17841784 for seq_record in SeqIO .parse (fasta , "fasta" ):
17851785 allele_fullname = seq_record .description .split (' ' )[1 ]
17861786 #allele_significant = allele_fullname[:8]
@@ -1827,7 +1827,7 @@ def generate_nonhla_database(data_dir, nonHLA_out = 'NonHuman_MHC_data.fasta'):
18271827
18281828 # Remove pre-existing raw file
18291829 try :
1830- os .system ('rm %s/OLD_MHC_prot .fasta' % data_dir )
1830+ os .system (f 'rm { data_dir } /OLD_MHC_raw .fasta' )
18311831 except :
18321832 pass
18331833
0 commit comments