Mercurial > repos > bgruening > hicexplorer_hicconvertformat
diff hicConvertFormat.xml @ 0:e136f22c2a0f draft
"planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/tools/hicexplorer commit 3b41d687ff30583540d055f6995de00530cca81d-dirty"
author | bgruening |
---|---|
date | Mon, 16 Dec 2019 15:28:54 -0500 |
parents | |
children | 2f62a87d4017 |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hicConvertFormat.xml Mon Dec 16 15:28:54 2019 -0500 @@ -0,0 +1,375 @@ +<tool id="hicexplorer_hicconvertformat" name="@BINARY@" version="@WRAPPER_VERSION@.0"> + <description>Convert between different file formats</description> + <macros> + <token name="@BINARY@">hicConvertFormat</token> + <token name="@SINGLE_INPUT@"> + #if $xml_path.inputFormat_selector == 'optionCool': + --matrices 'matrix.cool' + --inputFormat cool + #if $xml_path.correctionName: + --correction_name '$xml_path.correctionName' + #end if + + #if $xml_path.correctionDivision: + --correction_division + #end if + + #if $xml_path.chromosome: + #set $chromosome = ' '.join([ '\'%s\'' % $chrom for $chrom in str($xml_path.chromosome).split(' ') ]) + + --chromosome $chromosome + #end if + + #if $xml_path.loadRawValues: + --load_raw_values + #end if + #end if + #if $xml_path.inputFormat_selector == 'optionH5': + --matrices "matrix.h5" + --inputFormat h5 + + #end if + #if $xml_path.inputFormat_selector == 'optionHomer': + --matrices "matrix.homer" + --inputFormat homer + + #end if + #if $xml_path.inputFormat_selector == 'optionHicpro': + --matrices "matrix.hicpro" + --bedFileHicpro "matrix.bed" + --inputFormat hicpro + #end if + #if $xml_path.inputFormat_selector == 'optionHic': + --matrices "matrix.hic" + #if $xml_path.resolutions: + #set $resolutions = ' '.join([ '"%s"' % $resolution for $resolution in str($xml_path.resolutions).split(" ") ]) + + --resolutions $resolutions + #end if + --inputFormat hic + #end if + </token> + <import>macros.xml</import> + </macros> + + <expand macro="requirements" /> + <command detect_errors="exit_code"><![CDATA[ + + + ## single to single case + + + #if $outputSingleMultiple_conditional.outputSingleMultiple_selector == 'singleMatrix': + #set xml_path = $outputSingleMultiple_conditional.inputFormat_conditional + + #if $xml_path.inputFormat_selector == 'optionCool': + ln -s "$xml_path.matrix_h5_cooler" "matrix.cool" && + + #end if + #if $xml_path.inputFormat_selector == 'optionH5': + ln -s "$xml_path.matrix_h5_cooler" "matrix.h5" && + + #end if + #if $xml_path.inputFormat_selector == 'optionHomer': + ln -s "$xml_path.matrixHomer" "matrix.homer" && + + #end if + + #if $xml_path.inputFormat_selector == 'optionHicpro': + ln -s "$xml_path.matrixHicpro" "matrix.hicpro" && + ln -s "$xml_path.bedHicpro" "matrix.bed" && + #end if + + #if $xml_path.inputFormat_selector == 'optionHic': + ln -s "$xml_path.matrixHic" "matrix.hic" && + #end if + + + + @BINARY@ + @SINGLE_INPUT@ + + + --outputFormat $outputSingleMultiple_conditional.outputFormat_conditional.outputFormat_selector + --outFileName 'matrix.$outputSingleMultiple_conditional.outputFormat_conditional.outputFormat_selector' + + #if $outputSingleMultiple_conditional.outputFormat_conditional.outputFormat_selector == 'ginteractions': + && mv 'matrix.${outputSingleMultiple_conditional.outputFormat_conditional.outputFormat_selector}.tsv' matrix_out + + #else: + && mv "matrix.$outputSingleMultiple_conditional.outputFormat_conditional.outputFormat_selector" matrix_out + #end if + #end if + + + ### Set up links to matrices to have correct ending + #if $outputSingleMultiple_conditional.outputSingleMultiple_selector == 'multipleMatrix': + #if $outputSingleMultiple_conditional.resolutionOrManyToOne_conditional.resolutionOrManyToOne_selector == 'resolution_option': + #set xml_path = $outputSingleMultiple_conditional.resolutionOrManyToOne_conditional.inputFormat_conditional + #if $xml_path.inputFormat_selector == 'optionCool': + ln -s "$xml_path.matrix_h5_cooler" "matrix.cool" && + #end if + + #if $xml_path.inputFormat_selector == 'optionH5': + ln -s "$xml_path.matrix_h5_cooler" "matrix.h5" && + + #end if + + #if $xml_path.inputFormat_selector == 'optionHomer': + ln -s "$xml_path.matrix_h5_cooler" "matrix.homer" && + + #end if + + #if $xml_path.inputFormat_selector == 'optionHicpro': + ln -s "$xml_path.matrix_h5_cooler" "matrix.hicpro" && + ln -s "$xml_path.bedHicpro" "matrix.bed" && + + #end if + #if $xml_path.inputFormat_selector == 'optionHic': + ln -s "$xml_path.matrix_h5_cooler" "matrix.hic" && + + #end if + #else: + #set xml_manyToOne = $outputSingleMultiple_conditional.resolutionOrManyToOne_conditional + #if $xml_manyToOne.inputFormat_conditional.inputFormat_selector == 'optionCool': + #for $counter, $m in enumerate($xml_manyToOne.matrix_h5_cooler_multiple): + ln -s '$m' "${counter}_matrix.cool" && + #end for + #set $m = ' '.join([ '"%s_matrix"' % $counter for $counter, $matrix in enumerate($xml_manyToOne.matrix_h5_cooler_multiple) ]) + + #end if + #if $xml_manyToOne.inputFormat_conditional.inputFormat_selector == 'optionH5': + #for $counter, $m in enumerate($xml_manyToOne.matrix_h5_cooler_multiple): + ln -s '$m' "${counter}_matrix.h5" && + #end for + #set $m = ' '.join([ '"%s_matrix"' % $counter for $counter, $matrix in enumerate($xml_manyToOne.matrix_h5_cooler_multiple) ]) + #end if + #if $xml_manyToOne.inputFormat_conditional.inputFormat_selector == 'optionHomer': + #for $counter, $m in enumerate($xml_manyToOne.matrixHomer): + ln -s '$m' "${counter}_matrix.homer" && + #end for + #set $m = ' '.join([ '"%s_matrix.homer"' % $counter for $counter, $matrix in enumerate($xml_manyToOne.matrixHomer) ]) + #end if + #if $xml_manyToOne.inputFormat_conditional.inputFormat_selector == 'optionHicpro': + #for $counter, $m in enumerate($xml_manyToOne.matrixHicpro): + ln -s '$m' "${counter}_matrix.hicpro" && + #end for + #set $m = ' '.join([ '"%s_matrix.hicpro"' % $counter for $counter, $matrix in enumerate($xml_manyToOne.matrixHicpro) ]) + + #for $counter, $bed in enumerate($xml_manyToOne.bedHicpro): + ln -s '$bed' "${counter}_matrix.bed" && + #end for + #set $bed = ' '.join([ '"%s_matrix.bed"' % $counter for $counter, $matrix in enumerate($xml_manyToOne.bedHicpro) ]) + --bedFileHicpro '$bed' + #end if + #end if + + + @BINARY@ + --outputFormat mcool + + #if $outputSingleMultiple_conditional.resolutionOrManyToOne_conditional.resolutionOrManyToOne_selector == 'resolution_option': + #set $resolutions = ' '.join([ '"%s"' % $resolution for $resolution in str($outputSingleMultiple_conditional.resolutionOrManyToOne_conditional.resolutions).split(" ") ]) + + --resolutions $resolutions + #if $xml_path.inputFormat_selector == 'optionCool': + --matrices "matrix.cool" + --inputFormat cool + #end if + #if $xml_path.inputFormat_selector == 'optionH5': + --matrices "matrix.h5" + --inputFormat h5 + + #end if + #if $xml_path.inputFormat_selector == 'optionHomer': + --matrices "matrix.homer" + --inputFormat homer + + #end if + #if $xml_path.inputFormat_selector == 'optionHicpro': + --matrices "matrix.hicpro" + --bedFileHicpro "matrix.bed" + --inputFormat hicpro + #end if + #if $xml_path.inputFormat_selector == 'optionHic': + --matrices "matrix.hic" + --inputFormat hic + #end if + #end if + + #if $outputSingleMultiple_conditional.resolutionOrManyToOne_conditional.resolutionOrManyToOne_selector == 'manyToOne_option': + #if $xml_manyToOne.inputFormat_conditional.inputFormat_selector == 'optionCool': + --inputFormat cool + #end if + + #if $xml_manyToOne.inputFormat_conditional.inputFormat_selector == 'optionH5': + --inputFormat h5 + #end if + + + #if $xml_manyToOne.inputFormat_conditional.inputFormat_selector == 'optionHomer': + --inputFormat homer + #end if + + #if $xml_manyToOne.inputFormat_conditional.inputFormat_selector == 'optionHicpro': + --inputFormat hicpro + --bedFileHicpro '$bed' + #end if + + --matrices $m + #end if + --outFileName matrix.mcool + && mv matrix.mcool matrix_out + + #end if + + +]]> + </command> + <inputs> + + <conditional name="outputSingleMultiple_conditional"> + <param name="outputSingleMultiple_selector" type="select" label="Choose output matrix type"> + <option value="singleMatrix" selected="True">single matrix</option> + <option value="multipleMatrix">multiple matrix</option> + </param> + <when value='singleMatrix'> + <expand macro='convertFormat_single_macro' /> + <expand macro='convertFormat_single_output_macro' /> + </when> + <when value='multipleMatrix'> + <conditional name="resolutionOrManyToOne_conditional"> + <param name="resolutionOrManyToOne_selector" type="select" label="Choose input file type"> + <option value='resolution_option' >Create out of one matrix a multi matrix with diffrerent resolutions</option> + <option value='manyToOne_option'>Create out of n matrices one multi matrix </option> + </param> + <when value='resolution_option'> + <param name='resolutions' type='text' label='To be stored resolutions'/> + <expand macro='convertFormat_single_macro' /> + </when> + <when value='manyToOne_option'> + <expand macro='convertFormat_multiple_macro' /> + </when> + </conditional> + <param name='storeAppliedCorrection' type="boolean" truevalue="yes" falsevalue="" label='Store applied correction factors in column count'/> + <param name='enforceInteger' type="boolean" truevalue="yes" falsevalue="" label='Enforce integer for count column'/> + </when> + </conditional> + </inputs> + <outputs> + + <data name='output_converted_matrix' from_work_dir='matrix_out' format='cool' label='Converted matrix'> + <filter>outputSingleMultiple_conditional.outputSingleMultiple_selector == 'singleMatrix'</filter> + <change_format> + <when input="outputSingleMultiple_conditional.outputFormat_conditional.outputFormat_selector" value="h5" format="h5" /> + <when input="outputSingleMultiple_conditional.outputFormat_conditional.outputFormat_selector" value="homer" format="zip" /> + <when input="outputSingleMultiple_conditional.outputFormat_conditional.outputFormat_selector" value="ginteractions" format="tsv" /> + </change_format> + </data> + <data name='output_converted_matrix_multi' from_work_dir='matrix_out' format='mcool' label='Converted matrix mcool'> + <filter>outputSingleMultiple_conditional.outputSingleMultiple_selector == 'multipleMatrix'</filter> + </data> + </outputs> + <tests> + <test> + <conditional name='outputSingleMultiple_conditional'> + <param name='outputSingleMultiple_selector' value='singleMatrix'/> + <conditional name='inputFormat_conditional'> + <param name='inputFormat_selector' value='optionCool'/> + <param name='matrix_h5_cooler' value='small_test_matrix.cool'/> + </conditional> + + <conditional name='outputFormat_conditional'> + <param name='outputFormat_selector' value='h5'/> + </conditional> + </conditional> + <output name="output_converted_matrix" ftype="h5"> + <assert_contents> + <has_h5_keys keys='intervals,matrix,nan_bins'/> + </assert_contents> + </output> + </test> + <test> + <conditional name='outputSingleMultiple_conditional'> + <param name='outputSingleMultiple_selector' value='singleMatrix'/> + <conditional name='inputFormat_conditional'> + <param name='inputFormat_selector' value='optionH5'/> + <param name='matrix_h5_cooler' value='small_test_matrix.h5'/> + </conditional> + + <conditional name='outputFormat_conditional'> + <param name='outputFormat_selector' value='cool'/> + </conditional> + </conditional> + <output name="output_converted_matrix" ftype="cool"> + <assert_contents> + <has_h5_keys keys='bins,chroms,indexes,pixels'/> + </assert_contents> + </output> + </test> + <test> + <conditional name='outputSingleMultiple_conditional'> + <param name='outputSingleMultiple_selector' value='singleMatrix'/> + <conditional name='inputFormat_conditional'> + <param name='inputFormat_selector' value='optionCool'/> + <param name='matrix_h5_cooler' value='hicConvertFormat/small_test_matrix_chr4.cool'/> + </conditional> + + <conditional name='outputFormat_conditional'> + <param name='outputFormat_selector' value='homer'/> + </conditional> + </conditional> + <output name="output_converted_matrix" file="hicConvertFormat/small_test_matrix_chr4.homer" ftype="zip" compare="sim_size" delta="40000"/> + </test> + <test> + <conditional name='outputSingleMultiple_conditional'> + <param name='outputSingleMultiple_selector' value='singleMatrix'/> + <conditional name='inputFormat_conditional'> + <param name='inputFormat_selector' value='optionCool'/> + <param name='matrix_h5_cooler' value='hicConvertFormat/small_test_matrix_chr4.cool'/> + </conditional> + + <conditional name='outputFormat_conditional'> + <param name='outputFormat_selector' value='ginteractions'/> + </conditional> + </conditional> + <output name="output_converted_matrix" file="hicConvertFormat/small_test_matrix_chr4.ginteractions.tsv" ftype="tsv" compare="sim_size" delta="40000"/> + + </test> + <test> + <conditional name='outputSingleMultiple_conditional'> + <param name='outputSingleMultiple_selector' value='multipleMatrix'/> + <conditional name='resolutionOrManyToOne_conditional'> + <param name='resolutionOrManyToOne_selector' value='resolution_option'/> + <param name='resolutions' value='5000 10000 20000'/> + <conditional name='inputFormat_conditional'> + <param name='inputFormat_selector' value='optionH5'/> + <param name='matrix_h5_cooler' value='small_test_matrix.h5'/> + </conditional> + </conditional> + </conditional> + <output name="output_converted_matrix" ftype="cool"> + <assert_contents> + <has_h5_keys keys='resolutions'/> + </assert_contents> + </output> + </test> + </tests> + <help><![CDATA[ +Converting between different Hi-C interaction formats +===================================================== + +Conversion of Hi-C matrices of different file formats. We support the conversion of hic to cool format via hic2cool, +and homer, HicPro, h5 and cool format to h5, cool, homer or ginteractions format. Moreover, hicConvertFormat accepts multiple input files +from one format with different resolutions and creates a mcool file. Each original file is stored under the path e.g. ::/resolutions/10000. +A batch computation is possible, the number of input files and output files needs to match, all input files need to be of the same format type and +all output files too. +For input and output of cooler files special options are available, for all other formats they will be ignored. +HiCPro file format needs an additional bed file as input. + +| For more information about HiCExplorer please consider our documentation on readthedocs.io_ + +.. _readthedocs.io: http://hicexplorer.readthedocs.io/en/latest/index.html +]]></help> + <expand macro="citations" /> +</tool>