예제 #1
0
def main():
    """Print a GO term's lower-level hierarchy."""
    import argparse
    prs = argparse.ArgumentParser(__doc__,
                                  formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    prs.add_argument('go_ids', type=str, nargs='*',
                     help='GO Term, e.g. GO:0070458')
    prs.add_argument('--o', default=None, type=str,
                     help="Specifies the name of the output file")
    prs.add_argument('--no_indent', default=False,
                     help="Do not indent GO terms", action='store_true')
    prs.add_argument('--obo', default="go-basic.obo", type=str,
                     help="Location and name of the obo file")
    prs.add_argument('--dash_len', default=1, type=int,
                     help="Printed width of the dashes column")
    prs.add_argument('--max_depth', default=None, type=int,
                     help="max depth for printing relative to GO Term")
    prs.add_argument('--num_child', default=None, action='store_true',
                     help="Print count of total number of children for each GO")
    prs.add_argument('--short', default=False, action='store_true',
                     help="If a branch has already been printed, do not re-print."
                          "Print '===' instead of dashes to note the point of compression")

    args = prs.parse_args()

    obo_dag = GODag(obo_file=args.obo)

    file_out = sys.stdout if args.o is None else open(args.o, 'w')
    lenprt = args.dash_len if not args.no_indent else None

    if args.go_ids:
        for go_id in args.go_ids:
            obo_dag.write_hier(
                go_id,
                file_out,
                len_dash=lenprt,
                max_depth=args.max_depth,
                num_child=args.num_child,
                short_prt=args.short)
    else:
        obo_dag.write_hier_all(
            file_out,
            len_dash=lenprt,
            max_depth=args.max_depth,
            num_child=args.num_child,
            short_prt=args.short)

    if args.o is not None:
        file_out.close()
        sys.stdout.write("  WROTE: {}\n".format(args.o))
        default=False,
        action='store_true',
        help="If a branch has already been printed, do not re-print."
        "Print '===' instead of dashes to note the point of compression")

    args = p.parse_args()

    obo_dag = GODag(obo_file=args.obo)

    file_out = sys.stdout if args.o is None else open(args.o, 'w')
    lenprt = args.dash_len if not args.no_indent else None

    if args.go_ids:
        for go_id in args.go_ids:
            obo_dag.write_hier(go_id,
                               file_out,
                               len_dash=lenprt,
                               max_depth=args.max_depth,
                               num_child=args.num_child,
                               short_prt=args.short)
    else:
        obo_dag.write_hier_all(file_out,
                               len_dash=lenprt,
                               max_depth=args.max_depth,
                               num_child=args.num_child,
                               short_prt=args.short)

    if args.o is not None:
        file_out.close()
        sys.stdout.write("  WROTE: {}\n".format(args.o))
예제 #3
0
def main():
    """Print a GO term's lower-level hierarchy."""
    import argparse
    prs = argparse.ArgumentParser(
        __doc__, formatter_class=argparse.ArgumentDefaultsHelpFormatter)

    prs.add_argument('go_ids',
                     type=str,
                     nargs='*',
                     help='GO Term, e.g. GO:0070458')
    prs.add_argument('--o',
                     default=None,
                     type=str,
                     help="Specifies the name of the output file")
    prs.add_argument('--no_indent',
                     default=False,
                     help="Do not indent GO terms",
                     action='store_true')
    prs.add_argument('--obo',
                     default="go-basic.obo",
                     type=str,
                     help="Location and name of the obo file")
    prs.add_argument('--dash_len',
                     default=1,
                     type=int,
                     help="Printed width of the dashes column")
    prs.add_argument('--max_depth',
                     default=None,
                     type=int,
                     help="max depth for printing relative to GO Term")
    prs.add_argument(
        '--num_child',
        default=None,
        action='store_true',
        help="Print count of total number of children for each GO")
    prs.add_argument(
        '--short',
        default=False,
        action='store_true',
        help="If a branch has already been printed, do not re-print."
        "Print '===' instead of dashes to note the point of compression")

    args = prs.parse_args()

    obo_dag = GODag(obo_file=args.obo)

    file_out = sys.stdout if args.o is None else open(args.o, 'w')
    lenprt = args.dash_len if not args.no_indent else None

    if args.go_ids:
        for go_id in args.go_ids:
            obo_dag.write_hier(go_id,
                               file_out,
                               len_dash=lenprt,
                               max_depth=args.max_depth,
                               num_child=args.num_child,
                               short_prt=args.short)
    else:
        obo_dag.write_hier_all(file_out,
                               len_dash=lenprt,
                               max_depth=args.max_depth,
                               num_child=args.num_child,
                               short_prt=args.short)

    if args.o is not None:
        file_out.close()
        sys.stdout.write("  WROTE: {}\n".format(args.o))
예제 #4
0
                      "Print '===' instead of dashes to note the point of compression")

    args = p.parse_args()

    obo_dag = GODag(obo_file=args.obo)

    file_out = sys.stdout if args.o is None else open(args.o, 'w')
    lenprt = args.dash_len if not args.no_indent else None

    if args.go_ids:
      for go_id in args.go_ids:
        obo_dag.write_hier(
            go_id, 
            file_out, 
            len_dash=lenprt,
            max_depth=args.max_depth,
            num_child=args.num_child,
            short_prt=args.short)
    else:
      obo_dag.write_hier_all(
          file_out, 
          len_dash=lenprt,
          max_depth=args.max_depth,
          num_child=args.num_child,
          short_prt=args.short)

    if args.o is not None:
      file_out.close()
      sys.stdout.write("  WROTE: {}\n".format(args.o))