view main_macros.xml @ 2:764f6363e2a9 draft default tip

planemo upload for repository https://github.com/goeckslab/tools-mti/tree/main/tools/vitessce commit a6714d257c45c11d999c7cc2241c89da193cae15
author goeckslab
date Fri, 10 May 2024 17:21:02 +0000
parents 8097f9124f87
children
line wrap: on
line source

<macros>
    <token name="@TOOL_VERSION@">1.0.4</token>
    <token name="@VERSION_SUFFIX@">4</token>
    <token name="@PROFILE@">20.01</token>

    <xml name="vitessce_requirements">
        <requirements>
            <container type="docker">quay.io/goeckslab/vitessce:@TOOL_VERSION@v2</container>
        </requirements>
    </xml>

    <xml name="macro_stdio">
        <stdio>
            <exit_code range="1:" level="fatal" description="Error occurred. Please check Tool Standard Error" />
        </stdio>
    </xml>

    <xml name="vitessce_cmd" token_tool_id="vitessce_spatial">
        <command detect_errors="aggressive">
        <![CDATA[
        MAX_MEM=\${GALAXY_MEMORY_MB:-2000} &&
        export BF_MAX_MEM="\$((\$MAX_MEM/2))m" &&
        mkdir -p '${output.files_path}/A/0' &&
        ln -sf '$image' '${output.files_path}/A/0/image01.ome.tiff' &&
        #if $masks
            info=\$(showinf -nopix -nometa -noflat '${output.files_path}/A/0/image01.ome.tiff') &&
            echo '>showinf -nopix -nometa -noflat \$image' &&
            echo "\$info\n" &&
            masks_info=\$(showinf -nopix -nometa -noflat '$masks') &&
            echo '>showinf -nopix -nometa -noflat \$masks' &&
            echo "\$masks_info\n" &&
            masks_n_resolutions=\$(echo "\$masks_info" | grep '^\s*Resolutions\s*=' -m1 | cut -d'=' -f2 | xargs) &&
            if [ -z \$masks_n_resolutions ]; then
                n_resolutions=\$(echo "\$info" | grep '^\s*Resolutions\s*=' -m1 | cut -d'=' -f2 | xargs) &&
                pyramid_scale=1 &&
                if [ -z "\$n_resolutions" ]; then
                    echo "Warning: Failded to retrieve the number of pyramid resolutions. Set pyramid resolutions to 4 and scale to 2!";
                    n_resolutions=4;
                    pyramid_scale=2;
                else
                    echo "Found the number of pyramid resolutions: \$n_resolutions";
                    if [ "\$n_resolutions" -gt 1 ]; then
                        sizeX0=\$(echo "\$info" | grep '^\s*sizeX\[0\]\s*=' -m1 | cut -d'=' -f2 | xargs) ;
                        sizeX1=\$(echo "\$info" | grep '^\s*sizeX\[1\]\s*=' -m1 | cut -d'=' -f2 | xargs) ;
                        if [ "\$sizeX0" -gt 0 ] && [ "\$sizeX1" -gt 0 ]; then
                            pyramid_scale=\$(((\$sizeX0 + \$sizeX1 / 2 ) / \$sizeX1));
                            echo "Calculate pyramid scale: \$sizeX0 / \$sizeX1 ~= \$pyramid_scale.";
                        else
                            pyramid_scale=2;
                            echo "Warning: Failed to calculate the pyramid scale; set it to 2!";
                        fi;
                    fi;
                fi;
                tile_info=\$(showinf -nopix -nometa -noflat '${output.files_path}/A/0/image01.ome.tiff' | grep '^\s*Tile\ssize\s*=' -m1);
                tile_x=\$(echo "\$tile_info" | cut -d' ' -f4);
                tile_y=\$(echo "\$tile_info" | cut -d' ' -f6);
                convert_cmd="bfconvert -pyramid-resolutions \$n_resolutions -pyramid-scale \$pyramid_scale -noflat -tilex \$tile_x -tiley \$tile_y '$masks' '${output.files_path}/A/0/masks01.ome.tiff'";
                echo "\n>\$convert_cmd";
                eval \$convert_cmd;
                masks_info_new=\$(showinf -nopix -nometa -noflat '${output.files_path}/A/0/masks01.ome.tiff');
                echo "\n>showinf -nopix -nometa -noflat '${output.files_path}/A/0/masks01.ome.tiff'";
                echo "\$masks_info_new\n";
            else
                ln -sf '$masks' '${output.files_path}/A/0/masks01.ome.tiff';
            fi &&
        #end if
        python '$__tool_directory__/@TOOL_ID@.py'
            --inputs '$inputs'
            --output '${output.files_path}'
            --image '${output.files_path}/A/0/image01.ome.tiff'
            #if $masks
                --masks '${output.files_path}/A/0/masks01.ome.tiff'
            #end if
            #if $do_phenotyping.phenotyping_choice == 'add_h5ad'
            --anndata '$anndata'
            #end if
            &&
        cp -R '$__tool_directory__/static' '${output.files_path}' &&
        cp '$__tool_directory__/index.html' '$output';

        ]]>
        </command>
    </xml>

</macros>