Mercurial > repos > richard-burhans > segalign
changeset 16:4966e095e3c3 draft
planemo upload for repository https://github.com/richard-burhans/galaxytools/tree/main/tools/segalign commit 6cf972d7f1c9ecb097994494a27d00906c6c3e4d
author | richard-burhans |
---|---|
date | Tue, 30 Jul 2024 17:19:56 +0000 |
parents | 99ee8d6f6815 |
children | 52a13f003b2d |
files | package_output.py segalign.xml |
diffstat | 2 files changed, 51 insertions(+), 17 deletions(-) [+] |
line wrap: on
line diff
--- a/package_output.py Tue Jul 30 03:31:29 2024 +0000 +++ b/package_output.py Tue Jul 30 17:19:56 2024 +0000 @@ -18,11 +18,14 @@ top_dir: str = "galaxy", data_dir: str = "files", config_file: str = "commands.json", + format_file: str = "format.txt" ) -> None: self.pathname: str = os.path.realpath(pathname) self.data_root: str = os.path.join(top_dir, data_dir) self.config_path: str = os.path.join(top_dir, config_file) self.config_file: str = config_file + self.format_path: str = os.path.join(top_dir, format_file) + self.format_file: str = format_file self.tarfile: typing.Optional[tarfile.TarFile] = None self.name_cache: typing.Dict[typing.Any, typing.Any] = {} self.working_dir: str = os.path.realpath(os.getcwd()) @@ -76,6 +79,15 @@ self.name_cache[dest_path] = 1 # print(f"added: {dest_path}", flush=True) + def add_format(self, pathname: str) -> None: + if self.tarfile is None: + self._initialize() + + source_path = os.path.realpath(pathname) + + if self.tarfile is not None: + self.tarfile.add(source_path, arcname=self.format_path, recursive=False) + def close(self) -> None: if self.tarfile is not None: self.tarfile.close() @@ -87,13 +99,16 @@ self, pathname: str, config: configparser.ConfigParser, + args: argparse.Namespace, package_file: PackageFile, ) -> None: self.pathname: str = pathname self.config = config + self.args = args self.package_file = package_file self.executable: typing.Optional[str] = None self._parse_lines() + self._write_format() def _parse_lines(self) -> None: with open("commands.json", "w") as ofh: @@ -235,6 +250,21 @@ return command_dict + def _write_format(self) -> None: + if self.args.format_selector == "bam": + format_name = "bam" + elif self.args.format_selector == "maf": + format_name = "maf" + elif self.args.format_selector == "differences": + format_name = "interval" + else: + format_name = "tabular" + + with open("format.txt", "w") as ofh: + print(f"{format_name}", file=ofh) + + self.package_file.add_format("format.txt") + class nodevisitor(bashlex.ast.nodevisitor): # type: ignore[misc] def __init__(self, positions: typing.List[typing.Tuple[int, int]]) -> None: @@ -272,6 +302,7 @@ def main() -> None: parser = argparse.ArgumentParser() parser.add_argument("--tool_directory", type=str, required=True, help="tool directory") + parser.add_argument("--format_selector", type=str, required=True, help="format selector") args = parser.parse_args() lastz_command_config_file: str = os.path.join(args.tool_directory, "lastz-cmd.ini") @@ -281,7 +312,7 @@ package_file = PackageFile() lastz_command_file = "lastz-commands.txt" - bashCommandLineFile(lastz_command_file, config, package_file) + bashCommandLineFile(lastz_command_file, config, args, package_file) package_file.close()
--- a/segalign.xml Tue Jul 30 03:31:29 2024 +0000 +++ b/segalign.xml Tue Jul 30 17:19:56 2024 +0000 @@ -19,12 +19,14 @@ <include path="runner.py"/> </required_files> <command detect_errors="exit_code"><![CDATA[ -## Convert input to 2bit for lastz ------------------------------------- +## Convert input sequences to 2bit ------------------------------------- mkdir -p "\$(pwd)/work" && faToTwoBit <(gzip -cdfq '$target') "\$(pwd)/work/ref.2bit" && faToTwoBit <(gzip -cdfq '$query') "\$(pwd)/work/query.2bit" && +## Run SegAlign -------------------------------------------------------- + ## explicitly calling python to bypass a pulsar bug ## https://github.com/galaxyproject/pulsar/issues/341 python '$__tool_directory__/runner.py' @@ -77,7 +79,6 @@ ## Gapped Extension Options -------------------------------------------- - --nogapped --ydrop '$gapped_extension_options.ydrop' #if str($gapped_extension_options.gappedthresh) != "" --gappedthresh '$gapped_extension_options.gappedthresh' @@ -92,27 +93,28 @@ --format '$output_options.format.bam_options' #else if str($output_options.format.format_selector) == "general_def" --format general- +#else if str($output_options.format.format_selector) == "general_full" + --format 'general-:${output_options.format.fields}' + #else if str($output_options.format.format_selector) == "maf" --format '$output_options.format.maf_type' #else if str($output_options.format.format_selector) == "blastn" --format=BLASTN- -#else if str($output_options.format.format_selector) == "general_full" - --format 'general-:${output_options.format.fields}' #else if str($output_options.format.format_selector) == "differences" --format=differences #end if - ## todo :: rplot, bam - ## --action:target=multiple - ## $output_format.rplot - ## #if str( $output_format.out.format ) == "bam": - ## | samtools sort -@\${GALAXY_SLOTS:-2} -T "\${TMPDIR:-.}" -O bam -o '${output}' - ## #else: - ## > '${output}' - ## #end if - ## #if $output_format.rplot: - ## && - ## Rscript $r_plot > /dev/null 2>&1 - ## #end if +## todo :: rplot, bam +## --action:target=multiple +## $output_format.rplot +## .if str( $output_format.out.format ) == "bam": +## | samtools sort -@\${GALAXY_SLOTS:-2} -T "\${TMPDIR:-.}" -O bam -o '${output}' +## .else: +## > '${output}' +## .end if +## .if $output_format.rplot: +## && +## Rscript $r_plot > /dev/null 2>&1 +## .end if ## System Options ----------------------------------------------------- @@ -129,6 +131,7 @@ && python '$__tool_directory__/package_output.py' --tool_directory '$__tool_directory__' + --format_selector '$output_options.format.format_selector' ]]></command> <inputs>