dputhier / pygtftk

A python package and a set of shell commands to handle GTF files
GNU General Public License v3.0
44 stars 6 forks source link

Tests on arguments not performed when using Python API #141

Closed dputhier closed 3 years ago

dputhier commented 3 years ago

When using the code below file formats (and more) are not tested as these tests are embedded in the argument parser...

    from pygtftk.plugins.ologram import ologram

    ologram(
        inputfile="hg38_chr1.gtf.gz",
        peak_file="ENCFF112BHN_H3K4me3_chr1.bed",
        chrom_info="hg38_chr1.genome",
        upstream=1500,
        downstream=1500,
        sort_features="summed_bp_overlaps_pvalue",
        nb_threads=8
    )
dputhier commented 3 years ago

Here is another solution. Maybe not totally convincing. However its ensure that all arguments are tested by the parser dedicated classes (e.g. arg_formatter.FormattedFile())

    from pygtftk.plugins.ologram import ologram
    from pygtftk.plugins.ologram import make_parser

    myparser = make_parser()

    args = myparser.parse_args(['--inputfile', "hg38_chr1.gtf.gz",
                                    '--peak-file', "ENCFF112BHN_H3K4me3_chr1.bed",
                                    '--chrom-info', "hg38_chr1.genome",
                                    '--upstream', "1500",
                                    '--downstream', "1500",
                                    '--sort-features', "summed_bp_overlaps_pvalue"])
    args = dict(args.__dict__)
    ologram(**args)
dputhier commented 3 years ago

Here is another solution with 8 threads and increased verbosity

    from pygtftk.plugins.ologram import ologram
    from pygtftk.plugins.ologram import make_parser
    import pygtftk.utils 

    pygtftk.utils.VERBOSITY = 3

    myparser = make_parser()

    args = myparser.parse_args(['--inputfile', "hg38_chr1.gtf.gz",
                                    '--peak-file', "ENCFF112BHN_H3K4me3_chr1.bed",
                                    '--chrom-info', "hg38_chr1.genome",
                                    '--upstream', "1500",
                                    '--downstream', "1500",
                                    '--sort-features', "summed_bp_overlaps_pvalue",
                                    '--nb-threads', "8"])
    args = dict(args.__dict__)
    ologram(**args) 
dputhier commented 3 years ago

Note that VERBOSITY is normally controlled by the main parser (the parser below behaving normally as a sub_parser).