ROOTCP
Copy ROOT file/object(s) using the ROOT rootcp command line tool
URL: https://github.com/root-project/root/blob/master/main/python/rootcp.py
Example
This wrapper can be used in the following way:
rule rootcp:
input:
"ntuple0.root",
log:
"logs/rootcp/rootcp.log",
params:
input_object_name="TestTree",
extra="--recreate",
threads: 1
output:
"ntuple0_copy.root",
wrapper:
"v6.1.0/phys/root/rootcp"
Note that input, output and log file paths can be chosen freely.
When running with
snakemake --use-conda
the software dependencies will be automatically deployed into an isolated environment before execution.
Software dependencies
ROOT=6.30.4
Input/Output
Input:
ROOT file/object(s) target (to be copied) and destination.
Output:
single ROOT file containing copied target object(s).
Params
extra: extra parameters to rootcp (see ROOT documentation, e.g. -c for compression levels)input_object_name: (optional) object in ROOT file to be copied.output_object_name: (optional) name of destination object to be copied to.
Code
__author__ = "Jamie Gooding"
__copyright__ = "Copyright 2024, Jamie Gooding"
__email__ = "jamie.gooding@cern.ch"
__license__ = "MIT"
from snakemake.shell import shell
extra = snakemake.params.get("extra", "")
log = snakemake.log_fmt_shell(stdout=True, stderr=True)
object_in = snakemake.params.get("input_object_name", "")
if object_in:
object_in = f":{object_in}"
object_out = snakemake.params.get("output_object_name", "")
if object_out:
object_out = f":{object_out}"
shell(
"rootcp {extra} {snakemake.input}{object_in} {snakemake.output}{object_out} {log}"
)