Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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)))
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)
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"):
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)))
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)))