Example #1
0
    p.add_option(
        "--term",
        help="Write the parents and children of this query term",
    )

    opts, args = p.parse_args()

    if len(args) != 1:
        sys.exit(p.print_help())

    (obo_file, ) = args

    def description(rec):
        level = "level-{:>02}".format(rec.level)
        description = "{} [{}]".format(rec.name, rec.namespace)
        if rec.is_obsolete:
            description += " obsolete"
        alt_ids = ",".join(rec.alt_ids)
        return "\t".join((rec.item_id, level, description, alt_ids))

    g = GODag(obo_file, prt=None)
    header = "\t".join(("#id", "level", "name", "alt_ids"))
    print(header)
    for rec in sorted(set(g.values()), key=lambda x: x.item_id):
        print(description(rec))

    # run a test case
    if opts.term:
        rec = g.query_term(opts.term, verbose=True)
        g.draw_lineage([rec], verbose=True)
Example #2
0
                 " from the obo file specified in args",
                 action="store_true")
    p.add_option("--term",
                 dest="term",
                 help="write the parents and children"
                 "of the query term",
                 action="store",
                 type="string",
                 default=None)
    p.add_option("--gml",
                 action="store_true",
                 help="Write GML output (for Cytoscape) [default: %default]")

    opts, args = p.parse_args()

    if not len(args):
        obo_file = "gene_ontology.1_2.obo"
    else:
        obo_file = args[0]
        assert os.path.exists(obo_file), "file %s not found!" % obo_file

    g = GODag(obo_file)

    if opts.desc:
        g.write_dag()

    # run a test case
    if opts.term is not None:
        rec = g.query_term(opts.term, verbose=True)
        g.draw_lineage([rec], gml=opts.gml)
Example #3
0
                 dest='draw_parents',
                 help="Do not draw parents of the query term")
    p.add_option("--disable-draw-children",
                 action="store_false",
                 dest='draw_children',
                 help="Do not draw children of the query term")

    p.set_defaults(draw_parents=True)
    p.set_defaults(draw_children=True)

    opts, args = p.parse_args()

    if not len(args):
        obo_file = "go-basic.obo"
    else:
        obo_file = args[0]
        assert os.path.exists(obo_file), "file %s not found!" % obo_file

    g = GODag(obo_file)

    if opts.desc:
        g.write_dag()

    # run a test case
    if opts.term is not None:
        rec = g.query_term(opts.term, verbose=True)
        g.draw_lineage([rec], engine=opts.engine,
                       gml=opts.gml,
                       draw_parents=opts.draw_parents,
                       draw_children=opts.draw_children)
if __name__ == '__main__':

    import optparse
    p = optparse.OptionParser("%prog [obo_file]")
    p.add_option("--description", dest="desc",
                 help="write term descriptions to stdout"
                 " from the obo file specified in args", action="store_true")
    p.add_option("--term", dest="term", help="write the parents and children"
                 "of the query term", action="store", type="string",
                 default=None)
    p.add_option("--gml", action="store_true",
                 help="Write GML output (for Cytoscape) [default: %default]")

    opts, args = p.parse_args()

    if not len(args):
        obo_file = "gene_ontology.1_2.obo"
    else:
        obo_file = args[0]
        assert os.path.exists(obo_file), "file %s not found!" % obo_file

    g = GODag(obo_file)

    if opts.desc:
        g.write_dag()

    # run a test case
    if opts.term is not None:
        rec = g.query_term(opts.term, verbose=True)
        g.draw_lineage([rec], gml=opts.gml)
Example #5
0
    )

    p.set_defaults(draw_parents=True)
    p.set_defaults(draw_children=True)

    opts, args = p.parse_args()

    if not args:
        obo_file = "go-basic.obo"
    else:
        obo_file = args[0]
        assert os.path.exists(obo_file), "file %s not found!" % obo_file

    g = GODag(obo_file)

    if opts.desc:
        g.write_dag()

    # run a test case
    if opts.term is not None:
        rec = g.query_term(opts.term, verbose=True)
        g.draw_lineage(
            [rec],
            dpi=opts.dpi,
            engine=opts.engine,
            gml=opts.gml,
            output=opts.output,
            draw_parents=opts.draw_parents,
            draw_children=opts.draw_children,
        )
Example #6
0
    import optparse
    p = optparse.OptionParser("%prog [obo_file]")
    p.add_option("--description", dest="desc", 
            help="write term descriptions to stdout" \
                 " from the obo file specified in args", action="store_true")
    p.add_option("--term", dest="term", help="write the parents and children" \
            "of the query term", action="store", type="string", default=None)

    (options, args) = p.parse_args()

    if not len(args):
        obo_file = None
    else:
        obo_file = args[0]
        assert os.path.exists(obo_file), "file %s not found!" % obo_file

    if obo_file is None:
        g = GODag()
    else:
        g = GODag(obo_file)

    if options.desc:
        g.write_dag()

    # run a test case
    if options.term is not None:
        rec = g.query_term(options.term, verbose=True)
        g.draw_lineage(rec, dpi=50, verbose=True)

Example #7
0
    p.add_option(
        "--term",
        help="Write the parents and children of this query term",
    )

    opts, args = p.parse_args()

    if len(args) != 1:
        sys.exit(p.print_help())

    (obo_file, ) = args

    def description(record):
        level = "level-{:>02}".format(record.level)
        desc = "{} [{}]".format(record.name, record.namespace)
        if record.is_obsolete:
            desc += " obsolete"
        alt_ids = ",".join(record.alt_ids)
        return "\t".join((record.item_id, level, desc, alt_ids))

    g = GODag(obo_file, prt=None)
    header = "\t".join(("#id", "level", "name", "alt_ids"))
    print(header)
    for rec in sorted(set(g.values()), key=lambda x: x.item_id):
        print(description(rec))

    # run a test case
    if opts.term:
        rec = g.query_term(opts.term, verbose=True)
        g.draw_lineage([rec])
Example #8
0
    import optparse
    p = optparse.OptionParser("%prog [obo_file]")
    p.add_option("--description", dest="desc", 
            help="write term descriptions to stdout" \
                 " from the obo file specified in args", action="store_true")
    p.add_option("--term", dest="term", help="write the parents and children" \
            "of the query term", action="store", type="string", default=None)

    (options, args) = p.parse_args()

    if not len(args):
        obo_file = None
    else:
        obo_file = args[0]
        assert os.path.exists(obo_file), "file %s not found!" % obo_file

    if obo_file is None:
        g = GODag()
    else:
        g = GODag(obo_file)

    if options.desc:
        g.write_dag()

    # run a test case
    if options.term is not None:
        rec = g.query_term(options.term, verbose=True)
        g.draw_lineage([rec], verbose=True)