diff --git a/jcvi/algorithms/supermap.py b/jcvi/algorithms/supermap.py index f728341c..cef9e994 100755 --- a/jcvi/algorithms/supermap.py +++ b/jcvi/algorithms/supermap.py @@ -147,14 +147,14 @@ def supermap(blast_file, filter="intersection", dialect="blast", clip=0): filter_choices = ("ref", "query", "intersection", "union") dialect_choices = ("blast", "coords") - p.add_option( + p.add_argument( "--filter", choices=filter_choices, default="intersection", help="Available filters", ) - p.add_option("--dialect", choices=dialect_choices, help="Input format") - p.add_option( + p.add_argument("--dialect", choices=dialect_choices, help="Input format") + p.add_argument( "--clip", default=0, type=int, diff --git a/jcvi/annotation/ahrd.py b/jcvi/annotation/ahrd.py index ae39c3f7..cfdb1598 100644 --- a/jcvi/annotation/ahrd.py +++ b/jcvi/annotation/ahrd.py @@ -554,7 +554,7 @@ def fix(args): Fix ugly names from Uniprot. """ p = OptionParser(fix.__doc__) - p.add_option( + p.add_argument( "--ignore_sym_pat", default=False, action="store_true", @@ -650,19 +650,19 @@ def batch(args): ahrd_weights = {"blastp": [0.5, 0.3, 0.2], "blastx": [0.6, 0.4, 0.0]} blast_progs = tuple(ahrd_weights.keys()) - p.add_option( + p.add_argument( "--path", default="~/code/AHRD/", help="Path where AHRD is installed", ) - p.add_option( + p.add_argument( "--blastprog", default="blastp", choices=blast_progs, help="Specify the blast program being run. Based on this option," + " the AHRD parameters (score_weights) will be modified", ) - p.add_option( + p.add_argument( "--iprscan", default=None, help="Specify path to InterProScan results file if available." diff --git a/jcvi/annotation/automaton.py b/jcvi/annotation/automaton.py index ef2ec0a7..7db98a42 100644 --- a/jcvi/annotation/automaton.py +++ b/jcvi/annotation/automaton.py @@ -63,9 +63,13 @@ def augustus(args): annotation.reformat.augustus(). """ p = OptionParser(augustus.__doc__) - p.add_option("--species", default="maize", help="Use species model for prediction") - p.add_option("--hintsfile", help="Hint-guided AUGUSTUS") - p.add_option("--nogff3", default=False, action="store_true", help="Turn --gff3=off") + p.add_argument( + "--species", default="maize", help="Use species model for prediction" + ) + p.add_argument("--hintsfile", help="Hint-guided AUGUSTUS") + p.add_argument( + "--nogff3", default=False, action="store_true", help="Turn --gff3=off" + ) p.set_home("augustus") p.set_cpus() opts, args = p.parse_args(args) @@ -112,7 +116,7 @@ def star(args): Run star on a folder with reads. """ p = OptionParser(star.__doc__) - p.add_option( + p.add_argument( "--single", default=False, action="store_true", help="Single end mapping" ) p.set_fastq_names() @@ -163,7 +167,7 @@ def cufflinks(args): Run cufflinks on a folder containing tophat results. """ p = OptionParser(cufflinks.__doc__) - p.add_option("--gtf", help="Reference annotation") + p.add_argument("--gtf", help="Reference annotation") p.set_cpus() opts, args = p.parse_args(args) @@ -219,23 +223,23 @@ def tophat(args): from jcvi.formats.fastq import guessoffset p = OptionParser(tophat.__doc__) - p.add_option("--gtf", help="Reference annotation") - p.add_option( + p.add_argument("--gtf", help="Reference annotation") + p.add_argument( "--single", default=False, action="store_true", help="Single end mapping" ) - p.add_option( + p.add_argument( "--intron", default=15000, type=int, help="Max intron size", ) - p.add_option( + p.add_argument( "--dist", default=-50, type=int, help="Mate inner distance", ) - p.add_option( + p.add_argument( "--stdev", default=50, type=int, diff --git a/jcvi/annotation/depth.py b/jcvi/annotation/depth.py index 84acfe4f..6aaf151a 100755 --- a/jcvi/annotation/depth.py +++ b/jcvi/annotation/depth.py @@ -64,13 +64,13 @@ def bed(args): Write bed files where the bases have at least certain depth. """ p = OptionParser(bed.__doc__) - p.add_option( + p.add_argument( "-o", dest="output", default="stdout", help="Output file name", ) - p.add_option( + p.add_argument( "--cutoff", dest="cutoff", default=10, diff --git a/jcvi/annotation/maker.py b/jcvi/annotation/maker.py index 09284f39..0f3fab4c 100644 --- a/jcvi/annotation/maker.py +++ b/jcvi/annotation/maker.py @@ -351,7 +351,7 @@ def batcheval(args): from jcvi.formats.gff import make_index p = OptionParser(evaluate.__doc__) - p.add_option( + p.add_argument( "--type", default="CDS", help="list of features to extract, use comma to separate (e.g." @@ -450,17 +450,17 @@ def split(args): from jcvi.formats.bed import Bed p = OptionParser(split.__doc__) - p.add_option( + p.add_argument( "--key", default="Name", help="Key in the attributes to extract predictor.gff", ) - p.add_option( + p.add_argument( "--parents", default="match", help="list of features to extract, use comma to separate (e.g.'gene,mRNA')", ) - p.add_option( + p.add_argument( "--children", default="match_part", help="list of features to extract, use comma to separate (e.g." diff --git a/jcvi/annotation/pasa.py b/jcvi/annotation/pasa.py index a5c6ce5d..c23f0eb0 100644 --- a/jcvi/annotation/pasa.py +++ b/jcvi/annotation/pasa.py @@ -81,7 +81,7 @@ def assemble(args): """ p = OptionParser(assemble.__doc__) p.set_pasa_opts() - p.add_option( + p.add_argument( "--prepare", default=False, action="store_true", @@ -228,7 +228,7 @@ def compare(args): """ p = OptionParser(compare.__doc__) p.set_pasa_opts(action="compare") - p.add_option( + p.add_argument( "--prepare", default=False, action="store_true", @@ -320,7 +320,7 @@ def longest(args): from jcvi.formats.sizes import Sizes p = OptionParser(longest.__doc__) - p.add_option( + p.add_argument( "--prefix", default="pasa", help="Replace asmbl_ with prefix", @@ -393,31 +393,31 @@ def consolidate(args): supported_modes = ["name", "coords"] p = OptionParser(consolidate.__doc__) - p.add_option( + p.add_argument( "--slop", default=False, action="store_true", help="allow minor variation in terminal 5'/3' UTR start/stop position", ) - p.add_option( + p.add_argument( "--inferUTR", default=False, action="store_true", help="infer presence of UTRs from exon coordinates", ) - p.add_option( + p.add_argument( "--mode", default="name", choices=supported_modes, help="method used to determine overlapping loci", ) - p.add_option( + p.add_argument( "--summary", default=False, action="store_true", help="Generate summary table of consolidation process", ) - p.add_option( + p.add_argument( "--clusters", default=False, action="store_true", diff --git a/jcvi/annotation/qc.py b/jcvi/annotation/qc.py index fcb3e74b..825730dd 100644 --- a/jcvi/annotation/qc.py +++ b/jcvi/annotation/qc.py @@ -165,26 +165,26 @@ def trimUTR(args): from jcvi.formats.base import SetFile p = OptionParser(trimUTR.__doc__) - p.add_option( + p.add_argument( "--trim5", default=None, type=str, help="File containing gene list for 5' UTR trimming", ) - p.add_option( + p.add_argument( "--trim3", default=None, type=str, help="File containing gene list for 3' UTR trimming", ) - p.add_option( + p.add_argument( "--trimrange", default=None, type=str, help="File containing gene list for UTR trim back" + "based on suggested (start, stop) coordinate range", ) - p.add_option( + p.add_argument( "--refgff", default=None, type=str, diff --git a/jcvi/annotation/reformat.py b/jcvi/annotation/reformat.py index 40409597..cb68db5c 100644 --- a/jcvi/annotation/reformat.py +++ b/jcvi/annotation/reformat.py @@ -209,9 +209,9 @@ def plot(args): from jcvi.graphics.chromosome import ChromosomeMap p = OptionParser(plot.__doc__) - p.add_option("--firstn", type=int, help="Only plot the first N genes") - p.add_option("--ymax", type=int, help="Y-axis max value") - p.add_option("--log", action="store_true", help="Write plotting data") + p.add_argument("--firstn", type=int, help="Only plot the first N genes") + p.add_argument("--ymax", type=int, help="Y-axis max value") + p.add_argument("--log", action="store_true", help="Write plotting data") opts, args, iopts = p.set_image_options(args, figsize="6x4") if len(args) != 2: @@ -305,7 +305,7 @@ def instantiate(args): """ p = OptionParser(instantiate.__doc__) p.set_annot_reformat_opts() - p.add_option( + p.add_argument( "--extended_stride", default=False, action="store_true", @@ -594,13 +594,13 @@ def annotate(args): valid_resolve_choices = ["alignment", "overlap"] p = OptionParser(annotate.__doc__) - p.add_option( + p.add_argument( "--resolve", default="alignment", choices=valid_resolve_choices, help="Resolve ID assignment based on a certain metric", ) - p.add_option( + p.add_argument( "--atg_name", default=False, action="store_true", @@ -611,14 +611,14 @@ def annotate(args): "Optional parameters (alignment):\n" + "Use if resolving ambiguities based on sequence `alignment`", ) - g1.add_option( + g1.add_argument( "--pid", dest="pid", default=35.0, type=float, help="Percent identity cutoff", ) - g1.add_option( + g1.add_argument( "--score", dest="score", default=250.0, @@ -631,21 +631,21 @@ def annotate(args): + "Use if resolving ambiguities based on `overlap` length\n" + "Parameters equivalent to `intersectBed`", ) - g2.add_option( + g2.add_argument( "-f", dest="f", default=0.5, type=float, help="Minimum overlap fraction (0.0 - 1.0)", ) - g2.add_option( + g2.add_argument( "-r", dest="r", default=False, action="store_true", help="Require fraction overlap to be reciprocal", ) - g2.add_option( + g2.add_argument( "-s", dest="s", default=True, @@ -944,34 +944,34 @@ def rename(args): import string p = OptionParser(rename.__doc__) - p.add_option( + p.add_argument( "-a", dest="gene_increment", default=10, type=int, help="Increment for continuous genes", ) - p.add_option( + p.add_argument( "-b", dest="gap_increment", default=1000, type=int, help="Increment for gaps", ) - p.add_option( + p.add_argument( "--pad0", default=6, type=int, help="Pad gene identifiers with 0", ) - p.add_option( + p.add_argument( "--spad0", default=4, type=int, help="Pad gene identifiers on small scaffolds", ) - p.add_option("--prefix", default="Bo", help="Genome prefix") - p.add_option( + p.add_argument("--prefix", default="Bo", help="Genome prefix") + p.add_argument( "--jgi", default=False, action="store_true", @@ -1072,7 +1072,7 @@ def reindex(args): from tempfile import mkstemp p = OptionParser(reindex.__doc__) - p.add_option( + p.add_argument( "--scores", type=str, help="read from existing EMBOSS `needle` scores file" ) p.set_outfile() @@ -1235,7 +1235,7 @@ def publocus(args): Medtr1g007060.2 MTR_1g007060B """ p = OptionParser(publocus.__doc__) - p.add_option("--locus_tag", default="MTR_", help="GenBank locus tag") + p.add_argument("--locus_tag", default="MTR_", help="GenBank locus tag") opts, args = p.parse_args(args) if len(args) != 1: diff --git a/jcvi/annotation/stats.py b/jcvi/annotation/stats.py index 6f8025d7..ec477ab5 100644 --- a/jcvi/annotation/stats.py +++ b/jcvi/annotation/stats.py @@ -147,7 +147,9 @@ def genestats(args): A physical, genetic and functional sequence assembly of the barley genome """ p = OptionParser(genestats.__doc__) - p.add_option("--groupby", default="conf_class", help="Print separate stats groupby") + p.add_argument( + "--groupby", default="conf_class", help="Print separate stats groupby" + ) p.set_outfile() opts, args = p.parse_args(args) @@ -286,7 +288,7 @@ def histogram(args): from jcvi.graphics.histogram import histogram_multiple p = OptionParser(histogram.__doc__) - p.add_option( + p.add_argument( "--bins", dest="bins", default=40, @@ -338,8 +340,8 @@ def stats(args): With data written to disk then you can run %prog histogram """ p = OptionParser(stats.__doc__) - p.add_option("--gene", default="mRNA", help="The gene type") - p.add_option("--exon", default="CDS", help="The exon type") + p.add_argument("--gene", default="mRNA", help="The gene type") + p.add_argument("--exon", default="CDS", help="The exon type") opts, args = p.parse_args(args) if len(args) != 1: diff --git a/jcvi/annotation/train.py b/jcvi/annotation/train.py index 45e30b2f..9ef54431 100644 --- a/jcvi/annotation/train.py +++ b/jcvi/annotation/train.py @@ -89,7 +89,7 @@ def genemark(args): model gff file is needed. """ p = OptionParser(genemark.__doc__) - p.add_option("--junctions", help="Path to `junctions.bed` from Tophat2") + p.add_argument("--junctions", help="Path to `junctions.bed` from Tophat2") p.set_home("gmes") p.set_cpus(cpus=32) opts, args = p.parse_args(args) @@ -168,7 +168,7 @@ def augustus(args): """ p = OptionParser(augustus.__doc__) - p.add_option( + p.add_argument( "--autotrain", default=False, action="store_true", diff --git a/jcvi/annotation/trinity.py b/jcvi/annotation/trinity.py index 812683b9..1f742501 100644 --- a/jcvi/annotation/trinity.py +++ b/jcvi/annotation/trinity.py @@ -43,13 +43,13 @@ def prepare(args): If "--merge" is specified, the fastq files are merged together before assembling """ p = OptionParser(prepare.__doc__) - p.add_option( + p.add_argument( "--paired", default=False, action="store_true", help="Paired-end mode", ) - p.add_option( + p.add_argument( "--merge", default=False, action="store_true", diff --git a/jcvi/apps/align.py b/jcvi/apps/align.py index 6e96831b..54e3f7a8 100644 --- a/jcvi/apps/align.py +++ b/jcvi/apps/align.py @@ -157,7 +157,7 @@ def minimap(args): from jcvi.formats.fasta import Fasta p = OptionParser(minimap.__doc__) - p.add_option( + p.add_argument( "--chunks", type=int, default=2000000, @@ -216,7 +216,9 @@ def nucmer(args): from jcvi.formats.base import split p = OptionParser(nucmer.__doc__) - p.add_option("--chunks", type=int, help="Split both query and subject into chunks") + p.add_argument( + "--chunks", type=int, help="Split both query and subject into chunks" + ) p.set_params(prog="nucmer", params="-l 100 -c 500") p.set_cpus() opts, args = p.parse_args(args) @@ -350,9 +352,9 @@ def blast(args): task_choices = ("blastn", "blastn-short", "dc-megablast", "megablast", "vecscreen") p = OptionParser(blast.__doc__) p.set_align(pctid=0, evalue=0.01) - p.add_option("--wordsize", type=int, help="Word size") - p.add_option("--best", default=1, type=int, help="Only look for best N hits") - p.add_option( + p.add_argument("--wordsize", type=int, help="Word size") + p.add_argument("--best", default=1, type=int, help="Only look for best N hits") + p.add_argument( "--task", default="megablast", choices=task_choices, help="Task of the blastn" ) p.set_cpus() @@ -489,29 +491,29 @@ def last(args, dbtype=None): Works with LAST-719. """ p = OptionParser(last.__doc__) - p.add_option( + p.add_argument( "--dbtype", default="nucl", choices=("nucl", "prot"), help="Molecule type of subject database", ) - p.add_option("--path", help="Specify LAST path") - p.add_option( + p.add_argument("--path", help="Specify LAST path") + p.add_argument( "--mask", default=False, action="store_true", help="Invoke -c in lastdb" ) - p.add_option( + p.add_argument( "--format", default="BlastTab", choices=("TAB", "MAF", "BlastTab", "BlastTab+"), help="Output format", ) - p.add_option( + p.add_argument( "--minlen", default=0, type=int, help="Filter alignments by how many bases match", ) - p.add_option("--minid", default=0, type=int, help="Minimum sequence identity") + p.add_argument("--minid", default=0, type=int, help="Minimum sequence identity") p.set_cpus() p.set_outdir() p.set_params() @@ -598,13 +600,13 @@ def blast_main(args, dbtype=None): Run blastp/blastn by calling BLAST+ blastp/blastn depends on dbtype. """ p = OptionParser(blast_main.__doc__) - p.add_option( + p.add_argument( "--dbtype", default="nucl", choices=("nucl", "prot"), help="Molecule type of subject database", ) - p.add_option("--path", help="Specify BLAST path for blastn or blastp") + p.add_argument("--path", help="Specify BLAST path for blastn or blastp") p.set_cpus() p.set_outdir() @@ -662,7 +664,7 @@ def diamond_blastp_main(args, dbtype="prot"): """ p = OptionParser(diamond_blastp_main.__doc__) - p.add_option("--path", help="Specify diamond path for diamond blastp") + p.add_argument("--path", help="Specify diamond path for diamond blastp") p.set_cpus() p.set_outdir() diff --git a/jcvi/apps/base.py b/jcvi/apps/base.py index bbaa17ad..3fa3cc32 100644 --- a/jcvi/apps/base.py +++ b/jcvi/apps/base.py @@ -154,14 +154,6 @@ class OptionParser(ArgumentParser): def __init__(self, doc: Optional[str]): super(OptionParser, self).__init__(doc, epilog=JCVIHELP) - def add_option(self, *args, **kwargs): - """ - Add an option to the parser. - """ - if "help" in kwargs: - kwargs["help"] = kwargs["help"].replace("%prog", self.prog) - return self.add_argument(*args, **kwargs) - def parse_args(self, args=None): """ Parse the command line arguments. diff --git a/jcvi/apps/biomart.py b/jcvi/apps/biomart.py index f934aadb..e10ade33 100644 --- a/jcvi/apps/biomart.py +++ b/jcvi/apps/biomart.py @@ -123,7 +123,7 @@ def parse_configuration(self): for t in self.getiterator("FilterDescription"): f = Filter(**t.attrib) options = [Option(**x.attrib) for x in t.getiterator("Option")] - f.add_options(options) + f.add_arguments(options) yield f @@ -317,7 +317,7 @@ class Filter(MartArgument): then use the filter chromosome_name with value `1` """ - def add_options(self, options): + def add_arguments(self, options): self.options = dict((x.displayName, x) for x in options) diff --git a/jcvi/apps/blastplus.py b/jcvi/apps/blastplus.py index 5a7295c9..5756596e 100755 --- a/jcvi/apps/blastplus.py +++ b/jcvi/apps/blastplus.py @@ -36,19 +36,19 @@ def main(): """ p = OptionParser(main.__doc__) - p.add_option( + p.add_argument( "--format", default=" '6 qseqid sseqid pident length " "mismatch gapopen qstart qend sstart send evalue bitscore' ", help='0-11, learn more with "blastp -help"', ) - p.add_option( + p.add_argument( "--path", dest="blast_path", default=None, help="specify BLAST+ path including the program name", ) - p.add_option( + p.add_argument( "--prog", dest="blast_program", default="blastp", @@ -56,14 +56,14 @@ def main(): "http://www.ncbi.nlm.nih.gov/books/NBK52640/#chapter1.Installation", ) p.set_align(evalue=0.01) - p.add_option( + p.add_argument( "--best", default=1, type=int, help="Only look for best N hits", ) p.set_cpus() - p.add_option( + p.add_argument( "--nprocs", default=1, type=int, diff --git a/jcvi/apps/bowtie.py b/jcvi/apps/bowtie.py index a7f1f3aa..06a3a3c8 100644 --- a/jcvi/apps/bowtie.py +++ b/jcvi/apps/bowtie.py @@ -98,25 +98,25 @@ def align(args): p = OptionParser(align.__doc__) p.set_firstN(firstN=0) - p.add_option( + p.add_argument( "--full", default=False, action="store_true", help="Enforce end-to-end alignment [default: local]", ) - p.add_option( + p.add_argument( "--reorder", default=False, action="store_true", help="Keep the input read order", ) - p.add_option( + p.add_argument( "--null", default=False, action="store_true", help="Do not write to SAM/BAM output", ) - p.add_option( + p.add_argument( "--fasta", default=False, action="store_true", help="Query reads are FASTA" ) p.set_cutoff(cutoff=800) diff --git a/jcvi/apps/bwa.py b/jcvi/apps/bwa.py index 974a2696..45ccfd13 100644 --- a/jcvi/apps/bwa.py +++ b/jcvi/apps/bwa.py @@ -124,9 +124,9 @@ def index(args): def set_align_options(p): """Used in align() and batch()""" - p.add_option("--bwa", default="bwa", help="Run bwa at this path") - p.add_option("--rg", help="Read group") - p.add_option( + p.add_argument("--bwa", default="bwa", help="Run bwa at this path") + p.add_argument("--rg", help="Read group") + p.add_argument( "--readtype", choices=("pacbio", "pbread", "ont2d", "intractg"), help="Read type in bwa-mem", @@ -142,7 +142,7 @@ def align(args): """ valid_modes = ("bwasw", "aln", "mem") p = OptionParser(align.__doc__) - p.add_option("--mode", default="mem", choices=valid_modes, help="BWA mode") + p.add_argument("--mode", default="mem", choices=valid_modes, help="BWA mode") set_align_options(p) p.set_sam_options() diff --git a/jcvi/apps/cdhit.py b/jcvi/apps/cdhit.py index 686576e2..65f1bd3c 100644 --- a/jcvi/apps/cdhit.py +++ b/jcvi/apps/cdhit.py @@ -84,7 +84,7 @@ def filter(args): from jcvi.formats.fasta import Fasta, SeqIO p = OptionParser(filter.__doc__) - p.add_option("--minsize", default=2, type=int, help="Minimum cluster size") + p.add_argument("--minsize", default=2, type=int, help="Minimum cluster size") p.set_outfile() opts, args = p.parse_args(args) @@ -136,7 +136,7 @@ def ids(args): Get the representative ids from clstr file. """ p = OptionParser(ids.__doc__) - p.add_option("--prefix", type=int, help="Find rep id for prefix of len") + p.add_argument("--prefix", type=int, help="Find rep id for prefix of len") opts, args = p.parse_args(args) if len(args) != 1: @@ -192,25 +192,25 @@ def deduplicate(args): """ p = OptionParser(deduplicate.__doc__) p.set_align(pctid=96, pctcov=0) - p.add_option( + p.add_argument( "--fast", default=False, action="store_true", help="Place sequence in the first cluster", ) - p.add_option( + p.add_argument( "--consensus", default=False, action="store_true", help="Compute consensus sequences", ) - p.add_option( + p.add_argument( "--reads", default=False, action="store_true", help="Use `cd-hit-454` to deduplicate", ) - p.add_option( + p.add_argument( "--samestrand", default=False, action="store_true", diff --git a/jcvi/apps/fetch.py b/jcvi/apps/fetch.py index 876646c2..9ae25a3b 100644 --- a/jcvi/apps/fetch.py +++ b/jcvi/apps/fetch.py @@ -148,7 +148,7 @@ def ensembl(args): $ %prog ensembl danio_rerio,gasterosteus_aculeatus """ p = OptionParser(ensembl.__doc__) - p.add_option("--version", default="75", help="Ensembl version") + p.add_argument("--version", default="75", help="Ensembl version") opts, args = p.parse_args(args) version = opts.version @@ -227,19 +227,19 @@ def phytozome(args): from jcvi.apps.biomart import GlobusXMLParser p = OptionParser(phytozome.__doc__) - p.add_option( + p.add_argument( "--version", default="12", choices=("9", "10", "11", "12", "12_unrestricted", "13"), help="Phytozome version", ) - p.add_option( + p.add_argument( "--assembly", default=False, action="store_true", help="Download assembly", ) - p.add_option( + p.add_argument( "--format", default=False, action="store_true", @@ -363,13 +363,13 @@ def phytozome9(args): $ %prog phytozome9 Athaliana,Vvinifera,Osativa,Sbicolor,Slycopersicum """ p = OptionParser(phytozome9.__doc__) - p.add_option( + p.add_argument( "--assembly", default=False, action="store_true", help="Download assembly", ) - p.add_option( + p.add_argument( "--format", default=False, action="store_true", @@ -545,45 +545,45 @@ def entrez(args): valid_formats = tuple(allowed_databases.keys()) valid_databases = ("genome", "nuccore", "nucest", "nucgss", "protein", "gene") - p.add_option( + p.add_argument( "--noversion", dest="noversion", default=False, action="store_true", help="Remove trailing accession versions", ) - p.add_option( + p.add_argument( "--format", default="fasta", choices=valid_formats, help="download format", ) - p.add_option( + p.add_argument( "--database", default="nuccore", choices=valid_databases, help="search database", ) - p.add_option( + p.add_argument( "--retmax", default=1000000, type=int, help="how many results to return", ) - p.add_option( + p.add_argument( "--skipcheck", default=False, action="store_true", help="turn off prompt to check file existence", ) - p.add_option( + p.add_argument( "--batchsize", default=500, type=int, help="download the results in batch for speed-up", ) p.set_outdir(outdir=None) - p.add_option("--outprefix", default="out", help="output file name prefix") + p.add_argument("--outprefix", default="out", help="output file name prefix") p.set_email() opts, args = p.parse_args(args) @@ -674,7 +674,7 @@ def sra(args): """ p = OptionParser(sra.__doc__) - p.add_option( + p.add_argument( "--nogzip", dest="nogzip", default=False, diff --git a/jcvi/apps/gbsubmit.py b/jcvi/apps/gbsubmit.py index c98524d5..bbfb5260 100644 --- a/jcvi/apps/gbsubmit.py +++ b/jcvi/apps/gbsubmit.py @@ -135,7 +135,7 @@ def fcs(args): contig0800 124133 30512..30559 primer/adapter """ p = OptionParser(fcs.__doc__) - p.add_option( + p.add_argument( "--cutoff", default=200, help="Skip small components less than", @@ -259,7 +259,7 @@ def htgnew(args): from jcvi.formats.fasta import sequin p = OptionParser(htgnew.__doc__) - p.add_option("--comment", default="", help="Comments for this submission") + p.add_argument("--comment", default="", help="Comments for this submission") opts, args = p.parse_args(args) if len(args) != 3: @@ -358,12 +358,12 @@ def htg(args): from jcvi.apps.fetch import entrez p = OptionParser(htg.__doc__) - p.add_option( + p.add_argument( "--phases", default=None, help="Use another phasefile to override", ) - p.add_option("--comment", default="", help="Comments for this update") + p.add_argument("--comment", default="", help="Comments for this update") opts, args = p.parse_args(args) if len(args) != 2: diff --git a/jcvi/apps/gmap.py b/jcvi/apps/gmap.py index 2bd51875..f952e220 100644 --- a/jcvi/apps/gmap.py +++ b/jcvi/apps/gmap.py @@ -113,7 +113,7 @@ def index(args): Wrapper for `gmap_build`. Same interface. """ p = OptionParser(index.__doc__) - p.add_option( + p.add_argument( "--supercat", default=False, action="store_true", @@ -135,10 +135,10 @@ def gmap(args): Wrapper for `gmap`. """ p = OptionParser(gmap.__doc__) - p.add_option( + p.add_argument( "--cross", default=False, action="store_true", help="Cross-species alignment" ) - p.add_option( + p.add_argument( "--npaths", default=0, type=int, @@ -185,13 +185,13 @@ def align(args): from jcvi.formats.fastq import guessoffset p = OptionParser(align.__doc__) - p.add_option( + p.add_argument( "--rnaseq", default=False, action="store_true", help="Input is RNA-seq reads, turn splicing on", ) - p.add_option( + p.add_argument( "--native", default=False, action="store_true", diff --git a/jcvi/apps/grid.py b/jcvi/apps/grid.py index e7c8ffd2..06230a04 100644 --- a/jcvi/apps/grid.py +++ b/jcvi/apps/grid.py @@ -618,7 +618,7 @@ def kill(args): valid_methods = ("pattern", "jobid") p = OptionParser(kill.__doc__) - p.add_option( + p.add_argument( "--method", choices=valid_methods, help="Identify jobs based on [default: guess]", diff --git a/jcvi/apps/lastz.py b/jcvi/apps/lastz.py index acdc1a71..0b725f92 100755 --- a/jcvi/apps/lastz.py +++ b/jcvi/apps/lastz.py @@ -183,21 +183,21 @@ def main(): "sam-, softsam-, cigar, BLASTN, BLASTN-, differences, rdotplot, text".split(",") ) - p.add_option( + p.add_argument( "--format", default="BLASTN-", choices=supported_formats, help="Ooutput format", ) - p.add_option("--path", dest="lastz_path", default=None, help="specify LASTZ path") - p.add_option( + p.add_argument("--path", dest="lastz_path", default=None, help="specify LASTZ path") + p.add_argument( "--mask", dest="mask", default=False, action="store_true", help="treat lower-case letters as mask info", ) - p.add_option( + p.add_argument( "--similar", default=False, action="store_true", diff --git a/jcvi/apps/mask.py b/jcvi/apps/mask.py index 3fdb8bfb..126ea817 100755 --- a/jcvi/apps/mask.py +++ b/jcvi/apps/mask.py @@ -96,7 +96,7 @@ def mask(args): (default to lower case, set --hard for hardmasking). """ p = OptionParser(mask.__doc__) - p.add_option( + p.add_argument( "--hard", dest="hard", default=False, diff --git a/jcvi/apps/phylo.py b/jcvi/apps/phylo.py index 90b0e76e..f0127fad 100644 --- a/jcvi/apps/phylo.py +++ b/jcvi/apps/phylo.py @@ -701,8 +701,8 @@ def prepare(args): from jcvi.graphics.base import discrete_rainbow p = OptionParser(prepare.__doc__) - p.add_option("--addtandem", help="path to tandemfile") - p.add_option( + p.add_argument("--addtandem", help="path to tandemfile") + p.add_argument( "--writecolors", default=False, action="store_true", @@ -819,53 +819,53 @@ def build(args): from jcvi.formats.fasta import translate p = OptionParser(build.__doc__) - p.add_option( + p.add_argument( "--longest", action="store_true", help="Get longest ORF, only works if no pep file, e.g. ESTs", ) - p.add_option( + p.add_argument( "--nogblocks", action="store_true", help="don't use Gblocks to edit alignment", ) - p.add_option( + p.add_argument( "--synonymous", action="store_true", help="extract synonymous sites of the alignment", ) - p.add_option( + p.add_argument( "--fourfold", action="store_true", help="extract fourfold degenerate sites of the alignment", ) - p.add_option( + p.add_argument( "--msa", default="muscle", choices=("clustalw", "muscle"), help="software used to align the proteins", ) - p.add_option( + p.add_argument( "--noneighbor", action="store_true", help="don't build NJ tree", ) - p.add_option( + p.add_argument( "--ml", default=None, choices=("raxml", "phyml"), help="software used to build ML tree", ) - p.add_option("--outgroup", help="path to file containing outgroup orders") - p.add_option("--SH", help="path to reference Newick tree") - p.add_option("--shout", default="SH_out.txt", help="SH output file name") - p.add_option( + p.add_argument("--outgroup", help="path to file containing outgroup orders") + p.add_argument("--SH", help="path to reference Newick tree") + p.add_argument("--shout", default="SH_out.txt", help="SH output file name") + p.add_argument( "--treefix", action="store_true", help="use TreeFix to rearrange ML tree", ) - p.add_option("--stree", help="path to species Newick tree") - p.add_option( + p.add_argument("--stree", help="path to species Newick tree") + p.add_argument( "--smap", help="path to smap file: gene_name_patternspecies_name", ) @@ -1085,18 +1085,18 @@ def draw(args): """ trunc_name_options = ["headn", "oheadn", "tailn", "otailn"] p = OptionParser(draw.__doc__) - p.add_option( + p.add_argument( "--input", help="path to single input tree file or a dir " "containing ONLY the input tree files", ) - p.add_option( + p.add_argument( "--combine", type=str, default="1x1", help="combine multiple trees into one plot in nrowxncol", ) - p.add_option( + p.add_argument( "--trunc_name", default=None, help="Options are: {0}. " @@ -1104,27 +1104,27 @@ def draw(args): "truncate last n chars, retain only last chars. " "n=1~99.".format(trunc_name_options), ) - p.add_option( + p.add_argument( "--SH", default=None, help="path to a file containing SH test p-values in format:" "tree_file_namep-values " "This file can be generated with jcvi.apps.phylo build", ) - p.add_option( + p.add_argument( "--scutoff", default=50, type=int, help="cutoff for displaying node support, 0-100", ) - p.add_option( + p.add_argument( "--barcode", default=None, help="path to seq/taxon name barcode mapping file: " "barcodenew_name " "This option is downstream of `--trunc_name`", ) - p.add_option( + p.add_argument( "--leafcolorfile", default=None, help="path to a mapping file containing font colors " diff --git a/jcvi/apps/restriction.py b/jcvi/apps/restriction.py index a8544c12..42e901d0 100644 --- a/jcvi/apps/restriction.py +++ b/jcvi/apps/restriction.py @@ -125,13 +125,13 @@ def fragment(args): ends are NOT extracted, as in the first fragment. """ p = OptionParser(fragment.__doc__) - p.add_option( + p.add_argument( "--flank", default=150, type=int, help="Extract flanking bases of the cut sites", ) - p.add_option( + p.add_argument( "--full", default=False, action="store_true", diff --git a/jcvi/apps/softlink.py b/jcvi/apps/softlink.py index 934f5e21..9ef12b7a 100644 --- a/jcvi/apps/softlink.py +++ b/jcvi/apps/softlink.py @@ -43,7 +43,7 @@ def link(args): from jcvi.apps.base import mkdir p = OptionParser(link.__doc__) - p.add_option("--dir", help="Place links in a subdirectory") + p.add_argument("--dir", help="Place links in a subdirectory") opts, args = p.parse_args(args) if len(args) != 1: diff --git a/jcvi/apps/uclust.py b/jcvi/apps/uclust.py index 0d0c3f73..76b9d040 100644 --- a/jcvi/apps/uclust.py +++ b/jcvi/apps/uclust.py @@ -240,10 +240,10 @@ def stats(args): def add_consensus_options(p): - p.add_option("--prefix", default="mcluster", help="Output prefix") - p.add_option("--minlength", default=30, type=int, help="Min contig length") - p.add_option("--mindepth", default=3, type=int, help="Min depth for each stack") - p.add_option("--minsamp", default=3, type=int, help="Min number of samples") + p.add_argument("--prefix", default="mcluster", help="Output prefix") + p.add_argument("--minlength", default=30, type=int, help="Min contig length") + p.add_argument("--mindepth", default=3, type=int, help="Min depth for each stack") + p.add_argument("--minsamp", default=3, type=int, help="Min number of samples") def find_pctid(consensusfiles): @@ -430,7 +430,7 @@ def mconsensus(args): Call consensus along the stacks from cross-sample clustering. """ p = OptionParser(mconsensus.__doc__) - p.add_option( + p.add_argument( "--allele_counts", default="allele_counts", help="Directory to generate allele counts", @@ -556,7 +556,9 @@ def consensus(args): errors according to error rate, calls consensus. """ p = OptionParser(consensus.__doc__) - p.add_option("--ploidy", default=2, type=int, help="Number of haplotypes per locus") + p.add_argument( + "--ploidy", default=2, type=int, help="Number of haplotypes per locus" + ) add_consensus_options(p) p.set_verbose() opts, args = p.parse_args(args) diff --git a/jcvi/apps/uniprot.py b/jcvi/apps/uniprot.py index b99c8064..0d610fb1 100644 --- a/jcvi/apps/uniprot.py +++ b/jcvi/apps/uniprot.py @@ -98,36 +98,36 @@ def fetch(args): p = OptionParser(fetch.__doc__) - p.add_option( + p.add_argument( "--format", default="tab", choices=valid_formats, help="download format", ) - p.add_option( + p.add_argument( "--columns", default="entry name, protein names, genes,organism", help="columns to download, if --format is `tab` or `xls`", ) - p.add_option( + p.add_argument( "--include", default=False, action="store_true", help="Include isoforms when --format is `fasta` or include `description` when --format is `rdf`.", ) - p.add_option( + p.add_argument( "--limit", default=10, type=int, help="Max number of results to retrieve", ) - p.add_option( + p.add_argument( "--offset", default=0, type=int, help="Offset of first result, used with --limit", ) - p.add_option( + p.add_argument( "--skipcheck", default=False, action="store_true", diff --git a/jcvi/apps/vecscreen.py b/jcvi/apps/vecscreen.py index 9f194502..d4345270 100644 --- a/jcvi/apps/vecscreen.py +++ b/jcvi/apps/vecscreen.py @@ -47,7 +47,7 @@ def mask(args): perform FASTA tidy if requested. """ p = OptionParser(mask.__doc__) - p.add_option( + p.add_argument( "--db", default=ECOLI_URL, help="Contaminant db other than Ecoli K12, will download if file starts with http://, https://, or ftp://", @@ -90,13 +90,13 @@ def blast(args): on the vector/contaminant ranges. """ p = OptionParser(blast.__doc__) - p.add_option( + p.add_argument( "--dist", default=100, type=int, help="Merge adjacent HSPs separated by", ) - p.add_option("--db", help="Use a different database rather than UniVec_Core") + p.add_argument("--db", help="Use a different database rather than UniVec_Core") opts, args = p.parse_args(args) if len(args) != 1: diff --git a/jcvi/assembly/allmaps.py b/jcvi/assembly/allmaps.py index 501f2a9b..9eaa285e 100644 --- a/jcvi/assembly/allmaps.py +++ b/jcvi/assembly/allmaps.py @@ -1013,10 +1013,10 @@ def split(args): modified through --chunk option. """ p = OptionParser(split.__doc__) - p.add_option( + p.add_argument( "--chunk", default=4, type=int, help="Split chunks of at least N markers" ) - p.add_option( + p.add_argument( "--splitsingle", default=False, action="store_true", @@ -1061,7 +1061,7 @@ def movie(args): specific pseudomolecule, for example `chr1`. """ p = OptionParser(movie.__doc__) - p.add_option( + p.add_argument( "--gapsize", default=100, type=int, @@ -1151,9 +1151,9 @@ def estimategaps(args): The AGP file `input.chr.agp` will be modified in-place. """ p = OptionParser(estimategaps.__doc__) - p.add_option("--minsize", default=100, type=int, help="Minimum gap size") - p.add_option("--maxsize", default=500000, type=int, help="Maximum gap size") - p.add_option( + p.add_argument("--minsize", default=100, type=int, help="Minimum gap size") + p.add_argument("--maxsize", default=500000, type=int, help="Maximum gap size") + p.add_argument( "--links", default=10, type=int, @@ -1233,7 +1233,7 @@ def merge(args): scaffold_759,81336,1,9.7 """ p = OptionParser(merge.__doc__) - p.add_option( + p.add_argument( "-w", "--weightsfile", default="weights.txt", help="Write weights to file" ) p.set_outfile("out.bed") @@ -1274,7 +1274,7 @@ def mergebed(args): Combine bed maps to bed format, adding the map name. """ p = OptionParser(mergebed.__doc__) - p.add_option( + p.add_argument( "-w", "--weightsfile", default="weights.txt", help="Write weights to file" ) p.set_outfile("out.bed") @@ -1357,52 +1357,56 @@ def path(args): """ oargs = args p = OptionParser(path.__doc__) - p.add_option("-b", "--bedfile", help=SUPPRESS) - p.add_option("-s", "--fastafile", help=SUPPRESS) - p.add_option( + p.add_argument("-b", "--bedfile", help=SUPPRESS) + p.add_argument("-s", "--fastafile", help=SUPPRESS) + p.add_argument( "-w", "--weightsfile", default="weights.txt", help="Use weights from file" ) - p.add_option( + p.add_argument( "--compress", default=1e-6, type=float, help="Compress markers with distance <=", ) - p.add_option( + p.add_argument( "--noremoveoutliers", default=False, action="store_true", help="Don't remove outlier markers", ) - p.add_option( + p.add_argument( "--distance", default="rank", choices=distance_choices, help="Distance function when building initial consensus", ) - p.add_option( + p.add_argument( "--linkage", default="double", choices=linkage_choices, help="Linkage function when building initial consensus", ) - p.add_option( + p.add_argument( "--gapsize", default=100, type=int, help="Insert gaps of size between scaffolds", ) - p.add_option("--seqid", help="Only run partition with this seqid") - p.add_option("--partitions", help="Use predefined partitions of LGs") - p.add_option("--links", default=10, type=int, help="Only plot matchings more than") - p.add_option("--mincount", default=1, type=int, help="Minimum markers on a contig") - p.add_option( + p.add_argument("--seqid", help="Only run partition with this seqid") + p.add_argument("--partitions", help="Use predefined partitions of LGs") + p.add_argument( + "--links", default=10, type=int, help="Only plot matchings more than" + ) + p.add_argument( + "--mincount", default=1, type=int, help="Minimum markers on a contig" + ) + p.add_argument( "--noplot", default=False, action="store_true", help="Do not visualize the alignments", ) - p.add_option( + p.add_argument( "--renumber", default=False, action="store_true", @@ -1411,13 +1415,13 @@ def path(args): p.set_cpus(cpus=16) q = p.add_argument_group("Genetic algorithm options") - q.add_option( + q.add_argument( "--ngen", default=500, type=int, help="Iterations in GA, higher ~ slower" ) - q.add_option( + q.add_argument( "--npop", default=100, type=int, help="Population size in GA, higher ~ slower" ) - q.add_option("--seed", default=666, type=int, help="Random seed number") + q.add_argument("--seed", default=666, type=int, help="Random seed number") opts, args, iopts = p.set_image_options(args, figsize="10x6") if len(args) != 2: @@ -1705,7 +1709,7 @@ def build(args): new positions of the markers will be reported in *.lifted.bed. """ p = OptionParser(build.__doc__) - p.add_option( + p.add_argument( "--cleanup", default=False, action="store_true", @@ -1768,17 +1772,19 @@ def build(args): def add_allmaps_plot_options(p): - p.add_option( + p.add_argument( "-w", "--weightsfile", default="weights.txt", help="Use weights from file" ) - p.add_option( + p.add_argument( "--distance", default="cM", choices=distance_choices, help="Plot markers based on distance", ) - p.add_option("--links", default=10, type=int, help="Only plot matchings more than") - p.add_option( + p.add_argument( + "--links", default=10, type=int, help="Only plot matchings more than" + ) + p.add_argument( "--panels", default=False, action="store_true", help="Add panel labels A/B" ) @@ -1804,7 +1810,7 @@ def plot(args): from ..graphics.chromosome import Chromosome, GeneticMap, HorizontalChromosome p = OptionParser(plot.__doc__) - p.add_option("--title", help="Title of the plot") + p.add_argument("--title", help="Title of the plot") add_allmaps_plot_options(p) opts, args, iopts = p.set_image_options(args, figsize="10x6") diff --git a/jcvi/assembly/allpaths.py b/jcvi/assembly/allpaths.py index 1f172219..afa7ff8c 100644 --- a/jcvi/assembly/allpaths.py +++ b/jcvi/assembly/allpaths.py @@ -130,8 +130,8 @@ def dump(args): run allpaths folder. """ p = OptionParser(dump.__doc__) - p.add_option("--dir", help="Working directory") - p.add_option( + p.add_argument("--dir", help="Working directory") + p.add_argument( "--nosim", default=False, action="store_true", @@ -229,7 +229,7 @@ def fill(args): Run FillFragments on `frag_reads_corr.fastb`. """ p = OptionParser(fill.__doc__) - p.add_option( + p.add_argument( "--stretch", default=3, type=int, @@ -334,13 +334,13 @@ def pairs(args): from jcvi.assembly.preprocess import run_FastbAndQualb2Fastq p = OptionParser(pairs.__doc__) - p.add_option( + p.add_argument( "--header", default=False, action="store_true", help="Print header only", ) - p.add_option( + p.add_argument( "--suffix", default=False, action="store_true", @@ -415,19 +415,19 @@ def prepare(args): from jcvi.formats.fastq import guessoffset, readlen p = OptionParser(prepare.__doc__ + FastqNamings) - p.add_option( + p.add_argument( "--corr", default=False, action="store_true", help="Extra parameters for corrected data", ) - p.add_option( + p.add_argument( "--norun", default=False, action="store_true", help="Don't write `run.sh` script", ) - p.add_option("--ploidy", default="2", choices=("1", "2"), help="Ploidy") + p.add_argument("--ploidy", default="2", choices=("1", "2"), help="Ploidy") p.set_cpus() opts, args = p.parse_args(args) diff --git a/jcvi/assembly/automaton.py b/jcvi/assembly/automaton.py index 46074f69..b1c232ec 100644 --- a/jcvi/assembly/automaton.py +++ b/jcvi/assembly/automaton.py @@ -144,7 +144,7 @@ def contamination(args): from jcvi.apps.bowtie import align p = OptionParser(contamination.__doc__) - p.add_option( + p.add_argument( "--mapped", default=False, action="store_true", @@ -235,7 +235,7 @@ def allpaths(args): Run automated ALLPATHS on list of dirs. """ p = OptionParser(allpaths.__doc__) - p.add_option("--ploidy", default="1", choices=("1", "2"), help="Ploidy") + p.add_argument("--ploidy", default="1", choices=("1", "2"), help="Ploidy") opts, args = p.parse_args(args) if len(args) == 0: @@ -263,7 +263,7 @@ def prepare(args): Note that JIRA report can also be a list of FASTQ files. """ p = OptionParser(prepare.__doc__) - p.add_option( + p.add_argument( "--first", default=0, type=int, diff --git a/jcvi/assembly/base.py b/jcvi/assembly/base.py index 73189625..609acb6b 100644 --- a/jcvi/assembly/base.py +++ b/jcvi/assembly/base.py @@ -156,7 +156,7 @@ def n50(args): from jcvi.graphics.histogram import loghistogram p = OptionParser(n50.__doc__) - p.add_option( + p.add_argument( "--print0", default=False, action="store_true", diff --git a/jcvi/assembly/gaps.py b/jcvi/assembly/gaps.py index a975eeaa..4f50c3e5 100644 --- a/jcvi/assembly/gaps.py +++ b/jcvi/assembly/gaps.py @@ -38,7 +38,7 @@ def annotate(args): from jcvi.formats.agp import AGP, bed, tidy p = OptionParser(annotate.__doc__) - p.add_option("--minsize", default=200, help="Smallest component size") + p.add_argument("--minsize", default=200, help="Smallest component size") opts, args = p.parse_args(args) if len(args) != 3: @@ -243,7 +243,7 @@ def flanks(args): Create sequences flanking the gaps. """ p = OptionParser(flanks.__doc__) - p.add_option( + p.add_argument( "--extend", default=2000, type=int, diff --git a/jcvi/assembly/geneticmap.py b/jcvi/assembly/geneticmap.py index af86dcda..4d91c2b1 100644 --- a/jcvi/assembly/geneticmap.py +++ b/jcvi/assembly/geneticmap.py @@ -433,7 +433,7 @@ def heatmap(args): Calculate pairwise linkage disequilibrium given MSTmap. """ p = OptionParser(heatmap.__doc__) - p.add_option( + p.add_argument( "--subsample", default=1000, type=int, @@ -469,8 +469,8 @@ def header(args): from jcvi.formats.base import DictFile p = OptionParser(header.__doc__) - p.add_option("--prefix", default="", help="Prepend text to line number") - p.add_option("--ids", help="Write ids to file") + p.add_argument("--prefix", default="", help="Prepend text to line number") + p.add_argument("--ids", help="Write ids to file") opts, args = p.parse_args(args) if len(args) != 2: @@ -570,13 +570,13 @@ def bed(args): Convert MSTMAP output into bed format. """ p = OptionParser(bed.__doc__) - p.add_option( + p.add_argument( "--switch", default=False, action="store_true", help="Switch reference and aligned map elements", ) - p.add_option( + p.add_argument( "--sep", default=".", help="Separator that is used to delimit scaffold and position in the marker name", @@ -604,7 +604,7 @@ def fasta(args): from jcvi.formats.sizes import Sizes p = OptionParser(fasta.__doc__) - p.add_option( + p.add_argument( "--extend", default=1000, type=int, @@ -673,7 +673,7 @@ def breakpoint(args): from more_itertools import pairwise p = OptionParser(breakpoint.__doc__) - p.add_option( + p.add_argument( "--diff", default=0.1, type=float, diff --git a/jcvi/assembly/goldenpath.py b/jcvi/assembly/goldenpath.py index fe3d47fe..4d81d82c 100644 --- a/jcvi/assembly/goldenpath.py +++ b/jcvi/assembly/goldenpath.py @@ -656,7 +656,7 @@ def anneal(args): """ p = OptionParser(anneal.__doc__) p.set_align(pctid=GoodPct, hitlen=GoodOverlap) - p.add_option( + p.add_argument( "--hang", default=GoodOverhang, type=int, help="Maximum overhang length" ) p.set_outdir(outdir="outdir") @@ -759,7 +759,7 @@ def blast(args): from jcvi.apps.align import run_megablast p = OptionParser(blast.__doc__) - p.add_option("-n", type=int, default=2, help="Take best N hits") + p.add_argument("-n", type=int, default=2, help="Take best N hits") opts, args = p.parse_args(args) if len(args) != 2: @@ -926,23 +926,23 @@ def overlap(args): from jcvi.formats.blast import chain_HSPs p = OptionParser(overlap.__doc__) - p.add_option( + p.add_argument( "--dir", default=os.getcwd(), help="Download sequences to dir", ) - p.add_option( + p.add_argument( "--suffix", default="fasta", help="Suffix of the sequence file in dir", ) - p.add_option( + p.add_argument( "--qreverse", default=False, action="store_true", help="Reverse seq a", ) - p.add_option( + p.add_argument( "--nochain", default=False, action="store_true", diff --git a/jcvi/assembly/hic.py b/jcvi/assembly/hic.py index 6f68df86..90a3fd72 100644 --- a/jcvi/assembly/hic.py +++ b/jcvi/assembly/hic.py @@ -624,9 +624,9 @@ def dist(args): from jcvi.graphics.base import human_base_formatter, markup p = OptionParser(dist.__doc__) - p.add_option("--title", help="Title of the histogram") - p.add_option("--xmin", default=300, help="Minimum distance") - p.add_option("--xmax", default=6000000, help="Maximum distance") + p.add_argument("--title", help="Title of the histogram") + p.add_argument("--xmin", default=300, help="Minimum distance") + p.add_argument("--xmax", default=6000000, help="Maximum distance") opts, args, iopts = p.set_image_options(args, figsize="6x6") if len(args) != 2: @@ -817,12 +817,12 @@ def heatmap(args): and seq2 individually with green color. """ p = OptionParser(heatmap.__doc__) - p.add_option("--title", help="Title of the heatmap") - p.add_option("--groups", help="Groups file, see doc") - p.add_option("--vmin", default=1, type=int, help="Minimum value in the heatmap") - p.add_option("--vmax", default=6, type=int, help="Maximum value in the heatmap") - p.add_option("--chr", help="Plot this contig/chr only") - p.add_option( + p.add_argument("--title", help="Title of the heatmap") + p.add_argument("--groups", help="Groups file, see doc") + p.add_argument("--vmin", default=1, type=int, help="Minimum value in the heatmap") + p.add_argument("--vmax", default=6, type=int, help="Maximum value in the heatmap") + p.add_argument("--chr", help="Plot this contig/chr only") + p.add_argument( "--nobreaks", default=False, action="store_true", @@ -935,13 +935,13 @@ def bam2mat(args): from jcvi.utils.cbook import percentage p = OptionParser(bam2mat.__doc__) - p.add_option( + p.add_argument( "--resolution", default=500000, type=int, help="Resolution when counting the links", ) - p.add_option( + p.add_argument( "--seqids", default=None, help="Use a given seqids file, a single line with seqids joined by comma", @@ -1063,10 +1063,10 @@ def simulate(args): - Genes are distributed uniformly """ p = OptionParser(simulate.__doc__) - p.add_option("--genomesize", default=10000000, type=int, help="Genome size") - p.add_option("--genes", default=1000, type=int, help="Number of genes") - p.add_option("--contigs", default=100, type=int, help="Number of contigs") - p.add_option("--coverage", default=10, type=int, help="Link coverage") + p.add_argument("--genomesize", default=10000000, type=int, help="Genome size") + p.add_argument("--genes", default=1000, type=int, help="Number of genes") + p.add_argument("--contigs", default=100, type=int, help="Number of contigs") + p.add_argument("--coverage", default=10, type=int, help="Link coverage") opts, args = p.parse_args(args) if len(args) != 1: @@ -1220,7 +1220,7 @@ def density(args): Estimate link density of contigs. """ p = OptionParser(density.__doc__) - p.add_option( + p.add_argument( "--save", default=False, action="store_true", @@ -1260,19 +1260,19 @@ def optimize(args): Optimize the contig order and orientation, based on CLM file. """ p = OptionParser(optimize.__doc__) - p.add_option( + p.add_argument( "--skiprecover", default=False, action="store_true", help="Do not import 'recover' contigs", ) - p.add_option( + p.add_argument( "--startover", default=False, action="store_true", help="Do not resume from existing tour file", ) - p.add_option("--skipGA", default=False, action="store_true", help="Skip GA step") + p.add_argument("--skipGA", default=False, action="store_true", help="Skip GA step") p.set_outfile(outfile=None) p.set_cpus() opts, args = p.parse_args(args) @@ -1479,8 +1479,8 @@ def movie(args): Plot optimization history. """ p = OptionParser(movie.__doc__) - p.add_option("--frames", default=500, type=int, help="Only plot every N frames") - p.add_option( + p.add_argument("--frames", default=500, type=int, help="Only plot every N frames") + p.add_argument( "--engine", default="ffmpeg", choices=("ffmpeg", "gifsicle"), @@ -1666,7 +1666,7 @@ def movieframe(args): Draw heatmap and synteny in the same plot. """ p = OptionParser(movieframe.__doc__) - p.add_option("--label", help="Figure title") + p.add_argument("--label", help="Figure title") p.set_beds() p.set_outfile(outfile=None) opts, args, iopts = p.set_image_options( diff --git a/jcvi/assembly/kmer.py b/jcvi/assembly/kmer.py index 2f86b3ee..cb12ed39 100644 --- a/jcvi/assembly/kmer.py +++ b/jcvi/assembly/kmer.py @@ -624,7 +624,7 @@ def entropy(args): AAAAAAAAAAAGAAGAAAGAAA 34 """ p = OptionParser(entropy.__doc__) - p.add_option( + p.add_argument( "--threshold", default=0, type=int, help="Complexity needs to be above" ) opts, args = p.parse_args(args) @@ -684,38 +684,38 @@ def kmcop(args): Intersect or union kmc indices. """ p = OptionParser(kmcop.__doc__) - p.add_option( + p.add_argument( "--action", choices=("union", "intersect", "reduce"), default="union", help="Action", ) - p.add_option( + p.add_argument( "--ci_in", default=0, type=int, help="Exclude input kmers with less than ci_in counts", ) - p.add_option( + p.add_argument( "--cs", default=0, type=int, help="Maximal value of a counter, only used when action is reduce", ) - p.add_option( + p.add_argument( "--ci_out", default=0, type=int, help="Exclude output kmers with less than ci_out counts", ) - p.add_option( + p.add_argument( "--batch", default=1, type=int, help="Number of batch, useful to reduce memory usage", ) - p.add_option("--exclude", help="Exclude accessions from this list") - p.add_option("-o", default="results", help="Output name") + p.add_argument("--exclude", help="Exclude accessions from this list") + p.add_argument("-o", default="results", help="Output name") opts, args = p.parse_args(args) if len(args) < 2: @@ -772,25 +772,25 @@ def kmc(args): Run kmc3 on Illumina reads. """ p = OptionParser(kmc.__doc__) - p.add_option("-k", default=27, type=int, help="Kmer size") - p.add_option( + p.add_argument("-k", default=27, type=int, help="Kmer size") + p.add_argument( "--ci", default=2, type=int, help="Exclude kmers with less than ci counts" ) - p.add_option("--cs", default=0, type=int, help="Maximal value of a counter") - p.add_option("--cx", type=int, help="Exclude kmers with more than cx counts") - p.add_option( + p.add_argument("--cs", default=0, type=int, help="Maximal value of a counter") + p.add_argument("--cx", type=int, help="Exclude kmers with more than cx counts") + p.add_argument( "--single", default=False, action="store_true", help="Input is single-end data, only one FASTQ/FASTA", ) - p.add_option( + p.add_argument( "--fasta", default=False, action="store_true", help="Input is FASTA instead of FASTQ", ) - p.add_option( + p.add_argument( "--mem", default=48, type=int, help="Max amount of RAM in GB (`kmc -m`)" ) p.set_cpus() @@ -838,7 +838,7 @@ def meryl(args): Run meryl on Illumina reads. """ p = OptionParser(meryl.__doc__) - p.add_option("-k", default=19, type=int, help="Kmer size") + p.add_argument("-k", default=19, type=int, help="Kmer size") p.set_cpus() opts, args = p.parse_args(args) @@ -879,8 +879,8 @@ def model(args): from scipy.stats import binom, poisson p = OptionParser(model.__doc__) - p.add_option("-k", default=23, type=int, help="Kmer size") - p.add_option("--cov", default=50, type=int, help="Expected coverage") + p.add_argument("-k", default=23, type=int, help="Kmer size") + p.add_argument("--cov", default=50, type=int, help="Expected coverage") opts, args = p.parse_args(args) if len(args) != 1: @@ -1010,7 +1010,7 @@ def bincount(args): from jcvi.formats.sizes import Sizes p = OptionParser(bincount.__doc__) - p.add_option("-K", default=23, type=int, help="K-mer size") + p.add_argument("-K", default=23, type=int, help="K-mer size") p.set_outfile() opts, args = p.parse_args(args) @@ -1073,7 +1073,7 @@ def dump(args): Convert FASTA sequences to list of K-mers. """ p = OptionParser(dump.__doc__) - p.add_option("-K", default=23, type=int, help="K-mer size") + p.add_argument("-K", default=23, type=int, help="K-mer size") p.set_outfile() opts, args = p.parse_args(args) @@ -1100,15 +1100,15 @@ def jellyfish(args): from jcvi.utils.cbook import human_size p = OptionParser(jellyfish.__doc__) - p.add_option("-K", default=23, type=int, help="K-mer size") - p.add_option( + p.add_argument("-K", default=23, type=int, help="K-mer size") + p.add_argument( "--coverage", default=40, type=int, help="Expected sequence coverage", ) - p.add_option("--prefix", default="jf", help="Database prefix") - p.add_option( + p.add_argument("--prefix", default="jf", help="Database prefix") + p.add_argument( "--nohist", default=False, action="store_true", @@ -1171,10 +1171,10 @@ def multihistogram(args): on Star et al.'s method (Atlantic Cod genome paper). """ p = OptionParser(multihistogram.__doc__) - p.add_option("--kmin", default=15, type=int, help="Minimum K-mer size, inclusive") - p.add_option("--kmax", default=30, type=int, help="Maximum K-mer size, inclusive") - p.add_option("--vmin", default=2, type=int, help="Minimum value, inclusive") - p.add_option("--vmax", default=100, type=int, help="Maximum value, inclusive") + p.add_argument("--kmin", default=15, type=int, help="Minimum K-mer size, inclusive") + p.add_argument("--kmax", default=30, type=int, help="Maximum K-mer size, inclusive") + p.add_argument("--vmin", default=2, type=int, help="Minimum value, inclusive") + p.add_argument("--vmax", default=100, type=int, help="Maximum value, inclusive") opts, args, iopts = p.set_image_options(args, figsize="10x5", dpi=300) if len(args) < 1: @@ -1349,37 +1349,37 @@ def histogram(args): only used to annotate the graphic. """ p = OptionParser(histogram.__doc__) - p.add_option( + p.add_argument( "--vmin", dest="vmin", default=2, type=int, help="minimum value, inclusive", ) - p.add_option( + p.add_argument( "--vmax", dest="vmax", default=200, type=int, help="maximum value, inclusive", ) - p.add_option( + p.add_argument( "--method", choices=("nbinom", "allpaths"), default="nbinom", help="'nbinom' - slow but more accurate for het or polyploid genome; " + "'allpaths' - fast and works for homozygous enomes", ) - p.add_option( + p.add_argument( "--maxiter", default=100, type=int, help="Max iterations for optimization. Only used with --method nbinom", ) - p.add_option( + p.add_argument( "--coverage", default=0, type=int, help="Kmer coverage [default: auto]" ) - p.add_option( + p.add_argument( "--nopeaks", default=False, action="store_true", diff --git a/jcvi/assembly/opticalmap.py b/jcvi/assembly/opticalmap.py index 249ebf94..8ac22739 100644 --- a/jcvi/assembly/opticalmap.py +++ b/jcvi/assembly/opticalmap.py @@ -380,26 +380,26 @@ def bed(args): from jcvi.formats.bed import sort p = OptionParser(bed.__doc__) - p.add_option( + p.add_argument( "--blockonly", default=False, action="store_true", help="Only print out large blocks, not fragments", ) - p.add_option( + p.add_argument( "--point", default=False, action="store_true", help="Print accesssion as single point instead of interval", ) - p.add_option("--scale", type=float, help="Scale the OM distance by factor") - p.add_option( + p.add_argument("--scale", type=float, help="Scale the OM distance by factor") + p.add_argument( "--switch", default=False, action="store_true", help="Switch reference and aligned map elements", ) - p.add_option( + p.add_argument( "--nosort", default=False, action="store_true", diff --git a/jcvi/assembly/patch.py b/jcvi/assembly/patch.py index 02b8505e..8735c9ae 100644 --- a/jcvi/assembly/patch.py +++ b/jcvi/assembly/patch.py @@ -83,19 +83,19 @@ def pastegenes(args): from jcvi.utils.cbook import gene_name p = OptionParser(pastegenes.__doc__) - p.add_option( + p.add_argument( "--cutoff", default=90, type=int, help="Coverage cutoff to call gene missing", ) - p.add_option( + p.add_argument( "--flank", default=2000, type=int, help="Get the seq of size on two ends", ) - p.add_option( + p.add_argument( "--maxsize", default=50000, type=int, @@ -200,7 +200,7 @@ def pasteprepare(args): Prepare sequences for paste. """ p = OptionParser(pasteprepare.__doc__) - p.add_option( + p.add_argument( "--flank", default=5000, type=int, @@ -238,13 +238,13 @@ def paste(args): from jcvi.formats.bed import uniq p = OptionParser(paste.__doc__) - p.add_option( + p.add_argument( "--maxsize", default=300000, type=int, help="Maximum size of patchers to be replaced", ) - p.add_option("--prefix", help="Prefix of the new object") + p.add_argument("--prefix", help="Prefix of the new object") p.set_rclip(rclip=1) opts, args = p.parse_args(args) @@ -298,7 +298,7 @@ def closest(args): Identify the nearest gaps flanking suggested regions. """ p = OptionParser(closest.__doc__) - p.add_option( + p.add_argument( "--om", default=False, action="store_true", @@ -516,7 +516,7 @@ def fill(args): Perform gap filling of one assembly (bad) using sequences from another. """ p = OptionParser(fill.__doc__) - p.add_option( + p.add_argument( "--extend", default=2000, type=int, @@ -730,14 +730,14 @@ def install(args): p = OptionParser(install.__doc__) p.set_rclip(rclip=1) - p.add_option( + p.add_argument( "--maxsize", default=300000, type=int, help="Maximum size of patchers to be replaced", ) - p.add_option("--prefix", help="Prefix of the new object") - p.add_option( + p.add_argument("--prefix", help="Prefix of the new object") + p.add_argument( "--strict", default=False, action="store_true", @@ -814,7 +814,7 @@ def refine(args): from pybedtools import BedTool p = OptionParser(refine.__doc__) - p.add_option( + p.add_argument( "--closest", default=False, action="store_true", @@ -917,12 +917,12 @@ def patcher(args): from jcvi.formats.bed import uniq p = OptionParser(patcher.__doc__) - p.add_option( + p.add_argument( "--backbone", default="OM", help="Prefix of the backbone assembly", ) - p.add_option("--object", default="object", help="New object name") + p.add_argument("--object", default="object", help="New object name") opts, args = p.parse_args(args) if len(args) != 2: diff --git a/jcvi/assembly/postprocess.py b/jcvi/assembly/postprocess.py index 42cf4395..13737762 100644 --- a/jcvi/assembly/postprocess.py +++ b/jcvi/assembly/postprocess.py @@ -126,7 +126,7 @@ def circular(args): from jcvi.assembly.goldenpath import overlap p = OptionParser(circular.__doc__) - p.add_option( + p.add_argument( "--flip", default=False, action="store_true", @@ -246,7 +246,7 @@ def build(args): from jcvi.formats.fasta import sort p = OptionParser(build.__doc__) - p.add_option( + p.add_argument( "--nodedup", default=False, action="store_true", @@ -283,7 +283,7 @@ def screen(args): p = OptionParser(screen.__doc__) p.set_align(pctid=95, pctcov=50) - p.add_option("--best", default=1, type=int, help="Get the best N hit") + p.add_argument("--best", default=1, type=int, help="Get the best N hit") opts, args = p.parse_args(args) if len(args) != 2: @@ -324,7 +324,7 @@ def scaffold(args): from jcvi.formats.bed import Bed p = OptionParser(scaffold.__doc__) - p.add_option( + p.add_argument( "--prefix", default=False, action="store_true", diff --git a/jcvi/assembly/preprocess.py b/jcvi/assembly/preprocess.py index c8344571..d11b6b9c 100644 --- a/jcvi/assembly/preprocess.py +++ b/jcvi/assembly/preprocess.py @@ -100,11 +100,11 @@ def diginorm(args): from jcvi.apps.base import getfilesize p = OptionParser(diginorm.__doc__) - p.add_option( + p.add_argument( "--single", default=False, action="store_true", help="Single end reads" ) - p.add_option("--tablesize", help="Memory size") - p.add_option( + p.add_argument("--tablesize", help="Memory size") + p.add_argument( "--npass", default="1", choices=("1", "2"), @@ -309,8 +309,8 @@ def count(args): from jcvi.utils.table import loadtable, write_csv p = OptionParser(count.__doc__) - p.add_option("--dir", help="Sub-directory where FASTQC was run") - p.add_option( + p.add_argument("--dir", help="Sub-directory where FASTQC was run") + p.add_argument( "--human", default=False, action="store_true", @@ -353,9 +353,9 @@ def hetsmooth(args): reads_1.fq reads_2.fq """ p = OptionParser(hetsmooth.__doc__) - p.add_option("-K", default=23, type=int, help="K-mer size") - p.add_option("-L", type=int, help="Bottom threshold, first min") - p.add_option("-U", type=int, help="Top threshold, second min") + p.add_argument("-K", default=23, type=int, help="K-mer size") + p.add_argument("-L", type=int, help="Bottom threshold, first min") + p.add_argument("-U", type=int, help="Top threshold, second min") opts, args = p.parse_args(args) if len(args) != 3: @@ -389,43 +389,43 @@ def trim(args): tv = "0.32" TrimJar = "trimmomatic-{0}.jar".format(tv) p = OptionParser(trim.__doc__) - p.add_option( + p.add_argument( "--path", default=op.join("~/bin", TrimJar), help="Path to trimmomatic jar file", ) p.set_phred() - p.add_option( + p.add_argument( "--nofrags", default=False, action="store_true", help="Discard frags file in PE mode", ) - p.add_option( + p.add_argument( "--minqv", default=15, type=int, help="Average qv after trimming", ) - p.add_option( + p.add_argument( "--minlen", default=36, type=int, help="Minimum length after trimming", ) - p.add_option( + p.add_argument( "--adapteronly", default=False, action="store_true", help="Only trim adapters with no qv trimming", ) - p.add_option( + p.add_argument( "--nogz", default=False, action="store_true", help="Do not write to gzipped files", ) - p.add_option( + p.add_argument( "--log", default=None, dest="trimlog", @@ -583,21 +583,21 @@ def correct(args): from jcvi.assembly.base import FastqNamings p = OptionParser(correct.__doc__ + FastqNamings) - p.add_option("--dir", default="data", help="Working directory") - p.add_option( + p.add_argument("--dir", default="data", help="Working directory") + p.add_argument( "--fragsdedup", default=False, action="store_true", help="Don't deduplicate the fragment reads", ) - p.add_option("--ploidy", default="2", choices=("1", "2"), help="Ploidy") - p.add_option( + p.add_argument("--ploidy", default="2", choices=("1", "2"), help="Ploidy") + p.add_argument( "--haploidify", default=False, action="store_true", help="Set HAPLOIDIFY=True", ) - p.add_option( + p.add_argument( "--suffix", default=False, action="store_true", diff --git a/jcvi/assembly/sim.py b/jcvi/assembly/sim.py index c9f7dad2..19b39f55 100644 --- a/jcvi/assembly/sim.py +++ b/jcvi/assembly/sim.py @@ -29,13 +29,13 @@ def add_sim_options(p): """ Add options shared by eagle or wgsim. """ - p.add_option( + p.add_argument( "--distance", default=500, type=int, help="Outer distance between the two ends", ) - p.add_option("--readlen", default=150, type=int, help="Length of the read") + p.add_argument("--readlen", default=150, type=int, help="Length of the read") p.set_depth(depth=10) p.set_outfile(outfile=None) @@ -46,7 +46,7 @@ def eagle(args): """ p = OptionParser(eagle.__doc__) - p.add_option( + p.add_argument( "--share", default="/usr/local/share/EAGLE/", help="Default EAGLE share path" ) add_sim_options(p) @@ -158,19 +158,19 @@ def wgsim(args): Run dwgsim on fastafile. """ p = OptionParser(wgsim.__doc__) - p.add_option( + p.add_argument( "--erate", default=0.01, type=float, help="Base error rate of the read", ) - p.add_option( + p.add_argument( "--noerrors", default=False, action="store_true", help="Simulate reads with no errors", ) - p.add_option( + p.add_argument( "--genomesize", type=int, help="Genome size in Mb [default: estimate from data]", diff --git a/jcvi/assembly/soap.py b/jcvi/assembly/soap.py index 90b2ba86..273370f8 100644 --- a/jcvi/assembly/soap.py +++ b/jcvi/assembly/soap.py @@ -135,8 +135,8 @@ def clean(args): Clean and dedup paired FASTQ files. """ p = OptionParser(clean.__doc__) - p.add_option("-a", default=0, type=int, help="Trim length at 5' end") - p.add_option("-b", default=50, type=int, help="Trim length at 3' end") + p.add_argument("-a", default=0, type=int, help="Trim length at 5' end") + p.add_argument("-b", default=50, type=int, help="Trim length at 3' end") p.set_cpus() opts, args = p.parse_args(args) @@ -233,15 +233,15 @@ def prepare(args): from jcvi.formats.base import write_file p = OptionParser(prepare.__doc__ + FastqNamings) - p.add_option("-K", default=45, type=int, help="K-mer size") - p.add_option( + p.add_argument("-K", default=45, type=int, help="K-mer size") + p.add_argument( "--assemble_1st_rank_only", default=False, action="store_true", help="Assemble the first rank only, other libs asm_flags=2", ) - p.add_option("--scaffold", help="Only perform scaffolding") - p.add_option("--gapclose", help="Only perform gap closure") + p.add_argument("--scaffold", help="Only perform scaffolding") + p.add_argument("--gapclose", help="Only perform gap closure") p.set_cpus() opts, args = p.parse_args(args) diff --git a/jcvi/assembly/syntenypath.py b/jcvi/assembly/syntenypath.py index 94ca1e7d..c0b1e855 100644 --- a/jcvi/assembly/syntenypath.py +++ b/jcvi/assembly/syntenypath.py @@ -134,13 +134,15 @@ def bed(args): from ..compara.base import AnchorFile p = OptionParser(bed.__doc__) - p.add_option( + p.add_argument( "--switch", default=False, action="store_true", help="Switch reference and aligned map elements", ) - p.add_option("--scale", type=float, help="Scale the aligned map distance by factor") + p.add_argument( + "--scale", type=float, help="Scale the aligned map distance by factor" + ) p.set_beds() p.set_outfile() opts, args = p.parse_args(args) @@ -228,14 +230,14 @@ def partition(args): """ allowed_format = ("png", "ps") p = OptionParser(partition.__doc__) - p.add_option("--prefix", help="Add prefix to the name") - p.add_option( + p.add_argument("--prefix", help="Add prefix to the name") + p.add_argument( "--namestart", default=0, type=int, help="Use a shorter name, starting index", ) - p.add_option( + p.add_argument( "--format", default="png", choices=allowed_format, @@ -297,7 +299,7 @@ def merge(args): Merge multiple graphs together and visualize. """ p = OptionParser(merge.__doc__) - p.add_option( + p.add_argument( "--colorlist", default="black,red,pink,blue,green", help="The color palette", @@ -339,7 +341,7 @@ def happy(args): +-8254707:8254647:-8254690:{[8254694]:[8254713]:[8254531]:[8254797]}:8254802:8254788+ """ p = OptionParser(happy.__doc__) - p.add_option("--prefix", help="Add prefix to the name") + p.add_argument("--prefix", help="Add prefix to the name") opts, args = p.parse_args(args) if len(args) != 1: @@ -374,13 +376,13 @@ def fromblast(args): from jcvi.utils.range import range_distance p = OptionParser(fromblast.__doc__) - p.add_option( + p.add_argument( "--clique", default=False, action="store_true", help="Populate clique instead of linear path", ) - p.add_option( + p.add_argument( "--maxdist", default=100000, type=int, @@ -484,7 +486,7 @@ def connect(args): Connect contigs using long reads. """ p = OptionParser(connect.__doc__) - p.add_option( + p.add_argument( "--clip", default=2000, type=int, diff --git a/jcvi/compara/blastfilter.py b/jcvi/compara/blastfilter.py index 46fa2662..c44f4a68 100755 --- a/jcvi/compara/blastfilter.py +++ b/jcvi/compara/blastfilter.py @@ -290,20 +290,20 @@ def main(args): p = OptionParser(__doc__) p.set_beds() p.set_stripnames() - p.add_option( + p.add_argument( "--tandems_only", dest="tandems_only", action="store_true", default=False, help="only calculate tandems, write .localdup file and exit.", ) - p.add_option( + p.add_argument( "--tandem_Nmax", type=int, default=10, help="merge tandem genes within distance", ) - p.add_option( + p.add_argument( "--cscore", type=float, default=0.7, @@ -311,7 +311,7 @@ def main(args): "keep all values that are 50% or greater of the best hit. " "higher is more stringent", ) - p.add_option("--exclude", help="Remove anchors from a previous run") + p.add_argument("--exclude", help="Remove anchors from a previous run") opts, args = p.parse_args(args) diff --git a/jcvi/compara/catalog.py b/jcvi/compara/catalog.py index 1a455002..25d7444b 100644 --- a/jcvi/compara/catalog.py +++ b/jcvi/compara/catalog.py @@ -119,7 +119,7 @@ def enrich(args): Enrich OMG output by pulling genes misses by OMG. """ p = OptionParser(enrich.__doc__) - p.add_option( + p.add_argument( "--ghost", default=False, action="store_true", @@ -309,7 +309,7 @@ def layout(args): separated by comma in place of taxa, e.g. "BR,BO,AN,CN" """ p = OptionParser(layout.__doc__) - p.add_option("--sort", help="Sort layout file based on bedfile") + p.add_argument("--sort", help="Sort layout file based on bedfile") opts, args = p.parse_args(args) if len(args) != 2: @@ -508,9 +508,11 @@ def omgprepare(args): from jcvi.formats.base import DictFile p = OptionParser(omgprepare.__doc__) - p.add_option("--norbh", action="store_true", help="Disable RBH hits") - p.add_option("--pctid", default=0, type=int, help="Percent id cutoff for RBH hits") - p.add_option("--cscore", default=90, type=int, help="C-score cutoff for RBH hits") + p.add_argument("--norbh", action="store_true", help="Disable RBH hits") + p.add_argument( + "--pctid", default=0, type=int, help="Percent id cutoff for RBH hits" + ) + p.add_argument("--cscore", default=90, type=int, help="C-score cutoff for RBH hits") p.set_stripnames() p.set_beds() @@ -609,24 +611,24 @@ def ortholog(args): from jcvi.formats.blast import cscore, filter, filtered_blastfile_name p = OptionParser(ortholog.__doc__) - p.add_option( + p.add_argument( "--dbtype", default="nucl", choices=("nucl", "prot"), help="Molecule type of subject database", ) - p.add_option( + p.add_argument( "--full", default=False, action="store_true", help="Run in full 1x1 mode, including blocks and RBH", ) - p.add_option("--cscore", default=0.7, type=float, help="C-score cutoff") - p.add_option( + p.add_argument("--cscore", default=0.7, type=float, help="C-score cutoff") + p.add_argument( "--dist", default=20, type=int, help="Extent of flanking regions to search" ) - p.add_option( + p.add_argument( "-n", "--min_size", dest="n", @@ -634,41 +636,41 @@ def ortholog(args): default=4, help="minimum number of anchors in a cluster", ) - p.add_option("--quota", help="Quota align parameter") - p.add_option("--exclude", help="Remove anchors from a previous run") - p.add_option( + p.add_argument("--quota", help="Quota align parameter") + p.add_argument("--exclude", help="Remove anchors from a previous run") + p.add_argument( "--self_remove", default=98, type=float, help="Remove self hits that are above this percent identity", ) - p.add_option( + p.add_argument( "--no_strip_names", default=False, action="store_true", help="Do not strip alternative splicing (e.g. At5g06540.1 -> At5g06540)", ) - p.add_option( + p.add_argument( "--liftover_dist", type=int, help="Distance to extend from liftover. Defaults to half of --dist", ) p.set_cpus() dotplot_group = p.set_dotplot_opts() - dotplot_group.add_option( + dotplot_group.add_argument( "--notex", default=False, action="store_true", help="Do not use tex" ) - dotplot_group.add_option( + dotplot_group.add_argument( "--no_dotplot", default=False, action="store_true", help="Do not make dotplot" ) - p.add_option( + p.add_argument( "--ignore_zero_anchor", default=False, action="store_true", help="Ignore this pair of ortholog identification instead of throwing an error when performing many pairs of cataloging.", ) - p.add_option( + p.add_argument( "--align_soft", default="last", choices=("last", "blast", "diamond_blastp"), @@ -921,34 +923,34 @@ def tandem(args): pep_file can also be used in same manner. """ p = OptionParser(tandem.__doc__) - p.add_option( + p.add_argument( "--tandem_Nmax", dest="tandem_Nmax", type=int, default=3, help="merge tandem genes within distance", ) - p.add_option( + p.add_argument( "--percent_overlap", type=int, default=50, help="tandem genes have >=x% aligned sequence, x=0-100", ) p.set_align(evalue=0.01) - p.add_option( + p.add_argument( "--not_self", default=False, action="store_true", help="provided is not self blast file", ) - p.add_option( + p.add_argument( "--strip_gene_name", dest="sep", type=str, default=".", help="strip alternative splicing. Use None for no stripping.", ) - p.add_option( + p.add_argument( "--genefamily", dest="genefam", action="store_true", diff --git a/jcvi/compara/fractionation.py b/jcvi/compara/fractionation.py index 24682677..7452702d 100644 --- a/jcvi/compara/fractionation.py +++ b/jcvi/compara/fractionation.py @@ -156,7 +156,7 @@ def segment(args): from jcvi.formats.base import SetFile p = OptionParser(segment.__doc__) - p.add_option( + p.add_argument( "--chain", default=1, type=int, @@ -354,7 +354,7 @@ def gaps(args): from jcvi.utils.cbook import percentage p = OptionParser(gaps.__doc__) - p.add_option("--bdist", default=0, type=int, help="Base pair distance") + p.add_argument("--bdist", default=0, type=int, help="Base pair distance") opts, args = p.parse_args(args) if len(args) != 3: @@ -439,7 +439,7 @@ def summary(args): from jcvi.utils.cbook import percentage, Registry p = OptionParser(summary.__doc__) - p.add_option("--extra", help="Cross with extra tsv file") + p.add_argument("--extra", help="Cross with extra tsv file") opts, args = p.parse_args(args) if len(args) != 2: @@ -672,14 +672,14 @@ def loss(args): Extract likely gene loss candidates between genome a and b. """ p = OptionParser(loss.__doc__) - p.add_option( + p.add_argument( "--bed", default=False, action="store_true", help="Genomic BLAST is in bed format", ) - p.add_option("--gdist", default=20, type=int, help="Gene distance") - p.add_option( + p.add_argument("--gdist", default=20, type=int, help="Gene distance") + p.add_argument( "--bdist", default=20000, type=int, diff --git a/jcvi/compara/ks.py b/jcvi/compara/ks.py index 60aa5b89..53ddd533 100644 --- a/jcvi/compara/ks.py +++ b/jcvi/compara/ks.py @@ -364,7 +364,7 @@ def gc3(args): concatenated or separated. """ p = OptionParser(gc3.__doc__) - p.add_option( + p.add_argument( "--plot", default=False, action="store_true", help="Also plot the GC3 histogram" ) p.set_outfile() @@ -549,18 +549,18 @@ def calc(args): from jcvi.formats.fasta import translate p = OptionParser(calc.__doc__) - p.add_option( + p.add_argument( "--longest", action="store_true", help="Get longest ORF, only works if no pep file, e.g. ESTs", ) - p.add_option( + p.add_argument( "--msa", default="clustalw", choices=("clustalw", "muscle"), help="software used to align the proteins", ) - p.add_option("--workdir", default=os.getcwd(), help="Work directory") + p.add_argument("--workdir", default=os.getcwd(), help="Work directory") p.set_outfile() opts, args = p.parse_args(args) @@ -822,10 +822,10 @@ def subset(args): in tab delimited pairsfile/anchorfile. """ p = OptionParser(subset.__doc__) - p.add_option( + p.add_argument( "--noheader", action="store_true", help="don't write ksfile header line" ) - p.add_option( + p.add_argument( "--block", action="store_true", help="preserve block structure in input" ) p.set_stripnames() @@ -1081,21 +1081,25 @@ def plot_ks_dist( def add_plot_options(p): - p.add_option("--fit", default=False, action="store_true", help="Plot fitted lines") - p.add_option("--kde", default=False, action="store_true", help="Use KDE smoothing") - p.add_option("--vmin", default=0.0, type=float, help="Minimum value, inclusive") - p.add_option("--vmax", default=3.0, type=float, help="Maximum value, inclusive") - p.add_option( + p.add_argument( + "--fit", default=False, action="store_true", help="Plot fitted lines" + ) + p.add_argument( + "--kde", default=False, action="store_true", help="Use KDE smoothing" + ) + p.add_argument("--vmin", default=0.0, type=float, help="Minimum value, inclusive") + p.add_argument("--vmax", default=3.0, type=float, help="Maximum value, inclusive") + p.add_argument( "--bins", default=60, type=int, help="Number of bins to plot in the histogram" ) - p.add_option("--legendp", default="upper right", help="Place of the legend") - p.add_option( + p.add_argument("--legendp", default="upper right", help="Place of the legend") + p.add_argument( "--fill", default=False, action="store_true", help="Do not fill the histogram area", ) - p.add_option("--title", default="*Ks* distribution", help="Title of the plot") + p.add_argument("--title", default="*Ks* distribution", help="Title of the plot") def report(args): @@ -1109,13 +1113,13 @@ def report(args): from jcvi.graphics.histogram import stem_leaf_plot p = OptionParser(report.__doc__) - p.add_option( + p.add_argument( "--pdf", default=False, action="store_true", help="Generate graphic output for the histogram", ) - p.add_option( + p.add_argument( "--components", default=1, type=int, diff --git a/jcvi/compara/pad.py b/jcvi/compara/pad.py index e0b68edd..37e7988a 100644 --- a/jcvi/compara/pad.py +++ b/jcvi/compara/pad.py @@ -106,7 +106,7 @@ def pad(args): p = OptionParser(pad.__doc__) p.set_beds() - p.add_option( + p.add_argument( "--cutoff", default=0.3, type=float, @@ -238,10 +238,10 @@ def cluster(args): p = OptionParser(cluster.__doc__) p.set_beds() - p.add_option( + p.add_argument( "--minsize", default=10, type=int, help="Only segment using blocks >= size" ) - p.add_option( + p.add_argument( "--path", default="~/scratch/bin", help="Path to the CLUSTER 3.0 binary" ) diff --git a/jcvi/compara/pedigree.py b/jcvi/compara/pedigree.py index 72ca2dab..94536fca 100644 --- a/jcvi/compara/pedigree.py +++ b/jcvi/compara/pedigree.py @@ -238,9 +238,9 @@ def pedigree(args): Plot pedigree and calculate pedigree coefficients from a pedigree file. """ p = OptionParser(pedigree.__doc__) - p.add_option("--ploidy", default=2, type=int, help="Ploidy") - p.add_option("--N", default=10000, type=int, help="Number of samples") - p.add_option("--title", default="", help="Title of the graph") + p.add_argument("--ploidy", default=2, type=int, help="Ploidy") + p.add_argument("--N", default=10000, type=int, help="Number of samples") + p.add_argument("--title", default="", help="Title of the graph") opts, args, iopts = p.set_image_options(args) if len(args) != 1: diff --git a/jcvi/compara/phylogeny.py b/jcvi/compara/phylogeny.py index 859c4d08..0994460d 100644 --- a/jcvi/compara/phylogeny.py +++ b/jcvi/compara/phylogeny.py @@ -21,8 +21,10 @@ def lcn(args): %prog lcn Orthogroups/Orthogroups.tsv Orthogroup_Sequences/ lcn/ """ p = OptionParser(lcn.__doc__) - p.add_option("--min-single-ratio", default=0.9, help="Single copy ratio must be > ") - p.add_option("--max-zero-ratio", default=0, help="Zero copy ratio must be < ") + p.add_argument( + "--min-single-ratio", default=0.9, help="Single copy ratio must be > " + ) + p.add_argument("--max-zero-ratio", default=0, help="Zero copy ratio must be < ") opts, args = p.parse_args(args) if len(args) != 3: diff --git a/jcvi/compara/quota.py b/jcvi/compara/quota.py index aa5a1d9a..9efbca08 100755 --- a/jcvi/compara/quota.py +++ b/jcvi/compara/quota.py @@ -186,7 +186,7 @@ def main(args): p = OptionParser(__doc__) p.set_beds() - p.add_option( + p.add_argument( "--quota", default="1:1", help="`quota mapping` procedure -- screen blocks to constrain mapping" @@ -194,7 +194,7 @@ def main(args): "put in the format like (#subgenomes expected for genome X):" "(#subgenomes expected for genome Y)", ) - p.add_option( + p.add_argument( "--Nm", dest="Nmax", type=int, @@ -204,7 +204,7 @@ def main(args): "[default: %default units (gene or bp dist)]", ) - p.add_option( + p.add_argument( "--self", dest="self_match", action="store_true", @@ -214,7 +214,7 @@ def main(args): ) p.set_verbose(help="Show verbose solver output") - p.add_option( + p.add_argument( "--screen", default=False, action="store_true", diff --git a/jcvi/compara/reconstruct.py b/jcvi/compara/reconstruct.py index 6ffb461e..ccb494f7 100644 --- a/jcvi/compara/reconstruct.py +++ b/jcvi/compara/reconstruct.py @@ -244,7 +244,7 @@ def zipbed(args): proceeds by interleaving the genes together. """ p = OptionParser(zipbed.__doc__) - p.add_option("--prefix", default="b", help="Prefix for the new seqid") + p.add_argument("--prefix", default="b", help="Prefix for the new seqid") opts, args = p.parse_args(args) if len(args) != 2: diff --git a/jcvi/compara/synfind.py b/jcvi/compara/synfind.py index b413e477..96c826a3 100755 --- a/jcvi/compara/synfind.py +++ b/jcvi/compara/synfind.py @@ -248,22 +248,22 @@ def main(blastfile, p, opts): p.set_outfile() coge_group = p.add_argument_group("CoGe-specific options") - coge_group.add_option("--sqlite", help="Write sqlite database") - coge_group.add_option("--qnote", default="null", help="Query dataset group id") - coge_group.add_option("--snote", default="null", help="Subject dataset group id") + coge_group.add_argument("--sqlite", help="Write sqlite database") + coge_group.add_argument("--qnote", default="null", help="Query dataset group id") + coge_group.add_argument("--snote", default="null", help="Subject dataset group id") params_group = p.add_argument_group("Synteny parameters") - params_group.add_option( + params_group.add_argument( "--window", type=int, default=40, help="Synteny window size" ) - params_group.add_option( + params_group.add_argument( "--cutoff", type=float, default=0.1, help="Minimum number of anchors to call synteny", ) supported_scoring = ("collinear", "density") - params_group.add_option( + params_group.add_argument( "--scoring", choices=supported_scoring, default="collinear", diff --git a/jcvi/compara/synteny.py b/jcvi/compara/synteny.py index 9b048356..9e891ec0 100755 --- a/jcvi/compara/synteny.py +++ b/jcvi/compara/synteny.py @@ -410,13 +410,13 @@ def check_beds(hintfile, p, opts, sorted=True): return qbed, sbed, qorder, sorder, is_self -def add_options(p, args, dist=10): +def add_arguments(p, args, dist=10): """ scan and liftover has similar interfaces, so share common options returns opts, files """ p.set_beds() - p.add_option( + p.add_argument( "--dist", default=dist, type=int, help="Extent of flanking regions to search" ) @@ -569,7 +569,7 @@ def assemble(args): from jcvi.formats.fasta import some p = OptionParser(assemble.__doc__) - p.add_option( + p.add_argument( "--no_strip_names", default=False, action="store_true", @@ -784,7 +784,7 @@ def toaligns(args): with the Block ID. """ p = OptionParser(toaligns.__doc__) - p.add_option("--prefix", default="b", help="Prefix to the block id") + p.add_argument("--prefix", default="b", help="Prefix to the block id") p.set_outfile() opts, args = p.parse_args(args) @@ -813,8 +813,8 @@ def mcscanq(args): graphics.karyotype and graphics.synteny. """ p = OptionParser(mcscanq.__doc__) - p.add_option("--color", help="Add color highlight, used in plotting") - p.add_option( + p.add_argument("--color", help="Add color highlight, used in plotting") + p.add_argument( "--invert", default=False, action="store_true", help="Invert query and subject" ) opts, args = p.parse_args(args) @@ -842,7 +842,7 @@ def spa(args): from jcvi.utils.cbook import uniqify p = OptionParser(spa.__doc__) - p.add_option( + p.add_argument( "--unmapped", default=False, action="store_true", @@ -899,10 +899,10 @@ def rebuild(args): Rebuild anchors file from pre-built blocks file. """ p = OptionParser(rebuild.__doc__) - p.add_option( + p.add_argument( "--header", default=False, action="store_true", help="First line is header" ) - p.add_option( + p.add_argument( "--write_blast", default=False, action="store_true", @@ -990,7 +990,7 @@ def matrix(args): """ p = OptionParser(matrix.__doc__) - p.add_option("--seqids", help="File with seqids") + p.add_argument("--seqids", help="File with seqids") opts, args = p.parse_args(args) if len(args) != 3: @@ -1056,22 +1056,22 @@ def simple(args): block_id seqidB startB endB bpSpanB GeneB1 GeneB2 geneSpanB """ p = OptionParser(simple.__doc__) - p.add_option( + p.add_argument( "--rich", default=False, action="store_true", help="Output additional columns" ) - p.add_option( + p.add_argument( "--coords", default=False, action="store_true", help="Output columns with base coordinates", ) - p.add_option( + p.add_argument( "--bed", default=False, action="store_true", help="Generate BED file for the blocks", ) - p.add_option( + p.add_argument( "--noheader", default=False, action="store_true", help="Don't output header" ) p.set_beds() @@ -1240,18 +1240,18 @@ def screen(args): p = OptionParser(screen.__doc__) p.set_beds() - p.add_option("--ids", help="File with block IDs (0-based)") - p.add_option("--seqids", help="File with seqids") - p.add_option("--seqpairs", help="File with seqpairs") - p.add_option( + p.add_argument("--ids", help="File with block IDs (0-based)") + p.add_argument("--seqids", help="File with seqids") + p.add_argument("--seqpairs", help="File with seqpairs") + p.add_argument( "--intrabound", default=300, type=int, help="Lower bound of intra-chromosomal blocks (only for self comparison)", ) - p.add_option("--minspan", default=0, type=int, help="Only blocks with span >=") - p.add_option("--minsize", default=0, type=int, help="Only blocks with anchors >=") - p.add_option( + p.add_argument("--minspan", default=0, type=int, help="Only blocks with span >=") + p.add_argument("--minsize", default=0, type=int, help="Only blocks with anchors >=") + p.add_argument( "--simple", action="store_true", help="Write simple anchorfile with block ends" ) opts, args = p.parse_args(args) @@ -1358,7 +1358,7 @@ def summary(args): from jcvi.utils.cbook import SummaryStats p = OptionParser(summary.__doc__) - p.add_option("--prefix", help="Generate per block stats") + p.add_argument("--prefix", help="Generate per block stats") opts, args = p.parse_args(args) if len(args) != 1: @@ -1454,20 +1454,22 @@ def mcscan(args): tandem cluster as one line, tab separated. """ p = OptionParser(mcscan.__doc__) - p.add_option("--iter", default=100, type=int, help="Max number of chains to output") - p.add_option( + p.add_argument( + "--iter", default=100, type=int, help="Max number of chains to output" + ) + p.add_argument( "--ascii", default=False, action="store_true", help="Output symbols rather than gene names", ) - p.add_option( + p.add_argument( "--Nm", default=10, type=int, help="Clip block ends to allow slight overlaps" ) - p.add_option( + p.add_argument( "--trackids", action="store_true", help="Track block IDs in separate file" ) - p.add_option( + p.add_argument( "--mergetandem", default=None, help="merge tandems genes in output acoording to PATH-TO-TANDEM_FILE, " @@ -1579,13 +1581,13 @@ def depth(args): from jcvi.graphics.base import latex p = OptionParser(depth.__doc__) - p.add_option("--depthfile", help="Generate file with gene and depth") - p.add_option( + p.add_argument("--depthfile", help="Generate file with gene and depth") + p.add_argument( "--histogram", default=False, action="store_true", help="Plot histograms in PDF" ) - p.add_option("--xmax", type=int, help="x-axis maximum to display in plot") - p.add_option("--title", default=None, help="Title to display in plot") - p.add_option("--quota", help="Force to use this quota, e.g. 1:1, 1:2 ...") + p.add_argument("--xmax", type=int, help="x-axis maximum to display in plot") + p.add_argument("--title", default=None, help="Title to display in plot") + p.add_argument("--quota", help="Force to use this quota, e.g. 1:1, 1:2 ...") p.set_beds() opts, args = p.parse_args(args) @@ -1721,13 +1723,13 @@ def breakpoint(args): from jcvi.utils.range import range_interleave p = OptionParser(breakpoint.__doc__) - p.add_option( + p.add_argument( "--xdist", type=int, default=20, help="xdist (in related genome) cutoff" ) - p.add_option( + p.add_argument( "--ydist", type=int, default=200000, help="ydist (in current genome) cutoff" ) - p.add_option("-n", type=int, default=5, help="number of markers in a block") + p.add_argument("-n", type=int, default=5, help="number of markers in a block") opts, args = p.parse_args(args) if len(args) != 2: @@ -1758,7 +1760,7 @@ def scan(args): pull out syntenic anchors from blastfile based on single-linkage algorithm """ p = OptionParser(scan.__doc__) - p.add_option( + p.add_argument( "-n", "--min_size", dest="n", @@ -1766,21 +1768,21 @@ def scan(args): default=4, help="minimum number of anchors in a cluster", ) - p.add_option( + p.add_argument( "--intrabound", default=300, type=int, help="Lower bound of intra-chromosomal blocks (only for self comparison)", ) - p.add_option("--liftover", help="Scan BLAST file to find extra anchors") - p.add_option( + p.add_argument("--liftover", help="Scan BLAST file to find extra anchors") + p.add_argument( "--liftover_dist", type=int, help="Distance to extend from liftover. Defaults to half of --dist", ) p.set_stripnames() - blast_file, anchor_file, dist, opts = add_options(p, args, dist=20) + blast_file, anchor_file, dist, opts = add_arguments(p, args, dist=20) qbed, sbed, qorder, sorder, is_self = check_beds(blast_file, p, opts) intrabound = opts.intrabound @@ -1836,7 +1838,7 @@ def liftover(args): p = OptionParser(liftover.__doc__) p.set_stripnames() - blast_file, anchor_file, dist, opts = add_options(p, args) + blast_file, anchor_file, dist, opts = add_arguments(p, args) qbed, sbed, qorder, sorder, is_self = check_beds(blast_file, p, opts) filtered_blast = read_blast( diff --git a/jcvi/formats/agp.py b/jcvi/formats/agp.py index c91d6b14..76e40122 100644 --- a/jcvi/formats/agp.py +++ b/jcvi/formats/agp.py @@ -918,7 +918,7 @@ def fromcsv(args): from jcvi.formats.sizes import Sizes p = OptionParser(fromcsv.__doc__) - p.add_option("--evidence", default="map", help="Linkage evidence to add in AGP") + p.add_argument("--evidence", default="map", help="Linkage evidence to add in AGP") opts, args = p.parse_args(args) if len(args) != 3: @@ -1113,7 +1113,7 @@ def format(args): from jcvi.formats.base import DictFile p = OptionParser(format.__doc__) - p.add_option("--switchcomponent", help="Switch component id based on") + p.add_argument("--switchcomponent", help="Switch component id based on") opts, args = p.parse_args(args) if len(args) != 2: @@ -1147,13 +1147,13 @@ def frombed(args): columns. With the 4-th column indicating the new object. """ p = OptionParser(frombed.__doc__) - p.add_option( + p.add_argument( "--gapsize", default=100, type=int, help="Insert gaps of size", ) - p.add_option("--evidence", default="map", help="Linkage evidence to add in AGP") + p.add_argument("--evidence", default="map", help="Linkage evidence to add in AGP") opts, args = p.parse_args(args) if len(args) != 1: @@ -1259,7 +1259,7 @@ def stats(args): from jcvi.utils.table import tabulate p = OptionParser(stats.__doc__) - p.add_option( + p.add_argument( "--warn", default=False, action="store_true", @@ -1311,7 +1311,7 @@ def cut(args): Cut at the boundaries of the ranges in the bedfile. """ p = OptionParser(cut.__doc__) - p.add_option("--sep", default=".", help="Separator for splits") + p.add_argument("--sep", default=".", help="Separator for splits") opts, args = p.parse_args(args) if len(args) != 2: @@ -1383,36 +1383,36 @@ def mask(args): (--splitsingle). """ p = OptionParser(mask.__doc__) - p.add_option( + p.add_argument( "--splitobject", default=False, action="store_true", help="Create new names for object", ) - p.add_option( + p.add_argument( "--splitcomponent", default=False, action="store_true", help="Create new names for component", ) - p.add_option( + p.add_argument( "--splitsingle", default=False, action="store_true", help="Do not remove base on single point", ) - p.add_option( + p.add_argument( "--gaptype", default="scaffold", help="Masked region has gap type of", ) - p.add_option( + p.add_argument( "--noretain", default=False, action="store_true", help="Do not retain old names for non-split objects", ) - p.add_option("--sep", default=".", help="Separator for splits") + p.add_argument("--sep", default=".", help="Separator for splits") opts, args = p.parse_args(args) if len(args) != 2: @@ -1532,13 +1532,13 @@ def reindex(args): the target coordinates. """ p = OptionParser(reindex.__doc__) - p.add_option( + p.add_argument( "--nogaps", default=False, action="store_true", help="Remove all gap lines", ) - p.add_option( + p.add_argument( "--inplace", default=False, action="store_true", @@ -1695,13 +1695,13 @@ def tpf(args): Can optionally output scaffold gaps. """ p = OptionParser(tpf.__doc__) - p.add_option( + p.add_argument( "--noversion", default=False, action="store_true", help="Remove trailing accession versions", ) - p.add_option( + p.add_argument( "--gaps", default=False, action="store_true", @@ -1739,25 +1739,25 @@ def bed(args): from jcvi.formats.obo import validate_term p = OptionParser(bed.__doc__) - p.add_option( + p.add_argument( "--gaps", default=False, action="store_true", help="Only print bed lines for gaps", ) - p.add_option( + p.add_argument( "--nogaps", default=False, action="store_true", help="Do not print bed lines for gaps", ) - p.add_option( + p.add_argument( "--bed12", default=False, action="store_true", help="Produce bed12 formatted output", ) - p.add_option( + p.add_argument( "--component", default=False, action="store_true", @@ -1768,14 +1768,14 @@ def bed(args): "GFF specific parameters", "Note: If not specified, output will be in `bed` format", ) - g1.add_option( + g1.add_argument( "--gff", default=False, action="store_true", help="Produce gff3 formatted output. By default, ignores AGP gap lines", ) - g1.add_option("--source", default="MGSC", help="Specify a gff3 source") - g1.add_option( + g1.add_argument("--source", default="MGSC", help="Specify a gff3 source") + g1.add_argument( "--feature", default="golden_path_fragment", help="Specify a gff3 feature type", @@ -1849,19 +1849,19 @@ def extendbed(args): from jcvi.formats.sizes import Sizes p = OptionParser(extendbed.__doc__) - p.add_option( + p.add_argument( "--nogaps", default=False, action="store_true", help="Do not print bed lines for gaps", ) - p.add_option( + p.add_argument( "--bed12", default=False, action="store_true", help="Produce bed12 formatted output", ) - p.add_option( + p.add_argument( "--gff", default=False, action="store_true", @@ -1936,14 +1936,14 @@ def gaps(args): from jcvi.graphics.histogram import loghistogram p = OptionParser(gaps.__doc__) - p.add_option( + p.add_argument( "--merge", dest="merge", default=False, action="store_true", help="Merge adjacent gaps (to conform to AGP specification)", ) - p.add_option( + p.add_argument( "--header", default=False, action="store_true", @@ -2033,7 +2033,7 @@ def tidy(args): Final output is in `.tidy.agp`. """ p = OptionParser(tidy.__doc__) - p.add_option( + p.add_argument( "--nogaps", default=False, action="store_true", @@ -2098,14 +2098,14 @@ def build(args): Build targetfasta based on info from agpfile """ p = OptionParser(build.__doc__) - p.add_option( + p.add_argument( "--newagp", dest="newagp", default=False, action="store_true", help="Check components to trim dangling N's", ) - p.add_option( + p.add_argument( "--novalidate", dest="novalidate", default=False, diff --git a/jcvi/formats/base.py b/jcvi/formats/base.py index 0d8b6b12..4de649f3 100644 --- a/jcvi/formats/base.py +++ b/jcvi/formats/base.py @@ -570,7 +570,7 @@ def seqids(args): A03,A02,A01 """ p = OptionParser(seqids.__doc__) - p.add_option("--pad0", default=0, help="How many zeros to pad") + p.add_argument("--pad0", default=0, help="How many zeros to pad") opts, args = p.parse_args(args) if len(args) != 3: @@ -702,7 +702,7 @@ def flatten(args): p = OptionParser(flatten.__doc__) p.set_sep(sep=",") - p.add_option( + p.add_argument( "--zipflatten", default=None, dest="zipsep", @@ -741,7 +741,7 @@ def unflatten(args): Given a list of ids, one per line, unflatten the list onto a single line with sep. """ p = OptionParser(unflatten.__doc__) - p.add_option("--sep", default=",", help="Separator when joining ids") + p.add_argument("--sep", default=",", help="Separator when joining ids") p.set_outfile() opts, args = p.parse_args(args) @@ -785,11 +785,13 @@ def group(args): p = OptionParser(group.__doc__) p.set_sep() - p.add_option("--groupby", default=None, type=int, help="Default column to groupby") - p.add_option( + p.add_argument( + "--groupby", default=None, type=int, help="Default column to groupby" + ) + p.add_argument( "--groupsep", default=",", help="Separator to join the grouped elements" ) - p.add_option( + p.add_argument( "--nouniq", default=False, action="store_true", @@ -896,14 +898,16 @@ def split(args): """ p = OptionParser(split.__doc__) mode_choices = ("batch", "cycle", "optimal") - p.add_option("--all", default=False, action="store_true", help="split all records") - p.add_option( + p.add_argument( + "--all", default=False, action="store_true", help="split all records" + ) + p.add_argument( "--mode", default="optimal", choices=mode_choices, help="Mode when splitting records", ) - p.add_option( + p.add_argument( "--format", choices=("fasta", "fastq", "txt", "clust"), help="input file format" ) @@ -941,21 +945,21 @@ def join(args): in each file. """ p = OptionParser(join.__doc__) - p.add_option( + p.add_argument( "--column", default="0", help="0-based column id, multiple values allowed" ) p.set_sep(multiple=True) - p.add_option( + p.add_argument( "--noheader", default=False, action="store_true", help="Do not print header" ) - p.add_option("--na", default="na", help="Value for unjoined data") - p.add_option( + p.add_argument("--na", default="na", help="Value for unjoined data") + p.add_argument( "--compact", default=False, action="store_true", help="Do not repeat pivotal columns in output", ) - p.add_option( + p.add_argument( "--keysep", default=",", help="specify separator joining multiple elements in the key column" @@ -1046,11 +1050,11 @@ def subset(args): """ p = OptionParser(subset.__doc__) - p.add_option( + p.add_argument( "--column", default="0", help="0-based column id, multiple values allowed" ) p.set_sep(multiple=True) - p.add_option( + p.add_argument( "--pivot", default=1, type=int, @@ -1127,7 +1131,7 @@ def setop(args): from natsort import natsorted p = OptionParser(setop.__doc__) - p.add_option( + p.add_argument( "--column", default=0, type=int, diff --git a/jcvi/formats/bed.py b/jcvi/formats/bed.py index 33872f4b..4194b043 100755 --- a/jcvi/formats/bed.py +++ b/jcvi/formats/bed.py @@ -503,7 +503,7 @@ def gaps(args): from pybedtools import BedTool p = OptionParser(gaps.__doc__) - p.add_option( + p.add_argument( "--na_in", help="Add '_na_in_xxx' to gap name, use comma to separate, " + "e.g. --na_in=chr1,chr2 to note if gap is missing in chr1 or " @@ -511,7 +511,7 @@ def gaps(args): + "missing seqids happens to be the seqid of the current feature, " + "it will not be reported.", ) - p.add_option("--minsize", default=1000, type=int, help="Minimum gap size") + p.add_argument("--minsize", default=1000, type=int, help="Minimum gap size") p.set_outfile() opts, args = p.parse_args(args) @@ -560,7 +560,7 @@ def closest(args): from pybedtools import BedTool p = OptionParser(closest.__doc__) - p.add_option("--maxdist", default=5000, help="Maximum distance") + p.add_argument("--maxdist", default=5000, help="Maximum distance") p.set_outfile() opts, args = p.parse_args(args) @@ -593,8 +593,8 @@ def format(args): Re-format BED file, e.g. switch sequence ids. """ p = OptionParser(format.__doc__) - p.add_option("--prefix", help="Add prefix to name column (4th)") - p.add_option("--switch", help="Switch seqids based on two-column file") + p.add_argument("--prefix", help="Add prefix to name column (4th)") + p.add_argument("--switch", help="Switch seqids based on two-column file") p.set_outfile() opts, args = p.parse_args(args) @@ -660,7 +660,7 @@ def tiling(args): stackoverflow source. """ p = OptionParser(tiling.__doc__) - p.add_option( + p.add_argument( "--overlap", default=3000, type=int, @@ -739,7 +739,7 @@ def chain(args): Chain BED segments together. """ p = OptionParser(chain.__doc__) - p.add_option("--dist", default=100000, help="Chaining distance") + p.add_argument("--dist", default=100000, help="Chaining distance") p.set_outfile() opts, args = p.parse_args(args) @@ -884,9 +884,9 @@ def seqids(args): Print out all seqids on one line. Useful for graphics.karyotype. """ p = OptionParser(seqids.__doc__) - p.add_option("--maxn", default=100, type=int, help="Maximum number of seqids") - p.add_option("--prefix", help="Seqids must start with") - p.add_option("--exclude", default="random", help="Seqids should not contain") + p.add_argument("--maxn", default=100, type=int, help="Maximum number of seqids") + p.add_argument("--prefix", help="Seqids must start with") + p.add_argument("--exclude", default="random", help="Seqids should not contain") opts, args = p.parse_args(args) if len(args) < 1: @@ -994,16 +994,16 @@ def filter(args): Filter the bedfile to retain records between certain size range. """ p = OptionParser(filter.__doc__) - p.add_option("--minsize", default=0, type=int, help="Minimum feature length") - p.add_option( + p.add_argument("--minsize", default=0, type=int, help="Minimum feature length") + p.add_argument( "--maxsize", default=1000000000, type=int, help="Minimum feature length" ) - p.add_option( + p.add_argument( "--minaccn", type=int, help="Minimum value of accn, useful to filter based on coverage", ) - p.add_option("--minscore", type=int, help="Minimum score") + p.add_argument("--minscore", type=int, help="Minimum score") p.set_outfile() opts, args = p.parse_args(args) @@ -1060,7 +1060,7 @@ def mergebydepth(args): Similar to mergeBed, but only returns regions beyond certain depth. """ p = OptionParser(mergebydepth.__doc__) - p.add_option("--mindepth", default=3, type=int, help="Minimum depth required") + p.add_argument("--mindepth", default=3, type=int, help="Minimum depth required") opts, args = p.parse_args(args) if len(args) != 2: @@ -1131,9 +1131,9 @@ def longest(args): from jcvi.formats.sizes import Sizes p = OptionParser(longest.__doc__) - p.add_option("--maxsize", default=20000, type=int, help="Limit max size") - p.add_option("--minsize", default=60, type=int, help="Limit min size") - p.add_option( + p.add_argument("--maxsize", default=20000, type=int, help="Limit max size") + p.add_argument("--minsize", default=60, type=int, help="Limit min size") + p.add_argument( "--precedence", default="Medtr", help="Accessions with prefix take precedence" ) opts, args = p.parse_args(args) @@ -1216,7 +1216,7 @@ def fix(args): Fix non-standard bed files. One typical problem is start > end. """ p = OptionParser(fix.__doc__) - p.add_option("--minspan", default=0, type=int, help="Enforce minimum span") + p.add_argument("--minspan", default=0, type=int, help="Enforce minimum span") p.set_outfile() opts, args = p.parse_args(args) @@ -1267,7 +1267,7 @@ def some(args): from jcvi.utils.cbook import gene_name p = OptionParser(some.__doc__) - p.add_option( + p.add_argument( "-v", dest="inverse", default=False, @@ -1314,8 +1314,10 @@ def uniq(args): from jcvi.formats.sizes import Sizes p = OptionParser(uniq.__doc__) - p.add_option("--sizes", help="Use sequence length as score") - p.add_option("--mode", default="span", choices=("span", "score"), help="Pile mode") + p.add_argument("--sizes", help="Use sequence length as score") + p.add_argument( + "--mode", default="span", choices=("span", "score"), help="Pile mode" + ) opts, args = p.parse_args(args) if len(args) != 1: @@ -1404,15 +1406,15 @@ def bins(args): """ p = OptionParser(bins.__doc__) - p.add_option("--binsize", default=100000, type=int, help="Size of the bins") - p.add_option("--subtract", help="Subtract bases from window") - p.add_option( + p.add_argument("--binsize", default=100000, type=int, help="Size of the bins") + p.add_argument("--subtract", help="Subtract bases from window") + p.add_argument( "--mode", default="span", choices=("span", "count", "score"), help="Accumulate feature based on", ) - p.add_option( + p.add_argument( "--nomerge", default=False, action="store_true", help="Do not merge features" ) opts, args = p.parse_args(args) @@ -1506,7 +1508,7 @@ def pile(args): from jcvi.utils.grouper import Grouper p = OptionParser(pile.__doc__) - p.add_option("--minOverlap", default=0, type=int, help="Minimum overlap required") + p.add_argument("--minOverlap", default=0, type=int, help="Minimum overlap required") opts, args = p.parse_args(args) if len(args) != 2: @@ -1535,8 +1537,8 @@ def index(args): so that a bedgraph file can be generated and indexed. """ p = OptionParser(index.__doc__) - p.add_option("--fasta", help="Generate bedgraph and index") - p.add_option("--query", help="Chromosome location") + p.add_argument("--fasta", help="Generate bedgraph and index") + p.add_argument("--query", help="Chromosome location") p.set_outfile() opts, args = p.parse_args(args) @@ -1695,7 +1697,7 @@ def evaluate(args): from jcvi.formats.sizes import Sizes p = OptionParser(evaluate.__doc__) - p.add_option("--query", help="Chromosome location") + p.add_argument("--query", help="Chromosome location") opts, args = p.parse_args(args) if len(args) != 3: @@ -1811,7 +1813,7 @@ def distance(args): distances, which can be used to plot histogram, etc. """ p = OptionParser(distance.__doc__) - p.add_option( + p.add_argument( "--distmode", default="ss", choices=("ss", "ee"), @@ -1860,14 +1862,14 @@ def sample(args): from jcvi.assembly.coverage import Coverage p = OptionParser(sample.__doc__) - p.add_option( + p.add_argument( "--raindrop", default=0, type=int, help="Raindrop selection, ignores all other options", ) - p.add_option("--max", default=10, type=int, help="Max depth allowed") - p.add_option( + p.add_argument("--max", default=10, type=int, help="Max depth allowed") + p.add_argument( "--targetsize", type=int, help="Sample bed file to get target base number" ) p.set_outfile() @@ -1950,13 +1952,13 @@ def bedpe(args): from jcvi.assembly.coverage import bed_to_bedpe p = OptionParser(bedpe.__doc__) - p.add_option( + p.add_argument( "--span", default=False, action="store_true", help="Write span bed file" ) - p.add_option( + p.add_argument( "--strand", default=False, action="store_true", help="Write the strand columns" ) - p.add_option("--mates", help="Check the library stats from .mates file") + p.add_argument("--mates", help="Check the library stats from .mates file") opts, args = p.parse_args(args) if len(args) != 1: @@ -2215,10 +2217,10 @@ def summary(args): Sum the total lengths of the intervals. """ p = OptionParser(summary.__doc__) - p.add_option( + p.add_argument( "--sizes", default=False, action="store_true", help="Write .sizes file" ) - p.add_option( + p.add_argument( "--all", default=False, action="store_true", @@ -2258,7 +2260,7 @@ def sort(args): `sort` command. """ p = OptionParser(sort.__doc__) - p.add_option( + p.add_argument( "-i", "--inplace", dest="inplace", @@ -2266,20 +2268,20 @@ def sort(args): action="store_true", help="Sort bed file in place", ) - p.add_option( + p.add_argument( "-u", dest="unique", default=False, action="store_true", help="Uniqify the bed file", ) - p.add_option( + p.add_argument( "--accn", default=False, action="store_true", help="Sort based on the accessions", ) - p.add_option( + p.add_argument( "--num", default=False, action="store_true", @@ -2333,19 +2335,19 @@ def mates(args): Generate the mates file by inferring from the names. """ p = OptionParser(mates.__doc__) - p.add_option( + p.add_argument( "--lib", default=False, action="store_true", help="Output library information along with pairs", ) - p.add_option( + p.add_argument( "--nointra", default=False, action="store_true", help="Remove mates that are intra-scaffold", ) - p.add_option( + p.add_argument( "--prefix", default=False, action="store_true", @@ -2431,23 +2433,25 @@ def flanking(args): from numpy import array, argsort p = OptionParser(flanking.__doc__) - p.add_option( + p.add_argument( "--chrom", default=None, type=str, help="chrom name of the position in query. Make sure it matches bedfile.", ) - p.add_option( + p.add_argument( "--coord", default=None, type=int, help="coordinate of the position in query." ) - p.add_option("-n", default=10, type=int, help="number of flanking features to get") - p.add_option( + p.add_argument( + "-n", default=10, type=int, help="number of flanking features to get" + ) + p.add_argument( "--side", default="both", choices=("upstream", "downstream", "both"), help="which side to get flanking features", ) - p.add_option( + p.add_argument( "--max_d", default=None, type=int, help="features <= max_d away from position" ) p.set_outfile() diff --git a/jcvi/formats/blast.py b/jcvi/formats/blast.py index d80dff35..72a43314 100644 --- a/jcvi/formats/blast.py +++ b/jcvi/formats/blast.py @@ -296,13 +296,13 @@ def filter(args): - noself: remove self-self hits """ p = OptionParser(filter.__doc__) - p.add_option("--score", dest="score", default=0, type=int, help="Score cutoff") + p.add_argument("--score", dest="score", default=0, type=int, help="Score cutoff") p.set_align(pctid=95, hitlen=100, evalue=0.01) - p.add_option( + p.add_argument( "--noself", default=False, action="store_true", help="Remove self-self hits" ) - p.add_option("--ids", help="Path to file with ids to retain") - p.add_option( + p.add_argument("--ids", help="Path to file with ids to retain") + p.add_argument( "--inverse", default=False, action="store_true", @@ -527,8 +527,8 @@ def annotation(args): from jcvi.formats.base import DictFile p = OptionParser(annotation.__doc__) - p.add_option("--queryids", help="Query IDS file to switch") - p.add_option("--subjectids", help="Subject IDS file to switch") + p.add_argument("--queryids", help="Query IDS file to switch") + p.add_argument("--subjectids", help="Subject IDS file to switch") opts, args = p.parse_args(args) if len(args) != 1: @@ -562,7 +562,7 @@ def completeness(args): from jcvi.utils.cbook import SummaryStats p = OptionParser(completeness.__doc__) - p.add_option("--ids", help="Save ids that are over 50% complete") + p.add_argument("--ids", help="Save ids that are over 50% complete") opts, args = p.parse_args(args) if len(args) != 2: @@ -627,7 +627,7 @@ def annotate(args): p = OptionParser(annotate.__doc__) p.set_align(pctid=94, hitlen=500) - p.add_option("--hang", default=500, type=int, help="Maximum overhang length") + p.add_argument("--hang", default=500, type=int, help="Maximum overhang length") opts, args = p.parse_args(args) if len(args) != 3: @@ -665,13 +665,13 @@ def top10(args): from jcvi.formats.base import DictFile p = OptionParser(top10.__doc__) - p.add_option( + p.add_argument( "--top", default=10, type=int, help="Top N taxa to extract", ) - p.add_option( + p.add_argument( "--ids", default=None, help="Two column ids file to query seqid", @@ -701,25 +701,25 @@ def sort(args): sort is 'in-place'. """ p = OptionParser(sort.__doc__) - p.add_option( + p.add_argument( "--query", default=False, action="store_true", help="Sort by query position", ) - p.add_option( + p.add_argument( "--ref", default=False, action="store_true", help="Sort by reference position", ) - p.add_option( + p.add_argument( "--refscore", default=False, action="store_true", help="Sort by reference name, then score descending", ) - p.add_option( + p.add_argument( "--coords", default=False, action="store_true", @@ -774,19 +774,19 @@ def cscore(args): from jcvi.utils.cbook import gene_name p = OptionParser(cscore.__doc__) - p.add_option( + p.add_argument( "--cutoff", default=0.9999, type=float, help="Minimum C-score to report", ) - p.add_option( + p.add_argument( "--pct", default=False, action="store_true", help="Also include pct as last column", ) - p.add_option( + p.add_argument( "--writeblast", default=False, action="store_true", @@ -939,7 +939,7 @@ def chain(args): Chain adjacent HSPs together to form larger HSP. """ p = OptionParser(chain.__doc__) - p.add_option( + p.add_argument( "--dist", dest="dist", default=100, @@ -1042,29 +1042,29 @@ def covfilter(args): p = OptionParser(covfilter.__doc__) p.set_align(pctid=95, pctcov=50) - p.add_option( + p.add_argument( "--scov", default=False, action="store_true", help="Subject coverage instead of query", ) - p.add_option( + p.add_argument( "--supermap", action="store_true", help="Use supermap instead of union" ) - p.add_option( + p.add_argument( "--ids", dest="ids", default=None, help="Print out the ids that satisfy", ) - p.add_option( + p.add_argument( "--list", dest="list", default=False, action="store_true", help="List the id% and cov% per gene", ) - p.add_option( + p.add_argument( "--iterby", dest="iterby", default="query", @@ -1264,19 +1264,19 @@ def bed(args): from .bed import sort as bed_sort, mergeBed p = OptionParser(bed.__doc__) - p.add_option( + p.add_argument( "--swap", default=False, action="store_true", help="Write query positions", ) - p.add_option( + p.add_argument( "--both", default=False, action="store_true", help="Generate one line for each of query and subject", ) - p.add_option( + p.add_argument( "--merge", default=None, type=int, @@ -1345,7 +1345,7 @@ def anchors(args): """ p = OptionParser(anchors.__doc__) p.set_outfile() - p.add_option( + p.add_argument( "--best", default=False, action="store_true", help="Keep only the best hit" ) opts, args = p.parse_args(args) @@ -1379,20 +1379,20 @@ def best(args): """ p = OptionParser(best.__doc__) - p.add_option("-n", default=1, type=int, help="get best N hits") - p.add_option( + p.add_argument("-n", default=1, type=int, help="get best N hits") + p.add_argument( "--nosort", default=False, action="store_true", help="assume BLAST is already sorted", ) - p.add_option( + p.add_argument( "--hsps", default=False, action="store_true", help="get all HSPs for the best pair", ) - p.add_option( + p.add_argument( "--subject", default=False, action="store_true", @@ -1445,13 +1445,13 @@ def summary(args): qryspan, pct_qryspan, refspan, pct_refspan """ p = OptionParser(summary.__doc__) - p.add_option( + p.add_argument( "--strict", default=False, action="store_true", help="Strict 'gapless' mode. Exclude gaps from covered base.", ) - p.add_option( + p.add_argument( "--tabular", default=False, action="store_true", @@ -1483,17 +1483,17 @@ def subset(args): Otherwise the script will do nothing. """ p = OptionParser(subset.__doc__) - p.add_option( + p.add_argument( "--qchrs", default=None, help="query chrs to extract, comma sep", ) - p.add_option( + p.add_argument( "--schrs", default=None, help="subject chrs to extract, comma sep", ) - p.add_option( + p.add_argument( "--convert", default=False, action="store_true", diff --git a/jcvi/formats/chain.py b/jcvi/formats/chain.py index 42986a69..e22dd764 100644 --- a/jcvi/formats/chain.py +++ b/jcvi/formats/chain.py @@ -136,7 +136,7 @@ def fromagp(args): from jcvi.formats.sizes import Sizes p = OptionParser(fromagp.__doc__) - p.add_option( + p.add_argument( "--novalidate", default=False, action="store_true", help="Do not validate AGP" ) opts, args = p.parse_args(args) @@ -219,13 +219,13 @@ def blat(args): Generate psl file using blat. """ p = OptionParser(blat.__doc__) - p.add_option( + p.add_argument( "--minscore", default=100, type=int, help="Matches minus mismatches gap penalty", ) - p.add_option( + p.add_argument( "--minid", default=98, type=int, diff --git a/jcvi/formats/coords.py b/jcvi/formats/coords.py index 904bc861..44a89d41 100644 --- a/jcvi/formats/coords.py +++ b/jcvi/formats/coords.py @@ -388,7 +388,7 @@ def coverage(args): jcvi.algorithms.supermap --filter query """ p = OptionParser(coverage.__doc__) - p.add_option( + p.add_argument( "-c", dest="cutoff", default=0.5, @@ -434,13 +434,13 @@ def annotate(args): overlaps: {0}. """ p = OptionParser(annotate.__doc__.format(", ".join(Overlap_types))) - p.add_option( + p.add_argument( "--maxhang", default=100, type=int, help="Max hang to call dovetail overlap", ) - p.add_option( + p.add_argument( "--all", default=False, action="store_true", @@ -476,7 +476,7 @@ def summary(args): """ p = OptionParser(summary.__doc__) - p.add_option( + p.add_argument( "-s", dest="single", default=False, @@ -503,7 +503,7 @@ def filter(args): """ p = OptionParser(filter.__doc__) p.set_align(pctid=0, hitlen=0) - p.add_option( + p.add_argument( "--overlap", default=False, action="store_true", @@ -563,19 +563,19 @@ def bed(args): be beyond quality cutoff, say 50) in bed format """ p = OptionParser(bed.__doc__) - p.add_option( + p.add_argument( "--query", default=False, action="store_true", help="print out query intervals rather than ref", ) - p.add_option( + p.add_argument( "--pctid", default=False, action="store_true", help="use pctid in score", ) - p.add_option( + p.add_argument( "--cutoff", dest="cutoff", default=0, diff --git a/jcvi/formats/excel.py b/jcvi/formats/excel.py index 21da5bcc..4e839cd3 100644 --- a/jcvi/formats/excel.py +++ b/jcvi/formats/excel.py @@ -165,13 +165,13 @@ def fromcsv(args): from jcvi.formats.base import flexible_cast p = OptionParser(fromcsv.__doc__) - p.add_option( + p.add_argument( "--noheader", default=False, action="store_true", help="Do not treat the first row as header", ) - p.add_option("--rgb", default=-1, type=int, help="Show RGB color box") + p.add_argument("--rgb", default=-1, type=int, help="Show RGB color box") p.set_sep() opts, args = p.parse_args(args) diff --git a/jcvi/formats/fasta.py b/jcvi/formats/fasta.py index a70272cb..8671fcd7 100644 --- a/jcvi/formats/fasta.py +++ b/jcvi/formats/fasta.py @@ -443,7 +443,7 @@ def gc(args): Plot G+C content distribution. """ p = OptionParser(gc.__doc__) - p.add_option("--binsize", default=500, type=int, help="Bin size to use") + p.add_argument("--binsize", default=500, type=int, help="Bin size to use") opts, args = p.parse_args(args) if len(args) != 1: @@ -485,7 +485,7 @@ def trimsplit(args): from jcvi.utils.cbook import SummaryStats p = OptionParser(trimsplit.__doc__) - p.add_option( + p.add_argument( "--minlength", default=1000, type=int, help="Min length of contigs to keep" ) opts, args = p.parse_args(args) @@ -540,7 +540,9 @@ def qual(args): from jcvi.formats.sizes import Sizes p = OptionParser(qual.__doc__) - p.add_option("--qv", default=31, type=int, help="Dummy qv score for extended bases") + p.add_argument( + "--qv", default=31, type=int, help="Dummy qv score for extended bases" + ) p.set_outfile() opts, args = p.parse_args(args) @@ -567,7 +569,7 @@ def info(args): Run `sequence_info` on FASTA files. Generate a report per file. """ p = OptionParser(info.__doc__) - p.add_option( + p.add_argument( "--gaps", default=False, action="store_true", help="Count number of gaps" ) p.set_table() @@ -594,10 +596,10 @@ def fromtab(args): """ p = OptionParser(fromtab.__doc__) p.set_sep(sep=None) - p.add_option( + p.add_argument( "--noheader", default=False, action="store_true", help="Ignore first line" ) - p.add_option("--replace", help="Replace spaces in name to char") + p.add_argument("--replace", help="Replace spaces in name to char") opts, args = p.parse_args(args) if len(args) != 2: @@ -633,7 +635,7 @@ def longestorf(args): Find longest ORF for each sequence in fastafile. """ p = OptionParser(longestorf.__doc__) - p.add_option("--ids", action="store_true", help="Generate table with ORF info") + p.add_argument("--ids", action="store_true", help="Generate table with ORF info") opts, args = p.parse_args(args) if len(args) != 1: @@ -684,7 +686,7 @@ def ispcr(args): format: name, forward, reverse """ p = OptionParser(ispcr.__doc__) - p.add_option( + p.add_argument( "-r", dest="rclip", default=1, @@ -780,10 +782,10 @@ def clean(args): Remove irregular chars in FASTA seqs. """ p = OptionParser(clean.__doc__) - p.add_option( + p.add_argument( "--fancy", default=False, action="store_true", help="Pretty print the sequence" ) - p.add_option( + p.add_argument( "--canonical", default=False, action="store_true", help="Use only acgtnACGTN" ) p.set_outfile() @@ -822,31 +824,31 @@ def translate(args): transl_tables = [str(x) for x in range(1, 25)] p = OptionParser(translate.__doc__) - p.add_option( + p.add_argument( "--ids", default=False, action="store_true", help="Create .ids file with the complete/partial/gaps label", ) - p.add_option( + p.add_argument( "--longest", default=False, action="store_true", help="Find the longest ORF from each input CDS", ) - p.add_option( + p.add_argument( "--table", default=1, choices=transl_tables, help="Specify translation table to use", ) - p.add_option( + p.add_argument( "--strip_names", default=False, action="store_true", help="Strip alternative splicing (e.g. At5g06540.1 -> At5g06540)", ) - p.add_option( + p.add_argument( "--unique", default=False, action="store_true", @@ -976,7 +978,7 @@ def filter(args): Filter the FASTA file to contain records with size >= or <= certain cutoff. """ p = OptionParser(filter.__doc__) - p.add_option( + p.add_argument( "--less", default=False, action="store_true", @@ -1023,8 +1025,8 @@ def pool(args): from jcvi.formats.base import longest_unique_prefix p = OptionParser(pool.__doc__) - p.add_option("--sep", default=".", help="Separator between prefix and name") - p.add_option( + p.add_argument("--sep", default=".", help="Separator between prefix and name") + p.add_argument( "--sequential", default=False, action="store_true", help="Add sequential IDs" ) opts, args = p.parse_args(args) @@ -1049,10 +1051,10 @@ def ids(args): Generate the FASTA headers without the '>'. """ p = OptionParser(ids.__doc__) - p.add_option( + p.add_argument( "--until", default=None, help="Truncate the name and description at words" ) - p.add_option( + p.add_argument( "--description", default=False, action="store_true", @@ -1090,7 +1092,7 @@ def sort(args): Sort a list of sequences and output with sorted IDs, etc. """ p = OptionParser(sort.__doc__) - p.add_option( + p.add_argument( "--sizes", default=False, action="store_true", help="Sort by decreasing size" ) @@ -1138,18 +1140,20 @@ def join(args): from jcvi.formats.sizes import Sizes p = OptionParser(join.__doc__) - p.add_option("--newid", default=None, help="New sequence ID") - p.add_option( + p.add_argument("--newid", default=None, help="New sequence ID") + p.add_argument( "--gapsize", default=100, type=int, help="Number of N's in between the sequences", ) - p.add_option("--gaptype", default="contig", help="Gap type to use in the AGP file") - p.add_option( + p.add_argument( + "--gaptype", default="contig", help="Gap type to use in the AGP file" + ) + p.add_argument( "--evidence", default="", help="Linkage evidence to report in the AGP file" ) - p.add_option("--oo", help="Use .oo file generated by bambus") + p.add_argument("--oo", help="Use .oo file generated by bambus") opts, args = p.parse_args(args) nargs = len(args) @@ -1218,10 +1222,10 @@ def summary(args): from natsort import natsort_key p = OptionParser(summary.__doc__) - p.add_option( + p.add_argument( "--suffix", default="Mb", help="make the base pair counts human readable" ) - p.add_option("--ids", help="write the ids that have >= 50% N's") + p.add_argument("--ids", help="write the ids that have >= 50% N's") p.set_outfile() opts, args = p.parse_args(args) @@ -1275,70 +1279,70 @@ def format(args): """ sequential_choices = ("replace", "prefix", "suffix") p = OptionParser(format.__doc__) - p.add_option( + p.add_argument( "--pairs", default=False, action="store_true", help="Add trailing /1 and /2 for interleaved pairs", ) - p.add_option( + p.add_argument( "--sequential", default=None, choices=sequential_choices, help="Add sequential IDs", ) - p.add_option( + p.add_argument( "--sequentialoffset", default=0, type=int, help="Sequential IDs start at" ) - p.add_option( + p.add_argument( "--pad0", default=0, type=int, help="Pad a few zeros in front of sequential" ) - p.add_option( + p.add_argument( "--gb", default=False, action="store_true", help="For Genbank ID, get the accession", ) - p.add_option("--sep", default=None, help="Split description by certain symbol") - p.add_option( + p.add_argument("--sep", default=None, help="Split description by certain symbol") + p.add_argument( "--index", default=0, type=int, help="Extract i-th field after split with --sep", ) - p.add_option( + p.add_argument( "--noversion", default=False, action="store_true", help="Remove the gb trailing version", ) - p.add_option("--prefix", help="Prepend prefix to sequence ID") - p.add_option("--suffix", help="Append suffix to sequence ID") - p.add_option( + p.add_argument("--prefix", help="Prepend prefix to sequence ID") + p.add_argument("--suffix", help="Append suffix to sequence ID") + p.add_argument( "--template", default=False, action="store_true", help="Extract `template=aaa dir=x library=m` to `m-aaa/x`", ) - p.add_option("--switch", help="Switch ID from two-column file") - p.add_option( + p.add_argument("--switch", help="Switch ID from two-column file") + p.add_argument( "--annotation", help="Add functional annotation from two-column file ('ID <--> Annotation')", ) - p.add_option("--ids", help="Generate ID conversion table") - p.add_option( + p.add_argument("--ids", help="Generate ID conversion table") + p.add_argument( "--upper", default=False, action="store_true", help="Convert sequence to upper case", ) - p.add_option( + p.add_argument( "--nodesc", default=False, action="store_true", help="Remove description after identifier", ) - p.add_option( + p.add_argument( "--minlength", default=0, type=int, help="Minimum sequence length to keep" ) opts, args = p.parse_args(args) @@ -1522,31 +1526,31 @@ def diff(args): from jcvi.utils.table import banner p = OptionParser(diff.__doc__) - p.add_option( + p.add_argument( "--ignore_case", default=False, action="store_true", help="ignore case when comparing sequences", ) - p.add_option( + p.add_argument( "--ignore_N", default=False, action="store_true", help="ignore N and X's when comparing sequences", ) - p.add_option( + p.add_argument( "--ignore_stop", default=False, action="store_true", help="ignore stop codon when comparing sequences", ) - p.add_option( + p.add_argument( "--rc", default=False, action="store_true", help="also consider reverse complement", ) - p.add_option( + p.add_argument( "--quiet", default=False, action="store_true", @@ -1665,31 +1669,31 @@ def identical(args): allowed_checksum = ["MD5", "GCG"] p = OptionParser(identical.__doc__) - p.add_option( + p.add_argument( "--ignore_case", default=False, action="store_true", help="ignore case when comparing sequences", ) - p.add_option( + p.add_argument( "--ignore_N", default=False, action="store_true", help="ignore N and X's when comparing sequences", ) - p.add_option( + p.add_argument( "--ignore_stop", default=False, action="store_true", help="ignore stop codon when comparing sequences", ) - p.add_option( + p.add_argument( "--output_uniq", default=False, action="store_true", help="output uniq sequences in FASTA format", ) - p.add_option( + p.add_argument( "--checksum", default="MD5", choices=allowed_checksum, @@ -1788,19 +1792,19 @@ def some(args): from jcvi.utils.cbook import gene_name p = OptionParser(some.__doc__) - p.add_option( + p.add_argument( "--exclude", default=False, action="store_true", help="Output sequences not in the list file", ) - p.add_option( + p.add_argument( "--no_strip_names", default=False, action="store_true", help="Do not strip alternative splicing (e.g. At5g06540.1 -> At5g06540)", ) - p.add_option( + p.add_argument( "--uniprot", default=False, action="store_true", help="Header is from uniprot" ) @@ -1863,7 +1867,7 @@ def fastq(args): from jcvi.formats.fastq import FastqLite p = OptionParser(fastq.__doc__) - p.add_option("--qv", type=int, help="Use generic qv value") + p.add_argument("--qv", type=int, help="Use generic qv value") opts, args = p.parse_args(args) @@ -1911,7 +1915,7 @@ def pair(args): help="Separator in name to reduce to clone id" + "e.g. GFNQ33242/1 use /, BOT01-2453H.b1 use .", ) - p.add_option( + p.add_argument( "-m", dest="matepairs", default=False, @@ -1995,7 +1999,7 @@ def pairinplace(args): bulk.frags.fasta. """ p = OptionParser(pairinplace.__doc__) - p.add_option( + p.add_argument( "-r", dest="rclip", default=1, @@ -2053,23 +2057,23 @@ def extract(args): "seqname", or "seqname:start-stop", or "seqname:start-stop:-" """ p = OptionParser(extract.__doc__) - p.add_option("--newname", help="Use this new name instead") - p.add_option( + p.add_argument("--newname", help="Use this new name instead") + p.add_argument( "--include", default=False, action="store_true", help="search description line for match", ) - p.add_option( + p.add_argument( "--exclude", default=False, action="store_true", help="exclude description that matches", ) - p.add_option( + p.add_argument( "--idonly", default=False, action="store_true", help="Only search identifier" ) - p.add_option( + p.add_argument( "--bed", default=None, help="path to bed file to guide extraction by matching seqname", @@ -2197,10 +2201,10 @@ def uniq(args): remove fasta records that are the same """ p = OptionParser(uniq.__doc__) - p.add_option( + p.add_argument( "--seq", default=False, action="store_true", help="Uniqify the sequences" ) - p.add_option( + p.add_argument( "-t", "--trimname", dest="trimname", @@ -2314,14 +2318,14 @@ def trim(args): from jcvi.algorithms.maxsum import max_sum p = OptionParser(trim.__doc__) - p.add_option( + p.add_argument( "-c", dest="min_length", type=int, default=64, help="minimum sequence length after trimming", ) - p.add_option("-s", dest="score", default=QUAL, help="quality trimming cutoff") + p.add_argument("-s", dest="score", default=QUAL, help="quality trimming cutoff") opts, args = p.parse_args(args) if len(args) != 2: @@ -2394,12 +2398,12 @@ def sequin(args): TATTAACGATGAATAATAATGAGAAGCCATATAGAATTGGTGATAATGTAAAAAAAGGGGCTCTTATTAC """ p = OptionParser(sequin.__doc__) - p.add_option("--unk", default=100, type=int, help="The size for unknown gaps") - p.add_option("--newid", default=None, help="Use this identifier instead") - p.add_option( + p.add_argument("--unk", default=100, type=int, help="The size for unknown gaps") + p.add_argument("--newid", default=None, help="Use this identifier instead") + p.add_argument( "--chromosome", default=None, help="Add [chromosome= ] to FASTA header" ) - p.add_option("--clone", default=None, help="Add [clone= ] to FASTA header") + p.add_argument("--clone", default=None, help="Add [clone= ] to FASTA header") p.set_mingap(default=100) opts, args = p.parse_args(args) @@ -2485,14 +2489,14 @@ def tidy(args): Trim terminal Ns, normalize gap sizes and remove small components. """ p = OptionParser(tidy.__doc__) - p.add_option( + p.add_argument( "--gapsize", dest="gapsize", default=0, type=int, help="Set all gaps to the same size", ) - p.add_option( + p.add_argument( "--minlen", dest="minlen", default=100, @@ -2594,7 +2598,7 @@ def gaps(args): from jcvi.formats.agp import mask, build p = OptionParser(gaps.__doc__) - p.add_option( + p.add_argument( "--split", default=False, action="store_true", help="Generate .split.fasta" ) p.set_mingap(default=100) diff --git a/jcvi/formats/fastq.py b/jcvi/formats/fastq.py index ab09bc96..b0141274 100644 --- a/jcvi/formats/fastq.py +++ b/jcvi/formats/fastq.py @@ -356,13 +356,13 @@ def readlen(args): """ p = OptionParser(readlen.__doc__) p.set_firstN() - p.add_option( + p.add_argument( "--silent", default=False, action="store_true", help="Do not print read length stats", ) - p.add_option( + p.add_argument( "--nocheck", default=False, action="store_true", @@ -392,7 +392,7 @@ def fasta(args): Convert fastq to fasta and qual file. """ p = OptionParser(fasta.__doc__) - p.add_option( + p.add_argument( "--seqtk", default=False, action="store_true", help="Use seqtk to convert" ) p.set_outdir() @@ -496,14 +496,14 @@ def filter(args): format (two files) to filter on paired reads. """ p = OptionParser(filter.__doc__) - p.add_option( + p.add_argument( "-q", dest="qv", default=20, type=int, help="Minimum quality score to keep", ) - p.add_option( + p.add_argument( "-p", dest="pct", default=95, @@ -709,7 +709,7 @@ def format(args): """ p = OptionParser(format.__doc__) - p.add_option( + p.add_argument( "--convert", default=None, choices=[">=1.8", "<1.8", "sra"], @@ -784,14 +784,14 @@ def trim(args): Wraps `fastx_trimmer` to trim from begin or end of reads. """ p = OptionParser(trim.__doc__) - p.add_option( + p.add_argument( "-f", dest="first", default=0, type=int, help="First base to keep. Default is 1.", ) - p.add_option( + p.add_argument( "-l", dest="last", default=0, @@ -861,14 +861,14 @@ def splitread(args): Split fastqfile into two read fastqfiles, cut in the middle. """ p = OptionParser(splitread.__doc__) - p.add_option( + p.add_argument( "-n", dest="n", default=76, type=int, help="Split at N-th base position", ) - p.add_option( + p.add_argument( "--rc", default=False, action="store_true", @@ -993,7 +993,7 @@ def pairinplace(args): p = OptionParser(pairinplace.__doc__) p.set_rclip() p.set_tag() - p.add_option("--base", help="Base name for the output files") + p.add_argument("--base", help="Base name for the output files") opts, args = p.parse_args(args) if len(args) != 1: @@ -1050,13 +1050,13 @@ def fromsra(args): Convert sra file to fastq using the sratoolkit `fastq-dump` """ p = OptionParser(fromsra.__doc__) - p.add_option( + p.add_argument( "--paired", default=False, action="store_true", help="Specify if library layout is paired-end", ) - p.add_option( + p.add_argument( "--compress", default=None, choices=["gzip", "bzip2"], diff --git a/jcvi/formats/genbank.py b/jcvi/formats/genbank.py index 799b01d3..1b00df60 100644 --- a/jcvi/formats/genbank.py +++ b/jcvi/formats/genbank.py @@ -326,23 +326,23 @@ def gff(args): def preparegb(p, args): - p.add_option( + p.add_argument( "--gb_dir", default=None, help="path to dir containing GanBank files (.gb)" ) - p.add_option( + p.add_argument( "--id", default=None, help="GenBank accession IDs in a file. One ID per row, or all IDs" " in one row comma separated.", ) - p.add_option( + p.add_argument( "--simple", default=None, type=str, help="GenBank accession IDs comma separated " "(for lots of IDs please use --id instead).", ) - p.add_option( + p.add_argument( "--individual", default=False, action="store_true", @@ -388,7 +388,7 @@ def tofasta(args): or all records in one file """ p = OptionParser(tofasta.__doc__) - p.add_option("--prefix", default="gbfasta", help="prefix of output files") + p.add_argument("--prefix", default="gbfasta", help="prefix of output files") filenames, accessions, idfile, opts, args = preparegb(p, args) prefix = opts.prefix @@ -411,8 +411,8 @@ def getgenes(args): Either --gb_dir or --id/--simple should be provided. """ p = OptionParser(getgenes.__doc__) - p.add_option("--prefix", default="gbout", help="prefix of output files") - p.add_option( + p.add_argument("--prefix", default="gbout", help="prefix of output files") + p.add_argument( "--nopep", default=False, action="store_true", @@ -467,14 +467,14 @@ def getquals(args): into a tab-delimited file """ p = OptionParser(getquals.__doc__) - p.add_option( + p.add_argument( "--types", default="gene,mRNA,CDS", type=str, dest="quals_ftypes", help="Feature types from which to extract qualifiers", ) - p.add_option( + p.add_argument( "--ignore", default="locus_tag,product,codon_start,translation", type=str, diff --git a/jcvi/formats/gff.py b/jcvi/formats/gff.py index 4259896b..1a47b39f 100644 --- a/jcvi/formats/gff.py +++ b/jcvi/formats/gff.py @@ -546,8 +546,8 @@ def addparent(args): Merge sister features and infer parents. """ p = OptionParser(addparent.__doc__) - p.add_option("--childfeat", default="CDS", help="Type of children feature") - p.add_option("--parentfeat", default="mRNA", help="Type of merged feature") + p.add_argument("--childfeat", default="CDS", help="Type of children feature") + p.add_argument("--parentfeat", default="mRNA", help="Type of merged feature") p.set_outfile() opts, args = p.parse_args(args) @@ -812,13 +812,13 @@ def sizes(args): """ p = OptionParser(sizes.__doc__) p.set_outfile() - p.add_option( + p.add_argument( "--parents", dest="parents", default="mRNA", help="parent feature(s) for which size is to be calculated", ) - p.add_option( + p.add_argument( "--child", dest="child", default="CDS", @@ -861,13 +861,13 @@ def cluster(args): from itertools import combinations p = OptionParser(cluster.__doc__) - p.add_option( + p.add_argument( "--slop", default=False, action="store_true", help="allow minor variation in terminal 5'/3' UTR" + " start/stop position", ) - p.add_option( + p.add_argument( "--inferUTR", default=False, action="store_true", @@ -968,13 +968,13 @@ def summary(args): from jcvi.utils.table import tabulate p = OptionParser(summary.__doc__) - p.add_option( + p.add_argument( "--isoform", default=False, action="store_true", help="Find longest isoform of each id", ) - p.add_option("--ids", help="Only include features from certain IDs") + p.add_argument("--ids", help="Only include features from certain IDs") opts, args = p.parse_args(args) if len(args) != 1: @@ -1166,23 +1166,23 @@ def filter(args): (2) Total bp length of child features """ p = OptionParser(filter.__doc__) - p.add_option( + p.add_argument( "--type", default="mRNA", help="The feature to scan for the attributes" ) g1 = p.add_argument_group("Filter by identity/coverage attribute values") - g1.add_option("--id", default=95, type=float, help="Minimum identity") - g1.add_option("--coverage", default=90, type=float, help="Minimum coverage") - g1.add_option( + g1.add_argument("--id", default=95, type=float, help="Minimum identity") + g1.add_argument("--coverage", default=90, type=float, help="Minimum coverage") + g1.add_argument( "--nocase", default=False, action="store_true", help="Case insensitive lookup of attribute names", ) g2 = p.add_argument_group("Filter by child feature bp length") - g2.add_option( + g2.add_argument( "--child_ftype", default=None, type=str, help="Child featuretype to consider" ) - g2.add_option( + g2.add_argument( "--child_bp", default=None, type=int, @@ -1381,35 +1381,35 @@ def chain(args): valid_merge_op = ("sum", "min", "max", "mean", "collapse") p = OptionParser(chain.__doc__) - p.add_option( + p.add_argument( "--key", dest="attrib_key", default=None, help="Attribute to use as `key` for chaining operation", ) - p.add_option( + p.add_argument( "--chain_ftype", default="cDNA_match", help="GFF feature type to use for chaining operation", ) - p.add_option( + p.add_argument( "--parent_ftype", default=None, help="GFF feature type to use for the chained coordinates", ) - p.add_option( + p.add_argument( "--break", dest="break_chain", action="store_true", help="Break long chains which are non-contiguous", ) - p.add_option( + p.add_argument( "--transfer_attrib", dest="attrib_list", help="Attributes to transfer to parent feature; accepts comma" + " separated list of attribute names", ) - p.add_option( + p.add_argument( "--transfer_score", dest="score_merge_op", choices=valid_merge_op, @@ -1547,48 +1547,48 @@ def format(args): p = OptionParser(format.__doc__) g1 = p.add_argument_group("Parameter(s) used to modify GFF attributes (9th column)") - g1.add_option("--name", help="Add Name attribute from two-column file") - g1.add_option("--note", help="Add Note attribute from two-column file") - g1.add_option( + g1.add_argument("--name", help="Add Name attribute from two-column file") + g1.add_argument("--note", help="Add Note attribute from two-column file") + g1.add_argument( "--add_attribute", dest="attrib_files", help="Add new attribute(s) " + "from two-column file(s); attribute name comes from filename; " + "accepts comma-separated list of files", ) - g1.add_option( + g1.add_argument( "--add_dbxref", dest="dbxref_files", help="Add new Dbxref value(s) (DBTAG:ID) " + "from two-column file(s). DBTAG comes from filename, ID comes from 2nd column; " + "accepts comma-separated list of files", ) - g1.add_option( + g1.add_argument( "--nostrict", default=False, action="store_true", help="Disable strict parsing of GFF file and/or mapping file", ) - g1.add_option( + g1.add_argument( "--remove_attr", dest="remove_attrs", help="Specify attributes to remove; " + "accepts comma-separated list of attribute names", ) - g1.add_option( + g1.add_argument( "--copy_id_attr_to_name", default=False, action="store_true", help="Copy `ID` attribute value to `Name`, when `Name` is not defined", ) - g1.add_option( + g1.add_argument( "--invent_name_attr", default=False, action="store_true", help="Invent `Name` attribute for 2nd level child features; " + "Formatted like PARENT:FEAT_TYPE:FEAT_INDEX", ) - g1.add_option( + g1.add_argument( "--no_keep_attr_order", default=False, action="store_true", @@ -1596,22 +1596,22 @@ def format(args): ) g2 = p.add_argument_group("Parameter(s) used to modify content within columns 1-8") - g2.add_option( + g2.add_argument( "--seqid", help="Switch seqid from two-column file. If not" + " a file, value will globally replace GFF seqid", ) - g2.add_option( + g2.add_argument( "--source", help="Switch GFF source from two-column file. If not" + " a file, value will globally replace GFF source", ) - g2.add_option( + g2.add_argument( "--type", help="Switch GFF feature type from two-column file. If not" + " a file, value will globally replace GFF type", ) - g2.add_option( + g2.add_argument( "--fixphase", default=False, action="store_true", @@ -1621,53 +1621,53 @@ def format(args): g3 = p.add_argument_group( "Other parameter(s) to perform manipulations to the GFF file content" ) - g3.add_option( + g3.add_argument( "--unique", default=False, action="store_true", help="Make IDs unique" ) - g3.add_option( + g3.add_argument( "--chaindup", default=None, dest="duptype", help="Chain duplicate features of a particular GFF3 `type`," + " sharing the same ID attribute", ) - g3.add_option( + g3.add_argument( "--multiparents", default=None, choices=valid_multiparent_ops, help="Split/merge identical features (same `seqid`, `source`, `type`, `coord-range`, `strand`, `phase`) mapping to multiple parents", ) - g3.add_option( + g3.add_argument( "--remove_feats", help="Comma separated list of features to remove by type" ) - g3.add_option( + g3.add_argument( "--remove_feats_by_ID", help="List of features to remove by ID;" + " accepts comma-separated list or list file", ) - g3.add_option( + g3.add_argument( "--gsac", default=False, action="store_true", help="Fix GSAC GFF3 file attributes", ) - g3.add_option( + g3.add_argument( "--invent_protein_feat", default=False, action="store_true", help="Invent a protein feature span (chain CDS feats)", ) - g3.add_option( + g3.add_argument( "--process_ftype", default=None, type=str, help="Specify feature types to process; " "accepts comma-separated list of feature types", ) - g3.add_option( + g3.add_argument( "--gff3", default=False, action="store_true", help="Print output in GFF3 format" ) - g3.add_option( + g3.add_argument( "--make_gff_store", default=False, action="store_true", @@ -2057,13 +2057,13 @@ def fixboundaries(args): range chained child features, extracting their min and max values """ p = OptionParser(fixboundaries.__doc__) - p.add_option( + p.add_argument( "--type", default="gene", type=str, help="Feature type for which to adjust boundaries", ) - p.add_option( + p.add_argument( "--child_ftype", default="mRNA", type=str, @@ -2101,7 +2101,7 @@ def liftover(args): "gannotation.asmbl.000095.7" is the 8-th tile on asmbl.000095. """ p = OptionParser(liftover.__doc__) - p.add_option("--tilesize", default=50000, type=int, help="The size for each tile") + p.add_argument("--tilesize", default=50000, type=int, help="The size for each tile") opts, args = p.parse_args(args) if len(args) != 1: @@ -2252,16 +2252,16 @@ def uniq(args): """ supported_modes = ("span", "score") p = OptionParser(uniq.__doc__) - p.add_option("--type", default="gene", help="Types of features to non-redundify") - p.add_option("--mode", default="span", choices=supported_modes, help="Pile mode") - p.add_option("--best", default=1, type=int, help="Use best N features") - p.add_option( + p.add_argument("--type", default="gene", help="Types of features to non-redundify") + p.add_argument("--mode", default="span", choices=supported_modes, help="Pile mode") + p.add_argument("--best", default=1, type=int, help="Use best N features") + p.add_argument( "--name", default=False, action="store_true", help="Non-redundify Name attribute", ) - p.add_option( + p.add_argument( "--iter", default="2", choices=("1", "2"), @@ -2370,13 +2370,13 @@ def sort(args): valid_sort_methods = ("unix", "topo") p = OptionParser(sort.__doc__) - p.add_option( + p.add_argument( "--method", default="unix", choices=valid_sort_methods, help="Specify sort method", ) - p.add_option( + p.add_argument( "-i", dest="inplace", default=False, @@ -2430,11 +2430,11 @@ def fromgtf(args): the "transcript_id" in exon/CDS feature will be converted to "Parent=". """ p = OptionParser(fromgtf.__doc__) - p.add_option( + p.add_argument( "--transcript_id", default="transcript_id", help="Field name for transcript" ) - p.add_option("--gene_id", default="gene_id", help="Field name for gene") - p.add_option( + p.add_argument("--gene_id", default="gene_id", help="Field name for gene") + p.add_argument( "--augustus", default=False, action="store_true", help="Input is AUGUSTUS gtf" ) p.set_home("augustus") @@ -2489,8 +2489,8 @@ def frombed(args): Default type will be `match` and default source will be `source` """ p = OptionParser(frombed.__doc__) - p.add_option("--type", default="match", help="GFF feature type") - p.add_option("--source", default="default", help="GFF source qualifier") + p.add_argument("--type", default="match", help="GFF feature type") + p.add_argument("--source", default="default", help="GFF source qualifier") opts, args = p.parse_args(args) if len(args) != 1: @@ -2509,8 +2509,8 @@ def fromsoap(args): """ p = OptionParser(fromsoap.__doc__) - p.add_option("--type", default="nucleotide_match", help="GFF feature type") - p.add_option("--source", default="soap", help="GFF source qualifier") + p.add_argument("--type", default="nucleotide_match", help="GFF feature type") + p.add_argument("--source", default="soap", help="GFF source qualifier") p.set_fixchrnames(orgn="maize") p.set_outfile() opts, args = p.parse_args(args) @@ -2617,7 +2617,7 @@ def merge(args): to be a file with a list of gff files. """ p = OptionParser(merge.__doc__) - p.add_option( + p.add_argument( "--seq", default=False, action="store_true", @@ -2685,23 +2685,23 @@ def extract(args): involved, use "," to separate; or provide a file with multiple IDs, one per line """ p = OptionParser(extract.__doc__) - p.add_option("--contigs", help="Extract features from certain contigs") - p.add_option("--names", help="Extract features with certain names") - p.add_option( + p.add_argument("--contigs", help="Extract features from certain contigs") + p.add_argument("--names", help="Extract features with certain names") + p.add_argument( "--types", type=str, default=None, help="Extract features of certain feature types", ) - p.add_option( + p.add_argument( "--children", default=0, choices=["1", "2"], help="Specify number of iterations: `1` grabs children, " + "`2` grabs grand-children", ) - p.add_option("--tag", default="ID", help="Scan the tags for the names") - p.add_option( + p.add_argument("--tag", default="ID", help="Scan the tags for the names") + p.add_argument( "--fasta", default=False, action="store_true", help="Write FASTA if available" ) p.set_outfile() @@ -2802,18 +2802,18 @@ def note(args): Extract certain attribute field for each feature. """ p = OptionParser(note.__doc__) - p.add_option( + p.add_argument( "--type", default=None, help="Only process certain types, multiple types allowed with comma", ) - p.add_option( + p.add_argument( "--attribute", default="Parent,Note", help="Attribute field to extract, multiple fields allowd with comma", ) - p.add_option("--AED", type=float, help="Only extract lines with AED score <=") - p.add_option( + p.add_argument("--AED", type=float, help="Only extract lines with AED score <=") + p.add_argument( "--exoncount", default=False, action="store_true", @@ -2955,68 +2955,68 @@ def bed(args): generate a bed file """ p = OptionParser(bed.__doc__) - p.add_option( + p.add_argument( "--type", dest="type", default="gene", help="Feature type to extract, use comma for multiple, and `all` for all", ) - p.add_option("--key", default="ID", help="Key in the attributes to extract") - p.add_option("--accn", help="Use fixed accn in the 4th column") - p.add_option("--source", help="Source to extract from, use comma for multiple") - p.add_option( + p.add_argument("--key", default="ID", help="Key in the attributes to extract") + p.add_argument("--accn", help="Use fixed accn in the 4th column") + p.add_argument("--source", help="Source to extract from, use comma for multiple") + p.add_argument( "--span", default=False, action="store_true", help="Use feature span in the score column", ) - p.add_option( + p.add_argument( "--score_attrib", dest="score_attrib", default=False, help="Attribute whose value is to be used as score in `bedline`", ) - p.add_option( + p.add_argument( "--append_source", default=False, action="store_true", help="Append GFF source name to extracted key value", ) - p.add_option( + p.add_argument( "--append_ftype", default=False, action="store_true", help="Append GFF feature type to extracted key value", ) - p.add_option( + p.add_argument( "--append_attrib", default=None, help="Append attribute to extracted key value", ) - p.add_option( + p.add_argument( "--nosort", default=False, action="store_true", help="Do not sort the output bed file", ) - p.add_option( + p.add_argument( "--primary_only", default=False, action="store_true", help="Only retains a single transcript per gene", ) - p.add_option( + p.add_argument( "--parent_key", default="Parent", help="Parent gene key to group with --primary_only", ) - p.add_option( + p.add_argument( "--human_chr", default=False, action="store_true", help="Only allow 1-22XY, and add `chr` prefix to seqid", ) - p.add_option( + p.add_argument( "--ensembl_cds", default=False, action="store_true", @@ -3145,7 +3145,7 @@ def children(args): Get the children that have the same parent. """ p = OptionParser(children.__doc__) - p.add_option( + p.add_argument( "--parents", default="gene", help="list of features to extract, use comma to separate (e.g. 'gene,mRNA')", @@ -3199,21 +3199,21 @@ def load(args): valid_avoid_features = ["both_strands", "strand_specific"] p = OptionParser(load.__doc__) - p.add_option( + p.add_argument( "--parents", dest="parents", default="mRNA", help="list of features to extract, use comma to separate (e.g." + "'gene,mRNA')", ) - p.add_option( + p.add_argument( "--children", dest="children", default="CDS", help="list of features to extract, use comma to separate (e.g." + "'five_prime_UTR,CDS,three_prime_UTR')", ) - p.add_option( + p.add_argument( "--feature", dest="feature", help="feature type to extract (e.g. `--feature=CDS`). Extract " @@ -3221,23 +3221,23 @@ def load(args): + "upstream|downstream:TSS|TrSS|TES|TrES:length " + "(e.g. `--feature=upstream:TSS:500`)", ) - p.add_option( + p.add_argument( "--avoidFeatures", default=None, choices=["both_strands", "strand_specific"], help="Specify whether or not to avoid up or downstream features", ) - p.add_option( + p.add_argument( "--id_attribute", choices=valid_id_attributes, help="The attribute field to extract and use as FASTA sequence ID", ) - p.add_option( + p.add_argument( "--desc_attribute", default="Note", help="The attribute field to extract and use as FASTA sequence description", ) - p.add_option( + p.add_argument( "--full_header", default=None, choices=["default", "tair"], @@ -3245,18 +3245,18 @@ def load(args): ) g1 = p.add_argument_group("Optional parameters (if generating full header)") - g1.add_option( + g1.add_argument( "--sep", dest="sep", default=" ", help="Specify separator used to delimiter header elements", ) - g1.add_option( + g1.add_argument( "--datestamp", dest="datestamp", help="Specify a datestamp in the format YYYYMMDD or automatically pick `today`", ) - g1.add_option( + g1.add_argument( "--conf_class", dest="conf_class", default=False, @@ -3693,9 +3693,9 @@ def bed12(args): 12. blockStarts """ p = OptionParser(bed12.__doc__) - p.add_option("--parent", default="mRNA", help="Top feature type") - p.add_option("--block", default="exon", help="Feature type for regular blocks") - p.add_option("--thick", default="CDS", help="Feature type for thick blocks") + p.add_argument("--parent", default="mRNA", help="Top feature type") + p.add_argument("--block", default="exon", help="Feature type for regular blocks") + p.add_argument("--thick", default="CDS", help="Feature type for thick blocks") p.set_outfile() opts, args = p.parse_args(args) diff --git a/jcvi/formats/html.py b/jcvi/formats/html.py index 632259d1..9891e0bb 100644 --- a/jcvi/formats/html.py +++ b/jcvi/formats/html.py @@ -40,8 +40,8 @@ def gallery(args): from jcvi.apps.base import iglob p = OptionParser(gallery.__doc__) - p.add_option("--columns", default=3, type=int, help="How many cells per row") - p.add_option("--width", default=200, type=int, help="Image width") + p.add_argument("--columns", default=3, type=int, help="How many cells per row") + p.add_argument("--width", default=200, type=int, help="Image width") opts, args = p.parse_args(args) if len(args) != 2: @@ -72,7 +72,7 @@ def links(args): Extract all the links "" from web page. """ p = OptionParser(links.__doc__) - p.add_option( + p.add_argument( "--img", default=False, action="store_true", diff --git a/jcvi/formats/obo.py b/jcvi/formats/obo.py index 4ac9c6ae..7b2d4d51 100755 --- a/jcvi/formats/obo.py +++ b/jcvi/formats/obo.py @@ -74,7 +74,7 @@ def validate_term(term, so=None, method="verify"): if __name__ == "__main__": p = OptionParser(__doc__) - p.add_option( + p.add_argument( "--term", help="Write the parents and children of this query term", ) diff --git a/jcvi/formats/paf.py b/jcvi/formats/paf.py index a7f3087b..cb4a7277 100644 --- a/jcvi/formats/paf.py +++ b/jcvi/formats/paf.py @@ -90,7 +90,7 @@ def bed(args): from jcvi.formats.bed import sort as sort_bed p = OptionParser(bed.__doc__) - p.add_option( + p.add_argument( "--swap", default=False, action="store_true", help="Write query positions" ) diff --git a/jcvi/formats/pdf.py b/jcvi/formats/pdf.py index 5160dca5..1be1b381 100644 --- a/jcvi/formats/pdf.py +++ b/jcvi/formats/pdf.py @@ -47,10 +47,10 @@ def cat(args): In case you don't want chapter 10 before chapter 2. """ p = OptionParser(cat.__doc__.format(page_range_help=PAGE_RANGE_HELP)) - p.add_option( + p.add_argument( "--nosort", default=False, action="store_true", help="Do not sort file names" ) - p.add_option( + p.add_argument( "--cleanup", default=False, action="store_true", diff --git a/jcvi/formats/psl.py b/jcvi/formats/psl.py index 61bb3f6d..c105bd9b 100755 --- a/jcvi/formats/psl.py +++ b/jcvi/formats/psl.py @@ -312,20 +312,20 @@ def gff(args): Convert to gff format. """ p = OptionParser(gff.__doc__) - p.add_option("--source", default="GMAP", help="specify GFF source") - p.add_option( + p.add_argument("--source", default="GMAP", help="specify GFF source") + p.add_argument( "--type", default="EST_match", help="specify GFF feature type", ) - p.add_option("--suffix", default=".match", help="match ID suffix") - p.add_option( + p.add_argument("--suffix", default=".match", help="match ID suffix") + p.add_argument( "--swap", default=False, action="store_true", help="swap query and target features", ) - p.add_option( + p.add_argument( "--simple_score", default=False, action="store_true", diff --git a/jcvi/formats/sam.py b/jcvi/formats/sam.py index 101879f6..c1edcee6 100644 --- a/jcvi/formats/sam.py +++ b/jcvi/formats/sam.py @@ -310,7 +310,7 @@ def append(args): training AUGUSTUS gene models. """ p = OptionParser(append.__doc__) - p.add_option("--prepend", help="Prepend string to read names") + p.add_argument("--prepend", help="Prepend string to read names") opts, args = p.parse_args(args) if len(args) != 1: @@ -407,7 +407,7 @@ def count(args): Count the number of reads mapped using `htseq-count`. """ p = OptionParser(count.__doc__) - p.add_option("--type", default="exon", help="Only count feature type") + p.add_argument("--type", default="exon", help="Only count feature type") p.set_cpus(cpus=8) opts, args = p.parse_args(args) @@ -444,13 +444,15 @@ def coverage(args): --nosort. """ p = OptionParser(coverage.__doc__) - p.add_option( + p.add_argument( "--format", default="bigwig", choices=("bedgraph", "bigwig", "coverage"), help="Output format", ) - p.add_option("--nosort", default=False, action="store_true", help="Do not sort BAM") + p.add_argument( + "--nosort", default=False, action="store_true", help="Do not sort BAM" + ) p.set_outfile() opts, args = p.parse_args(args) @@ -568,10 +570,10 @@ def consensus(args): """ valid_callers = ("bcftools", "gatk4") p = OptionParser(consensus.__doc__) - p.add_option( + p.add_argument( "--nosort", default=False, action="store_true", help="Do not sort the BAM files" ) - p.add_option( + p.add_argument( "--caller", default="bcftools", choices=valid_callers, @@ -610,10 +612,10 @@ def vcf(args): valid_callers = ("mpileup", "freebayes") p = OptionParser(vcf.__doc__) p.set_outfile(outfile="out.vcf.gz") - p.add_option( + p.add_argument( "--nosort", default=False, action="store_true", help="Do not sort the BAM files" ) - p.add_option( + p.add_argument( "--caller", default="mpileup", choices=valid_callers, help="Use variant caller" ) opts, args = p.parse_args(args) @@ -704,10 +706,10 @@ def index(args): If SAM file, convert to BAM, sort and then index, using SAMTOOLS """ p = OptionParser(index.__doc__) - p.add_option( + p.add_argument( "--fasta", dest="fasta", default=None, help="add @SQ header to the BAM file" ) - p.add_option( + p.add_argument( "--unique", default=False, action="store_true", @@ -887,39 +889,39 @@ def ace(args): assembler. """ p = OptionParser(ace.__doc__) - p.add_option( + p.add_argument( "--splitdir", dest="splitdir", default="outRoot", help="split the ace per contig to dir", ) - p.add_option( + p.add_argument( "--unpaired", dest="unpaired", default=False, help="remove read pairs on the same contig", ) - p.add_option( + p.add_argument( "--minreadno", dest="minreadno", default=3, type=int, help="minimum read numbers per contig", ) - p.add_option( + p.add_argument( "--minctgsize", dest="minctgsize", default=100, type=int, help="minimum contig size per contig", ) - p.add_option( + p.add_argument( "--astat", default=False, action="store_true", help="create .astat to list repetitiveness", ) - p.add_option( + p.add_argument( "--readids", default=False, action="store_true", diff --git a/jcvi/formats/sizes.py b/jcvi/formats/sizes.py index b6b5124d..122013ff 100644 --- a/jcvi/formats/sizes.py +++ b/jcvi/formats/sizes.py @@ -156,8 +156,8 @@ def histogram(args): p.set_histogram( vmax=50000, bins=100, xlabel="Read length", title="Read length distribution" ) - p.add_option("--ylabel1", default="Counts", help="Label of y-axis on the left") - p.add_option( + p.add_argument("--ylabel1", default="Counts", help="Label of y-axis on the left") + p.add_argument( "--color", default="0", choices=[str(x) for x in range(8)], diff --git a/jcvi/formats/vcf.py b/jcvi/formats/vcf.py index d8e17c6d..3455cfe0 100644 --- a/jcvi/formats/vcf.py +++ b/jcvi/formats/vcf.py @@ -151,7 +151,7 @@ def validate(args): import pyfasta p = OptionParser(validate.__doc__) - p.add_option("--prefix", help="Add prefix to seqid") + p.add_argument("--prefix", help="Add prefix to seqid") opts, args = p.parse_args(args) vcffile, fastafile = args @@ -496,7 +496,7 @@ def location(args): from jcvi.graphics.histogram import stem_leaf_plot p = OptionParser(location.__doc__) - p.add_option( + p.add_argument( "--dist", default=100, type=int, @@ -551,8 +551,8 @@ def summary(args): from jcvi.utils.table import tabulate p = OptionParser(summary.__doc__) - p.add_option("--counts", help="Print SNP counts in a txt file") - p.add_option("--bed", help="Print SNPs locations in a bed file") + p.add_argument("--counts", help="Print SNP counts in a txt file") + p.add_argument("--bed", help="Print SNPs locations in a bed file") opts, args = p.parse_args(args) if len(args) != 2: @@ -685,43 +685,43 @@ def mstmap(args): from jcvi.assembly.geneticmap import MSTMatrix p = OptionParser(mstmap.__doc__) - p.add_option( + p.add_argument( "--dh", default=False, action="store_true", help="Double haploid population, no het", ) - p.add_option( + p.add_argument( "--freq", default=0.2, type=float, help="Allele must be above frequency", ) - p.add_option( + p.add_argument( "--mindepth", default=3, type=int, help="Only trust genotype calls with depth", ) - p.add_option( + p.add_argument( "--missing_threshold", default=0.25, type=float, help="Fraction missing must be below", ) - p.add_option( + p.add_argument( "--noheader", default=False, action="store_true", help="Do not print MSTmap run parameters", ) - p.add_option( + p.add_argument( "--pv4", default=False, action="store_true", help="Enable filtering strand-bias, tail distance bias, etc.", ) - p.add_option( + p.add_argument( "--freebayes", default=False, action="store_true", @@ -796,7 +796,7 @@ def liftover(args): Lift over coordinates in vcf file. """ p = OptionParser(liftover.__doc__) - p.add_option( + p.add_argument( "--newid", default=False, action="store_true", help="Make new identifiers" ) opts, args = p.parse_args(args) diff --git a/jcvi/graphics/assembly.py b/jcvi/graphics/assembly.py index 50b8d410..264a3e5b 100644 --- a/jcvi/graphics/assembly.py +++ b/jcvi/graphics/assembly.py @@ -44,10 +44,10 @@ def covlen(args): from jcvi.formats.base import DictFile p = OptionParser(covlen.__doc__) - p.add_option("--maxsize", default=1000000, type=int, help="Max contig size") - p.add_option("--maxcov", default=100, type=int, help="Max contig size") - p.add_option("--color", default="m", help="Color of the data points") - p.add_option( + p.add_argument("--maxsize", default=1000000, type=int, help="Max contig size") + p.add_argument("--maxcov", default=100, type=int, help="Max contig size") + p.add_argument("--color", default="m", help="Color of the data points") + p.add_argument( "--kind", default="scatter", choices=("scatter", "reg", "resid", "kde", "hex"), @@ -109,8 +109,8 @@ def coverage(args): from jcvi.formats.bed import mates, bedpe p = OptionParser(coverage.__doc__) - p.add_option("--ymax", default=None, type=int, help="Limit ymax") - p.add_option( + p.add_argument("--ymax", default=None, type=int, help="Limit ymax") + p.add_argument( "--spans", default=False, action="store_true", @@ -260,13 +260,13 @@ def scaffold(args): from more_itertools import grouper p = OptionParser(scaffold.__doc__) - p.add_option( + p.add_argument( "--cutoff", type=int, default=1000000, help="Plot scaffolds with size larger than", ) - p.add_option( + p.add_argument( "--highlights", help="A set of regions in BED format to highlight", ) @@ -450,20 +450,20 @@ def A50(args): Plots A50 graphics, see blog post (http://blog.malde.org/index.php/a50/) """ p = OptionParser(A50.__doc__) - p.add_option( + p.add_argument( "--overwrite", default=False, action="store_true", help="overwrite .rplot file if exists", ) - p.add_option( + p.add_argument( "--cutoff", default=0, type=int, dest="cutoff", help="use contigs above certain size", ) - p.add_option( + p.add_argument( "--stepsize", default=10, type=int, diff --git a/jcvi/graphics/blastplot.py b/jcvi/graphics/blastplot.py index 8f425728..9f98093e 100755 --- a/jcvi/graphics/blastplot.py +++ b/jcvi/graphics/blastplot.py @@ -233,43 +233,43 @@ def increaseDensity(a, ratio=4): from jcvi.formats.bed import sizes p = OptionParser(__doc__) - p.add_option("--qsizes", help="Path to two column qsizes file") - p.add_option("--ssizes", help="Path to two column ssizes file") - p.add_option("--qbed", help="Path to qbed") - p.add_option("--sbed", help="Path to sbed") - p.add_option( + p.add_argument("--qsizes", help="Path to two column qsizes file") + p.add_argument("--ssizes", help="Path to two column ssizes file") + p.add_argument("--qbed", help="Path to qbed") + p.add_argument("--sbed", help="Path to sbed") + p.add_argument( "--qselect", default=0, type=int, help="Minimum size of query contigs to select", ) - p.add_option( + p.add_argument( "--sselect", default=0, type=int, help="Minimum size of subject contigs to select", ) - p.add_option("--qh", help="Path to highlight bed for query") - p.add_option("--sh", help="Path to highlight bed for subject") - p.add_option( + p.add_argument("--qh", help="Path to highlight bed for query") + p.add_argument("--sh", help="Path to highlight bed for subject") + p.add_argument( "--dotstyle", default="dot", choices=DotStyles, help="Style of the dots", ) - p.add_option( + p.add_argument( "--proportional", default=False, action="store_true", help="Make image width:height equal to seq ratio", ) - p.add_option( + p.add_argument( "--stripNames", default=False, action="store_true", help="Remove trailing .? from gene names", ) - p.add_option( + p.add_argument( "--nmax", default=None, type=int, diff --git a/jcvi/graphics/coverage.py b/jcvi/graphics/coverage.py index 715abd78..69ab792b 100644 --- a/jcvi/graphics/coverage.py +++ b/jcvi/graphics/coverage.py @@ -215,7 +215,7 @@ def setup_gauge_ax(gauge_ax, start, end, gauge_step, float_formatter=False): def main(): p = OptionParser(__doc__) - p.add_option("--order", help="The order to plot the tracks, comma-separated") + p.add_argument("--order", help="The order to plot the tracks, comma-separated") opts, args, iopts = p.set_image_options() if len(args) != 3: diff --git a/jcvi/graphics/dotplot.py b/jcvi/graphics/dotplot.py index b730a8a2..9bc7a712 100755 --- a/jcvi/graphics/dotplot.py +++ b/jcvi/graphics/dotplot.py @@ -400,57 +400,57 @@ def subset_bed(bed, seqids): def dotplot_main(args): p = OptionParser(__doc__) p.set_beds() - p.add_option( + p.add_argument( "--synteny", default=False, action="store_true", help="Run a fast synteny scan and display blocks", ) - p.add_option("--cmaptext", help="Draw colormap box on the bottom-left corner") - p.add_option( + p.add_argument("--cmaptext", help="Draw colormap box on the bottom-left corner") + p.add_argument( "--vmin", dest="vmin", type=float, default=0, help="Minimum value in the colormap", ) - p.add_option( + p.add_argument( "--vmax", dest="vmax", type=float, default=2, help="Maximum value in the colormap", ) - p.add_option( + p.add_argument( "--nmax", dest="sample_number", type=int, default=10000, help="Maximum number of data points to plot", ) - p.add_option( + p.add_argument( "--minfont", type=int, default=4, help="Do not render labels with size smaller than", ) - p.add_option("--colormap", help="Two column file, block id to color mapping") - p.add_option( + p.add_argument("--colormap", help="Two column file, block id to color mapping") + p.add_argument( "--colororientation", action="store_true", default=False, help="Color the blocks based on orientation, similar to mummerplot", ) - p.add_option( + p.add_argument( "--nosort", default=False, action="store_true", help="Do not sort the seqids along the axes", ) - p.add_option( + p.add_argument( "--nosep", default=False, action="store_true", help="Do not add contig lines" ) - p.add_option("--title", help="Title of the dot plot") + p.add_argument("--title", help="Title of the dot plot") p.set_dotplot_opts() p.set_outfile(outfile=None) opts, args, iopts = p.set_image_options( diff --git a/jcvi/graphics/glyph.py b/jcvi/graphics/glyph.py index 85dd648b..16970ba9 100644 --- a/jcvi/graphics/glyph.py +++ b/jcvi/graphics/glyph.py @@ -601,10 +601,12 @@ def gff(args): """ align_choices = ("left", "center", "right") p = OptionParser(gff.__doc__) - p.add_option( + p.add_argument( "--align", default="left", choices=align_choices, help="Horizontal alignment" ) - p.add_option("--noUTR", default=False, action="store_true", help="Do not plot UTRs") + p.add_argument( + "--noUTR", default=False, action="store_true", help="Do not plot UTRs" + ) opts, args = p.parse_args(args) if len(args) < 1: diff --git a/jcvi/graphics/grabseeds.py b/jcvi/graphics/grabseeds.py index 310bd8f0..f9a00e93 100644 --- a/jcvi/graphics/grabseeds.py +++ b/jcvi/graphics/grabseeds.py @@ -268,17 +268,17 @@ def add_seeds_options(p, args): Add options to the OptionParser for seeds() and batchseeds() functions. """ g1 = p.add_argument_group("Image manipulation") - g1.add_option("--rotate", default=0, type=int, help="Rotate degrees clockwise") - g1.add_option( + g1.add_argument("--rotate", default=0, type=int, help="Rotate degrees clockwise") + g1.add_argument( "--rows", default=":", help="Crop rows e.g. `:800` from first 800 rows" ) - g1.add_option( + g1.add_argument( "--cols", default=":", help="Crop cols e.g. `-800:` from last 800 cols" ) - g1.add_option("--labelrows", help="Label rows e.g. `:800` from first 800 rows") - g1.add_option("--labelcols", help="Label cols e.g. `-800: from last 800 rows") + g1.add_argument("--labelrows", help="Label rows e.g. `:800` from first 800 rows") + g1.add_argument("--labelcols", help="Label cols e.g. `-800: from last 800 rows") valid_colors = ("red", "green", "blue", "purple", "yellow", "orange", "INVERSE") - g1.add_option( + g1.add_argument( "--changeBackground", default=0, choices=valid_colors, @@ -286,17 +286,19 @@ def add_seeds_options(p, args): ) g2 = p.add_argument_group("Object recognition") - g2.add_option( + g2.add_argument( "--minsize", default=0.05, type=float, help="Min percentage of object to image", ) - g2.add_option( + g2.add_argument( "--maxsize", default=50, type=float, help="Max percentage of object to image" ) - g2.add_option("--count", default=100, type=int, help="Report max number of objects") - g2.add_option( + g2.add_argument( + "--count", default=100, type=int, help="Report max number of objects" + ) + g2.add_argument( "--watershed", default=False, action="store_true", @@ -305,41 +307,41 @@ def add_seeds_options(p, args): g3 = p.add_argument_group("De-noise") valid_filters = ("canny", "roberts", "sobel") - g3.add_option( + g3.add_argument( "--filter", default="canny", choices=valid_filters, help="Edge detection algorithm", ) - g3.add_option( + g3.add_argument( "--sigma", default=1, type=int, help="Canny edge detection sigma, higher for noisy image", ) - g3.add_option( + g3.add_argument( "--kernel", default=2, type=int, help="Edge closure, higher if the object edges are dull", ) - g3.add_option( + g3.add_argument( "--border", default=5, type=int, help="Remove image border of certain pixels" ) g4 = p.add_argument_group("Output") - g4.add_option("--calibrate", help="JSON file to correct distance and color") - g4.add_option( + g4.add_argument("--calibrate", help="JSON file to correct distance and color") + g4.add_argument( "--edges", default=False, action="store_true", help="Visualize edges in middle PDF panel", ) - g4.add_option( + g4.add_argument( "--outdir", default=".", help="Store intermediate images and PDF in folder" ) - g4.add_option("--prefix", help="Output prefix") - g4.add_option( + g4.add_argument("--prefix", help="Output prefix") + g4.add_argument( "--noheader", default=False, action="store_true", help="Do not print header" ) opts, args, iopts = p.set_image_options(args, figsize="12x6", style="white") diff --git a/jcvi/graphics/heatmap.py b/jcvi/graphics/heatmap.py index 3f8c1679..200526f0 100644 --- a/jcvi/graphics/heatmap.py +++ b/jcvi/graphics/heatmap.py @@ -62,14 +62,14 @@ def parse_csv(csvfile, vmin=0, groups=False): def main(): p = OptionParser(__doc__) - p.add_option( + p.add_argument( "--groups", default=False, action="store_true", help="The first row contains group info", ) - p.add_option("--rowgroups", help="Row groupings") - p.add_option( + p.add_argument("--rowgroups", help="Row groupings") + p.add_argument( "--horizontalbar", default=False, action="store_true", diff --git a/jcvi/graphics/histogram.py b/jcvi/graphics/histogram.py index cfd226b7..56a5f5af 100644 --- a/jcvi/graphics/histogram.py +++ b/jcvi/graphics/histogram.py @@ -276,47 +276,47 @@ def main(): """ allowed_format = ("emf", "eps", "pdf", "png", "ps", "raw", "rgba", "svg", "svgz") p = OptionParser(main.__doc__) - p.add_option("--skip", default=0, type=int, help="skip the first several lines") - p.add_option("--col", default=0, type=int, help="Get the n-th column") + p.add_argument("--skip", default=0, type=int, help="skip the first several lines") + p.add_argument("--col", default=0, type=int, help="Get the n-th column") p.set_histogram() - p.add_option( + p.add_argument( "--tags", dest="tags", default=None, help="tags for data if multiple input files, comma sep", ) - p.add_option( + p.add_argument( "--ascii", default=False, action="store_true", help="print ASCII text stem-leaf plot", ) - p.add_option( + p.add_argument( "--base", default="0", choices=("0", "2", "10"), help="use logarithm axis with base, 0 to disable", ) - p.add_option( + p.add_argument( "--facet", default=False, action="store_true", help="place multiple histograms side-by-side", ) - p.add_option("--fill", default="white", help="color of the bin") - p.add_option( + p.add_argument("--fill", default="white", help="color of the bin") + p.add_argument( "--format", default="pdf", choices=allowed_format, help="Generate image of format", ) - p.add_option( + p.add_argument( "--quick", default=False, action="store_true", help="Use quick plot, assuming bins are already counted", ) - p.add_option( + p.add_argument( "--noprintstats", default=False, action="store_true", diff --git a/jcvi/graphics/karyotype.py b/jcvi/graphics/karyotype.py index a7957580..c1119000 100644 --- a/jcvi/graphics/karyotype.py +++ b/jcvi/graphics/karyotype.py @@ -403,31 +403,31 @@ def __init__( def main(): p = OptionParser(__doc__) - p.add_option( + p.add_argument( "--basepair", default=False, action="store_true", help="Use base pair position instead of gene rank", ) - p.add_option( + p.add_argument( "--keep-chrlabels", default=False, action="store_true", help="Keep chromosome labels", ) - p.add_option( + p.add_argument( "--nocircles", default=False, action="store_true", help="Do not plot chromosome circles", ) - p.add_option( + p.add_argument( "--shadestyle", default="curve", choices=Shade.Styles, help="Style of syntenic wedges", ) - p.add_option( + p.add_argument( "--chrstyle", default="auto", choices=Chromosome.Styles, diff --git a/jcvi/graphics/landscape.py b/jcvi/graphics/landscape.py index 663e12cf..146c1034 100644 --- a/jcvi/graphics/landscape.py +++ b/jcvi/graphics/landscape.py @@ -205,8 +205,8 @@ def mosdepth(args): sns.set_style("darkgrid") p = OptionParser(mosdepth.__doc__) - p.add_option("--maxdepth", default=100, type=int, help="Maximum depth to plot") - p.add_option( + p.add_argument("--maxdepth", default=100, type=int, help="Maximum depth to plot") + p.add_argument( "--logscale", default=False, action="store_true", help="Use log-scale on depth" ) opts, args, iopts = p.set_image_options(args, style="dark", figsize="6x8") @@ -494,15 +494,15 @@ def depth(args): composite figure. """ p = OptionParser(depth.__doc__) - p.add_option( + p.add_argument( "--chrinfo", help="Comma-separated mappings between seqid, color, new_name" ) - p.add_option( + p.add_argument( "--titleinfo", help="Comma-separated titles mappings between filename, title", ) - p.add_option("--maxdepth", default=100, type=int, help="Maximum depth to show") - p.add_option( + p.add_argument("--maxdepth", default=100, type=int, help="Maximum depth to show") + p.add_argument( "--logscale", default=False, action="store_true", help="Use log-scale on depth" ) opts, args, iopts = p.set_image_options(args, style="dark", figsize="14x4") @@ -548,10 +548,10 @@ def add_window_options(p): """ Add options for window plotting. """ - p.add_option("--window", default=500000, type=int, help="Size of window") - p.add_option("--shift", default=100000, type=int, help="Size of shift") - p.add_option("--subtract", help="Subtract bases from window") - p.add_option( + p.add_argument("--window", default=500000, type=int, help="Size of window") + p.add_argument("--shift", default=100000, type=int, help="Size of shift") + p.add_argument("--subtract", help="Subtract bases from window") + p.add_argument( "--nomerge", default=False, action="store_true", help="Do not merge features" ) @@ -641,16 +641,16 @@ def composite(args): --altbars: similar to bars, yet in two alternating tracks, e.g. scaffolds """ p = OptionParser(composite.__doc__) - p.add_option("--lines", help="Features to plot in lineplot") - p.add_option("--bars", help="Features to plot in bars") - p.add_option("--altbars", help="Features to plot in alt-bars") - p.add_option( + p.add_argument("--lines", help="Features to plot in lineplot") + p.add_argument("--bars", help="Features to plot in bars") + p.add_argument("--altbars", help="Features to plot in alt-bars") + p.add_argument( "--fatten", default=False, action="store_true", help="Help visualize certain narrow features", ) - p.add_option( + p.add_argument( "--mode", default="span", choices=("span", "count", "score"), @@ -754,22 +754,22 @@ def multilineplot(args): --lines: traditional line plots, useful for plotting feature freq """ p = OptionParser(multilineplot.__doc__) - p.add_option("--lines", help="Features to plot in lineplot") - p.add_option("--colors", help="List of colors matching number of input bed files") - p.add_option( + p.add_argument("--lines", help="Features to plot in lineplot") + p.add_argument("--colors", help="List of colors matching number of input bed files") + p.add_argument( "--mode", default="span", choices=("span", "count", "score"), help="Accumulate feature based on", ) - p.add_option( + p.add_argument( "--binned", default=False, action="store_true", help="Specify whether the input is already binned; " + "if True, input files are considered to be binfiles", ) - p.add_option("--ymax", type=int, help="Set Y-axis max") + p.add_argument("--ymax", type=int, help="Set Y-axis max") add_window_options(p) opts, args, iopts = p.set_image_options(args, figsize="8x5") @@ -946,17 +946,17 @@ def heatmap(args): given chromosome. Need to give multiple beds to --stacks and --heatmaps """ p = OptionParser(heatmap.__doc__) - p.add_option( + p.add_argument( "--stacks", default="Exons,Introns,DNA_transposons,Retrotransposons", help="Features to plot in stackplot", ) - p.add_option( + p.add_argument( "--heatmaps", default="Copia,Gypsy,hAT,Helitron,Introns,Exons", help="Features to plot in heatmaps", ) - p.add_option("--meres", default=None, help="Extra centromere / telomere features") + p.add_argument("--meres", default=None, help="Extra centromere / telomere features") add_window_options(p) opts, args, iopts = p.set_image_options(args, figsize="8x5") @@ -1172,13 +1172,13 @@ def stack(args): sequences along the chromosomes. """ p = OptionParser(stack.__doc__) - p.add_option("--top", default=10, type=int, help="Draw the first N chromosomes") - p.add_option( + p.add_argument("--top", default=10, type=int, help="Draw the first N chromosomes") + p.add_argument( "--stacks", default="Exons,Introns,DNA_transposons,Retrotransposons", help="Features to plot in stackplot", ) - p.add_option("--switch", help="Change chr names based on two-column file") + p.add_argument("--switch", help="Change chr names based on two-column file") add_window_options(p) opts, args, iopts = p.set_image_options(args, figsize="8x8") diff --git a/jcvi/graphics/mummerplot.py b/jcvi/graphics/mummerplot.py index db513aef..ce11408a 100644 --- a/jcvi/graphics/mummerplot.py +++ b/jcvi/graphics/mummerplot.py @@ -32,26 +32,26 @@ def main(args): query. Control "major" by option --refcov. """ p = OptionParser(main.__doc__) - p.add_option("--refids", help="Use subset of contigs in the ref") - p.add_option( + p.add_argument("--refids", help="Use subset of contigs in the ref") + p.add_argument( "--refcov", default=0.01, type=float, help="Minimum reference coverage", ) - p.add_option( + p.add_argument( "--all", default=False, action="store_true", help="Plot one pdf file per ref in refidsfile", ) - p.add_option( + p.add_argument( "--color", default="similarity", choices=("similarity", "direction", "none"), help="Color the dots based on", ) - p.add_option( + p.add_argument( "--nolayout", default=False, action="store_true", diff --git a/jcvi/graphics/synteny.py b/jcvi/graphics/synteny.py index 7a170cd0..d69facea 100644 --- a/jcvi/graphics/synteny.py +++ b/jcvi/graphics/synteny.py @@ -628,14 +628,14 @@ def draw_gene_legend( def main(): p = OptionParser(__doc__) - p.add_option("--switch", help="Rename the seqid with two-column file") - p.add_option("--tree", help="Display trees on the bottom of the figure") - p.add_option("--extra", help="Extra features in BED format") - p.add_option( + p.add_argument("--switch", help="Rename the seqid with two-column file") + p.add_argument("--tree", help="Display trees on the bottom of the figure") + p.add_argument("--extra", help="Extra features in BED format") + p.add_argument( "--genelabels", help='Show only these gene labels, separated by comma. Example: "At1g12340,At5g54690"', ) - p.add_option( + p.add_argument( "--genelabelsize", default=0, type=int, @@ -643,43 +643,43 @@ def main(): + "However, plot may appear visually crowded. " + "Reasonably good values are 2 to 6 [Default: disabled]", ) - p.add_option( + p.add_argument( "--genelabelrotation", default=25, type=int, help="Rotate gene labels at this angle (anti-clockwise), useful for debugging. " + "[Default: 25]", ) - p.add_option( + p.add_argument( "--scalebar", default=False, action="store_true", help="Add scale bar to the plot", ) - p.add_option( + p.add_argument( "--glyphstyle", default="box", choices=Glyph.Styles, help="Style of feature glyphs", ) - p.add_option( + p.add_argument( "--glyphcolor", default="orientation", choices=Glyph.Palette, help="Glyph coloring based on", ) - p.add_option( + p.add_argument( "--shadestyle", default="curve", choices=Shade.Styles, help="Style of syntenic wedges", ) - p.add_option( + p.add_argument( "--outputprefix", default="", help="Prefix for the output file", ) - p.add_option( + p.add_argument( "--noprune", default=False, action="store_true", diff --git a/jcvi/graphics/tree.py b/jcvi/graphics/tree.py index ff2d0408..a9daa222 100644 --- a/jcvi/graphics/tree.py +++ b/jcvi/graphics/tree.py @@ -548,44 +548,46 @@ def main(args): on, also show the number of amino acids. """ p = OptionParser(main.__doc__) - p.add_option( + p.add_argument( "--outgroup", help="Outgroup for rerooting the tree. " + "Use comma to separate multiple taxa.", ) - p.add_option( + p.add_argument( "--noreroot", default=False, action="store_true", help="Don't reroot the input tree", ) - p.add_option( + p.add_argument( "--rmargin", default=0.2, type=float, help="Set blank rmargin to the right" ) - p.add_option("--gffdir", default=None, help="The directory that contain GFF files") - p.add_option("--sizes", default=None, help="The FASTA file or the sizes file") - p.add_option("--SH", default=None, type=str, help="SH test p-value") - - group = p.add_option_group("Node style") - group.add_option("--leafcolor", default="k", help="Font color for the OTUs") - group.add_option("--leaffont", default=12, help="Font size for the OTUs") - group.add_option( + p.add_argument( + "--gffdir", default=None, help="The directory that contain GFF files" + ) + p.add_argument("--sizes", default=None, help="The FASTA file or the sizes file") + p.add_argument("--SH", default=None, type=str, help="SH test p-value") + + group = p.add_argument_group("Node style") + group.add_argument("--leafcolor", default="k", help="Font color for the OTUs") + group.add_argument("--leaffont", default=12, help="Font size for the OTUs") + group.add_argument( "--leafinfo", help="CSV file specifying the leaves: name,color,new_name" ) - group.add_option( + group.add_argument( "--scutoff", default=0, type=int, help="cutoff for displaying node support, 0-100", ) - group.add_option( + group.add_argument( "--no_support", dest="support", default=True, action="store_false", help="Do not print node support values", ) - group.add_option( + group.add_argument( "--no_internal", dest="internal", default=True, @@ -593,25 +595,25 @@ def main(args): help="Do not show internal nodes", ) - group = p.add_option_group("Edge style") - group.add_option( + group = p.add_argument_group("Edge style") + group.add_argument( "--dashedoutgroup", default=False, action="store_true", help="Gray out the edges connecting outgroup and non-outgroup", ) - group = p.add_option_group("Additional annotations") - group.add_option( + group = p.add_argument_group("Additional annotations") + group.add_argument( "--geoscale", default=False, action="store_true", help="Plot geological scale", ) - group.add_option( + group.add_argument( "--wgdinfo", help="CSV specifying the position and style of WGD events" ) - group.add_option( + group.add_argument( "--groups", help="Group names from top to bottom, to the right of the tree. " "Each distinct color in --leafinfo is considered part of the same group. " diff --git a/jcvi/graphics/wheel.py b/jcvi/graphics/wheel.py index 86fc339f..1cdbb493 100644 --- a/jcvi/graphics/wheel.py +++ b/jcvi/graphics/wheel.py @@ -73,7 +73,7 @@ def wheel(args): Wheel plot that shows continous data in radial axes. """ p = OptionParser(wheel.__doc__) - p.add_option( + p.add_argument( "--column", default="score", choices=("score", "percentile"), diff --git a/jcvi/projects/ies.py b/jcvi/projects/ies.py index 294bbbc5..c005039d 100644 --- a/jcvi/projects/ies.py +++ b/jcvi/projects/ies.py @@ -47,7 +47,7 @@ def variation(args): Associate IES in parents and progeny. """ p = OptionParser(variation.__doc__) - p.add_option( + p.add_argument( "--diversity", choices=("breakpoint", "variant"), default="variant", @@ -197,7 +197,7 @@ def insertionpairs(args): (RE) (LE) """ p = OptionParser(insertionpairs.__doc__) - p.add_option( + p.add_argument( "--extend", default=10, type=int, @@ -240,7 +240,7 @@ def insertion(args): 'lesions' (stack of broken reads) in the MAC genome. """ p = OptionParser(insertion.__doc__) - p.add_option( + p.add_argument( "--mindepth", default=6, type=int, help="Minimum depth to call an insertion" ) p.set_outfile() @@ -276,13 +276,13 @@ def deletion(args): Find IES based on mapping MAC reads to MIC genome. """ p = OptionParser(deletion.__doc__) - p.add_option( + p.add_argument( "--mindepth", default=3, type=int, help="Minimum depth to call a deletion" ) - p.add_option( + p.add_argument( "--minspan", default=30, type=int, help="Minimum span to call a deletion" ) - p.add_option( + p.add_argument( "--split", default=False, action="store_true", diff --git a/jcvi/projects/misc.py b/jcvi/projects/misc.py index 7c074ac3..1c739611 100644 --- a/jcvi/projects/misc.py +++ b/jcvi/projects/misc.py @@ -180,7 +180,7 @@ def utricularia(args): from jcvi.graphics.synteny import main as synteny_main p = OptionParser(synteny_main.__doc__) - p.add_option("--switch", help="Rename the seqid with two-column file") + p.add_argument("--switch", help="Rename the seqid with two-column file") opts, args, iopts = p.set_image_options(args, figsize="8x7") if len(args) != 3: @@ -377,7 +377,7 @@ def oropetium(args): Build a composite figure that calls graphis.synteny. """ p = OptionParser(oropetium.__doc__) - p.add_option("--extra", help="Extra features in BED format") + p.add_argument("--extra", help="Extra features in BED format") opts, args, iopts = p.set_image_options(args, figsize="9x6") if len(args) != 4: @@ -493,8 +493,8 @@ def amborella(args): Build a composite figure that calls graphics.karyotype and graphics.synteny. """ p = OptionParser(amborella.__doc__) - p.add_option("--tree", help="Display trees on the bottom of the figure") - p.add_option("--switch", help="Rename the seqid with two-column file") + p.add_argument("--tree", help="Display trees on the bottom of the figure") + p.add_argument("--switch", help="Rename the seqid with two-column file") opts, args, iopts = p.set_image_options(args, figsize="8x7") if len(args) != 5: @@ -540,8 +540,8 @@ def cotton(args): Build a composite figure that calls graphics.karyotype and graphic.synteny. """ p = OptionParser(cotton.__doc__) - p.add_option("--depthfile", help="Use depth info in this file") - p.add_option("--switch", help="Rename the seqid with two-column file") + p.add_argument("--depthfile", help="Use depth info in this file") + p.add_argument("--switch", help="Rename the seqid with two-column file") opts, args, iopts = p.set_image_options(args, figsize="8x7") if len(args) != 5: diff --git a/jcvi/projects/napus.py b/jcvi/projects/napus.py index 454d163f..69c8c009 100644 --- a/jcvi/projects/napus.py +++ b/jcvi/projects/napus.py @@ -129,21 +129,21 @@ def cov(args): homeologous gene pairs. Allow multiple chromosomes to multiple chromosomes. """ p = OptionParser(cov.__doc__) - p.add_option( + p.add_argument( "--order", default="swede,kale,h165,yudal,aviso,abu,bristol,bzh", help="The order to plot the tracks, comma-separated", ) - p.add_option( + p.add_argument( "--reverse", default=False, action="store_true", help="Plot the order in reverse", ) - p.add_option( + p.add_argument( "--gauge_step", default=5000000, type=int, help="Step size for the base scale" ) - p.add_option( + p.add_argument( "--hlsuffix", default="regions.forhaibao", help="Suffix for the filename to be used to highlight regions", @@ -284,7 +284,7 @@ def fig3(args): from jcvi.formats.bed import Bed p = OptionParser(fig3.__doc__) - p.add_option( + p.add_argument( "--gauge_step", default=10000000, type=int, @@ -533,7 +533,7 @@ def fig4(args): showing read alignments from high GL and low GL lines. """ p = OptionParser(fig4.__doc__) - p.add_option( + p.add_argument( "--gauge_step", default=200000, type=int, help="Step size for the base scale" ) opts, args, iopts = p.set_image_options(args, figsize="9x7") diff --git a/jcvi/projects/pineapple.py b/jcvi/projects/pineapple.py index 7aa522ac..8be49b63 100644 --- a/jcvi/projects/pineapple.py +++ b/jcvi/projects/pineapple.py @@ -71,7 +71,7 @@ def flanking(args): Extract flanking genes for given SI loci. """ p = OptionParser(flanking.__doc__) - p.add_option("-N", default=50, type=int, help="How many genes on both directions") + p.add_argument("-N", default=50, type=int, help="How many genes on both directions") opts, args = p.parse_args(args) if len(args) != 4: @@ -300,7 +300,7 @@ def ploidy(args): and graphic.synteny. """ p = OptionParser(ploidy.__doc__) - p.add_option("--switch", help="Rename the seqid with two-column file") + p.add_argument("--switch", help="Rename the seqid with two-column file") opts, args, iopts = p.set_image_options(args, figsize="9x7") if len(args) != 5: diff --git a/jcvi/projects/str.py b/jcvi/projects/str.py index 538e9099..9ffac1b6 100644 --- a/jcvi/projects/str.py +++ b/jcvi/projects/str.py @@ -283,7 +283,7 @@ def mendelian2(args): counts and gender information to correct error estimate of X-linked loci. """ p = OptionParser(mendelian2.__doc__) - p.add_option( + p.add_argument( "--treds", default=None, help="Extract specific treds, use comma to separate" ) opts, args = p.parse_args(args) @@ -764,7 +764,7 @@ def mendelian(args): Calculate Mendelian errors based on trios and duos. """ p = OptionParser(mendelian.__doc__) - p.add_option("--tolerance", default=0, type=int, help="Tolernace for differences") + p.add_argument("--tolerance", default=0, type=int, help="Tolernace for differences") p.set_verbose() opts, args = p.parse_args(args) @@ -884,10 +884,10 @@ def mini(args): Prepare mini-BAMs that contain only the STR loci. """ p = OptionParser(mini.__doc__) - p.add_option( + p.add_argument( "--pad", default=20000, type=int, help="Add padding to the STR reigons" ) - p.add_option( + p.add_argument( "--treds", default=None, help="Extract specific treds, use comma to separate" ) p.set_outfile() @@ -1439,13 +1439,13 @@ def allelefreq(args): Plot the allele frequencies of some STRs. """ p = OptionParser(allelefreq.__doc__) - p.add_option( + p.add_argument( "--nopanels", default=False, action="store_true", help="No panel labels A, B, ...", ) - p.add_option("--usereport", help="Use allele frequency in report file") + p.add_argument("--usereport", help="Use allele frequency in report file") opts, args, iopts = p.set_image_options(args, figsize="9x13") if len(args) != 1: @@ -1500,8 +1500,8 @@ def make_fasta(seq, fastafile, id): def add_simulate_options(p): - p.add_option("--readlen", default=150, type=int, help="Length of the read") - p.add_option( + p.add_argument("--readlen", default=150, type=int, help="Length of the read") + p.add_argument( "--distance", default=500, type=int, @@ -1519,16 +1519,16 @@ def simulate(args): `run_dir`. """ p = OptionParser(simulate.__doc__) - p.add_option( + p.add_argument( "--method", choices=("wgsim", "eagle"), default="eagle", help="Read simulator" ) - p.add_option( + p.add_argument( "--ref", default="hg38", choices=("hg38", "hg19"), help="Reference genome version", ) - p.add_option("--tred", default="HD", help="TRED locus") + p.add_argument("--tred", default="HD", help="TRED locus") add_simulate_options(p) opts, args = p.parse_args(args) @@ -1642,7 +1642,7 @@ def batchlobstr(args): $ tred.py bamlist --haploid chr4 --workdir tredparse_results """ p = OptionParser(batchlobstr.__doc__) - p.add_option( + p.add_argument( "--haploid", default="chrY,chrM", help="Use haploid model for these chromosomes" ) p.set_cpus() @@ -1703,7 +1703,7 @@ def evidences(args): - Longer allele """ p = OptionParser(evidences.__doc__) - p.add_option( + p.add_argument( "--csv", default="hli.20170328.tred.tsv", help="TRED csv output to plot" ) opts, args, iopts = p.set_image_options(args, format="pdf") @@ -2044,7 +2044,9 @@ def compare2(args): Compare performances of various variant callers on simulated STR datasets. """ p = OptionParser(compare2.__doc__) - p.add_option("--maxinsert", default=300, type=int, help="Maximum number of repeats") + p.add_argument( + "--maxinsert", default=300, type=int, help="Maximum number of repeats" + ) add_simulate_options(p) opts, args, iopts = p.set_image_options(args, figsize="10x5") @@ -2099,7 +2101,9 @@ def power(args): This compares the power of various evidence types. """ p = OptionParser(power.__doc__) - p.add_option("--maxinsert", default=300, type=int, help="Maximum number of repeats") + p.add_argument( + "--maxinsert", default=300, type=int, help="Maximum number of repeats" + ) add_simulate_options(p) opts, args, iopts = p.set_image_options(args, figsize="10x10", format="png") @@ -2196,7 +2200,9 @@ def tredparse(args): Adds coverage comparisons as panel C and D. """ p = OptionParser(tredparse.__doc__) - p.add_option("--maxinsert", default=300, type=int, help="Maximum number of repeats") + p.add_argument( + "--maxinsert", default=300, type=int, help="Maximum number of repeats" + ) add_simulate_options(p) opts, args, iopts = p.set_image_options(args, figsize="10x10") diff --git a/jcvi/projects/sugarcane.py b/jcvi/projects/sugarcane.py index 3c91acf4..0e4767f5 100644 --- a/jcvi/projects/sugarcane.py +++ b/jcvi/projects/sugarcane.py @@ -418,13 +418,13 @@ def simulate(args): sns.set_style("darkgrid") p = OptionParser(simulate.__doc__) - p.add_option( + p.add_argument( "--verbose", default=False, action="store_true", help="Verbose logging during simulation", ) - p.add_option("-N", default=10000, type=int, help="Number of simulated samples") + p.add_argument("-N", default=10000, type=int, help="Number of simulated samples") opts, args, iopts = p.set_image_options(args, figsize="6x6") if len(args) != 1: sys.exit(not p.print_help()) @@ -669,8 +669,8 @@ def divergence(args): sns.set_style("white") p = OptionParser(divergence.__doc__) - p.add_option("--title", default="Gapless", help="Plot title") - p.add_option( + p.add_argument("--title", default="Gapless", help="Plot title") + p.add_argument( "--xmin", default=94, type=int, diff --git a/jcvi/projects/tgbs.py b/jcvi/projects/tgbs.py index 8163f956..f1bc9f4b 100644 --- a/jcvi/projects/tgbs.py +++ b/jcvi/projects/tgbs.py @@ -164,12 +164,12 @@ def mstmap(args): from jcvi.assembly.geneticmap import MSTMatrix p = OptionParser(mstmap.__doc__) - p.add_option( + p.add_argument( "--population_type", default="RIL6", help="Type of population, possible values are DH and RILd", ) - p.add_option( + p.add_argument( "--missing_threshold", default=0.5, help="Missing threshold, .25 excludes any marker with >25% missing", @@ -207,8 +207,8 @@ def weblogo(args): from rich.progress import Progress p = OptionParser(weblogo.__doc__) - p.add_option("-N", default=10, type=int, help="Count the first and last N bases") - p.add_option("--nreads", default=1000000, type=int, help="Parse first N reads") + p.add_argument("-N", default=10, type=int, help="Count the first and last N bases") + p.add_argument("--nreads", default=1000000, type=int, help="Parse first N reads") opts, args = p.parse_args(args) if len(args) != 1: @@ -286,7 +286,7 @@ def count(args): from jcvi.utils.cbook import SummaryStats p = OptionParser(count.__doc__) - p.add_option("--csv", help="Write depth per contig to file") + p.add_argument("--csv", help="Write depth per contig to file") opts, args = p.parse_args(args) if len(args) != 1: @@ -335,7 +335,7 @@ def novo(args): from jcvi.apps.cdhit import filter as cdhit_filter p = OptionParser(novo.__doc__) - p.add_option( + p.add_argument( "--technology", choices=("illumina", "454", "iontorrent"), default="iontorrent", diff --git a/jcvi/utils/aws.py b/jcvi/utils/aws.py index e5b080cc..3d738616 100644 --- a/jcvi/utils/aws.py +++ b/jcvi/utils/aws.py @@ -144,14 +144,14 @@ def start(args): Launch ec2 instance through command line. """ p = OptionParser(start.__doc__) - p.add_option( + p.add_argument( "--ondemand", default=False, action="store_true", help="Do we want a more expensive on-demand instance", ) - p.add_option("--profile", default="mvrad-datasci-role", help="Profile name") - p.add_option("--price", default=4.0, type=float, help="Spot price") + p.add_argument("--profile", default="mvrad-datasci-role", help="Profile name") + p.add_argument("--price", default=4.0, type=float, help="Spot price") opts, args = p.parse_args(args) if len(args) != 0: @@ -257,7 +257,7 @@ def stop(args): Stop EC2 instance. """ p = OptionParser(stop.__doc__) - p.add_option("--profile", default="mvrad-datasci-role", help="Profile name") + p.add_argument("--profile", default="mvrad-datasci-role", help="Profile name") opts, args = p.parse_args(args) if len(args) != 0: @@ -362,7 +362,7 @@ def cp(args): Copy files to folder. Accepts list of s3 addresses as input. """ p = OptionParser(cp.__doc__) - p.add_option( + p.add_argument( "--force", default=False, action="store_true", help="Force overwrite if exists" ) p.set_cpus() @@ -405,8 +405,8 @@ def ls(args): List files with support for wildcards. """ p = OptionParser(ls.__doc__) - p.add_option("--keys", help="List of keys to include") - p.add_option( + p.add_argument("--keys", help="List of keys to include") + p.add_argument( "--recursive", default=False, action="store_true", help="Recursive search" ) opts, args = p.parse_args(args) @@ -510,8 +510,8 @@ def role(args): ) = "205134639408 htang 114692162163 mvrad-datasci-role".split() p = OptionParser(role.__doc__) - p.add_option("--profile", default="mvrad-datasci-role", help="Profile name") - p.add_option( + p.add_argument("--profile", default="mvrad-datasci-role", help="Profile name") + p.add_argument( "--device", default="arn:aws:iam::" + src_acct + ":mfa/" + src_username, metavar="arn:aws:iam::123456788990:mfa/dudeman", @@ -519,7 +519,7 @@ def role(args): "provided via the environment variable 'MFA_DEVICE' or" " the ~/.aws/credentials variable 'aws_mfa_device'.", ) - p.add_option( + p.add_argument( "--duration", type=int, default=3600, @@ -531,7 +531,7 @@ def role(args): "can also be provided via the environment " "variable 'MFA_STS_DURATION'. ", ) - p.add_option( + p.add_argument( "--assume-role", "--assume", default="arn:aws:iam::" + dst_acct + ":role/" + dst_role, @@ -540,12 +540,12 @@ def role(args): "assume, if specified. This value can also be provided" " via the environment variable 'MFA_ASSUME_ROLE'", ) - p.add_option( + p.add_argument( "--role-session-name", help="Friendly session name required when using --assume-role", default=getpass.getuser(), ) - p.add_option( + p.add_argument( "--force", help="Refresh credentials even if currently valid.", action="store_true", diff --git a/jcvi/utils/db.py b/jcvi/utils/db.py index 05a527dd..043abb49 100644 --- a/jcvi/utils/db.py +++ b/jcvi/utils/db.py @@ -171,7 +171,7 @@ def pull(args): """ p = OptionParser(pull.__doc__) p.set_db_opts(dbname="mtg2", credentials=None) - p.add_option( + p.add_argument( "--frag", default=False, action="store_true", @@ -239,7 +239,7 @@ def query(args): """ p = OptionParser(query.__doc__) p.set_db_opts() - p.add_option( + p.add_argument( "--dryrun", default=False, action="store_true", diff --git a/jcvi/variation/cnv.py b/jcvi/variation/cnv.py index 8e35aa62..00e0056d 100644 --- a/jcvi/variation/cnv.py +++ b/jcvi/variation/cnv.py @@ -804,7 +804,7 @@ def cib(args): Convert BAM to CIB (a binary storage of int8 per base). """ p = OptionParser(cib.__doc__) - p.add_option("--prefix", help="Report seqids with this prefix only") + p.add_argument("--prefix", help="Report seqids with this prefix only") p.set_cpus() opts, args = p.parse_args(args) @@ -837,7 +837,7 @@ def batchcn(args): Run CNV segmentation caller in batch mode. Scans a workdir. """ p = OptionParser(batchcn.__doc__) - p.add_option( + p.add_argument( "--upload", default="s3://hli-mv-data-science/htang/ccn", help="Upload cn and seg results to s3", @@ -878,14 +878,14 @@ def hmm(args): directory. """ p = OptionParser(hmm.__doc__) - p.add_option("--mu", default=0.003, type=float, help="Transition probability") - p.add_option( + p.add_argument("--mu", default=0.003, type=float, help="Transition probability") + p.add_argument( "--sigma", default=0.1, type=float, help="Standard deviation of Gaussian emission distribution", ) - p.add_option( + p.add_argument( "--threshold", default=1, type=float, @@ -1064,27 +1064,29 @@ def cn(args): Download CCN output folder and convert cib to copy number per 1Kb. """ p = OptionParser(cn.__doc__) - p.add_option( + p.add_argument( "--binsize", default=1000, type=int, help="Window size along chromosome" ) - p.add_option( + p.add_argument( "--cleanup", default=False, action="store_true", help="Clean up downloaded s3 folder", ) - p.add_option( + p.add_argument( "--hmm", default=False, action="store_true", help="Run HMM caller after computing CN", ) - p.add_option( + p.add_argument( "--upload", default="s3://hli-mv-data-science/htang/ccn", help="Upload cn and seg results to s3", ) - p.add_option("--rebuildgc", help="Rebuild GC directory rather than pulling from S3") + p.add_argument( + "--rebuildgc", help="Rebuild GC directory rather than pulling from S3" + ) opts, args = p.parse_args(args) if len(args) == 2: @@ -1182,7 +1184,7 @@ def validate(args): Plot RDR/BAF/CN for validation of CNV calls in `sample.vcf.gz`. """ p = OptionParser(validate.__doc__) - p.add_option( + p.add_argument( "--no-rdr-logy", default=False, action="store_true", @@ -1421,7 +1423,7 @@ def wes_vs_wgs(args): Compare WES and WGS CNVs. """ p = OptionParser(wes_vs_wgs.__doc__) - p.add_option( + p.add_argument( "--no-rdr-logy", default=False, action="store_true", diff --git a/jcvi/variation/deconvolute.py b/jcvi/variation/deconvolute.py index 30e788ae..df8f7409 100644 --- a/jcvi/variation/deconvolute.py +++ b/jcvi/variation/deconvolute.py @@ -141,19 +141,19 @@ def split(args): """ p = OptionParser(split.__doc__) p.set_outdir(outdir="deconv") - p.add_option( + p.add_argument( "--nocheckprefix", default=False, action="store_true", help="Don't check shared prefix", ) - p.add_option( + p.add_argument( "--paired", default=False, action="store_true", help="Paired-end data", ) - p.add_option( + p.add_argument( "--append", default=False, action="store_true", diff --git a/jcvi/variation/delly.py b/jcvi/variation/delly.py index a07102f3..88c4ae15 100644 --- a/jcvi/variation/delly.py +++ b/jcvi/variation/delly.py @@ -86,8 +86,8 @@ def mitosomatic(args): import pandas as pd p = OptionParser(mitosomatic.__doc__) - p.add_option("--minaf", default=0.005, type=float, help="Minimum allele fraction") - p.add_option("--maxaf", default=0.1, type=float, help="Maximum allele fraction") + p.add_argument("--minaf", default=0.005, type=float, help="Minimum allele fraction") + p.add_argument("--maxaf", default=0.1, type=float, help="Maximum allele fraction") opts, args = p.parse_args(args) if len(args) != 1: @@ -196,16 +196,16 @@ def mito(args): """ p = OptionParser(mito.__doc__) p.set_aws_opts(store="hli-mv-data-science/htang/mito-deletions") - p.add_option( + p.add_argument( "--realignonly", default=False, action="store_true", help="Realign only" ) - p.add_option( + p.add_argument( "--svonly", default=False, action="store_true", help="Run Realign => SV calls only", ) - p.add_option( + p.add_argument( "--support", default=1, type=int, help="Minimum number of supporting reads" ) p.set_home("speedseq", default="/mnt/software/speedseq/bin") diff --git a/jcvi/variation/phase.py b/jcvi/variation/phase.py index fe0530a7..8ce1a043 100644 --- a/jcvi/variation/phase.py +++ b/jcvi/variation/phase.py @@ -83,7 +83,7 @@ def prepare(args): - variants_to_phase: in format of phased vcf """ p = OptionParser(prepare.__doc__) - p.add_option("--accuracy", default=0.85, help="Sequencing per-base accuracy") + p.add_argument("--accuracy", default=0.85, help="Sequencing per-base accuracy") opts, args = p.parse_args(args) if len(args) != 2: diff --git a/jcvi/variation/snp.py b/jcvi/variation/snp.py index d8f65e02..d316326e 100644 --- a/jcvi/variation/snp.py +++ b/jcvi/variation/snp.py @@ -38,7 +38,7 @@ def mappability(args): """ p = OptionParser(mappability.__doc__) - p.add_option("--mer", default=50, type=int, help="User mer size") + p.add_argument("--mer", default=50, type=int, help="User mer size") p.set_cpus() opts, args = p.parse_args(args) @@ -85,7 +85,7 @@ def gatk(args): Call SNPs based on GATK best practices. """ p = OptionParser(gatk.__doc__) - p.add_option( + p.add_argument( "--indelrealign", default=False, action="store_true", @@ -207,7 +207,7 @@ def rmdup(args): Remove PCR duplicates from BAM files, generate a list of commands. """ p = OptionParser(rmdup.__doc__) - p.add_option( + p.add_argument( "-S", default=False, action="store_true", help="Treat PE reads as SE in rmdup" ) opts, args = p.parse_args(args) @@ -258,8 +258,8 @@ def freebayes(args): Call SNPs using freebayes. """ p = OptionParser(freebayes.__doc__) - p.add_option("--mindepth", default=3, type=int, help="Minimum depth") - p.add_option("--minqual", default=20, type=int, help="Minimum quality") + p.add_argument("--mindepth", default=3, type=int, help="Minimum depth") + p.add_argument("--minqual", default=20, type=int, help="Minimum quality") opts, args = p.parse_args(args) if len(args) < 2: @@ -283,8 +283,8 @@ def freq(args): Call SNP frequencies and generate GFF file. """ p = OptionParser(freq.__doc__) - p.add_option("--mindepth", default=3, type=int, help="Minimum depth") - p.add_option("--minqual", default=20, type=int, help="Minimum quality") + p.add_argument("--mindepth", default=3, type=int, help="Minimum depth") + p.add_argument("--minqual", default=20, type=int, help="Minimum quality") p.set_outfile() opts, args = p.parse_args(args) @@ -306,7 +306,7 @@ def frommaf(args): Convert to four-column tabular format from MAF. """ p = OptionParser(frommaf.__doc__) - p.add_option("--validate", help="Validate coordinates against FASTA") + p.add_argument("--validate", help="Validate coordinates against FASTA") opts, args = p.parse_args(args) if len(args) != 1: diff --git a/jcvi/variation/str.py b/jcvi/variation/str.py index 51e7401f..072e4b65 100644 --- a/jcvi/variation/str.py +++ b/jcvi/variation/str.py @@ -390,7 +390,7 @@ def treds(args): from jcvi.apps.base import datafile p = OptionParser(treds.__doc__) - p.add_option( + p.add_argument( "--csv", default=False, action="store_true", help="Also write `meta.csv`" ) opts, args = p.parse_args(args) @@ -615,7 +615,7 @@ def meta(args): $ intersectBed -a all-STR.bed -b all-exons.bed -wo > STR-exons.wo.bed """ p = OptionParser(meta.__doc__) - p.add_option( + p.add_argument( "--cutoff", default=0.5, type=float, @@ -693,7 +693,7 @@ def bin(args): Conver tsv to binary format. """ p = OptionParser(bin.__doc__) - p.add_option("--dtype", choices=("float32", "int32"), help="dtype of the matrix") + p.add_argument("--dtype", choices=("float32", "int32"), help="dtype of the matrix") opts, args = p.parse_args(args) if len(args) != 1: @@ -790,7 +790,7 @@ def data(args): Make data.tsv based on meta.tsv. """ p = OptionParser(data.__doc__) - p.add_option( + p.add_argument( "--notsv", default=False, action="store_true", help="Do not write data.tsv" ) opts, args = p.parse_args(args) @@ -990,8 +990,8 @@ def compilevcf(args): Compile vcf results into master spreadsheet. """ p = OptionParser(compilevcf.__doc__) - p.add_option("--db", default="hg38", help="Use these lobSTR db") - p.add_option( + p.add_argument("--db", default="hg38", help="Use these lobSTR db") + p.add_argument( "--nofilter", default=False, action="store_true", @@ -1150,7 +1150,7 @@ def liftover(args): LiftOver CODIS/Y-STR markers. """ p = OptionParser(liftover.__doc__) - p.add_option( + p.add_argument( "--checkvalid", default=False, action="store_true", @@ -1192,24 +1192,24 @@ def trf(args): cparams = "1 1 2 80 5 200 2000" p = OptionParser(trf.__doc__) - p.add_option("--mismatch", default=31, type=int, help="Mismatch and gap penalty") - p.add_option( + p.add_argument("--mismatch", default=31, type=int, help="Mismatch and gap penalty") + p.add_argument( "--minscore", default=MINSCORE, type=int, help="Minimum score to report" ) - p.add_option("--period", default=6, type=int, help="Maximum period to report") - p.add_option( + p.add_argument("--period", default=6, type=int, help="Maximum period to report") + p.add_argument( "--lobstr", default=False, action="store_true", help="Generate output for lobSTR", ) - p.add_option( + p.add_argument( "--telomeres", default=False, action="store_true", help="Run telomere search: minscore=140 period=7", ) - p.add_option( + p.add_argument( "--centromeres", default=False, action="store_true", @@ -1267,7 +1267,7 @@ def batchlobstr(args): sample-name,s3-location """ p = OptionParser(batchlobstr.__doc__) - p.add_option("--sep", default=",", help="Separator for building commandline") + p.add_argument("--sep", default=",", help="Separator for building commandline") p.set_home("lobstr", default="s3://hli-mv-data-science/htang/str-build/lobSTR/") p.set_aws_opts(store="hli-mv-data-science/htang/str-data") opts, args = p.parse_args(args) @@ -1324,11 +1324,11 @@ def lobstr(args): (e.g. s3://hli-mv-data-science/htang/str-build/lobSTR/) """ p = OptionParser(lobstr.__doc__) - p.add_option( + p.add_argument( "--haploid", default="chrY,chrM", help="Use haploid model for these chromosomes" ) - p.add_option("--chr", help="Run only this chromosome") - p.add_option( + p.add_argument("--chr", help="Run only this chromosome") + p.add_argument( "--simulation", default=False, action="store_true", help="Simulation mode" ) p.set_home("lobstr", default="s3://hli-mv-data-science/htang/str-build/lobSTR/") @@ -1458,8 +1458,8 @@ def locus(args): db_choices = ("hg38", "hg19") p = OptionParser(locus.__doc__) - p.add_option("--tred", choices=INCLUDE, help="TRED name") - p.add_option("--ref", choices=db_choices, default="hg38", help="Reference genome") + p.add_argument("--tred", choices=INCLUDE, help="TRED name") + p.add_argument("--ref", choices=db_choices, default="hg38", help="Reference genome") p.set_home("lobstr") opts, args = p.parse_args(args) @@ -1511,7 +1511,7 @@ def lobstrindex(args): by str(). """ p = OptionParser(lobstrindex.__doc__) - p.add_option( + p.add_argument( "--notreds", default=False, action="store_true",