Esempio n. 1
0
def _filter_column_list(column_spec_list, potential_col_list,
                        column_spec_filename):

    actual_column_list = []
    glossary_fields = OrderedDict()
    for i, column_regex in enumerate(column_spec_list):
        no_columns_found = True
        for (column_name, vcf_tag) in potential_col_list.items():
            column_exists = column_name in actual_column_list
            regex_matches = re.match("^" + column_regex + "$", column_name)
            if regex_matches and not column_exists:
                glossary_fields[vcf_tag] = 1
                actual_column_list.append(column_name)
                no_columns_found = False

        if no_columns_found:
            logger.warning(UNUSED_REGEX_WARNING_FORMAT, column_regex,
                           column_spec_filename, i + 1)

    if not actual_column_list:
        raise utils.JQException(
            "The selected_columns_file [{}] would "
            "exclude all input columns. Review "
            "inputs/usage and try again.", column_spec_filename)
    glossary_fields = [x for x in glossary_fields.keys() if x]
    return actual_column_list, glossary_fields
Esempio n. 2
0
def _filter_column_list(column_spec_list,
                        potential_col_list,
                        column_spec_filename):

    actual_column_list = []
    glossary_fields = OrderedDict()
    for i, column_regex in enumerate(column_spec_list):
        no_columns_found = True
        for (column_name, vcf_tag) in potential_col_list.items():
            column_exists = column_name in actual_column_list
            regex_matches = re.match("^" + column_regex + "$", column_name)
            if regex_matches and not column_exists:
                glossary_fields[vcf_tag] = 1
                actual_column_list.append(column_name)
                no_columns_found = False

        if no_columns_found:
            logger.warning(UNUSED_REGEX_WARNING_FORMAT,
                           column_regex,
                           column_spec_filename,
                           i + 1)

    if not actual_column_list:
        raise utils.JQException("The selected_columns_file [{}] would "
                                "exclude all input columns. Review "
                                "inputs/usage and try again.",
                                column_spec_filename)
    glossary_fields = [x for x in glossary_fields.keys() if x]
    return actual_column_list, glossary_fields
Esempio n. 3
0
    def test_warning(self):
        tool = "foo"
        args = Namespace(subparser_name=tool,
                         log_file=None,
                         verbose=None)
        logger.initialize_logger(args)
        self.assertFalse(logger.WARNING_OCCURRED)
        logger.warning("bar")
        self.assertTrue(logger.WARNING_OCCURRED)
        root_logger = logger.logging.getLogger()

        current_time = datetime.now().strftime('%Y-%m-%d')
        output_lines = self.output.getvalue().rstrip().split("\n")

        self.assertEquals(["root: WARNING: bar"], root_logger.handlers[0].buffer)
        self.assertRegexpMatches(output_lines[0], ""+current_time+r".*\|WARNING\|foo\|bar")
Esempio n. 4
0
    def test_warning(self):
        tool = "foo"
        args = Namespace(subparser_name=tool, log_file=None, verbose=None)
        logger.initialize_logger(args)
        self.assertFalse(logger.WARNING_OCCURRED)
        logger.warning("bar")
        self.assertTrue(logger.WARNING_OCCURRED)
        root_logger = logger.logging.getLogger()

        current_time = datetime.now().strftime('%Y-%m-%d')
        output_lines = self.output.getvalue().rstrip().split("\n")

        self.assertEquals(["root: WARNING: bar"],
                          root_logger.handlers[0].buffer)
        self.assertRegexpMatches(output_lines[0],
                                 "" + current_time + r".*\|WARNING\|foo\|bar")
Esempio n. 5
0
def _validate_consistent_samples(file_readers):
    readers_per_patient = _get_readers_per_patient(file_readers)

    all_callers = set()
    for callers in readers_per_patient.values():
        all_callers.update(callers)
    warning = 0
    for patient, callers in readers_per_patient.items():
        missing_callers = set(all_callers).difference(set(callers))
        if missing_callers:
            warning = 1
            msg = "Sample [{}] is missing VCF(s): {}"
            logger.warning(msg, patient, sorted(list(missing_callers)))
    if warning:
        msg = "Some samples appear to be missing VCF(s)"
        logger.warning(msg)
Esempio n. 6
0
def _validate_consistent_samples(file_readers):
    readers_per_patient = _get_readers_per_patient(file_readers)

    all_callers = set()
    for callers in readers_per_patient.values():
        all_callers.update(callers)
    warning = 0
    for patient, callers in readers_per_patient.items():
        missing_callers = set(all_callers).difference(set(callers))
        if missing_callers:
            warning = 1
            msg = "Sample [{}] is missing VCF(s): {}"
            logger.warning(msg,
                           patient,
                           sorted(list(missing_callers)))
    if warning:
        msg = "Some samples appear to be missing VCF(s)"
        logger.warning(msg)
Esempio n. 7
0
def _build_format_tags(format_tag_regex, vcf_readers):
    retained_tags = set()
    regexes_used = set()

    for vcf_reader in vcf_readers:
        for tag_regex in format_tag_regex:
            for original_tag, new_tag in list(vcf_reader.format_tags.items()):
                if re.match(tag_regex + "$", original_tag):
                    retained_tags.add(new_tag)
                    regexes_used.add(tag_regex)

    if len(retained_tags) == 0:
        msg = ("The specified format tag regex [{}] would exclude all format "
               "tags. Review inputs/usage and try again")
        raise utils.JQException(msg, format_tag_regex)

    unused_regexes = set(format_tag_regex).difference(regexes_used)
    if unused_regexes:
        for unused_regex in unused_regexes:
            msg = ("In the specified list of regexes {}, the regex [{}] does "
                   "not match any format tags; this expression may be "
                   "irrelevant.")
            logger.warning(msg, format_tag_regex, unused_regex)
    return sorted(list(retained_tags))
Esempio n. 8
0
def _build_format_tags(format_tag_regex, vcf_readers):
    retained_tags = set()
    regexes_used = set()

    for vcf_reader in vcf_readers:
        for tag_regex in format_tag_regex:
            for original_tag, new_tag in list(vcf_reader.format_tags.items()):
                if re.match(tag_regex + "$", original_tag):
                    retained_tags.add(new_tag)
                    regexes_used.add(tag_regex)

    if len(retained_tags) == 0:
        msg = ("The specified format tag regex [{}] would exclude all format "
               "tags. Review inputs/usage and try again")
        raise utils.JQException(msg, format_tag_regex)

    unused_regexes = set(format_tag_regex).difference(regexes_used)
    if unused_regexes:
        for unused_regex in unused_regexes:
            msg = ("In the specified list of regexes {}, the regex [{}] does "
                   "not match any format tags; this expression may be "
                   "irrelevant.")
            logger.warning(msg, format_tag_regex, unused_regex)
    return sorted(list(retained_tags))
Esempio n. 9
0
def _log_unclaimed_readers(unclaimed_readers):
    unclaimed_log_message = "The input file [{}] will not be translated"
    for reader in sorted(unclaimed_readers):
        msg = unclaimed_log_message.format(reader.file_name)
        logger.warning(msg)
Esempio n. 10
0
def _log_unclaimed_readers(unclaimed_readers):
    unclaimed_log_message = "The input file [{}] will not be translated"
    for reader in sorted(unclaimed_readers):
        msg = unclaimed_log_message.format(reader.file_name)
        logger.warning(msg)