LiuzLab / AI_MARRVEL

AI-MARRVEL (AIM) is an AI system for rare genetic disorder diagnosis
GNU General Public License v3.0
8 stars 5 forks source link

Implement parameter validation for all required parameters #49

Closed hyunhwan-bcm closed 1 month ago

hyunhwan-bcm commented 1 month ago

Description

We need to add a validation step at the beginning of our Nextflow pipeline to ensure that all required parameters are declared. This will help prevent runtime errors and provide clear feedback to users when necessary parameters are missing.

Proposed Implementation

  1. Create a new process or function for parameter validation
  2. Check all required parameters
  3. Provide clear error messages for any missing parameters
  4. (Optional) Implement type checking and value validation for certain parameters

Required Parameters to Check

Based on the provided Nextflow script, here's a non-exhaustive list of parameters that should be checked:

(Note: This list may not be complete and should be reviewed to ensure all required parameters are included)

Example Implementation

def validateParameters() {
    def requiredParams = [
        'input_vcf', 'input_hpo', 'run_id', 'ref_ver', 'outdir',
        'ref_loc', 'ref_to_sym', 'ref_sorted_sym', 'ref_exonic_filter_bed',
        'vep_dir_cache', 'vep_dir_plugins', 'vep_custom_gnomad',
        'vep_custom_clinvar', 'vep_custom_hgmd', 'vep_plugin_revel',
        'vep_plugin_spliceai_snv', 'vep_plugin_spliceai_indel',
        'vep_plugin_cadd', 'vep_plugin_dbnsfp', 'vep_idx'
    ]

    def missingParams = []

    requiredParams.each { param ->
        if (!params.containsKey(param) || params[param] == null || params[param].toString().trim().isEmpty()) {
            missingParams.add(param)
        }
    }

    if (missingParams.size() > 0) {
        error """
        The following required parameters are missing:
        ${missingParams.join(', ')}

        Please provide values for these parameters and run the pipeline again.
        """
    }

    // Additional type and value checks can be added here
    if (params.ref_ver != 'hg38' && params.ref_ver != 'hg19') {
        error "ref_ver must be either 'hg38' or 'hg19'. Provided value: ${params.ref_ver}"
    }

    // Add more specific checks as needed
}

workflow {
    // Call the validation function at the start of the workflow
    validateParameters()

    // Rest of the workflow...
}

Tasks

Additional Considerations