old_contents: #!/usr/bin/env python 
  
  import os
  import sys
  
  __description__ = "Parses the taxonomy id file from UniProt for all the species."
  __author__ = "Malvika Sharan <malvika.sharan@uni-wuerzburg.de>"
  __email__ = "malvika.sharan@uni-wuerzburg.de"
  
  def select_taxids(taxonomy_file, species):
      '''Selects taxonomy ids for the query species'''
      if not str(species) == 'None':
          parse_uniprot_tax_file(species, db_path)
      else:
          parse_uniprot_tax_file('N=', db_path)
      
  def parse_uniprot_tax_file(species, db_path):
      '''Parses the taxonomy id file from UniProt for all the species'''
      with open('bin/selected_taxonomy_ids.txt', 'w') as out_fh:
          out_fh.write("Official (scientific) name\tTaxonomy ID\n")
          with open(taxonomy_file, 'r') as in_fh:
              for entry in in_fh:
                  if 'N=' in entry:
                      if ',' in species:
                          for each_species in species.split(','):
                              if each_species.lower() in entry.lower():
                                  tax_id = entry.split(':')[0].split(' ')[-1]
                                  species_name = entry.strip().split('=')[1]
                                  out_fh.write("%s\t%s\n" % (species_name, tax_id))
                      else:
                          if species.lower() in entry.lower():
                              tax_id = entry.split(':')[0].split(' ')[-1]
                              species_name = entry.strip().split('=')[1]
                              out_fh.write("%s\t%s\n" % (species_name, tax_id))
    
  if __name__ == '__main__':
      db_path = sys.argv[1]
      species = sys.argv[2]
      setup_analysis_folders(db_path, species)
  
new_contents: #!/usr/bin/env python 
  
  import os
  import sys
  
  __description__ = "Parses the taxonomy id file from UniProt for all the species."
  __author__ = "Malvika Sharan <malvika.sharan@uni-wuerzburg.de>"
  __email__ = "malvika.sharan@uni-wuerzburg.de"
  
  def select_taxids(taxonomy_file, species):
      '''Selects taxonomy ids for the query species'''
      if not str(species) == 'None':
          parse_uniprot_tax_file(species, taxonomy_file)
      else:
          parse_uniprot_tax_file('N=', taxonomy_file)
      
  def parse_uniprot_tax_file(species, taxonomy_file):
      '''Parses the taxonomy id file from UniProt for all the species'''
      with open('bin/selected_taxonomy_ids.txt', 'w') as out_fh:
          out_fh.write("Official (scientific) name\tTaxonomy ID\n")
          with open(taxonomy_file, 'r') as in_fh:
              for entry in in_fh:
                  if 'N=' in entry:
                      if ',' in species:
                          for each_species in species.split(','):
                              if each_species.lower() in entry.lower():
                                  tax_id = entry.split(':')[0].split(' ')[-1]
                                  species_name = entry.strip().split('=')[1]
                                  out_fh.write("%s\t%s\n" % (species_name, tax_id))
                      else:
                          if species.lower() in entry.lower():
                              tax_id = entry.split(':')[0].split(' ')[-1]
                              species_name = entry.strip().split('=')[1]
                              out_fh.write("%s\t%s\n" % (species_name, tax_id))
    
  if __name__ == '__main__':
      taxonomy_file = sys.argv[1]
      species = sys.argv[2]
      setup_analysis_folders(taxonomy_file, species)
  
subject: Update uniprot_taxid.py