<commit_before>##input: /Users/metagenomics/Documents/Databases/uniprot_tremble.dat or uniprot_sprot.dat

import sys
import os
from Bio import SeqIO
#import gzip

uniprot = open(sys.argv[1], "rU")

taxa_to_print=[]
for record in SeqIO.parse(uniprot, "swiss"):
#	print record
#	id = record.id
	taxa_to_print.append(sys.argv[1].split(".")[0])
	taxa_to_print.append(record.annotations['organism'])
	for taxa in record.annotations['taxonomy']:
		taxa_to_print.append(taxa)
print '\t'.join(taxa_to_print)
	#if record.annotations['taxonomy'] >1:
	#	domain = record.annotations['taxonomy'][1]
	#	if kingdom != 'Eukaryota':
	#		print "%s\t%s" % (id, kingdom)
	#	else:
	#		if domain == 'Fungi':
#	print '\t'.joint(strain, taxa_to_print)<commit_msg>wrote get taxa into a function, removed fungi code from before<commit_after>##input: /Users/metagenomics/Documents/Databases/uniprot_tremble.dat or uniprot_sprot.dat

import sys
import os
from Bio import SeqIO
#import gzip

#This script uses biopython to get taxonomy from uniprot .dat file
'''
record.annotations         record.letter_annotations
record.dbxrefs             record.lower
record.description         record.name
record.features            record.reverse_complement
record.format              record.seq
record.id                  record.upper
'''

def get_taxa(uniprot_dat):
	taxa_to_print=[]
	for record in SeqIO.parse(uniprot_dat, "swiss"):
#		taxa_to_print.append(record.id)
		taxa_to_print.append(uniprot_dat.split(".")[0])
		taxa_to_print.append(record.annotations['organism'])
		for taxa in record.annotations['taxonomy']:
			taxa_to_print.append(taxa)
	return '\t'.join(taxa_to_print)

uniprot_dat = sys.argv[1:]

for f in uniprot_dat:
	taxa = get_taxa(f)
	print taxa
{'fraction_non_alphanumeric': 0.1267361111111111, 'fraction_numerical': 0.004050925925925926, 'mean_word_length': 4.559485530546624, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, '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}}
{'dir': 'git-commits-cleaned', 'id': '2171565', 'n_tokens_mistral': 656, 'n_tokens_neox': 635, 'n_words': 129}