Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update module docstring usage #1130

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions augur/align.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,8 @@ def register_arguments(parser):
parser.add_argument('--debug', action="store_true", default=False, help="Produce extra files (e.g. pre- and post-aligner files) which can help with debugging poor alignments.")


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("align", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("align", **kwargs)
register_arguments(parser)
return parser

Expand Down
4 changes: 2 additions & 2 deletions augur/ancestral.py
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,8 @@ def collect_mutations_and_sequences(tt, infer_tips=False, full_sequences=False,
return {"nodes": data, "mask": mask}


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("ancestral", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("ancestral", **kwargs)
parser.add_argument('--tree', '-t', required=True, help="prebuilt Newick")
parser.add_argument('--alignment', '-a', help="alignment in fasta or VCF format")
parser.add_argument('--output-node-data', type=str, help='name of JSON file to save mutations and ancestral sequences to')
Expand Down
6 changes: 4 additions & 2 deletions augur/argparse_.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
"""
from argparse import Action, ArgumentDefaultsHelpFormatter

from augur.utils import first_line


def add_default_command(parser):
"""
Expand Down Expand Up @@ -37,7 +39,7 @@ def add_command_subparsers(subparsers, commands, command_attribute='__command__'
"""
for command in commands:
# Allow each command to register its own subparser
subparser = command.register_parser(subparsers)
subparser = command.register_parser(subparsers, help=first_line(command.__doc__))

# Add default attribute for command module
if command_attribute:
Expand All @@ -48,7 +50,7 @@ def add_command_subparsers(subparsers, commands, command_attribute='__command__'
subparser.formatter_class = ArgumentDefaultsHelpFormatter

if not subparser.description and command.__doc__:
subparser.description = command.__doc__
subparser.description = first_line(command.__doc__)

# If a command doesn't have its own run() function, then print its help when called.
if not getattr(command, "run", None):
Expand Down
4 changes: 2 additions & 2 deletions augur/clades.py
Original file line number Diff line number Diff line change
Expand Up @@ -248,8 +248,8 @@ def get_reference_sequence_from_root_node(all_muts, root_name):
return ref


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("clades", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("clades", **kwargs)
parser.add_argument('--tree', help="prebuilt Newick -- no tree will be built if provided")
parser.add_argument('--mutations', nargs='+', help='JSON(s) containing ancestral and tip nucleotide and/or amino-acid mutations ')
parser.add_argument('--reference', nargs='+', help='fasta files containing reference and tip nucleotide and/or amino-acid sequences ')
Expand Down
4 changes: 2 additions & 2 deletions augur/curate/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,9 +89,9 @@ def create_shared_parser():
return shared_parser


def register_parser(parent_subparsers):
def register_parser(parent_subparsers, **kwargs):
shared_parser = create_shared_parser()
parser = parent_subparsers.add_parser("curate", help=__doc__)
parser = parent_subparsers.add_parser("curate", **kwargs)

# Add print_help so we can run it when no subcommands are called
parser.set_defaults(print_help = parser.print_help)
Expand Down
6 changes: 2 additions & 4 deletions augur/curate/normalize_strings.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,11 @@
"""
import unicodedata

from augur.utils import first_line


def register_parser(parent_subparsers):
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("normalize-strings",
parents=[parent_subparsers.shared_parser],
help=first_line(__doc__))
**kwargs)

optional = parser.add_argument_group(title="OPTIONAL")
optional.add_argument("--form", default="NFC", choices=["NFC", "NFKC", "NFD", "NFKD"],
Expand Down
4 changes: 2 additions & 2 deletions augur/curate/passthru.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,10 @@
"""


def register_parser(parent_subparsers):
def register_parser(parent_subparsers, **kwargs):
return parent_subparsers.add_parser("passthru",
parents=[parent_subparsers.shared_parser],
help=__doc__)
**kwargs)


def run(args, records):
Expand Down
6 changes: 3 additions & 3 deletions augur/distance.py
Original file line number Diff line number Diff line change
Expand Up @@ -159,7 +159,7 @@

from .frequency_estimators import timestamp_to_float
from .reconstruct_sequences import load_alignments
from .utils import annotate_parents_for_tree, first_line, read_node_data, write_json
from .utils import annotate_parents_for_tree, read_node_data, write_json


def read_distance_map(map_file):
Expand Down Expand Up @@ -626,8 +626,8 @@ def get_distances_to_all_pairs(tree, sequences_by_node_and_gene, distance_map, e
return distances_by_node


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("distance", help=first_line(__doc__))
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("distance", **kwargs)
parser.add_argument("--tree", help="Newick tree", required=True)
parser.add_argument("--alignment", nargs="+", help="sequence(s) to be used, supplied as FASTA files", required=True)
parser.add_argument('--gene-names', nargs="+", type=str, help="names of the sequences in the alignment, same order assumed", required=True)
Expand Down
4 changes: 2 additions & 2 deletions augur/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
]


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("export", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("export", **kwargs)
# Add subparsers for subcommands
metavar_msg ="Augur export now needs you to define the JSON version " + \
"you want, e.g. `augur export v2`."
Expand Down
4 changes: 2 additions & 2 deletions augur/export_v1.py
Original file line number Diff line number Diff line change
Expand Up @@ -331,8 +331,8 @@ def add_option_args(parser):
return options


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("v1", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("v1", **kwargs)
add_core_args(parser)
add_option_args(parser)
parser.add_argument("--v1", help=SUPPRESS, default=True)
Expand Down
4 changes: 2 additions & 2 deletions augur/export_v2.py
Original file line number Diff line number Diff line change
Expand Up @@ -820,8 +820,8 @@ def node_data_prop_is_normal_trait(name):
return True


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("v2", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("v2", **kwargs)

required = parser.add_argument_group(
title="REQUIRED"
Expand Down
4 changes: 2 additions & 2 deletions augur/filter/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,8 +72,8 @@ def register_arguments(parser):
parser.set_defaults(probabilistic_sampling=True)


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("filter", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("filter", **kwargs)
register_arguments(parser)
return parser

Expand Down
4 changes: 2 additions & 2 deletions augur/frequencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@
from .utils import read_node_data, write_json


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("frequencies", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("frequencies", **kwargs)
# Shared arguments
parser.add_argument('--method', choices=["diffusion", "kde"], required=True,
help="method by which frequencies should be estimated")
Expand Down
5 changes: 2 additions & 3 deletions augur/import_/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,15 +2,14 @@
Import analyses into augur pipeline from other systems
"""
from augur.argparse_ import add_command_subparsers
from augur.utils import first_line
from . import beast

SUBCOMMANDS = [
beast,
]

def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("import", help=first_line(__doc__))
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("import", **kwargs)
metavar_msg = "Import analyses into augur pipeline from other systems"
subparsers = parser.add_subparsers(title="TYPE",
metavar=metavar_msg)
Expand Down
7 changes: 4 additions & 3 deletions augur/import_/beast.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
"""
"""Import BEAST analysis.

Parse a BEAST MCC tree for further analysis in augur or
export for auspice v2+ (using `augur export v2` or greater).
"""
Expand All @@ -13,11 +14,11 @@
from treetime import TreeAnc
from augur.utils import write_json

def register_parser(parent_subparsers):
def register_parser(parent_subparsers, **kwargs):
"""
Arguments available to `augur import beast`
"""
beast_parser = parent_subparsers.add_parser('beast', help="Import beast analysis")
beast_parser = parent_subparsers.add_parser('beast', **kwargs)
beast_parser.add_argument("--beast", help=SUPPRESS, default=True) # used to disambiguate subcommands
beast_parser.add_argument('--mcc', required=True, help="BEAST MCC tree")
beast_parser.add_argument('--most-recent-tip-date', default=0, type=float, help='Numeric date of most recent tip in tree (--tip-date-regex, --tip-date-format and --tip-date-delimeter are ignored if this is set)')
Expand Down
4 changes: 2 additions & 2 deletions augur/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@
from .io.sequences import read_sequences
from .io.vcf import is_vcf, read_vcf

def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("index", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("index", **kwargs)
parser.add_argument('--sequences', '-s', required=True, help="sequences in FASTA or VCF formats. Augur will summarize the content of FASTA sequences and only report the names of strains found in a given VCF.")
parser.add_argument('--output', '-o', help="tab-delimited file containing the number of bases per sequence in the given file. Output columns include strain, length, and counts for A, C, G, T, N, other valid IUPAC characters, ambiguous characters ('?' and '-'), and other invalid characters.", required=True)
parser.add_argument('--verbose', '-v', action="store_true", help="print index statistics to stdout")
Expand Down
4 changes: 2 additions & 2 deletions augur/lbi.py
Original file line number Diff line number Diff line change
Expand Up @@ -79,8 +79,8 @@ def calculate_LBI(tree, attr="lbi", tau=0.4, transform=lambda x:x, normalize=Tru
setattr(node, attr, node.attr[attr])


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("lbi", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("lbi", **kwargs)
parser.add_argument("--tree", help="Newick tree", required=True)
parser.add_argument("--branch-lengths", help="JSON with branch lengths and internal node dates estimated by TreeTime", required=True)
parser.add_argument("--output", help="JSON file with calculated distances stored by node name and attribute name", required=True)
Expand Down
4 changes: 2 additions & 2 deletions augur/mask.py
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ def register_arguments(parser):
parser.add_argument('--no-cleanup', dest="cleanup", action="store_false",
help="Leave intermediate files around. May be useful for debugging")

def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("mask", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("mask", **kwargs)
register_arguments(parser)
return parser

Expand Down
5 changes: 2 additions & 3 deletions augur/measurements/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
Create JSON files suitable for visualization within the measurements panel of Auspice.
"""
from augur.argparse_ import add_command_subparsers
from augur.utils import first_line
from . import export, concat

SUBCOMMANDS = [
Expand All @@ -11,8 +10,8 @@
]


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("measurements", help=first_line(__doc__))
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("measurements", **kwargs)
# Add subparsers for subcommands
subparsers = parser.add_subparsers(dest='subcommand')
add_command_subparsers(subparsers, SUBCOMMANDS)
Expand Down
6 changes: 3 additions & 3 deletions augur/measurements/concat.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,15 @@
"""
import sys

from augur.utils import first_line, write_json
from augur.utils import write_json
from augur.validate import (
measurements as read_measurements_json,
ValidateError
)


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("concat", help=first_line(__doc__))
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("concat", **kwargs)

required = parser.add_argument_group(
title="REQUIRED"
Expand Down
6 changes: 3 additions & 3 deletions augur/measurements/export.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
import sys

from augur.argparse_ import HideAsFalseAction
from augur.utils import first_line, write_json
from augur.utils import write_json
from augur.validate import (
measurements as read_measurements_json,
measurements_collection_config as read_collection_config_json,
Expand All @@ -22,8 +22,8 @@
}


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("export", help=first_line(__doc__))
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("export", **kwargs)

required = parser.add_argument_group(
title="REQUIRED"
Expand Down
4 changes: 2 additions & 2 deletions augur/parse.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,8 @@ def parse_sequence(sequence, fields, strain_key="strain", separator="|", prettif
return sequence, metadata


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("parse", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("parse", **kwargs)
parser.add_argument('--sequences', '-s', required=True, help="sequences in fasta or VCF format")
parser.add_argument('--output-sequences', help="output sequences file")
parser.add_argument('--output-metadata', help="output metadata file")
Expand Down
4 changes: 2 additions & 2 deletions augur/reconstruct_sequences.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,8 @@



def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("reconstruct-sequences", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("reconstruct-sequences", **kwargs)
parser.add_argument('--tree', required=True, help="tree as Newick file")
parser.add_argument('--gene', type=str, help="gene to translate (list or file containing list)")
parser.add_argument('--mutations', required=True, type=str, help="json file containing mutations "
Expand Down
4 changes: 2 additions & 2 deletions augur/refine.py
Original file line number Diff line number Diff line change
Expand Up @@ -93,8 +93,8 @@ def collect_node_data(T, attributes):
return data


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("refine", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("refine", **kwargs)
parser.add_argument('--alignment', '-a', help="alignment in fasta or VCF format")
parser.add_argument('--tree', '-t', required=True, help="prebuilt Newick")
parser.add_argument('--metadata', type=str, metavar="FILE", help="sequence metadata, as CSV or TSV")
Expand Down
4 changes: 2 additions & 2 deletions augur/sequence_traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -290,8 +290,8 @@ def attach_features(annotations, label, count):
return seq_feature_dict


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("sequence-traits", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("sequence-traits", **kwargs)
parser.add_argument('--ancestral-sequences', type=str, help="nucleotide alignment (VCF) to search for sequence traits in (can be generated from 'ancestral' using '--output-vcf')")
parser.add_argument('--translations', type=str, help="AA alignment to search for sequence traits in (can include ancestral sequences)")
parser.add_argument('--vcf-reference', type=str, help='fasta file of the sequence the nucleotide VCF was mapped to')
Expand Down
4 changes: 2 additions & 2 deletions augur/titers.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
from .argparse_ import add_default_command


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("titers", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("titers", **kwargs)
subparsers = parser.add_subparsers()
add_default_command(parser)

Expand Down
4 changes: 2 additions & 2 deletions augur/traits.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,15 +97,15 @@ def mugration_inference(tree=None, seq_meta=None, field='country', confidence=Tr
return tt.tree, tt.gtr, letter_to_state


def register_parser(parent_subparsers):
def register_parser(parent_subparsers, **kwargs):
"""Add subcommand specific arguments

Parameters
----------
parser : argparse
subcommand argument parser
"""
parser = parent_subparsers.add_parser("traits", help=__doc__)
parser = parent_subparsers.add_parser("traits", **kwargs)
parser.add_argument('--tree', '-t', required=True, help="tree to perform trait reconstruction on")
parser.add_argument('--metadata', required=True, metavar="FILE", help="table with metadata, as CSV or TSV")
parser.add_argument('--weights', required=False, help="tsv/csv table with equilibrium probabilities of discrete states")
Expand Down
4 changes: 2 additions & 2 deletions augur/translate.py
Original file line number Diff line number Diff line change
Expand Up @@ -302,8 +302,8 @@ def get_genes_from_file(fname):
return unique_genes


def register_parser(parent_subparsers):
parser = parent_subparsers.add_parser("translate", help=__doc__)
def register_parser(parent_subparsers, **kwargs):
parser = parent_subparsers.add_parser("translate", **kwargs)
parser.add_argument('--tree', help="prebuilt Newick -- no tree will be built if provided")
parser.add_argument('--ancestral-sequences', type=str, help='JSON (fasta input) or VCF (VCF input) containing ancestral and tip sequences')
parser.add_argument('--reference-sequence', required=True,
Expand Down
Loading