Ejemplo n.º 1
0
def _check_there_will_be_output(module, args):
    predicted_output = module.report_prediction(args)

    if not predicted_output:
        message = ("Executing the {} command with the input [{}] would not "
                   "create any output files. Review inputs and try again.")\
                   .format(args.subparser_name, args.input)
        raise utils.UsageError(message)
Ejemplo n.º 2
0
def _check_input_readable(dummy, args):
    try:
        if os.path.isdir(args.input):
            os.listdir(args.input)
        else:
            open(args.input, "r").close()
    except (OSError, IOError):
        raise utils.UsageError(("Specified input [{}] cannot be read. Review "
                                "inputs and try again.").format(args.input))
Ejemplo n.º 3
0
def _check_output_correct_type(module_name, output_path, required_type):
    actual_type = _actual_type(output_path)
    if required_type != actual_type:
        raise utils.UsageError(("The {} command outputs a {}, but the "
                                "specified output [{}] is a {}. "
                                "Review inputs and try again.")\
                                 .format(module_name,
                                         required_type,
                                         output_path,
                                         actual_type))
Ejemplo n.º 4
0
def _create_temp_working_dir(dummy, args):
    try:
        _makepath(args.temp_working_dir)
        if args.required_output_type == "directory":
            _makepath(args.output)
    except OSError:
        parent_dir = os.path.dirname(args.temp_working_dir)
        raise utils.UsageError(("Jacquard cannot write to output directory "
                                "[{}]. Review inputs and try again.")\
                                .format(parent_dir))
Ejemplo n.º 5
0
def _check_overwrite_existing_files(module, args):
    output = args.output_path
    if not os.path.isdir(output):
        output = os.path.dirname(output)

    existing_output_paths = sorted(glob.glob(os.path.join(output, "*")))
    existing_output = set([os.path.basename(i) for i in existing_output_paths])
    predicted_output = module.report_prediction(args)
    collisions = sorted(list(existing_output.intersection(predicted_output)))

    if collisions and not args.force:
        message = _build_collision_message(args.subparser_name, collisions)
        raise utils.UsageError(message)
Ejemplo n.º 6
0
def _check_input_correct_type(dummy, args):
    module_name = args.subparser_name
    input_path = args.input
    required_type = args.required_input_type
    actual_type = _actual_type(input_path)
    if required_type != actual_type:
        raise utils.UsageError(("The {} command requires a {} as "
                                "input, but the specified input [{}] is a {}. "
                                "Review inputs and try again.") \
                                 .format(module_name,
                                         required_type,
                                         input_path,
                                         actual_type))
Ejemplo n.º 7
0
def _get_format_tag_regex(args):
    if args.tags and args.include_all:
        msg = (
            "Unable to process command-line arguments. --include_format_tags cannot "
            "be specified if --include_all is specified.")
        raise utils.UsageError(msg)

    if args.include_all:
        format_tag_regex = ['.*']
    elif args.tags:
        format_tag_regex = args.tags.split(",")
    else:
        format_tag_regex = _DEFAULT_INCLUDED_FORMAT_TAGS

    return format_tag_regex
Ejemplo n.º 8
0
def _check_snp_indel_pairings(altered_file_names, args):
    if not set([len(i) for i in altered_file_names.values()]) == set([1]):
        if not args.allow_inconsistent_sample_sets:
            error = 0
            for file_names in altered_file_names.values():
                if len(file_names) % 2 != 0:
                    message = ("File {} was missing a "
                               "corresponding snp/indel file.")
                    logger.error(message, file_names)
                    error = 1
            if error:
                message = ("Not all patients were represented by the same set "
                           "of caller-VCFs. Review inputs/command options to "
                           "align file pairings or use the flag "
                           "--allow_inconsistent_sample_sets.")
                raise utils.UsageError(message)
Ejemplo n.º 9
0
def _validate_consistent_input(vcf_readers, include_all):
    if not include_all:
        untranslated_readers = []
        translated = False
        untranslated = False

        for vcf_reader in vcf_readers:
            if '##jacquard.translate.caller' in vcf_reader.metaheaders:
                translated = True
            else:
                untranslated = True
                untranslated_readers.append(vcf_reader)

        if translated and untranslated:
            msg = ("Some input VCFs [{}] were not translated by Jacquard. "
                    "Review input and/or use --included_all flag")\
                   .format(untranslated_readers)
            raise utils.UsageError(msg)
Ejemplo n.º 10
0
def _check_input_exists(dummy, args):
    if not os.path.exists(args.input):
        raise utils.UsageError(("Specified input [{}] does not exist. Review "\
                                 "inputs and try again.").format(args.input))