How to use the pypeline.tools.bam_pipeline.makefile.MakefileError function in Pypeline

To help you get started, we’ve selected a few Pypeline examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github MikkelSchubert / paleomix / pypeline / tools / bam_pipeline / validation.py View on Github external
filenames[realpath].append((target, sample, library, barcode))                        

    has_overlap = {}
    for (filename, records) in filenames.iteritems():
        if len(records) > 1:
            has_overlap[filename] = list(set(records))

    by_records = sorted(zip(has_overlap.values(), has_overlap.keys()))
    for (records, pairs) in itertools.groupby(by_records, lambda x: x[0]):
        descriptions = []
        for (ii, record) in enumerate(records, start = 1):
            descriptions.append("\t- Record {0}: Name: {1},  Sample: {2},  Library: {3},  Barcode: {4}".format(ii, *record))
        for (ii, (_, filename)) in enumerate(sorted(pairs), start = 1):
            descriptions.append("\t- Canonical path {0}: {1}".format(ii, filename))

        raise MakefileError("Path included multiple times by one or more records:\n{0}\n".format("\n".join(descriptions)))
github MikkelSchubert / paleomix / pypeline / tools / bam_pipeline / validation.py View on Github external
def _validate_makefiles_duplicate_targets(makefiles):
    targets = set()
    for makefile in makefiles:
        for target in makefile["Targets"]:
            if target in targets:
                raise MakefileError("Target '%s' specified multiple times!" % target)
            targets.add(target)
github MikkelSchubert / paleomix / pypeline / tools / bam_pipeline / validation.py View on Github external
def _validate_makefile_options(makefile):
    for (target, sample, library, barcode, record) in _iterate_over_records(makefile):
        options = record["Options"]
        for (key, value) in options.iteritems():
            if key not in DEFAULT_OPTIONS:
                raise MakefileError("Unknown option: Key = '%s', value = '%s'" % (key, value))
            elif (key == "QualityOffset"):
                if not isinstance(value, (str, int)):
                    raise MakefileError("Option value has wrong type:\n\tOption = '%s', value = '%s'\n\tExpected type = int/str, found = %s" \
                                        % (key, value, value.__class__.__name__))
            elif not isinstance(value, type(DEFAULT_OPTIONS[key])):
                raise MakefileError("Option value has wrong type:\n\tOption = '%s', value = '%s'\n\tExpected type = %s, found = %s" \
                                        % (key, value, DEFAULT_OPTIONS[key].__class__.__name__, value.__class__.__name__))

        if options["Platform"].upper() not in _PLATFORMS:
            raise MakefileError("Unknown Platform specified: '%s'" % options["Platform"])

        if options["QualityOffset"] not in (33, 64, "Solexa"):
            raise MakefileError("QualityBase must be 33 (Sanger/Illumina 1.8+), 64 (Illumina 1.3+ / 1.5+), or 'Solexa', not '%i'." \
                                  % options["QualityOffset"])

        if options["Aligner"] not in ("BWA", "Bowtie2"):
github MikkelSchubert / paleomix / pypeline / tools / bam_pipeline / validation.py View on Github external
def _validate_makefile_libraries(makefile):
    libraries = collections.defaultdict(set)
    for (target, sample, library, barcode, record) in _iterate_over_records(makefile):
        libraries[(target, library)].add(sample)

    for ((target, library), samples) in libraries.iteritems():
        if len(samples) > 1:
            raise MakefileError("Library '%s' in target '%s' spans multiple samples: %s" \
                                    % (library, target, ", ".join(samples)))
github MikkelSchubert / paleomix / pypeline / tools / bam_pipeline / validation.py View on Github external
if not isinstance(value, (str, int)):
                    raise MakefileError("Option value has wrong type:\n\tOption = '%s', value = '%s'\n\tExpected type = int/str, found = %s" \
                                        % (key, value, value.__class__.__name__))
            elif not isinstance(value, type(DEFAULT_OPTIONS[key])):
                raise MakefileError("Option value has wrong type:\n\tOption = '%s', value = '%s'\n\tExpected type = %s, found = %s" \
                                        % (key, value, DEFAULT_OPTIONS[key].__class__.__name__, value.__class__.__name__))

        if options["Platform"].upper() not in _PLATFORMS:
            raise MakefileError("Unknown Platform specified: '%s'" % options["Platform"])

        if options["QualityOffset"] not in (33, 64, "Solexa"):
            raise MakefileError("QualityBase must be 33 (Sanger/Illumina 1.8+), 64 (Illumina 1.3+ / 1.5+), or 'Solexa', not '%i'." \
                                  % options["QualityOffset"])

        if options["Aligner"] not in ("BWA", "Bowtie2"):
            raise MakefileError("QualityBase must be 33 (Sanger/Illumina 1.8+), 64 (Illumina 1.3+ / 1.5+), or 'Solexa', not '%i'." \
                                  % options["QualityOffset"])

        unknown_reads = set(options["ExcludeReads"]) - set(READ_TYPES)
        if unknown_reads:
            raise MakefileError("Unknown reads specified in option 'ExcludeReads': '%s'\n\tValid values are '%s'" \
                                    % ("', '".join(unknown_reads), "', '".join(READ_TYPES)))

        unknown_feats = set(options["Features"]) - set(FEATURES)
        if unknown_feats:
            raise MakefileError("Unknown feature(s) specified': '%s'\n\tValid values are '%s'" \
                                    % ("', '".join(unknown_feats), "', '".join(FEATURES)))