Skip to content

Commit

Permalink
GeneOntologyDb code rewrites; Check_args fix (#30)
Browse files Browse the repository at this point in the history
* condense ifelse conditional for is_in_db function

* fix incorrect filename for tax_check

* simplify slim-ancestors loop
  • Loading branch information
jraysajulga authored and Caleb Easterly committed Mar 31, 2019
1 parent df7402e commit a568978
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 9 deletions.
12 changes: 4 additions & 8 deletions metaquantome/databases/GeneOntologyDb.py
Original file line number Diff line number Diff line change
Expand Up @@ -96,10 +96,7 @@ def is_in_db(self, goid):
:param goid: query GO term
:return: True if GO is present in GO database; False otherwise
"""
if goid in self.gofull.keys():
return True
else:
return False
return goid in self.gofull.keys()

def map_set_to_slim(self, sample_set):
"""
Expand Down Expand Up @@ -142,10 +139,9 @@ def map_id_to_slim(self, goid):
potential_closest = set()
# get term parents
ancestors = list(ancestor_set)
in_slim = [full_id in slim_ids for full_id in ancestors]
for i in range(0, len(ancestors)):
if in_slim[i]:
potential_closest.update(safe_cast_to_list(ancestors[i]))
for full_id in ancestors:
if full_id in slim_ids:
potential_closest.update(safe_cast_to_list(full_id))
# no potential closest
if len(potential_closest) == 0:
# new ancestors are the parents of the old ancestors
Expand Down
2 changes: 1 addition & 1 deletion metaquantome/util/check_args.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ def tax_check(tax_file, tax_colname):
if not tax_file:
raise IOError('Taxonomy tabular file not provided (--tax_file)')
if not os.path.exists(tax_file):
raise FileNotFoundError('func_file does not exist. Please check filename')
raise FileNotFoundError('tax_file does not exist. Please check filename')
if not tax_colname:
raise ValueError('tax_colname=None. Please provide a taxonomy column name (--tax_colname)')

0 comments on commit a568978

Please sign in to comment.