Skip to content

Commit

Permalink
Fixed bug in cellular locations
Browse files Browse the repository at this point in the history
  • Loading branch information
iriziotis committed May 30, 2024
1 parent de234cc commit 3ef55b6
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 103 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
__pycache__/
test/
todel/
results/
data/*
!data/sample*
tt
yy
jj
Expand Down
100 changes: 0 additions & 100 deletions data/uniprot_ids_first100.txt

This file was deleted.

7 changes: 4 additions & 3 deletions uniprot_annotation.py
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ def get_prot_annotations(results):
"""Extracts protein-level annotations (e.g. GO-terms,
subcellular locations etc.)"""
# Initialise dictionaries
slocs = set() # Curated subcellular locations
slocs = defaultdict(set) # Curated subcellular locations
go_func = defaultdict(set) # Molecular function GO terms
go_proc = defaultdict(set) # Biological process GO terms
go_comp = defaultdict(set) # Cellular component GO terms
Expand All @@ -191,7 +191,7 @@ def get_prot_annotations(results):
for ann in entry['to']['comments']:
if ann['commentType'] == 'SUBCELLULAR LOCATION':
for sloc in ann['subcellularLocations']:
slocs.add(sloc['location']['value'])
slocs[key].add(sloc['location']['value'])
except KeyError:
continue
# Go terms
Expand Down Expand Up @@ -264,6 +264,7 @@ def write_csv(features, variants, slocs, go_all,
print(header, file=o)
for k,v in features.items():
vnts = variants.get(k, set())
_slocs = slocs.get(k[0], set())
_go_all = go_all.get(k[0], set())
_go_func = go_func.get(k[0], set())
_go_proc = go_proc.get(k[0], set())
Expand All @@ -272,7 +273,7 @@ def write_csv(features, variants, slocs, go_all,
f'{k[1]},'
f'"{";".join(v)}",'
f'"{";".join(vnts)}",'
f'"{";".join(slocs)}",'
f'"{";".join(_slocs)}",'
f'"{";".join(_go_all)}",'
f'"{";".join(_go_func)}",'
f'"{";".join(_go_proc)}",'
Expand Down

0 comments on commit 3ef55b6

Please sign in to comment.