Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
def _get_objanno(fin_anno, anno_type=None, **kws):
"""Get association object"""
full_anno = os.path.join(REPO, fin_anno)
dnld_annofile(full_anno, anno_type)
obj = get_objanno(full_anno, anno_type, **kws)
return obj
def get_objanno(fin_anno, anno_type=None, **kws):
"""Get association object"""
full_anno = os.path.join(REPO, fin_anno)
dnld_annofile(full_anno, anno_type)
obj = get_objanno(full_anno, anno_type, **kws)
return obj
def get_objanno(fin_anno, godag, namespace='all'):
"""Get annotation object"""
fin_full = get_anno_fullname(fin_anno)
return get_objanno_factory(fin_full, godag=godag, namespace=namespace)
def _get_objanno(fin_anno, anno_type=None, **kws):
"""Get association object"""
full_anno = os.path.join(REPO, fin_anno)
dnld_annofile(full_anno, anno_type)
obj = get_objanno(full_anno, anno_type, **kws)
return obj
def _get_objanno(fin_anno, anno_type=None, **kws):
"""Get association object"""
full_anno = os.path.join(REPO, fin_anno)
dnld_annofile(full_anno, anno_type)
obj = get_objanno(full_anno, anno_type, **kws)
if obj.name in {'gene2go', 'gaf'} or 'godag' in kws:
assert hasattr(obj.associations[0], 'NS')
# Check namespaces, if provided by the user
if 'namespaces' in kws:
_chk_namespaces(obj, kws['namespaces'])
return obj
def _get_objanno(fin_anno, anno_type=None, **kws):
"""Get association object"""
full_anno = os.path.join(REPO, fin_anno)
dnld_annofile(full_anno, anno_type)
obj = get_objanno(full_anno, anno_type, **kws)
return obj
def test_update_association():
"""Compare new propagate cnts function with original function. Test assc results is same."""
print('\n1) READ GODAG:')
assc_name = "goa_human.gaf" # gene_association.fb gene_association.mgi
obo = os.path.join(REPO, "go-basic.obo")
tic = timeit.default_timer()
godag = get_godag(obo)
tic = prt_hms(tic, "Created two GODags: One for original and one for new propagate counts")
print('\n2) READ ANNOTATIONS:')
assc_orig = dnld_assc(os.path.join(REPO, assc_name), godag)
tic = prt_hms(tic, "Associations Read")
objanno = get_objanno(os.path.join(REPO, assc_name), 'gaf', godag=godag)
tic = prt_hms(tic, "Associations Read")
print('\n3) MAKE COPIES OF ASSOCIATIONS:')
assc1 = {g:set(gos) for g, gos in assc_orig.items()}
assc2 = {g:set(gos) for g, gos in assc_orig.items()}
tic = prt_hms(tic, "Associations Copied: One for original and one for new")
print('\n4) UPDATE ASSOCIATIONS (PROPAGATE COUNTS):')
godag.update_association(assc1)
tic = prt_hms(tic, "ORIG: godag.update_association(assc)")
update_association(assc2, godag)
tic = prt_hms(tic, "NEW SA: update_association(go2obj, assc_orig)")
assc3 = objanno.get_id2gos(namespace='BP', propagate_counts=True)
tic = prt_hms(tic, "NEW BASE: update_association(go2obj, assc_orig)")
print('\n5) RUN CHECKS')
def _get_objanno(self, assoc_fn):
"""Get an annotation object"""
# Determine annotation file format from filename, if possible
anno_type = get_anno_desc(assoc_fn, None)
# Default annotation file format is id2gos
if anno_type is None:
anno_type = self.args.annofmt if self.args.annofmt else 'id2gos'
# kws: namespaces taxid godag
kws = self._get_kws_objanno(anno_type)
return get_objanno(assoc_fn, anno_type, **kws)