def picard_command(config, command): """Returns basic AtomicJavaCmdBuilder for Picard tools commands.""" jar_path = os.path.join(config.jar_root, _PICARD_JAR) if jar_path not in _PICARD_VERSION_CACHE: params = AtomicJavaCmdBuilder(jar_path, temp_root=config.temp_root, jre_options=config.jre_options) # Arbitrary command, since just '--version' does not work params.set_option("MarkDuplicates") params.set_option("--version") requirement = versions.Requirement( call=params.finalized_call, name="Picard tools", search=r"\b(\d+)\.(\d+)\.\d+", checks=versions.GE(1, 137), ) _PICARD_VERSION_CACHE[jar_path] = requirement version = _PICARD_VERSION_CACHE[jar_path] params = AtomicJavaCmdBuilder( jar_path, temp_root=config.temp_root, jre_options=config.jre_options, CHECK_JAR=version, set_cwd=True, ) params.set_option(command) return params
def picard_command(config, command): """Returns basic AtomicJavaCmdBuilder for Picard tools commands.""" jar_path = os.path.join(config.jar_root, _PICARD_JAR) if jar_path not in _PICARD_VERSION_CACHE: params = AtomicJavaCmdBuilder(jar_path, temp_root=config.temp_root, jre_options=config.jre_options) # Arbitrary command, since just '--version' does not work params.set_option("MarkDuplicates") params.set_option("--version") requirement = versions.Requirement(call=params.finalized_call, name="Picard tools", search=r"\b(\d+)\.(\d+)\.\d+", checks=versions.GE(1, 137)) _PICARD_VERSION_CACHE[jar_path] = requirement version = _PICARD_VERSION_CACHE[jar_path] params = AtomicJavaCmdBuilder(jar_path, temp_root=config.temp_root, jre_options=config.jre_options, CHECK_JAR=version) params.set_option(command) return params
def test_java_builder__defaults__call(): builder = AtomicJavaCmdBuilder("/path/Foo.jar", temp_root="/disk/tmp") assert_equal(builder.call, [ "java", "-server", "-Djava.io.tmpdir=/disk/tmp", "-Djava.awt.headless=true", "-XX:+UseSerialGC", "-Xmx4g", "-jar", "%(AUX_JAR)s" ])
def test_java_builder__default__no_config(): builder = AtomicJavaCmdBuilder("/path/Foo.jar") assert_equal(builder.call, [ "java", "-server", "-Djava.io.tmpdir=%(TEMP_DIR)s", "-Djava.awt.headless=true", "-XX:+UseSerialGC", "-Xmx4g", "-jar", "%(AUX_JAR)s" ])
def test_java_builder__multithreaded_gc(): builder = AtomicJavaCmdBuilder("/path/Foo.jar", temp_root="/disk/tmp", gc_threads=3) assert_equal(builder.call, [ "java", "-server", "-Djava.io.tmpdir=/disk/tmp", "-Djava.awt.headless=true", "-XX:ParallelGCThreads=3", "-Xmx4g", "-jar", "%(AUX_JAR)s" ])
def _get_gatk_version_check(config): """Returns a version-check object for the "GenomeAnalysisTK.jar" located at config.jar_root; for now, this check only serves to verify that the JAR can be executed, which may not be the case if the JRE is outdated. """ jar_file = os.path.join(config.jar_root, "GenomeAnalysisTK.jar") if jar_file not in _GATK_VERSION: params = AtomicJavaCmdBuilder(jar_file, temp_root=config.temp_root, jre_options=config.jre_options) params.add_value("--version") # Any version is fine; for now just catch old JREs requirement = versions.Requirement(call=params.finalized_call, name="GenomeAnalysisTK", search=r"^(\d+)\.(\d+)", checks=versions.Any()) _GATK_VERSION[jar_file] = requirement return _GATK_VERSION[jar_file]
def __init__(self, config, reference, intervals, infiles, outfile, dependencies=()): self._basename = os.path.basename(outfile) infiles = safe_coerce_to_tuple(infiles) jar_file = os.path.join(config.jar_root, "GenomeAnalysisTK.jar") command = AtomicJavaCmdBuilder(jar_file, jre_options=config.jre_options) command.set_option("-T", "IndelRealigner") command.set_option("-R", "%(IN_REFERENCE)s") command.set_option("-targetIntervals", "%(IN_INTERVALS)s") command.set_option("-o", "%(OUT_BAMFILE)s") command.set_option("--bam_compression", 0) command.set_option("--disable_bam_indexing") _set_input_files(command, infiles) command.set_kwargs(IN_REFERENCE=reference, IN_REF_DICT=fileutils.swap_ext(reference, ".dict"), IN_INTERVALS=intervals, OUT_BAMFILE=outfile, CHECK_GATK=_get_gatk_version_check(config)) calmd = AtomicCmd(["samtools", "calmd", "-b", "%(TEMP_IN_BAM)s", "%(IN_REF)s"], TEMP_IN_BAM=self._basename, IN_REF=reference, TEMP_OUT_STDOUT=self._basename + ".calmd", CHECK_VERSION=SAMTOOLS_VERSION) description = "<GATK Indel Realigner (aligning): %s -> %r>" \ % (describe_files(infiles), outfile) CommandNode.__init__(self, description=description, command=ParallelCmds([command.finalize(), calmd]), dependencies=dependencies)
def __init__(self, config, reference, infiles, outfile, threads=1, dependencies=()): threads = _get_max_threads(reference, threads) infiles = safe_coerce_to_tuple(infiles) jar_file = os.path.join(config.jar_root, "GenomeAnalysisTK.jar") command = AtomicJavaCmdBuilder(jar_file, jre_options=config.jre_options) command.set_option("-T", "RealignerTargetCreator") command.set_option("-R", "%(IN_REFERENCE)s") command.set_option("-o", "%(OUT_INTERVALS)s") command.set_option("-nt", threads) _set_input_files(command, infiles) command.set_kwargs(IN_REFERENCE=reference, IN_REF_DICT=fileutils.swap_ext(reference, ".dict"), OUT_INTERVALS=outfile, CHECK_GATK=_get_gatk_version_check(config)) description = "<GATK Indel Realigner (training): %s -> %r>" \ % (describe_files(infiles), outfile) CommandNode.__init__(self, threads=threads, description=description, command=command.finalize(), dependencies=dependencies)
def test_java_builder__kwargs(): builder = AtomicJavaCmdBuilder("/path/Foo.jar", set_cwd=True) assert_equal(builder.kwargs, {"AUX_JAR": "/path/Foo.jar", "set_cwd": True})
def test_java_builder__defaults__kwargs(): builder = AtomicJavaCmdBuilder("/path/Foo.jar") assert_equal(builder.kwargs, {"AUX_JAR": "/path/Foo.jar"})