berntpopp / hardnormly

MIT License
1 stars 0 forks source link

Feature request: Add Subcommands for Specific Steps #5

Open berntpopp opened 2 months ago

berntpopp commented 2 months ago

Description: Add subcommands for generating only exclusion or inclusion BED files without running the full pipeline. Possible subcommands:

berntpopp commented 2 months ago

Plan for Subcommands Implementation in Bash Script

Objective:

To implement three subcommands:

  1. generate-exclusion-bed: Generates exclusion BED files only.
  2. generate-inclusion-bed: Generates inclusion BED files only.
  3. run-pipeline: Executes the entire pipeline, including BED file generation, VCF normalization, annotation, and filtering.

Implementation Plan:

  1. Subcommands:

    • Use a case block to parse and execute specific subcommands based on user input.
  2. Functions:

    • generate_exclusion_bed():
      • Normalize exclusion BED files.
      • Combine and process the BED files.
      • Compress and index the output files.
    • generate_inclusion_bed():
      • Normalize inclusion BED files.
      • Combine and process the BED files.
      • Compress and index the output files.
    • run_pipeline():
      • Call both generate_exclusion_bed() and generate_inclusion_bed().
      • Normalize the VCF using bcftools norm.
      • Annotate the VCF using the generated BED files with bcftools annotate.
      • Apply filters using bcftools filter.
      • Generate statistics and plots (optional).
  3. Helper Functions:

    • normalize_bed(): Applies sorting and annotation to a BED file.
    • combine_and_process_bed(): Merges, compresses, and indexes the BED files.
    • normalize_and_annotate_vcf(): Handles VCF normalization and annotation using bcftools.
  4. Execution Flow:

    • If the user runs generate-exclusion-bed, only the exclusion BED files will be generated.
    • If the user runs generate-inclusion-bed, only the inclusion BED files will be generated.
    • If the user runs run-pipeline, all steps are executed sequentially, including VCF processing.
  5. Debugging and Logging:

    • Ensure all steps are logged with appropriate messages.
    • Use debug_msg() for detailed command logs when --debug is enabled.
  6. Error Handling:

    • Apply consistent error handling using || { log_msg "Error"; exit 1; } after critical commands.
  7. Testing:

    • Test each subcommand separately to ensure modular functionality.
    • Test run-pipeline to confirm the full workflow is executed correctly.