本文整理汇总了Python中paleomix.atomiccmd.builder.AtomicCmdBuilder类的典型用法代码示例。如果您正苦于以下问题:Python AtomicCmdBuilder类的具体用法?Python AtomicCmdBuilder怎么用?Python AtomicCmdBuilder使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了AtomicCmdBuilder类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_builder__set__kwargs__overwriting
def test_builder__set__kwargs__overwriting():
expected = {"IN_PATH": "/a/b/"}
builder = AtomicCmdBuilder("echo")
builder.set_kwargs(IN_PATH="/a/b/")
assert_raises(AtomicCmdBuilderError,
builder.set_kwargs, IN_PATH="/dst/file")
assert_equal(builder.kwargs, expected)
示例2: _bowtie2_template
def _bowtie2_template(call, prefix, iotype = "IN", **kwargs):
params = AtomicCmdBuilder(call, **kwargs)
for postfix in ("1.bt2", "2.bt2", "3.bt2", "4.bt2", "rev.1.bt2", "rev.2.bt2"):
key = "%s_PREFIX_%s" % (iotype, postfix.upper())
params.set_kwargs(**{key : (prefix + "." + postfix)})
return params
示例3: test_builder__set_kwargs__after_finalize
def test_builder__set_kwargs__after_finalize():
expected = {"IN_PATH": "/a/b/"}
builder = AtomicCmdBuilder("echo")
builder.set_kwargs(IN_PATH="/a/b/")
builder.finalize()
assert_raises(AtomicCmdBuilderError, builder.set_kwargs, OUT_PATH="/dst/file")
assert_equal(builder.kwargs, expected)
示例4: _do_test_builder__pop_option
def _do_test_builder__pop_option(setter):
builder = AtomicCmdBuilder("find")
setter(builder, "-empty", fixed=False)
setter(builder, "-size", "1", fixed=False)
setter(builder, "-name", "*.txt", fixed=False)
builder.pop_option("-size")
assert_equal(builder.call, ["find", "-empty", "-name", "*.txt"])
示例5: customize
def customize(self, config, reference, input_files, output_file, directory,
dependencies=()):
input_files = safe_coerce_to_tuple(input_files)
stats_out_fname = "Stats_out_MCMC_correct_prob.csv"
command = AtomicCmdBuilder(["mapDamage", "--rescale-only",
"-i", "%(TEMP_IN_BAM)s",
"-d", "%(TEMP_DIR)s",
"-r", "%(IN_REFERENCE)s",
"--rescale-out", "%(OUT_BAM)s"],
TEMP_IN_BAM=MultiBAMInputNode.PIPE_FILE,
IN_REFERENCE=reference,
TEMP_OUT_LOG="Runtime_log.txt",
TEMP_OUT_CSV=stats_out_fname,
OUT_BAM=output_file,
CHECK_VERSION=MAPDAMAGE_VERSION)
command.add_multiple_kwargs(input_files)
return {"command": command,
"config": config,
"input_files": input_files,
"directory": directory,
"dependencies": dependencies}
示例6: customize
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}
示例7: test_builder__add_multiple_values
def test_builder__add_multiple_values():
values = ("file_a", "file_b")
expected = {"IN_FILE_01": "file_a", "IN_FILE_02": "file_b"}
builder = AtomicCmdBuilder("ls")
kwargs = builder.add_multiple_values(values)
assert_equal(kwargs, expected)
assert_equal(builder.kwargs, expected)
assert_equal(builder.call, ["ls", "%(IN_FILE_01)s", "%(IN_FILE_02)s"])
示例8: test_builder__add_multiple_values_with_template
def test_builder__add_multiple_values_with_template():
values = ("file_a", "file_b")
expected = {"OUT_BAM_1": "file_a", "OUT_BAM_2": "file_b"}
builder = AtomicCmdBuilder("ls")
kwargs = builder.add_multiple_values(values, template="OUT_BAM_%i")
assert_equal(kwargs, expected)
assert_equal(builder.kwargs, expected)
assert_equal(builder.call, ["ls", "%(OUT_BAM_1)s", "%(OUT_BAM_2)s"])
示例9: test_builder__add_multiple_kwargs_multiple_times
def test_builder__add_multiple_kwargs_multiple_times():
expected = {"IN_FILE_01": "file_a", "IN_FILE_02": "file_b"}
builder = AtomicCmdBuilder("ls")
kwargs = builder.add_multiple_kwargs(("file_a",))
assert_equal(kwargs, {"IN_FILE_01": "file_a"})
kwargs = builder.add_multiple_kwargs(("file_b",))
assert_equal(kwargs, {"IN_FILE_02": "file_b"})
assert_equal(builder.kwargs, expected)
assert_equal(builder.call, ["ls"])
示例10: test_builder__add_multiple_options_with_sep
def test_builder__add_multiple_options_with_sep():
values = ("file_a", "file_b")
expected = {"IN_FILE_01": "file_a", "IN_FILE_02": "file_b"}
builder = AtomicCmdBuilder("ls")
kwargs = builder.add_multiple_options("-i", values, sep="=")
assert_equal(kwargs, expected)
assert_equal(builder.kwargs, expected)
assert_equal(builder.call, ["ls",
"-i=%(IN_FILE_01)s",
"-i=%(IN_FILE_02)s"])
示例11: _get_bwa_template
def _get_bwa_template(call, prefix, iotype="IN", **kwargs):
extensions = ["amb", "ann", "bwt", "pac", "sa"]
try:
if BWA_VERSION.version < (0, 6, 0):
extensions.extend(("rbwt", "rpac", "rsa"))
except versions.VersionRequirementError:
pass # Ignored here, handled elsewhere
params = AtomicCmdBuilder(call, **kwargs)
for postfix in extensions:
key = "%s_PREFIX_%s" % (iotype, postfix.upper())
params.set_kwargs(**{key: (prefix + "." + postfix)})
return params
示例12: __init__
def __init__(self, input_file, k_groups, output_root,
samples=None, dependencies=()):
self._samples = samples
self._input_file = input_file
self._k_groups = k_groups
group_key = "Group(%i)" % (self._k_groups,)
self._supervised = samples and any((row[group_key] != '-')
for row in samples.itervalues())
assert k_groups in (2, 3), k_groups
prefix = os.path.splitext(os.path.basename(input_file))[0]
output_prefix = os.path.join(output_root,
"%s.%i" % (prefix, k_groups))
cmd = AtomicCmdBuilder("admixture",
IN_FILE_BED=input_file,
IN_FILE_BIM=fileutils.swap_ext(input_file,
".bim"),
IN_FILE_FAM=fileutils.swap_ext(input_file,
".fam"),
TEMP_OUT_FILE_BED=prefix + ".bed",
TEMP_OUT_FILE_BIM=prefix + ".bim",
TEMP_OUT_FILE_FAM=prefix + ".fam",
TEMP_OUT_FILE_POP=prefix + ".pop",
OUT_P=output_prefix + ".P",
OUT_Q=output_prefix + ".Q",
OUT_STDOUT=output_prefix + ".log",
CHECK_VERSION=ADMIXTURE_VERSION,
set_cwd=True)
cmd.set_option("-s", random.randint(0, 2 ** 16 - 1))
if self._supervised:
cmd.set_option("--supervised")
cmd.add_value("%(TEMP_OUT_FILE_BED)s")
cmd.add_value(int(k_groups))
CommandNode.__init__(self,
description="<Admixture -> '%s.*''>"
% (output_prefix,),
command=cmd.finalize(),
dependencies=dependencies)
示例13: test_builder__add_option__overwrite
def test_builder__add_option__overwrite():
builder = AtomicCmdBuilder("find")
builder.add_option("-name", "*.txt")
builder.add_option("-or")
builder.add_option("-name", "*.bat")
assert_equal(builder.call, ["find", "-name",
"*.txt", "-or", "-name", "*.bat"])
示例14: test_builder__finalize__calls_atomiccmd
def test_builder__finalize__calls_atomiccmd():
was_called = []
class _AtomicCmdMock:
def __init__(self, *args, **kwargs):
assert_equal(args, (["echo", "-out", "%(OUT_FILE)s", "%(IN_FILE)s"],))
assert_equal(kwargs, {"IN_FILE": "/in/file",
"OUT_FILE": "/out/file",
"set_cwd": True})
was_called.append(True)
with Monkeypatch("paleomix.atomiccmd.builder.AtomicCmd", _AtomicCmdMock):
builder = AtomicCmdBuilder("echo", set_cwd=True)
builder.add_option("-out", "%(OUT_FILE)s")
builder.add_value("%(IN_FILE)s")
builder.set_kwargs(OUT_FILE="/out/file",
IN_FILE="/in/file")
builder.finalize()
assert was_called
示例15: customize
def customize(cls, input_alignment, output_tree, dependencies = ()):
"""
Arguments:
input_alignment -- An alignment file in a format readable by RAxML.
output_tree -- Filename for the output newick tree."""
command = AtomicCmdBuilder("parsimonator", set_cwd = True)
command.set_option("-s", "%(TEMP_OUT_ALN)s")
command.set_option("-n", "output")
# Random seed for the stepwise addition process
command.set_option("-p", int(random.random() * 2**31 - 1), fixed = False)
command.set_kwargs(# Auto-delete: Symlinks
TEMP_OUT_ALN = os.path.basename(input_alignment),
# Input files, are not used directly (see below)
IN_ALIGNMENT = input_alignment,
# Final output file, are not created directly
OUT_TREE = output_tree)
return {"command" : command}