view recetox_aplcms_recover_weaker_signals.xml @ 12:24278c6b6d1c draft

planemo upload for repository https://github.com/RECETOX/galaxytools/tree/master/tools/recetox_aplcms commit f5e491b0f3f4005e3d8f75954f2d469297b300bf
author recetox
date Mon, 16 Sep 2024 15:17:59 +0000
parents d7f5878a98c3
children
line wrap: on
line source

<tool id="recetox_aplcms_recover_weaker_signals" name="recetox-aplcms - recover weaker signals" version="@TOOL_VERSION@+galaxy0" profile="21.09">
    <description>recover weaker signals from raw data using an aligned feature table</description>
    <macros>
        <import>macros.xml</import>
        <import>help.xml</import>
    </macros>
    <expand macro="annotation"/>
    <edam_operations>
        <edam_operation>operation_3215</edam_operation>
        <edam_operation>operation_3799</edam_operation>
    </edam_operations>
    <expand macro="refs"/>
    <expand macro="creator"/>
    <expand macro="requirements"/>

    <command detect_errors="aggressive"><![CDATA[
        python '${__tool_directory__}/mzml_id_getter.py' '$input_file';
        Rscript -e 'source("${__tool_directory__}/utils.R")' -e 'source("${run_script}")'
    ]]></command>
    <configfiles>
        <configfile name="run_script"><![CDATA[
            sample_name <- readChar('sample_name.txt', file.info('sample_name.txt')\$size)

            if(is.na(sample_name)) {
                stop("The mzML file does not contain run ID.")
            }

            #set extracted_filenames = str("', '").join([str($f) for $f in $extracted_files])
            extracted_feature_tables <- load_parquet_collection(c('$extracted_filenames'))
            sample_names <- unlist(lapply(extracted_feature_tables, load_sample_name))
            validate_sample_names(sample_names)
            extracted_features <- select_table_with_sample_name(extracted_feature_tables, sample_name)

            #set corrected_filenames = str("', '").join([str($f) for $f in $corrected_files])
            corrected_feature_tables <- load_parquet_collection(c('$corrected_filenames'))
            sample_names <- unlist(lapply(corrected_feature_tables, load_sample_name))
            validate_sample_names(sample_names)
            corrected_features <- select_table_with_sample_name(corrected_feature_tables, sample_name)

            metadata <- load_data_from_parquet_file('$metadata_file')
            rt_table <- load_data_from_parquet_file('$rt_file')
            intensity_table <- load_data_from_parquet_file('$intensity_file')

            recovered <- recover.weaker(
                filename = '$input_file',
                sample_name = sample_name,
                extracted_features = extracted_features,
                adjusted_features = corrected_features,
                metadata_table = metadata,
                rt_table = rt_table,
                intensity_table = intensity_table,
                mz_tol = $mz_tol/1e6,
                mz_tol_relative = $mz_tol_relative_ppm * 1e-06,
                rt_tol_relative = $rt_tol,
                #if $recover_mz_range:
                recover_mz_range = $recover_mz_range/1e6,
                #else:
                recover_mz_range = NA,
                #end if
                #if $recover_rt_range:
                recover_rt_range = $recover_rt_range,
                #else:
                recover_rt_range = NA,
                #end if
                use_observed_range = $use_observed_range,
                bandwidth = $bandwidth,
                #if $min_bandwidth:
                min_bandwidth = $min_bandwidth,
                #else:
                min_bandwidth = NA,
                #end if
                #if $max_bandwidth:
                max_bandwidth = $max_bandwidth,
                #else:
                max_bandwidth = NA,
                #end if
                recover_min_count = $recover_min_count,
                intensity_weighted = $intensity_weighted
            )

            recovered <- select_adjusted(recovered)

            recovered <- save_sample_name(recovered, sample_name)
            save_data_as_parquet_file(recovered, '$output_file')
        ]]></configfile>
    </configfiles>

    <inputs>
        <param name="input_file" type="data" format="mzml" label="Input spectra data"
               help="Mass spectrometry sample-wise features table." />
        <param name="extracted_files" type="data_collection" collection_type="list" format="parquet"
               label="Input extracted feature samples collection" help="Mass spectrometry files containing feature samples." />
        <param name="corrected_files" type="data_collection" collection_type="list" format="parquet"
               label="Input corrected feature samples collection" help="Mass spectrometry file containing corrected feature samples." />
        <param name="metadata_file" type="data" format="parquet" label="Metadata table"
               help="Peak metadata table from the align features step." />
        <param name="rt_file" type="data" format="parquet" label="RT table"
               help="Table with retention times for features (rows) across samples (columns)." />
        <param name="intensity_file" type="data" format="parquet" label="Intensity table"
               help="Table with intensities for features (rows) across samples (columns)." />
        <expand macro="tolerances"/>
        <expand macro="recover_weaker_params"/>
        <expand macro="bandwidth_params"/>
    </inputs>

    <outputs>
        <data label="${($input_file.element_identifier).rsplit('.',1)[0]}.parquet" name="output_file" format="parquet" />
    </outputs>

    <tests>
        <test expect_failure="true" />
    </tests>

    <help>
        <![CDATA[
            @RECOVER_WEAKER_SIGNALS_HELP@

            @GENERAL_HELP@
        ]]>
    </help>

    <expand macro="citations"/>
</tool>