コード例 #1
0
def _test_path_bp_mf(branch_dist, godag, prt):
    """Test distances between BP branch and MF branch."""
    go_mf = 'GO:0003676'  # level-03 depth-03 nucleic acid binding [molecular_function]
    go_bp = 'GO:0007516'  # level-04 depth-05 hemocyte development [biological_process]
    dst_none = semantic_distance(go_mf, go_bp, godag)
    sim_none = semantic_similarity(go_mf, go_bp, godag)
    assc = dnld_assc("gene_association.tair", godag)
    termcounts = TermCounts(godag, assc)
    fmt = '({GO1}, {GO2}) {TYPE:6} score = {VAL}\n'
    sim_r = resnik_sim(go_mf, go_bp, godag, termcounts)
    sim_l = lin_sim(go_mf, go_bp, godag, termcounts)
    if prt is not None:
        prt.write(
            fmt.format(TYPE='semantic distance',
                       GO1=go_mf,
                       GO2=go_bp,
                       VAL=dst_none))
        prt.write(
            fmt.format(TYPE='semantic similarity',
                       GO1=go_mf,
                       GO2=go_bp,
                       VAL=sim_none))
        prt.write(
            fmt.format(TYPE='Resnik similarity',
                       GO1=go_mf,
                       GO2=go_bp,
                       VAL=sim_r))
        prt.write(
            fmt.format(TYPE='Lin similarity', GO1=go_mf, GO2=go_bp, VAL=sim_l))
    assert dst_none is None
    assert sim_none is None
    assert sim_r is None
    assert sim_l is None
    sim_d = semantic_distance(go_mf, go_bp, godag, branch_dist)
    if prt is not None:
        prt.write(
            fmt.format(TYPE='semantic distance',
                       GO1=go_mf,
                       GO2=go_bp,
                       VAL=sim_d))
    assert sim_d == godag[go_mf].depth + godag[go_bp].depth + branch_dist
コード例 #2
0
def _test_path_same(godag, prt):
    """Test distances btween GO IDs on the same path."""
    goid_bottom = 'GO:0007516' # level-04 depth-05 hemocyte development [biological_process]
    # Test distances up the same branch
    goids_bp = [
        'GO:0008150', # level-00 depth-00 biological_process [biological_process]
        'GO:0009987', # level-01 depth-01 cellular process [biological_process]
        'GO:0044763', # level-02 depth-02 single-organism cellular process [biological_process]
        'GO:0048869', # level-03 depth-03 cellular developmental process [biological_process]
        'GO:0048468'] # level-03 depth-04 cell development [biological_process]
    fmt = '{DST} semantic_distance for {GO1} and {GO2} on the same branch\n'
    for dst_exp, goid in enumerate(reversed(goids_bp), 1):
        dst_act = semantic_distance(goid_bottom, goid, godag)
        if prt is not None:
            prt.write(fmt.format(DST=dst_act, GO1=goid_bottom, GO2=goid))
        assert dst_act == dst_exp
コード例 #3
0
def _test_path_parallel(godag, prt):
    """Test distances between GO IDs on parallel branches."""
    goid_bottom = 'GO:0007516' # BP level-04 depth-05 hemocyte development
    # Test distances up a parallel branch
    goids = [
        'GO:0044763',  # BP level-02 depth-02 single-organism cellular process
        'GO:0008219',  # BP level-03 depth-03 cell death
        'GO:0070997',  # BP level-04 depth-04 neuron death
        'GO:0036475',  # BP level-05 depth-05 neuron death in response to oxidative stress
        'GO:0036476']  # BP level-06 depth-06 neuron death in response to hydrogen peroxide
    fmt = '{DST} semantic_distance between {GO1} and {GO2} on parallel branches\n'
    for dst_exp, goid in enumerate(goids, 3):
        dst_act = semantic_distance(goid_bottom, goid, godag)
        if prt is not None:
            prt.write(fmt.format(DST=dst_act, GO1=goid_bottom, GO2=goid))
        assert dst_act == dst_exp