def test_find_samples_from_file(self): """Find samples defined in file with empty lines and erroneous names""" with open(os.path.join(j_doe_00_05, "P001_101_index3-bcbb-config.yaml"), "w") as fh: fh.write("\n") flist = find_samples(j_doe_00_05, sample=os.path.join(j_doe_00_05, "samples.txt")) validate_sample_directories(flist, j_doe_00_05) self.assertEqual(len(flist),2) os.unlink(os.path.join(j_doe_00_05, "P001_101_index3-bcbb-config.yaml"))
def run(self): if not self._check_pargs(["project"]): return if self.pargs.post_process: self.pargs.post_process = os.path.abspath(self.pargs.post_process) basedir = os.path.abspath(os.path.join(self.app.controller._meta.root_path, self.app.controller._meta.path_id)) if self.pargs.from_ssheet: [ samplesheet_csv_to_yaml(fn) for fn in find_samples(basedir, pattern="SampleSheet.csv$", **vars(self.pargs)) ] flist = find_samples(basedir, **vars(self.pargs)) # Add filtering on flowcell if necessary self._meta.pattern = ".*" flist = [x for x in flist if self._filter_fn(x)] if self.pargs.merged: ## Setup merged samples and append to flist if new list longer flist = setup_merged_samples(flist, **vars(self.pargs)) if not len(flist) > 0: self.log.info("No sample configuration files found") return if len(flist) > 0 and not query_yes_no( "Going to start {} jobs... Are you sure you want to continue?".format(len(flist)), force=self.pargs.force ): return # Make absolutely sure analysis directory is a *subdirectory* of the working directory validate_sample_directories(flist, basedir) orig_dir = os.path.abspath(os.getcwd()) for run_info in flist: os.chdir(os.path.abspath(os.path.dirname(run_info))) setup_sample(run_info, **vars(self.pargs)) os.chdir(orig_dir) if self.pargs.only_setup: return if self.pargs.only_failed: status = {x: self._sample_status(x) for x in flist} flist = [x for x in flist if self._sample_status(x) == "FAIL"] ## Here process files again, removing if requested, and running the pipeline for run_info in flist: self.app.log.info("Running analysis defined by config file {}".format(run_info)) os.chdir(os.path.abspath(os.path.dirname(run_info))) if self.app.cmd.monitor(work_dir=os.path.dirname(run_info)): self.app.log.warn("Not running job") continue if self.pargs.restart: self.app.log.info("Removing old analysis files in {}".format(os.path.dirname(run_info))) remove_files(run_info, **vars(self.pargs)) (cl, platform_args) = run_bcbb_command(run_info, **vars(self.pargs)) self.app.cmd.command( cl, **{"platform_args": platform_args, "saveJobId": True, "workingDirectory": os.path.dirname(run_info)} ) os.chdir(orig_dir)
def test_find_samples_from_file(self): """Find samples defined in file with empty lines and erroneous names""" with open( os.path.join(j_doe_00_05, "P001_101_index3-bcbb-config.yaml"), "w") as fh: fh.write("\n") flist = find_samples(j_doe_00_05, sample=os.path.join(j_doe_00_05, "samples.txt")) validate_sample_directories(flist, j_doe_00_05) self.assertEqual(len(flist), 2) os.unlink(os.path.join(j_doe_00_05, "P001_101_index3-bcbb-config.yaml"))
def run(self): if not self._check_pargs(["project"]): return if self.pargs.post_process: self.pargs.post_process = os.path.abspath(self.pargs.post_process) basedir = os.path.abspath( os.path.join(self.app.controller._meta.root_path, self.app.controller._meta.path_id)) if self.pargs.from_ssheet: [ samplesheet_csv_to_yaml(fn) for fn in find_samples( basedir, pattern="SampleSheet.csv$", **vars(self.pargs)) ] flist = find_samples(basedir, **vars(self.pargs)) # Add filtering on flowcell if necessary self._meta.pattern = ".*" flist = [x for x in flist if self._filter_fn(x)] if self.pargs.merged: ## Setup merged samples and append to flist if new list longer flist = setup_merged_samples(flist, **vars(self.pargs)) if not len(flist) > 0: self.log.info("No sample configuration files found") return if len(flist) > 0 and not query_yes_no( "Going to start {} jobs... Are you sure you want to continue?". format(len(flist)), force=self.pargs.force): return # Make absolutely sure analysis directory is a *subdirectory* of the working directory validate_sample_directories(flist, basedir) orig_dir = os.path.abspath(os.getcwd()) for run_info in flist: os.chdir(os.path.abspath(os.path.dirname(run_info))) setup_sample(run_info, **vars(self.pargs)) os.chdir(orig_dir) if self.pargs.only_setup: return if self.pargs.only_failed: status = {x: self._sample_status(x) for x in flist} flist = [x for x in flist if self._sample_status(x) == "FAIL"] ## Here process files again, removing if requested, and running the pipeline for run_info in flist: self.app.log.info( "Running analysis defined by config file {}".format(run_info)) os.chdir(os.path.abspath(os.path.dirname(run_info))) if self.app.cmd.monitor(work_dir=os.path.dirname(run_info)): self.app.log.warn("Not running job") continue if self.pargs.restart: self.app.log.info("Removing old analysis files in {}".format( os.path.dirname(run_info))) remove_files(run_info, **vars(self.pargs)) (cl, platform_args) = run_bcbb_command(run_info, **vars(self.pargs)) self.app.cmd.command( cl, **{ 'platform_args': platform_args, 'saveJobId': True, 'workingDirectory': os.path.dirname(run_info) }) os.chdir(orig_dir)