Exemplo n.º 1
0
def folder_parser(sup_parser: argparse):

    folder_parser = sup_parser.add_parser(
        'folder', help='Manage folders. Folders allows to group tasks')
    folder_subparser = folder_parser.add_subparsers(
        dest='action', metavar='', description='Commands to work with folders')
    folder_subparser.required = True

    create = folder_subparser.add_parser('create', help='Create new folder')
    create.add_argument('name', help='Folder name')

    show = folder_subparser.add_parser('show', help='Show folders  info')
    folder_show_parser(show)

    populate = folder_subparser.add_parser(
        'populate', help='Populate folder with provided task')
    populate.add_argument('-fid', '--folder_id', required=True, type=valid_int)
    populate.add_argument('-tid', '--task_id', required=True, type=valid_int)

    unpopulate = folder_subparser.add_parser('unpopulate',
                                             help='delete task from folder')
    unpopulate.add_argument('-fid',
                            '--folder_id',
                            required=True,
                            type=valid_int)
    unpopulate.add_argument('-tid', '--task_id', required=True, type=valid_int)

    edit = folder_subparser.add_parser('edit', help='Edit folder by id')
    edit.add_argument('folder_id', type=valid_int)
    edit.add_argument('name', help='Folder name')

    delete = folder_subparser.add_parser('delete', help='Delete folder by id')
    delete.add_argument('folder_id', type=valid_int)
Exemplo n.º 2
0
def reminder_parser(sup_parser: argparse):
    reminder_parser = sup_parser.add_parser(
        'reminder',
        help='Manage reminders. Reminders remind you about your tasks')
    reminder_subparser = reminder_parser.add_subparsers(
        dest='action',
        metavar='',
        description='Commands to work with reminders')

    reminder_subparser.required = True

    create = reminder_subparser.add_parser(
        'create', help='Create reminder for existing task')
    create.add_argument('task_id', help='Task id', type=valid_int)
    create.add_argument('date', help='Reminder date', type=valid_future_date)

    show = reminder_subparser.add_parser('show', help='Show reminders info')
    reminder_show_parser(show)

    edit = reminder_subparser.add_parser('edit', help='Edit reminder')
    edit.add_argument('reminder_id', help='Reminder id', type=valid_int)
    edit.add_argument('date', help='Reminder date', type=valid_future_date)

    delete = reminder_subparser.add_parser('delete',
                                           help='Delete reminder by id')
    delete.add_argument('reminder_id', type=valid_int)
Exemplo n.º 3
0
def plan_parser(sup_parser: argparse):

    plan_parser = sup_parser.add_parser(
        'plan', help='Manage plans. Plans allows to automate tasks creation')
    plan_subparser = plan_parser.add_subparsers(
        dest='action', metavar='', description='Commands to work with plans')

    plan_subparser.required = True

    create = plan_subparser.add_parser('create',
                                       help='Create plan for existing task')
    create.add_argument('task_id', help='task id', type=valid_int)
    create.add_argument('period_amount', help='Period amount', type=valid_int)
    create.add_argument('period',
                        help='Period type',
                        choices=[x.name.lower() for x in Period])

    create.add_argument('-s',
                        '--start_date',
                        type=valid_future_date,
                        help='Plan start date.',
                        required=True)
    create.add_argument('-r',
                        '--plan_amount',
                        type=valid_int,
                        help='How much times plan should be executed')
    create.add_argument('-e',
                        '--end_date',
                        type=valid_future_date,
                        help='Plan end date.')

    show = plan_subparser.add_parser('show', help='Show plans info')
    plan_show_parser(show)

    edit = plan_subparser.add_parser('edit', help='Edit plan')
    edit.add_argument('plan_id', help='plan_id', type=valid_int)
    edit.add_argument('-p',
                      '--period_amount',
                      help='Period amount',
                      type=valid_int)
    edit.add_argument('-t',
                      '--period',
                      help='Period type',
                      choices=[x.name.lower() for x in Period])
    edit.add_argument('-r',
                      '--plan_amount',
                      type=valid_int,
                      help='How much plan should be executed')
    edit.add_argument('-e',
                      '--end_date',
                      type=valid_future_date,
                      help='Plan end date.')

    delete = plan_subparser.add_parser('delete', help='Delete plan by id')
    delete.add_argument('plan_id', type=valid_int)
Exemplo n.º 4
0
def append_service_interfaces_to_parser(
    parent_parser: argparse,
    interfaces: Dict[str, BaseInterface],
    interface_group_name: Optional[str] = 'sub_interface'
) -> argparse.ArgumentParser:
    """
    Append multiple service interfaces to a single parser

    :param parent_parser:
    :param interfaces: A dictionary service interface packages where the key is the name of that interface,
                    and the value is the interface object itself.
    :param interface_group_name: A name identifying where in the component, interface, sub-interface hierarchy these
                                 service_interfaces should be placed
    :return: The parser object
    """

    for name, value in interfaces.items():
        if isinstance(value, tuple):
            interfaces, help_str = value
            new_section_parser = parent_parser.add_parser(name=name,
                                                          help=help_str)
            new_section_subparsers = new_section_parser.add_subparsers()
            append_service_interfaces_to_parser(
                parent_parser=new_section_subparsers,
                interfaces=interfaces,
                interface_group_name=interface_group_name)
        elif isinstance(value, dict):
            new_section_parser = parent_parser.add_parser(name=name,
                                                          help='<None Given>')
            new_section_subparsers = new_section_parser.add_subparsers()
            append_service_interfaces_to_parser(
                parent_parser=new_section_subparsers,
                interfaces=value,
                interface_group_name=interface_group_name)
        else:
            append_service_interface_to_parser(
                parent_parser=parent_parser,
                interface_name=name,
                interface=value,
                interface_group_name=interface_group_name)
    return parent_parser
Exemplo n.º 5
0
def user_parser(sup_parser: argparse):
    user_parser = sup_parser.add_parser(
        'user', help='Manage users. Sign up, login, logout, list all users')
    user_subparser = user_parser.add_subparsers(
        dest='action', metavar='', description='Commands to work with user')
    user_subparser.required = True

    create = user_subparser.add_parser('create', help='Register new user')
    create.add_argument('username')
    login = user_subparser.add_parser('login', help='Auth by username')
    login.add_argument('username')
    user_subparser.add_parser('logout', help='Logout user')
    user_subparser.add_parser('current', help='Show current user')
    user_subparser.add_parser('all', help='Show all users in app')
Exemplo n.º 6
0
def append_service_interface_to_parser(
    parent_parser: argparse,
    interface_name: str,
    interface: BaseInterface,
    interface_group_name: Optional[str] = 'interface'
) -> argparse.ArgumentParser:
    """
    Add an interface to an existing parser.

    :param parent_parser: The parent parser to add the interface too
    :param interface_name: The name of this interface as it will appear in the commandline utility
    :param interface: The interface object itself
    :param interface_group_name: A name identifying where in the component, interface, sub-interface hierarchy this
                                 service_interface should be placed
    :return: The parser object
    """
    from dynamite_nsm.cmd import service_interfaces
    from dynamite_nsm.cmd import config_object_interfaces
    from dynamite_nsm.cmd.config_object_interfaces import AnalyzersInterface, FilebeatTargetsInterface
    from dynamite_nsm.cmd.service_interfaces import MultipleResponsibilityInterface, SingleResponsibilityInterface, \
        SimpleConfigManagerInterface

    if not interface:
        return argparse.ArgumentParser()
    interface_group_name_kwargs = {interface_group_name: interface_name}
    sub_interface_parser = parent_parser.add_parser(
        interface_name, help=interface.interface_description)
    sub_interface_parser.set_defaults(**interface_group_name_kwargs)

    if isinstance(interface, SimpleConfigManagerInterface):
        service_interfaces.append_service_simple_config_management_interface_to_parser(
            parser=sub_interface_parser, interface=interface)
    elif isinstance(interface, SingleResponsibilityInterface):
        service_interfaces.append_service_single_responsibility_interface_to_parser(
            parser=sub_interface_parser, interface=interface)
    elif isinstance(interface, MultipleResponsibilityInterface):
        service_interfaces.append_service_multiple_responsibility_interface_to_parser(
            parser=sub_interface_parser, interface=interface)
    elif isinstance(interface, AnalyzersInterface):
        config_object_interfaces.append_config_object_analyzer_interface_to_parser(
            parser=sub_interface_parser, interface=interface)
    elif isinstance(interface, FilebeatTargetsInterface):
        config_object_interfaces.append_config_object_filebeat_targets_to_parser(
            parser=sub_interface_parser, interface=interface)

    return parent_parser
Exemplo n.º 7
0
def add_subparser_args(subparsers: argparse) -> argparse:
    """Add tool-specific arguments for remove-background.

    Args:
        subparsers: Parser object before addition of arguments specific to
            remove-background.

    Returns:
        parser: Parser object with additional parameters.

    """

    subparser = subparsers.add_parser("remove-background",
                                      description="Remove background RNA "
                                                  "from count matrix.",
                                      help="Remove background ambient RNA "
                                           "and barcode-swapped reads from "
                                           "a count matrix, producing a "
                                           "new count matrix and "
                                           "determining which barcodes "
                                           "contain real cells.")

    subparser.add_argument("--input", nargs=None, type=str,
                           dest='input_file', default=None,
                           required=True,
                           help="Data file on which to run tool, as either "
                                "_raw_gene_barcode_matrices_h5.h5 file, or "
                                "as the path containing the raw "
                                "matrix.mtx, barcodes.tsv, and genes.tsv "
                                "files. Supported for outputs of "
                                "CellRanger v2 and v3.")
    subparser.add_argument("--output", nargs=None, type=str,
                           dest='output_file', default=None,
                           required=True,
                           help="Output file location (the path must "
                                "exist, and the file name must have .h5 "
                                "extension).")
    subparser.add_argument("--expected-cells", nargs=None, type=int,
                           default=None,
                           dest="expected_cell_count",
                           help="Number of cells expected in the dataset "
                                "(a rough estimate within a factor of 2 "
                                "is sufficient).")
    subparser.add_argument("--total-droplets-included",
                           nargs=None, type=int,
                           default=consts.TOTAL_DROPLET_DEFAULT,
                           dest="total_droplets",
                           help="The number of droplets from the "
                                "rank-ordered UMI plot that will be "
                                "analyzed. The largest 'total_droplets' "
                                "droplets will have their cell "
                                "probabilities inferred as an output. (default: %(default)s)")
    subparser.add_argument("--model", nargs=None, type=str,
                           default="full",
                           choices=["simple", "ambient", "swapping", "full"],
                           dest="model",
                           help="Which model is being used for count data. "
                                " 'simple' does not model either ambient "
                                "RNA or random barcode swapping (for "
                                "debugging purposes -- not recommended).  "
                                "'ambient' assumes background RNA is "
                                "incorporated into droplets.  'swapping' "
                                "assumes background RNA comes from random "
                                "barcode swapping.  'full' uses a "
                                "combined ambient and swapping model.  "
                                "(default: %(default)s)")
    subparser.add_argument("--epochs", nargs=None, type=int, default=150,
                           dest="epochs",
                           help="Number of epochs to train. (default: %(default)s)")
    subparser.add_argument("--cuda",
                           dest="use_cuda", action="store_true",
                           help="Including the flag --cuda will run the "
                                "inference on a GPU.")
    subparser.add_argument("--low-count-threshold", type=int,
                           default=consts.LOW_UMI_CUTOFF,
                           dest="low_count_threshold",
                           help="Droplets with UMI counts below this "
                                "number are completely excluded from the "
                                "analysis.  This can help identify the "
                                "correct prior for empty droplet counts "
                                "in the rare case where empty counts "
                                "are extremely high (over 200). (default: %(default)s)")
    subparser.add_argument("--z-dim", type=int, default=100,
                           dest="z_dim",
                           help="Dimension of latent variable z. (default: %(default)s)")
    subparser.add_argument("--z-layers", nargs="+", type=int, default=[500],
                           dest="z_hidden_dims",
                           help="Dimension of hidden layers in the encoder "
                                "for z. (default: %(default)s)")
    subparser.add_argument("--training-fraction",
                           type=float, nargs=None,
                           default=consts.TRAINING_FRACTION,
                           dest="training_fraction",
                           help="Training detail: the fraction of the "
                                "data used for training.  The rest is never "
                                "seen by the inference algorithm.  Speeds up "
                                "learning. (default: %(default)s)")
    subparser.add_argument("--empty-drop-training-fraction",
                           type=float, nargs=None,
                           default=consts.FRACTION_EMPTIES,
                           dest="fraction_empties",
                           help="Training detail: the fraction of the "
                                "training data each epoch "
                                "that is drawn (randomly sampled) from "
                                "surely empty droplets. (default: %(default)s)")
    subparser.add_argument("--blacklist-genes", nargs="+", type=int,
                           default=[],
                           dest="blacklisted_genes",
                           help="Integer indices of genes to ignore "
                                "entirely.  In the output count matrix, "
                                "the counts for these genes will be set "
                                "to zero.")
    subparser.add_argument("--fpr", nargs="+",
                           type=float, default=[0.01],
                           dest="fpr",
                           help="Target false positive rate in (0, 1).  A false "
                                "positive is a true signal count that is "
                                "erroneously removed.  More background removal "
                                "is accompanied by more signal removal "
                                "at high values of FPR.  You can specify "
                                "multiple values, which will create multiple "
                                "output files. (default: %(default)s)")
    subparser.add_argument("--exclude-antibody-capture",
                           dest="exclude_antibodies", action="store_true",
                           help="Including the flag --exclude-antibody-capture "
                                "will cause remove-background to operate on "
                                "gene counts only, ignoring other features.")
    subparser.add_argument("--learning-rate", nargs=None,
                           type=float, default=1e-4,
                           dest="learning_rate",
                           help="Training detail: lower learning rate for "
                                "inference. A OneCycle learning rate schedule "
                                "is used, where the upper learning rate is ten "
                                "times this value. (For this value, probably "
                                "do not exceed 1e-3). (default: %(default)s)")
    subparser.add_argument("--final-elbo-fail-fraction", type=float,
                           help="Training is considered to have failed if "
                                "final_training_ELBO >= best_training_ELBO*(1+FINAL_ELBO_FAIL_FRACTION). "
                                "(default: do not fail training based on final_training_ELBO)")
    subparser.add_argument("--epoch-elbo-fail-fraction", type=float,
                           help="Training is considered to have failed if "
                                "current_epoch_training_ELBO >= previous_epoch_training_ELBO*(1+EPOCH_ELBO_FAIL_FRACTION). "
                                "(default: do not fail training based on epoch_training_ELBO)")
    subparser.add_argument("--num-training-tries", type=int, default=1,
                           help="Number of times to attempt to train the model.  Each subsequent "
                                "attempt the learning rate is multiplied by LEARNING_RATE_RETRY_MULT. "
                                "(default: %(default)s)")
    subparser.add_argument("--learning-rate-retry-mult", type=float, default=0.5,
                           help="Learning rate is multiplied by this amount each time "
                                "(default: %(default)s)")

    subparser.add_argument("--posterior-batch-size", type=int, default=consts.PROP_POSTERIOR_BATCH_SIZE,
                           dest="posterior_batch_size",
                           help="Size of batches when creating the posterior.  Reduce this to avoid "
                                "running out of GPU memory creating the posterior (will be slower). "
                                "(default: %(default)s)")
    subparser.add_argument("--cells-posterior-reg-calc", type=int, default=consts.CELLS_POSTERIOR_REG_CALC,
                           dest="cells_posterior_reg_calc",
                           help="Number of cells used to estimate posterior regularization lambda. "
                                "(default: %(default)s)")

    return subparsers
Exemplo n.º 8
0
    def add_subparser_args(self, subparsers: argparse) -> argparse:
        """Add tool-specific arguments for remove_background.

        Args:
            subparsers: Parser object before addition of arguments specific to
                remove_background.

        Returns:
            parser: Parser object with additional parameters.

        """

        subparser = subparsers.add_parser(
            self.name,
            description="Remove background RNA from "
            "count matrix.",
            help="Remove background ambient RNA and "
            "barcode-swapped reads from a count "
            "matrix, producing a new count matrix "
            "and determining which barcodes "
            "contain real cells.")

        subparser.add_argument("--input",
                               nargs="+",
                               type=str,
                               dest='input_files',
                               default=[],
                               help="Data files on which to run tool, as "
                               "_raw_gene_barcode_matrices_h5.h5 files.")
        subparser.add_argument(
            "--output",
            nargs="+",
            type=str,
            dest='output_files',
            default=[],
            help="Path to location of output data files, which "
            "will be .h5 files.")
        subparser.add_argument("--epochs",
                               type=int,
                               default=150,
                               dest="epochs",
                               help="Number of epochs to train.")
        subparser.add_argument("--z_dim",
                               type=int,
                               default=20,
                               dest="z_dim",
                               help="Dimension of latent variable z.")
        subparser.add_argument(
            "--z_layers",
            nargs="+",
            type=int,
            default=[500],
            dest="z_hidden_dims",
            help="Dimension of hidden layers in the encoder for z.")
        subparser.add_argument(
            "--d_layers",
            nargs="+",
            type=int,
            default=[5, 2, 2],
            dest="d_hidden_dims",
            help="Dimension of hidden layers in the encoder for d.")
        subparser.add_argument(
            "--p_layers",
            nargs="+",
            type=int,
            default=[100, 10],
            dest="p_hidden_dims",
            help="Dimension of hidden layers in the encoder for p.")
        subparser.add_argument(
            "--expected_cells",
            nargs="+",
            type=int,
            default=[None],
            dest="expected_cell_count",
            help="Number of cells expected in each dataset.")
        subparser.add_argument(
            "--additional_barcodes",
            nargs="+",
            type=int,
            default=[None],
            dest="additional_barcodes",
            help="The number of additional droplets after the "
            "number of expected cells "
            "that have any chance of containing cells.")
        subparser.add_argument(
            "--empty_drop_training_fraction",
            type=float,
            default=0.5,
            dest="fraction_empties",
            help="Fraction of the training data that should be "
            "empty droplets.")
        subparser.add_argument(
            "--training_fraction",
            type=float,
            default=0.95,
            dest="training_fraction",
            help="Fraction of the data to use for training.")
        subparser.add_argument("--blacklist_genes",
                               nargs="+",
                               type=int,
                               default=[],
                               dest="blacklisted_genes",
                               help="Indices of genes to ignore entirely.")
        subparser.add_argument(
            "--model",
            nargs="+",
            type=str,
            default=["full"],
            choices=["simple", "ambient", "swapping", "full"],
            dest="model",
            help="Which model is being used for count data.  "
            "'simple' does not model background or ambient "
            "RNA.  'ambient' assumes background RNA is "
            "incorporated into droplets.  'swapping' assumes "
            "background RNA comes from barcode swapping. "
            "'full' uses a combined ambient and swapping "
            "model.")
        subparser.add_argument(
            "--transform_counts",
            nargs=1,
            type=str,
            default=["identity"],
            choices=["identity", "log", "sqrt"],
            dest="transform",
            help="Transformation to apply to count data prior "
            "to running inference.")
        subparser.add_argument(
            "--learning_rate",
            type=float,
            default=1e-3,
            dest="learning_rate",
            help="Learning rate for inference (probably don't "
            "exceed 1e-3).")
        # subparser.add_argument("--lambda", type=float, default=0.,
        #                        dest="lambda_reg",
        #                        help="Regularization parameter.  Default zero.  "
        #                             "L1 regularizer applied to decoder.")
        subparser.add_argument(
            "--cuda",
            dest="use_cuda",
            action="store_true",
            help="Including the flag --cuda will run the inference "
            "on a GPU.")
        subparser.add_argument("--decaying_average_baseline",
                               dest="use_decaying_average_baseline",
                               action="store_true",
                               help="Including the flag "
                               "--decaying_average_baseline will use a "
                               "decaying average baseline during inference.")
        subparser.add_argument("--use_IAF",
                               dest="use_IAF",
                               action="store_true",
                               help="Including the flag "
                               "--use_IAF will use an inverse autoregressive "
                               "flow during inference to allow more "
                               "flexibility in the learned posterior.")
        subparser.add_argument("--low_count_threshold",
                               type=int,
                               default=30,
                               dest="low_count_threshold",
                               help="Droplets with UMI counts below this are"
                               "completely excluded from the analysis.  This "
                               "can help adjust the prior for empty droplet "
                               "counts in the rare case where empty counts "
                               "are extremely high (over 200).")
        subparser.add_argument(
            "--test",
            dest="test",
            action="store_true",
            help="Including the flag --test will run tests only, "
            "and disregard other input parameters.")

        return subparsers
Exemplo n.º 9
0
def task_parser(sup_parser: argparse):
    task_parser = sup_parser.add_parser(
        'task', help='Manage tasks. Task is the main application object.')
    task_subparser = task_parser.add_subparsers(
        dest='action', metavar='', description='Commands to work with tasks')
    task_subparser.required = True

    create = task_subparser.add_parser('create', help='Create new task')
    create.add_argument('name', help='Task name')
    create.add_argument('-d', '--description', help='Task description')
    create.add_argument('-s',
                        '--start_date',
                        type=valid_date,
                        help='Start date (current time by default)')
    create.add_argument('-e', '--end_date', type=valid_date, help='End date')
    create.add_argument('-p',
                        '--parent_task_id',
                        type=valid_int,
                        help='Parent task id')
    create.add_argument('--priority',
                        type=str,
                        choices=[x.name.lower() for x in TaskPriority])
    create.add_argument('--status',
                        type=str,
                        choices=[x.name.lower() for x in TaskStatus])
    create.add_argument('--event',
                        help='Mark as event. No by default settings',
                        choices=['yes', 'no'])

    show = task_subparser.add_parser('show', help='Show tasks')
    task_show_parser(show)

    edit = task_subparser.add_parser('edit', help='Edit task with provided id')
    edit.add_argument('-tid', '--task_id', required=True, type=valid_int)
    edit.add_argument('-n', '--name', help='Task name')
    edit.add_argument('-d', '--description', help='Task description')
    edit.add_argument('-s', '--start_date', type=valid_date, help='Start date')
    edit.add_argument('-e', '--end_date', type=valid_date, help='End date')
    edit.add_argument('--priority',
                      type=str,
                      choices=[x.name.lower() for x in TaskPriority])
    edit.add_argument('--status',
                      type=str,
                      choices=[x.name.lower() for x in TaskStatus])
    edit.add_argument('--event',
                      choices=['yes', 'no'],
                      help='Mark as event. No by default settings')

    share = task_subparser.add_parser('share', help='Share task with user')
    share.add_argument('-tid',
                       '--task_id',
                       type=valid_int,
                       help='Id of task to be shared',
                       required=True)
    share.add_argument('-ur',
                       '--user_receiver',
                       type=str,
                       help='User name to share task with',
                       required=True)

    unshare = task_subparser.add_parser('unshare',
                                        help='Unshare shared task with user')
    unshare.add_argument('-tid',
                         '--task_id',
                         help='Task id',
                         required=True,
                         type=valid_int)
    unshare.add_argument('-urn',
                         '--user_receiver',
                         help='User name to unshare task with',
                         required=True,
                         type=str)

    assign = task_subparser.add_parser('assign', help='Assign task executor')
    assign.add_argument('-tid',
                        '--task_id',
                        help='Task id',
                        required=True,
                        type=valid_int)
    assign.add_argument('-urn',
                        '--user_receiver',
                        help='User name to assign task',
                        required=True,
                        type=str)

    subtask = task_subparser.add_parser(
        'add_subtask',
        help='Set task with task_id as the subtask of task with parent_id')
    subtask.add_argument('-tid',
                         '--task_id',
                         required=True,
                         help='Task id',
                         type=valid_int)
    subtask.add_argument('-pid',
                         '--parent_task_id',
                         help='Parent task id',
                         required=True,
                         type=valid_int)

    subtask = task_subparser.add_parser(
        'detach', help='Remove relation between task and parent task')
    subtask.add_argument('-tid',
                         '--task_id',
                         required=True,
                         help='Task id to detach from parent task',
                         type=valid_int)

    archive = task_subparser.add_parser('archive', help='Archive task')
    archive.add_argument('--subtasks',
                         action='store_true',
                         help='Archive subtasks too')

    archive.add_argument('task_id', help='task id', type=valid_int)
    done = task_subparser.add_parser('done', help='Done task')
    done.add_argument('task_id', help='task id', type=valid_int)

    search = task_subparser.add_parser(
        'search', help='Case insensitive task search by name')
    search.add_argument('name', help='Task name')

    filter = task_subparser.add_parser('filter',
                                       help='Search tasks by specified params')
    filter.add_argument('-n', '--name', help='Task name')
    filter.add_argument('-d', '--description', help='Task description')
    filter.add_argument('-s',
                        '--start_date',
                        type=valid_date,
                        help='Task start date from')
    filter.add_argument('-e',
                        '--end_date',
                        type=valid_date,
                        help='Task end date till to')
    filter.add_argument('-p',
                        '--parent_task_id',
                        type=valid_int,
                        help='Parent task id')
    filter.add_argument('--priority',
                        choices=[x.name.lower() for x in TaskPriority],
                        help='Task priority')
    filter.add_argument('--status',
                        choices=[x.name.lower() for x in TaskStatus],
                        help='Task status')
    filter.add_argument('--event', choices=['yes', 'no'], help='Is Event')

    delete = task_subparser.add_parser('delete',
                                       help='Delete task with provided id')
    delete.add_argument('task_id', type=valid_int)
Exemplo n.º 10
0
def add_subparser_args(subparsers: argparse) -> argparse:
    """Add tool-specific arguments for remove-background.

    Args:
        subparsers: Parser object before addition of arguments specific to
            remove-background.

    Returns:
        parser: Parser object with additional parameters.

    """

    subparser = subparsers.add_parser("remove-background",
                                      description="Remove background RNA "
                                                  "from count matrix.",
                                      help="Remove background ambient RNA "
                                           "and barcode-swapped reads from "
                                           "a count matrix, producing a "
                                           "new count matrix and "
                                           "determining which barcodes "
                                           "contain real cells.")

    subparser.add_argument("--input", nargs=None, type=str,
                           dest='input_file', default=None,
                           required=True,
                           help="Data file on which to run tool, as either "
                                "_raw_gene_barcode_matrices_h5.h5 file, or "
                                "as the path containing the raw "
                                "matrix.mtx, barcodes.tsv, and genes.tsv "
                                "files. Supported for outputs of "
                                "CellRanger v2 and v3.")
    subparser.add_argument("--output", nargs=None, type=str,
                           dest='output_file', default=None,
                           required=True,
                           help="Output file location (the path must "
                                "exist, and the file name must have .h5 "
                                "extension).")
    subparser.add_argument("--expected-cells", nargs=None, type=int,
                           default=None,
                           dest="expected_cell_count",
                           help="Number of cells expected in the dataset "
                                "(a rough estimate within a factor of 2 "
                                "is sufficient).")
    subparser.add_argument("--total-droplets-included",
                           nargs=None, type=int,
                           default=consts.TOTAL_DROPLET_DEFAULT,
                           dest="total_droplets",
                           help="The number of droplets from the "
                                "rank-ordered UMI plot that will be "
                                "analyzed. The largest 'total_droplets' "
                                "droplets will have their cell "
                                "probabilities inferred as an output.")
    subparser.add_argument("--model", nargs=None, type=str, default="full",
                           choices=["simple", "ambient",
                                    "swapping", "full"],
                           dest="model",
                           help="Which model is being used for count data. "
                                " 'simple' does not model either ambient "
                                "RNA or random barcode swapping (for "
                                "debugging purposes -- not recommended).  "
                                "'ambient' assumes background RNA is "
                                "incorporated into droplets.  'swapping' "
                                "assumes background RNA comes from random "
                                "barcode swapping.  'full' uses a "
                                "combined ambient and swapping model.  "
                                "Defaults to 'full'.")
    subparser.add_argument("--epochs", nargs=None, type=int, default=150,
                           dest="epochs",
                           help="Number of epochs to train.")
    subparser.add_argument("--cuda",
                           dest="use_cuda", action="store_true",
                           help="Including the flag --cuda will run the "
                                "inference on a GPU.")
    subparser.add_argument("--low-count-threshold", type=int,
                           default=consts.LOW_UMI_CUTOFF,
                           dest="low_count_threshold",
                           help="Droplets with UMI counts below this "
                                "number are completely excluded from the "
                                "analysis.  This can help identify the "
                                "correct prior for empty droplet counts "
                                "in the rare case where empty counts "
                                "are extremely high (over 200).")
    subparser.add_argument("--z-dim", type=int, default=20,
                           dest="z_dim",
                           help="Dimension of latent variable z.")
    subparser.add_argument("--z-layers", nargs="+", type=int, default=[500],
                           dest="z_hidden_dims",
                           help="Dimension of hidden layers in the encoder "
                                "for z.")
    subparser.add_argument("--d-layers", nargs="+", type=int,
                           default=[5, 2, 2],
                           dest="d_hidden_dims",
                           help="Dimension of hidden layers in the encoder "
                                "for d.")
    subparser.add_argument("--p-layers", nargs="+", type=int,
                           default=[100, 10],
                           dest="p_hidden_dims",
                           help="Dimension of hidden layers in the encoder "
                                "for p.")
    subparser.add_argument("--empty-drop-training-fraction",
                           type=float, nargs=None,
                           default=consts.FRACTION_EMPTIES,
                           dest="fraction_empties",
                           help="Training detail: the fraction of the "
                                "training data each epoch "
                                "that is drawn (randomly sampled) from "
                                "surely empty droplets.")
    subparser.add_argument("--blacklist-genes", nargs="+", type=int,
                           default=[],
                           dest="blacklisted_genes",
                           help="Integer indices of genes to ignore "
                                "entirely.  In the output count matrix, "
                                "the counts for these genes will be set "
                                "to zero.")
    subparser.add_argument("--learning-rate", nargs=None,
                           type=float, default=1e-3,
                           dest="learning_rate",
                           help="Training detail: learning rate for "
                                "inference (probably "
                                "do not exceed 1e-3).")

    return subparsers