gseapy/__main__.py
def main():
    """The Main function/pipeline for GSEApy."""

    # Parse options...
    argparser = prepare_argparser()
    args = argparser.parse_args()
    subcommand = args.subcommand_name

    if subcommand == "replot":
        # reproduce plots using GSEAPY
        from .gsea import Replot
        rep = Replot(indir=args.indir, outdir=args.outdir, weighted_score_type=args.weight,
                     figsize=args.figsize, graph_num=args.graph,
                     format=args.format, verbose=args.verbose)
        rep.run()


    elif subcommand == "gsea":
        # compute using GSEAPY
        from .gsea import GSEA

        gs = GSEA(args.data, args.gmt, args.cls, args.outdir,
                  args.mins, args.maxs, args.n, args.weight,
                  args.type, args.method, args.ascending, args.threads,
                  args.figsize, args.format, args.graph, args.noplot, args.seed, args.verbose)
        gs.run()
    elif subcommand == "prerank":
        from .gsea import Prerank

        pre = Prerank(args.rnk, args.gmt, args.outdir, args.label[0], args.label[1],
                      args.mins, args.maxs, args.n, args.weight, args.ascending, args.threads,
                      args.figsize, args.format, args.graph, args.noplot, args.seed, args.verbose)
        pre.run()

    elif subcommand == "ssgsea":
        from .gsea import SingleSampleGSEA
        ss = SingleSampleGSEA(data=args.data, gene_sets=args.gmt, outdir=args.outdir,
                              sample_norm_method=args.norm,
                              min_size=args.mins, max_size=args.maxs, permutation_num=args.n,
                              weighted_score_type=args.weight, scale=args.scale,
                              ascending=args.ascending, processes=args.threads,
                              figsize=args.figsize, format=args.format, graph_num=args.graph,
                              no_plot=args.noplot, seed=args.seed, verbose=args.verbose)
        ss.run()

    elif subcommand == "enrichr":
        # calling enrichr API
        from .enrichr import Enrichr
        enr = Enrichr(gene_list=args.gene_list, descriptions=args.descrip,
                      gene_sets=args.library, organism=args.organism,
                      outdir=args.outdir, format=args.format, cutoff=args.thresh, 
                      background=args.bg, figsize=args.figsize,
                      top_term=args.term, no_plot=args.noplot, verbose=args.verbose)
        enr.run()
    elif subcommand == "biomart":
        from .parser import Biomart
        # read input file or a argument
        name, value = args.filter
        if os.path.isfile(value):
            with open(value, 'r') as val:
                lines = val.readlines()
            value = [ l.strip() for l in lines]
        # run query
        bm = Biomart(host=args.host, verbose=args.verbose)
        bm.query(dataset=args.bg, attributes=args.attrs.split(","), 
                 filters={name : value}, filename=args.ofile)
    else:
        argparser.print_help()
        sys.exit(0)
def main():
    """The Main function/pipeline for GSEApy."""

    # Parse options...
    argparser = prepare_argparser()
    args = argparser.parse_args()
    subcommand = args.subcommand_name

    if subcommand == "replot":
        # reproduce plots using GSEAPY
        from .gsea import Replot
        rep = Replot(indir=args.indir, outdir=args.outdir, weighted_score_type=args.weight,
                     figsize=args.figsize, graph_num=args.graph,
                     format=args.format, verbose=args.verbose)
        rep.run()


    elif subcommand == "gsea":
        # compute using GSEAPY
        from .gsea import GSEA

        gs = GSEA(args.data, args.gmt, args.cls, args.outdir,
                  args.mins, args.maxs, args.n, args.weight,
                  args.type, args.method, args.ascending, args.threads,
                  args.figsize, args.format, args.graph, args.noplot, args.seed, args.verbose)
        gs.run()
    elif subcommand == "prerank":
        from .gsea import Prerank

        pre = Prerank(args.rnk, args.gmt, args.outdir, args.label[0], args.label[1],
                      args.mins, args.maxs, args.n, args.weight, args.ascending, args.threads,
                      args.figsize, args.format, args.graph, args.noplot, args.seed, args.verbose)
        pre.run()

    elif subcommand == "ssgsea":
        from .gsea import SingleSampleGSEA
        ss = SingleSampleGSEA(data=args.data, gene_sets=args.gmt, outdir=args.outdir,
                              sample_norm_method=args.norm,
                              min_size=args.mins, max_size=args.maxs, permutation_num=args.n,
                              weighted_score_type=args.weight, scale=args.scale,
                              ascending=args.ascending, processes=args.threads,
                              figsize=args.figsize, format=args.format, graph_num=args.graph,
                              no_plot=args.noplot, seed=args.seed, verbose=args.verbose)
        ss.run()

    elif subcommand == "enrichr":
        # calling enrichr API
        from .enrichr import Enrichr
        enr = Enrichr(gene_list=args.gene_list, descriptions=args.descrip,
                      gene_sets=args.library, organism=args.organism,
                      outdir=args.outdir, format=args.format, cutoff=args.thresh, 
                      background=args.bg, figsize=args.figsize,
                      top_term=args.term, no_plot=args.noplot, verbose=args.verbose)
        enr.run()
    elif subcommand == "biomart":
        from .parser import Biomart
        # read input file or a argument
        name, value = args.filter
        if os.path.isfile(value):
            with open(value, 'r') as val:
                lines = val.readlines()
            value = [ l.strip() for l in lines]
        # run query
        bm = Biomart(host=args.host, verbose=args.verbose)
        bm.query(dataset=args.bg, attributes=args.attrs.split(","), 
                 filters={name : value}, filename=args.ofile)
    else:
        argparser.print_help()
        sys.exit(0)
def main ( ) : # Parse options... argparser = prepare_argparser ( ) args = argparser . parse_args ( ) subcommand = args . subcommand_name if subcommand == "replot" : # reproduce plots using GSEAPY from . gsea import Replot rep = Replot ( indir = args . indir , outdir = args . outdir , weighted_score_type = args . weight , figsize = args . figsize , graph_num = args . graph , format = args . format , verbose = args . verbose ) rep . run ( ) elif subcommand == "gsea" : # compute using GSEAPY from . gsea import GSEA gs = GSEA ( args . data , args . gmt , args . cls , args . outdir , args . mins , args . maxs , args . n , args . weight , args . type , args . method , args . ascending , args . threads , args . figsize , args . format , args . graph , args . noplot , args . seed , args . verbose ) gs . run ( ) elif subcommand == "prerank" : from . gsea import Prerank pre = Prerank ( args . rnk , args . gmt , args . outdir , args . label [ 0 ] , args . label [ 1 ] , args . mins , args . maxs , args . n , args . weight , args . ascending , args . threads , args . figsize , args . format , args . graph , args . noplot , args . seed , args . verbose ) pre . run ( ) elif subcommand == "ssgsea" : from . gsea import SingleSampleGSEA ss = SingleSampleGSEA ( data = args . data , gene_sets = args . gmt , outdir = args . outdir , sample_norm_method = args . norm , min_size = args . mins , max_size = args . maxs , permutation_num = args . n , weighted_score_type = args . weight , scale = args . scale , ascending = args . ascending , processes = args . threads , figsize = args . figsize , format = args . format , graph_num = args . graph , no_plot = args . noplot , seed = args . seed , verbose = args . verbose ) ss . run ( ) elif subcommand == "enrichr" : # calling enrichr API from . enrichr import Enrichr enr = Enrichr ( gene_list = args . gene_list , descriptions = args . descrip , gene_sets = args . library , organism = args . organism , outdir = args . outdir , format = args . format , cutoff = args . thresh , background = args . bg , figsize = args . figsize , top_term = args . term , no_plot = args . noplot , verbose = args . verbose ) enr . run ( ) elif subcommand == "biomart" : from . parser import Biomart # read input file or a argument name , value = args . filter if os . path . isfile ( value ) : with open ( value , 'r' ) as val : lines = val . readlines ( ) value = [ l . strip ( ) for l in lines ] # run query bm = Biomart ( host = args . host , verbose = args . verbose ) bm . query ( dataset = args . bg , attributes = args . attrs . split ( "," ) , filters = { name : value } , filename = args . ofile ) else : argparser . print_help ( ) sys . exit ( 0 )
The Main function/pipeline for GSEApy.
The Main function / pipeline for GSEApy .