# total number of proteins read from file protein_count = 0 # counters for TF and nucleus proteins tf_nucleus_count = 0 not_tf_nucleus_count = 0 tf_not_nucleus_count = 0 not_tf_not_nucleus_count = 0 for line in yeast_file: protein_count += 1 fields = line.strip().split("\t") protein_id = fields[0] protein_identifiers.append(protein_id) go_terms = getGOTerms(fields[0]) go_terms_dict[protein_id] = go_terms if "GO:0005634" in go_terms: # check if nucleus if "GO:0003700" in go_terms: # check if TF tf_nucleus_count += 1 else: not_tf_nucleus_count += 1 else: if "GO:0003700" in go_terms: # check if TF tf_not_nucleus_count += 1 else: not_tf_not_nucleus_count += 1 file.close() print "Exercise 4.1 - protein identifiers: ", protein_identifiers print "Exercise 4.2 - GO Terms"
# counters for TF and nucleus proteins tf_nucleus_count = 0 not_tf_nucleus_count = 0 tf_not_nucleus_count = 0 not_tf_not_nucleus_count = 0 for line in yeast_file: protein_count += 1 fields = line.strip().split("\t") protein_id = fields[0] protein_identifiers.append(protein_id) # ex 5.1 yeast_file.close() # dictionary of go_terms with the gene ID as the key go_terms_dict = getGOTerms(protein_identifiers) for protein_id in go_terms_dict: go_terms = go_terms_dict.get(protein_id) if "GO:0005634" in go_terms: # check if nucleus if "GO:0003700" in go_terms: # check if TF tf_nucleus_count += 1 else: not_tf_nucleus_count += 1 else: if "GO:0003700" in go_terms: # check if TF tf_not_nucleus_count += 1 else: not_tf_not_nucleus_count += 1