def _teardown(self, config, temp): # Picard creates a folder named after the user in the temp-root try_rmtree(os.path.join(temp, getpass.getuser())) # Some JREs may create a folder for temporary performance counters try_rmtree(os.path.join(temp, "hsperfdata_" + getpass.getuser())) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp): for filename in os.listdir(temp): if filename.endswith(".txt") or filename.endswith( ".pdf") or filename.endswith(".csv"): if not filename.startswith("pipe_"): os.remove(os.path.join(temp, filename)) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp): os.remove(os.path.join(temp, "RAxML_info.output")) source = os.path.join(temp, "RAxML_parsimonyTree.output.0") destination = fileutils.reroot_path(temp, self._output_tree) fileutils.move_file(source, destination) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp): template = self._output_template bootstraps = self._bootstrap_num start = self._bootstrap_start for (src_file, dst_file) in self._bootstraps(template, bootstraps, start): src_file = os.path.join(temp, src_file) dst_file = fileutils.reroot_path(temp, dst_file) fileutils.move_file(src_file, dst_file) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp): for filename in os.listdir(temp): match = re.match("RAxML_(.*).Pypeline", filename) if match: source = os.path.join(temp, filename) destination = os.path.join(temp, self._template % match.groups()) fileutils.move_file(source, destination) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp): fileutils.move_file(os.path.join(temp, "RAxML_info.Pypeline"), os.path.join(temp, fileutils.swap_ext(self._output_alignment, ".info"))) fileutils.move_file(os.path.join(temp, "input.alignment.BS0"), os.path.join(temp, self._output_alignment)) os.remove(os.path.join(temp, "input.alignment")) os.remove(os.path.join(temp, "input.partition")) CommandNode._teardown(self, config, temp)
def test_commandnode_teardown__missing_optional_files(temp_folder): destination, temp_folder = _setup_temp_folders(temp_folder) cmd = AtomicCmd(("echo", "-n", "1 2 3"), TEMP_OUT_BAR = "bar.txt", OUT_STDOUT = os.path.join(destination, "foo.txt")) cmd.run(temp_folder) assert_equal(cmd.join(), [0]) node = CommandNode(cmd) node._teardown(None, temp_folder) assert_equal(os.listdir(temp_folder), []) assert_equal(os.listdir(destination), ["foo.txt"])
def _teardown(self, config, temp): fileutils.move_file( os.path.join(temp, "RAxML_info.Pypeline"), os.path.join(temp, fileutils.swap_ext(self._output_alignment, ".info"))) fileutils.move_file(os.path.join(temp, "input.alignment.BS0"), os.path.join(temp, self._output_alignment)) os.remove(os.path.join(temp, "input.alignment")) os.remove(os.path.join(temp, "input.partition")) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp): for filename in os.listdir(temp): match = re.match("ExaML_(.*).Pypeline", filename) if match: if "binaryCheckpoint" in match.groups(): os.remove(os.path.join(temp, filename)) else: source = os.path.join(temp, filename) destination = os.path.join(temp, self._template % match.groups()) fileutils.move_file(source, destination) CommandNode._teardown(self, config, temp)
def test_commandnode_teardown(temp_folder): destination, temp_folder = _setup_temp_folders(temp_folder) cmd = AtomicCmd(("echo", "-n", "1 2 3"), OUT_STDOUT = os.path.join(destination, "foo.txt")) cmd.run(temp_folder) assert_equal(cmd.join(), [0]) node = CommandNode(cmd) assert os.path.exists(os.path.join(temp_folder, "foo.txt")) assert not os.path.exists(os.path.join(destination, "foo.txt")) node._teardown(None, temp_folder) assert not os.path.exists(os.path.join(temp_folder, "foo.txt")) assert os.path.exists(os.path.join(destination, "foo.txt"))
def _teardown(self, config, temp): for postfix in ("ALIGNMENT", "PARTITION"): filenames = [self._kwargs["TEMP_IN_" + postfix], self._kwargs["TEMP_IN_" + postfix] + ".reduced", self._kwargs["OUT_" + postfix]] for (source, destination) in zip(filenames, filenames[1:]): source = fileutils.reroot_path(temp, source) destination = fileutils.reroot_path(temp, destination) if not os.path.exists(destination): fileutils.copy_file(source, destination) os.remove(source) CommandNode._teardown(self, config, temp)
class MAFFTNode(CommandNode): @create_customizable_cli_parameters def customize(cls, input_file, output_file, algorithm = "auto", dependencies = ()): command = AtomicCmdBuilder(_PRESETS[algorithm.lower()]) command.add_value("%(IN_FASTA)s") command.set_kwargs(IN_FASTA = input_file, OUT_STDOUT = output_file, CHECK_VERSION = MAFFT_VERSION) return {"command" : command, "dependencies" : dependencies} @use_customizable_cli_parameters def __init__(self, parameters): self._output_file = parameters.output_file description = "<MAFFTNode (%s): '%s' -> '%s'>" \ % (parameters.algorithm, parameters.input_file, parameters.output_file) CommandNode.__init__(self, command = parameters.command.finalize(), description = description, dependencies = parameters.dependencies) def _teardown(self, config, temp): # Validate output from MAFFT output_file = reroot_path(temp, self._output_file) try: MSA.from_file(output_file) except MSAError, error: raise NodeError("Invalid MSA produced by MAFFT:\n%s" % (error,)) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp): for postfix in ("ALIGNMENT", "PARTITION"): filenames = [ self._kwargs["TEMP_IN_" + postfix], self._kwargs["TEMP_IN_" + postfix] + ".reduced", self._kwargs["OUT_" + postfix] ] for (source, destination) in zip(filenames, filenames[1:]): source = fileutils.reroot_path(temp, source) destination = fileutils.reroot_path(temp, destination) if not os.path.exists(destination): fileutils.copy_file(source, destination) os.remove(source) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp): """See CommandNode._teardown.""" os.remove(reroot_path(temp, self._infile)) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp_root): pipe_fname = os.path.join(temp_root, self._bam_input.pipe) os.remove(pipe_fname) try_remove(pipe_fname + ".bai") CommandNode._teardown(self, config, temp_root)
def _teardown(self, config, temp): os.rename(os.path.join(temp, self._basename) + ".calmd", os.path.join(temp, self._basename)) CommandNode._teardown(self, config, temp)
def _teardown(self, config, temp): for filename in os.listdir(temp): if filename.endswith(".txt") or filename.endswith(".pdf") or filename.endswith(".csv"): if not filename.startswith("pipe_"): os.remove(os.path.join(temp, filename)) CommandNode._teardown(self, config, temp)
def test_commandnode_teardown__commit(temp_folder): cmd_mock = _build_cmd_mock() cmd_mock.should_receive("commit").with_args(temp_folder).once node = CommandNode(cmd_mock) node._teardown(None, temp_folder)
def _teardown(self, config, temp): basename = os.path.basename(self._output_tree) os.rename(os.path.join(temp, "RAxML_parsimonyTree.Pypeline"), os.path.join(temp, basename)) CommandNode._teardown(self, config, temp)