Skip to content

Commit

Permalink
Enable ASCII art gene printer to work with genes in a string or a list.
Browse files Browse the repository at this point in the history
  • Loading branch information
dvklopfenstein committed Aug 21, 2018
1 parent 292b589 commit 5984ccc
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions goatools/grouper/aart_geneproducts_one.py
Original file line number Diff line number Diff line change
Expand Up @@ -167,10 +167,17 @@ def get_sec2gos(sortobj):
def get_gene2gos(go2nt):
"""Create a gene product to GO set dict."""
gene2gos = cx.defaultdict(set)
#print("NNNNTTTT", next(iter(go2nt.values())))
nt0 = next(iter(go2nt.values()))
b_str = isinstance(nt0.study_items, str)
# print("NNNNTTTT", nt0)
for goid, ntgo in go2nt.items():
for geneid in ntgo.study_items:
study_items = ntgo.study_items.split(', ') if b_str else ntgo.study_items
for geneid in study_items:
gene2gos[geneid].add(goid)
if b_str:
b_set = set(isinstance(g.isdigit(), int) for g in nt0.study_items.split(', '))
if b_set == set([True]):
return {int(g):gos for g, gos in gene2gos.items()}
return {g:gos for g, gos in gene2gos.items()}

@staticmethod
Expand Down

0 comments on commit 5984ccc

Please sign in to comment.