Пример #1
0
def write_hier_mrk(gosubdag, out):
    """Print all paths, but mark GO Terms of interest. """
    mark_lst = [
        'GO:0000001', 'GO:0000003', 'GO:0000006', 'GO:0000008', 'GO:0000009'
    ]
    objwr = WrHierGO(gosubdag, go_marks=mark_lst)
    objwr.prt_hier_down("GO:0000001", out)
Пример #2
0
def write_hier_mrk(gosubdag, out):
    """Print all paths, but mark GO Terms of interest. """
    mark_lst = [
        'GO:0000001', 'GO:0000003', 'GO:0000006', 'GO:0000008', 'GO:0000009'
    ]
    out.write('\nTEST MARK: 01->03->06->08->09:\n')
    objwr = WrHierGO(gosubdag, go_marks=mark_lst)
    objwr.prt_hier_down("GO:0000001", out)
Пример #3
0
 def prt_hier(self, prt=sys.stdout):
     """Write hierarchy below specfied GO IDs."""
     objwr = WrHierGO(self.gosubdag, **self.kws)
     assert self.goids, "NO VALID GO IDs WERE PROVIDED"
     if 'up' not in objwr.usrset:
         for goid in self.goids:
             objwr.prt_hier_down(goid, prt)
     else:
         objwr.prt_hier_up(self.goids, prt)
Пример #4
0
 def prt_hier(self, prt=sys.stdout):
     """Write hierarchy below specfied GO IDs."""
     objwr = WrHierGO(self.gosubdag, **self.kws)
     assert self.goids, "NO VALID GO IDs WERE PROVIDED"
     if 'up' not in objwr.usrset:
         for goid in self.goids:
             objwr.prt_hier_down(goid, prt)
     else:
         objwr.prt_hier_up(self.goids, prt)
Пример #5
0
 def prt_hier(self, prt=sys.stdout):
     """Write hierarchy below specfied GO IDs."""
     objwr = WrHierGO(self.gosubdag, **self.kws)
     assert self.goids, "NO VALID GO IDs WERE PROVIDED"
     # kws = {k:v for k, v in self.kws.items() if k in self.kws_dct_wr}
     # objwr.write_hier_all(prt=prt, **kws)
     # max_indent=None, num_child=None, short_prt=False):
     if 'up' not in objwr.usrset:
         for goid in self.goids:
             objwr.prt_hier_down(goid, prt)
     else:
         objwr.prt_hier_up(self.goids, prt)
Пример #6
0
def test_write_hier_mrk(gosubdag, out):
    """Print all paths, but mark GO Terms of interest. """
    # > - GO:0000001      BP     9 L00 D00 top
    #   -- GO:0000002     BP     2 L01 D01 B
    #   --- GO:0000005    BP     1 L02 D02 c
    #   ---- GO:0000010   BP     0 L03 D04 ac
    # > -- GO:0000003     BP     7 L01 D01 A
    #   --- GO:0000004    BP     2 L02 D02 b
    #   ---- GO:0000007   BP     1 L03 D03 b1
    # > ----- GO:0000009  BP     0 L04 D04 ab
    #   --- GO:0000005    BP     1 L02 D02 c
    #   ---- GO:0000010   BP     0 L03 D04 ac
    # > --- GO:0000006    BP     3 L02 D02 a
    # > ---- GO:0000008   BP     2 L03 D03 a1
    # > ----- GO:0000009  BP     0 L04 D04 ab
    #   ----- GO:0000010  BP     0 L03 D04 ac
    mark_lst = [
        'GO:0000001', 'GO:0000003', 'GO:0000006', 'GO:0000008', 'GO:0000009'
    ]
    out.write('\nTEST {NAME} MARK: 01->03->06->08->09:\n'.format(NAME="MINI"))
    objwr = WrHierGO(gosubdag, item_marks=mark_lst, sortby=lambda o: o.item_id)
    gos_prtd = objwr.prt_hier_down("GO:0000001", out)
    assert gos_prtd == [
        'GO:0000001', 'GO:0000002', 'GO:0000005', 'GO:0000010', 'GO:0000003',
        'GO:0000004', 'GO:0000007', 'GO:0000009', 'GO:0000005', 'GO:0000010',
        'GO:0000006', 'GO:0000008', 'GO:0000009', 'GO:0000010'
    ]
Пример #7
0
def write_hier_lim(gosubdag, out):
    """Limits hierarchy list to GO Terms specified by user."""
    go_omit = ['GO:0000005', 'GO:0000010']
    go_ids = [go_id for go_id in gosubdag.go2obj if go_id not in go_omit]
    out.write('\nTEST OMIT: 05 and 10:\n')
    objwr = WrHierGO(gosubdag, include_only=go_ids)
    gos_printed = objwr.prt_hier_down("GO:0000001", out)
    assert not gos_printed.intersection(go_omit), "SHOULD NOT PRINT {GOs}".format(GOs=go_omit)
Пример #8
0
def write_hier_mrk_lst(gosubdag, out):
    """Print all paths, but mark GO Terms of interest. """
    mark_lst = ['GO:0000001', 'GO:0000003', 'GO:0000006', 'GO:0000008', 'GO:0000009']
    out.write('\nTEST MARK LIST: 01->03->06->08->09:\n')
    objwr = WrHierGO(gosubdag, item_marks=mark_lst, sortby=lambda o: o.item_id)
    gos_printed = objwr.prt_hier_down("GO:0000001", out)
    assert gos_printed == ['GO:0000001', 'GO:0000002', 'GO:0000005', 'GO:0000010',
                           'GO:0000003', 'GO:0000004', 'GO:0000007', 'GO:0000009',
                           'GO:0000005', 'GO:0000010', 'GO:0000006', 'GO:0000008',
                           'GO:0000009', 'GO:0000010']
Пример #9
0
def write_hier_lim(gosubdag, out):
    """Limits hierarchy list to GO Terms specified by user."""
    go_omit = ['GO:0000005', 'GO:0000010']
    go_ids = [go_id for go_id in gosubdag.go2obj if go_id not in go_omit]
    out.write('\nTEST OMIT: 05 and 10:\n')
    objwr = WrHierGO(gosubdag, include_only=go_ids, sortby=lambda o: o.item_id)
    gos_printed = objwr.prt_hier_down("GO:0000001", out)
    assert not set(gos_printed).intersection(go_omit), "SHOULD NOT PRINT {GOs}".format(GOs=go_omit)
    assert gos_printed == ['GO:0000001', 'GO:0000002', 'GO:0000003', 'GO:0000004',
                           'GO:0000007', 'GO:0000009', 'GO:0000006', 'GO:0000008',
                           'GO:0000009']
Пример #10
0
def write_hier_norep(gosubdag, out):
    """Shortens hierarchy report by only printing branches once.
         Prints the 'entire hierarchy' of GO:0000005 the 1st time seen:
           ---     1 GO:0000005    L-02    D-02
           ----     0 GO:0000010   L-03    D-04
         Prints just GO:0000005 (ommit child GO:10) the 2nd time seen:
           ===     1 GO:0000005    L-02    D-02
         '=' is used in hierarchy mark to indicate that the pathes
             below the marked term have already been printed.
    """
    # out.write('\nTEST ALL: Print branches just once:\n')
    objwr = WrHierGO(gosubdag, concise=True)
    gos_printed = objwr.prt_hier_down("GO:0000001", out)
    assert gos_printed == set(objwr.gosubdag.go2nt)
Пример #11
0
def test_write_hier_lim(gosubdag, out):
    """Limits hierarchy list to GO Terms specified by user."""
    # - GO:0000001      BP     9 L00 D00 top
    # -- GO:0000002     BP     2 L01 D01 B
    # -- GO:0000003     BP     7 L01 D01 A
    # --- GO:0000004    BP     2 L02 D02 b
    # ---- GO:0000007   BP     1 L03 D03 b1
    # ----- GO:0000009  BP     0 L04 D04 ab
    # --- GO:0000006    BP     3 L02 D02 a
    # ---- GO:0000008   BP     2 L03 D03 a1
    # ----- GO:0000009  BP     0 L04 D04 ab
    go_omit = ['GO:0000005']
    go_ids = [go_id for go_id in gosubdag.go2nt.keys() if go_id not in go_omit]
    out.write('\nTEST {NAME} OMIT: 05->10:\n'.format(NAME="MINI"))
    objwr = WrHierGO(gosubdag, include_only=go_ids, sortby=lambda o: o.item_id)
    gos_prtd = objwr.prt_hier_down("GO:0000001", out)
    print(gos_prtd)
    assert gos_prtd == ['GO:0000001', 'GO:0000002', 'GO:0000003', 'GO:0000004', 'GO:0000007',
                        'GO:0000009', 'GO:0000006', 'GO:0000008', 'GO:0000009', 'GO:0000010']
Пример #12
0
def test_write_hier_lim(gosubdag, out):
    """Limits hierarchy list to GO Terms specified by user."""
    # - GO:0000001      BP     9 L00 D00 top
    # -- GO:0000002     BP     2 L01 D01 B
    # -- GO:0000003     BP     7 L01 D01 A
    # --- GO:0000004    BP     2 L02 D02 b
    # ---- GO:0000007   BP     1 L03 D03 b1
    # ----- GO:0000009  BP     0 L04 D04 ab
    # --- GO:0000006    BP     3 L02 D02 a
    # ---- GO:0000008   BP     2 L03 D03 a1
    # ----- GO:0000009  BP     0 L04 D04 ab
    go_omit = ['GO:0000005']
    go_ids = [go_id for go_id in gosubdag.go2nt.keys() if go_id not in go_omit]
    out.write('\nTEST {NAME} OMIT: 05->10:\n'.format(NAME="MINI"))
    objwr = WrHierGO(gosubdag, include_only=go_ids, sortby=lambda o: o.item_id)
    gos_prtd = objwr.prt_hier_down("GO:0000001", out)
    print(gos_prtd)
    assert gos_prtd == [
        'GO:0000001', 'GO:0000002', 'GO:0000003', 'GO:0000004', 'GO:0000007',
        'GO:0000009', 'GO:0000006', 'GO:0000008', 'GO:0000009', 'GO:0000010'
    ]
Пример #13
0
def test_write_hier_mrk(gosubdag, out):
    """Print all paths, but mark GO Terms of interest. """
    # > - GO:0000001      BP     9 L00 D00 top
    #   -- GO:0000002     BP     2 L01 D01 B
    #   --- GO:0000005    BP     1 L02 D02 c
    #   ---- GO:0000010   BP     0 L03 D04 ac
    # > -- GO:0000003     BP     7 L01 D01 A
    #   --- GO:0000004    BP     2 L02 D02 b
    #   ---- GO:0000007   BP     1 L03 D03 b1
    # > ----- GO:0000009  BP     0 L04 D04 ab
    #   --- GO:0000005    BP     1 L02 D02 c
    #   ---- GO:0000010   BP     0 L03 D04 ac
    # > --- GO:0000006    BP     3 L02 D02 a
    # > ---- GO:0000008   BP     2 L03 D03 a1
    # > ----- GO:0000009  BP     0 L04 D04 ab
    #   ----- GO:0000010  BP     0 L03 D04 ac
    mark_lst = ['GO:0000001', 'GO:0000003', 'GO:0000006', 'GO:0000008', 'GO:0000009']
    out.write('\nTEST {NAME} MARK: 01->03->06->08->09:\n'.format(NAME="MINI"))
    objwr = WrHierGO(gosubdag, item_marks=mark_lst, sortby=lambda o: o.item_id)
    gos_prtd = objwr.prt_hier_down("GO:0000001", out)
    assert gos_prtd == ['GO:0000001', 'GO:0000002', 'GO:0000005', 'GO:0000010', 'GO:0000003',
                        'GO:0000004', 'GO:0000007', 'GO:0000009', 'GO:0000005', 'GO:0000010',
                        'GO:0000006', 'GO:0000008', 'GO:0000009', 'GO:0000010']
Пример #14
0
def write_hier_norep(gosubdag, out):
    """Shortens hierarchy report by only printing branches once.

         Prints the 'entire hierarchy' of GO:0000005 the 1st time seen:

           ---     1 GO:0000005    L-02    D-02
           ----     0 GO:0000010   L-03    D-04

         Prints just GO:0000005 (ommit child GO:10) the 2nd time seen:

           ===     1 GO:0000005    L-02    D-02

         '=' is used in hierarchy mark to indicate that the pathes
             below the marked term have already been printed.
    """
    out.write('\nTEST ALL: Print branches just once:\n')
    objwr = WrHierGO(gosubdag, concise=True, sortby=lambda o: o.item_id)
    gos_printed = objwr.prt_hier_down("GO:0000001", out)
    assert set(gos_printed) == set(objwr.gosubdag.go2nt)
    assert gos_printed == ['GO:0000001', 'GO:0000002', 'GO:0000005', 'GO:0000010',
                           'GO:0000003', 'GO:0000004', 'GO:0000007', 'GO:0000009',
                           'GO:0000005', 'GO:0000006', 'GO:0000008', 'GO:0000009',
                           'GO:0000010']
Пример #15
0
def write_hier_all(gosubdag, out, root_term):
    """write_hier.py: Prints the entire mini GO hierarchy, with counts of children."""
    out.write('\nTEST ALL: Print all hierarchies:\n')
    objwr = WrHierGO(gosubdag)
    gos_printed = objwr.prt_hier_down(root_term, out)
    print len(gos_printed)
Пример #16
0
def write_hier_all(gosubdag, out):
    """write_hier.py: Prints the entire mini GO hierarchy, with counts of children."""
    out.write('\nTEST ALL: Print all hierarchies:\n')
    objwr = WrHierGO(gosubdag)
    gos_printed = objwr.prt_hier_down("GO:0000001", out)
    assert set(gos_printed) == set(objwr.gosubdag.go2nt)
Пример #17
0
def write_hier_all(gosubdag, out):
    """write_hier.py: Prints the entire mini GO hierarchy, with counts of children."""
    out.write('\nTEST ALL: Print all hierarchies:\n')
    objwr = WrHierGO(gosubdag)
    gos_printed = objwr.prt_hier_down("GO:0000001", out)
    assert set(gos_printed) == set(objwr.gosubdag.go2nt)