예제 #1
0
def test_write_hier_bp_mf_cc():
    """Test that write hierarchy writes all: BP, MF, CC"""
    fin_anno = os.path.join(REPO, 'gene2go')
    fin_dag = os.path.join(REPO, "go-basic.obo")
    _dnld_anno(fin_anno)
    #godag = get_godag(os.path.join(REPO, 'go-basic.obo'), loading_bar=None)

    print('\nTEST STORING ONLY ONE SPECIES')
    #### obj = Gene2GoReader(fin_anno)
    godag = get_godag(fin_dag)
    gene2gos = read_annotations(namespace='ALL')
    tcntobj = TermCounts(godag, gene2gos) if gene2gos else None
    gosubdag = GoSubDag(godag.keys(),
                        godag,
                        relationships=False,
                        tcntobj=tcntobj,
                        children=True,
                        prt=sys.stdout)
    objwr = WrHierGO(gosubdag)

    # 2020 11:
    #     594,748 GO lines under GO:0008150
    #      23,199 GO lines under GO:0003674
    #       6,259 GO lines under GO:0005575
    #     624,206 items WROTE: tmp_test_wr_hier_BP_MF_CC.txt
    assert len(_wr_hier(['BP', 'MF', 'CC'], gosubdag.go2nt, objwr)) > 600000
    assert len(_wr_hier([
        'BP',
    ], gosubdag.go2nt, objwr)) > 500000
    assert len(_wr_hier([
        'MF',
    ], gosubdag.go2nt, objwr)) > 20000
    assert len(_wr_hier([
        'CC',
    ], gosubdag.go2nt, objwr)) > 5000
예제 #2
0
def test_semantic_i88():
    """Full set of annotations can be used to set TermCounts. No need to break it up."""
    godag = get_godag("go-basic.obo")
    # Associations
    fin_gaf = os.path.join(REPO, "tair.gaf")
    gene2gos_all = read_annotations(gaf=fin_gaf, namespace='ALL')
    gene2gos_bp = read_annotations(gaf=fin_gaf, namespace='BP')
    gene2gos_mf = read_annotations(gaf=fin_gaf, namespace='MF')
    gene2gos_cc = read_annotations(gaf=fin_gaf, namespace='CC')
    # Termcounts
    prt = sys.stdout
    termcounts_all = TermCounts(godag, gene2gos_all, prt=prt)
    termcounts_bp = TermCounts(godag, gene2gos_bp, prt=prt)
    termcounts_mf = TermCounts(godag, gene2gos_mf, prt=prt)
    termcounts_cc = TermCounts(godag, gene2gos_cc, prt=prt)
    # Test content in subset is the same as in the full GO counts
    for goid, cnt in termcounts_bp.gocnts.items():
        assert termcounts_all.gocnts[goid] == cnt
    for goid, cnt in termcounts_mf.gocnts.items():
        assert termcounts_all.gocnts[goid] == cnt
    for goid, cnt in termcounts_cc.gocnts.items():
        assert termcounts_all.gocnts[goid] == cnt
예제 #3
0
 def __init__(self, args=None, prt=sys.stdout):
     self.kws = DocOptParse(__doc__, self.kws_dct_all, self.kws_set_all).get_docargs(
         args, intvals=set(['max_indent', 'dash_len']))
     opt_attrs = OboOptionalAttrs.attributes.intersection(self.kws.keys())
     godag = get_godag(self.kws['dag'], prt, optional_attrs=opt_attrs)
     self.gene2gos = read_annotations(**self.kws)
     self.tcntobj = TermCounts(godag, self.gene2gos) if self.gene2gos is not None else None
     self.gosubdag = GoSubDag(godag.keys(), godag,
                              relationships='relationship' in opt_attrs,
                              tcntobj=self.tcntobj,
                              children=True,
                              prt=prt)
     self.goids = self._init_goids()
     self._adj_item_marks()
     self._adj_include_only()
     self._adj_for_assc()
예제 #4
0
 def __init__(self, args=None, prt=sys.stdout):
     self.kws = DocOptParse(__doc__, self.kws_dct_all, self.kws_set_all).get_docargs(
         args, intvals=set(['max_indent', 'dash_len']))
     opt_attrs = OboOptionalAttrs.attributes.intersection(self.kws.keys())
     godag = get_godag(self.kws['dag'], prt, optional_attrs=opt_attrs)
     self.gene2gos = read_annotations(**self.kws)
     self.tcntobj = TermCounts(godag, self.gene2gos) if self.gene2gos is not None else None
     self.gosubdag = GoSubDag(godag.keys(), godag,
                              relationships='relationship' in opt_attrs,
                              tcntobj=self.tcntobj,
                              children=True,
                              prt=prt)
     self.goids = self._init_goids()
     self._adj_item_marks()
     self._adj_include_only()
     self._adj_for_assc()