Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Globally prepend module's "src" directory in modules to simplify use of bundled scripts #146

Open
rdmorin opened this issue Dec 7, 2020 · 0 comments

Comments

@rdmorin
Copy link
Collaborator

rdmorin commented Dec 7, 2020

The latest Lofreq modification implements a cleaner and more maintainable approach to utilize bundled scripts in "src". Our original approach meant that each script had to be specified in the config. The new structure for the config is shown below.

lcr-modules:
    lofreq:
        inputs:
            # Available wildcards: {seq_type} {genome_build} {sample_id}
            sample_bam: "__UPDATE__"
            sample_bai: "__UPDATE__"
            src_dir: "{MODSDIR}/src" #prepended to PATH to make bundled scripts available without needing the specify the path to each script 

The value of src_dir is then used in the module as follows.

#Near top of module file
CFG = op.setup_module(
    name = "lofreq",
    version = "1.0",
    subdirectories = ["inputs", "lofreq", "combined", "filtered", "outputs"],
)
#set variable for prepending to PATH based on config
SCRIPT_PATH = CFG['inputs']['src_dir']
#simplified example from lofreq showing use of bundled lofreq_filter.sh
shell:
        op.as_one_line("""
        PATH={SCRIPT_PATH}:$PATH;
        SCRIPT=$(which lofreq_filter.sh);   #debugging lines. Unnecessary but sometimes helpful
        echo $SCRIPT;    #debugging lines. Unnecessary but sometimes helpful
        lofreq_filter.sh {input.vcf_all} | bgzip > {output.vcf_all_clean}
          && tabix -p vcf {output.vcf_all_clean}
              &&
        lofreq_filter.sh {input.vcf_all_filtered} | bgzip > {output.vcf_all_filtered_clean}
          && tabix -p vcf {output.vcf_all_filtered_clean}
        """)

In order to implement this in existing modules we will need to do away with the subdirectory structure of src (i.e. all scripts are in the top-level src directory). These scripts will also need to be made executable and have a shebang line (ideally using "/usr/bin/env" for maximal portability.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants