Skip to content
Snippets Groups Projects
Commit b4e35fa3 authored by aknecht2's avatar aknecht2
Browse files

Added rewrite option to pass to module_generators. Updated module generators...

Added rewrite option to pass to module_generators.  Updated module generators to allow module yaml to specify db saving & prefix type.
parent f81488ec
No related branches found
No related tags found
1 merge request!18Resolve "Parse ccat / peakranger output into bed files"
...@@ -80,7 +80,15 @@ class ModuleGenerator(object): ...@@ -80,7 +80,15 @@ class ModuleGenerator(object):
all_jobs.append(self.workflow_jobs[job_name]) all_jobs.append(self.workflow_jobs[job_name])
for output_info in job_info["outputs"]: for output_info in job_info["outputs"]:
logical_name = output_info.keys()[0] logical_name = output_info.keys()[0]
result = Result(logical_name, final_result.control_samples, final_result.signal_samples, all_markers, all_jobs, should_save=False) result = Result(
logical_name,
final_result.control_samples,
final_result.signal_samples,
all_markers,
all_jobs,
should_save=output_info[logical_name]["save_result"] if "save_result" in output_info[logical_name] else False,
prefix_join=output_info[logical_name].get("prefix_join")
)
results.append(result) results.append(result)
run.add_result(self.module.name, result) run.add_result(self.module.name, result)
results.append(final_result) results.append(final_result)
...@@ -163,10 +171,12 @@ class ModuleGenerator(object): ...@@ -163,10 +171,12 @@ class ModuleGenerator(object):
self._download_from_gridfs(run, result) self._download_from_gridfs(run, result)
return return
def generate(self, run): def generate(self, run, rewrite=False):
""" """
:param run: The target run to generate jobs for. :param run: The target run to generate jobs for.
:type run: :py:class:chipathlon.run.Run :type run: :py:class:chipathlon.run.Run
:param rewrite: Whether or not to rewrite data even if it exists.
:type rewrite: bool
Generates actual workflow jobs for a particular run. The logic for Generates actual workflow jobs for a particular run. The logic for
job generation is based on the fact that all output files are unique, job generation is based on the fact that all output files are unique,
...@@ -184,9 +194,9 @@ class ModuleGenerator(object): ...@@ -184,9 +194,9 @@ class ModuleGenerator(object):
""" """
final_results = self.create_final_results(run) final_results = self.create_final_results(run)
for result in final_results: for result in final_results:
if not result.exists_in_db(self.mdb, run.genome): if rewrite or not result.exists_in_db(self.mdb, run.genome):
for prev_result in self.get_prev_results(run, result): for prev_result in self.get_prev_results(run, result):
if prev_result.exists_in_encode() or prev_result.exists_in_db(self.mdb, run.genome): if prev_result.exists_in_encode() or (not rewrite and prev_result.exists_in_db(self.mdb, run.genome)):
self.add_download_job(run, prev_result) self.add_download_job(run, prev_result)
self.add_jobs(run, result) self.add_jobs(run, result)
return return
...@@ -276,4 +286,3 @@ class ModuleGenerator(object): ...@@ -276,4 +286,3 @@ class ModuleGenerator(object):
will be used to get a target result. will be used to get a target result.
This should be overriden by the actual generators. This should be overriden by the actual generators.
""" """
return
...@@ -10,7 +10,7 @@ class Result(object): ...@@ -10,7 +10,7 @@ class Result(object):
run on the result file up to this point. run on the result file up to this point.
""" """
def __init__(self, logical_name, control_samples, signal_samples, all_markers, all_jobs, should_save=False): def __init__(self, logical_name, control_samples, signal_samples, all_markers, all_jobs, should_save=False, prefix_join=None):
""" """
:param logical_name: The unique name of the file as presented in the module yaml :param logical_name: The unique name of the file as presented in the module yaml
:type logical_name: string :type logical_name: string
...@@ -43,7 +43,7 @@ class Result(object): ...@@ -43,7 +43,7 @@ class Result(object):
self.should_save = should_save self.should_save = should_save
self.prefix = self._get_prefix() self.prefix = self._get_prefix()
self.full_name = self.prefix + "_" + self.logical_name self.full_name = self.prefix + ("_" if prefix_join is None else prefix_join) + self.logical_name
self.file_type = os.path.splitext(self.logical_name)[1][1:] self.file_type = os.path.splitext(self.logical_name)[1][1:]
self.pegasus_file = File(self.full_name) self.pegasus_file = File(self.full_name)
return return
......
No preview for this file type
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment