number of elements in collections and multiple-true-params
Dear list, in a tool I want to process a set of (bam) files. For the convenience of the user I thought that it would be nice to allow collections as well as manually selected files (in a param with multiple=true). Like so: ``` <conditional name="input_type"> <param name="input_type_selector" type="select" label="BAM files"> <option value="list">data set list</option> <option value="manual">data sets</option> </param> <when value="manual"> <param name="input_bam" format="bam" type="data" multiple="true" optional="false" label="BAM files" /> </when> <when value="list"> <param name="input_bam" format="bam" type="data_collection" collection_type="list" label="BAM files" /> </when> </conditional> ``` Is there a way to get the number of data sets in both cases (in the collection or selection) in a consistent way? Currently the only way I found is: ``` #if $input_type.input_type_selector == 'manual': #set count = len($input_type.input_bam) #else #set count = len($input_type.input_bam.keys()) #end if ``` Appart from this looping works like a charm: ``` #for $bam in $input_type.input_bam: OPERATIONS... #end for ``` Cheers, Matthias -- ------------------------------------------- Matthias Bernt Bioinformatics Service Molekulare Systembiologie (MOLSYB) Helmholtz-Zentrum für Umweltforschung GmbH - UFZ/ Helmholtz Centre for Environmental Research GmbH - UFZ Permoserstraße 15, 04318 Leipzig, Germany Phone +49 341 235 482296, m.bernt@ufz.de, www.ufz.de Sitz der Gesellschaft/Registered Office: Leipzig Registergericht/Registration Office: Amtsgericht Leipzig Handelsregister Nr./Trade Register Nr.: B 4703 Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: MinDirig Wilfried Kraus Wissenschaftlicher Geschäftsführer/Scientific Managing Director: Prof. Dr. Dr. h.c. Georg Teutsch -------------------------------------------
Hi Matthias, I think you're right in that len($input_type.input_bam) is inconsistent, we can implement __len__ for the collection case, but that is not done yet. That said, unless your example is a toy example for a more complex scenario the switch seems unnecessary, a multiple="true" data paramater can take either multiple datasets or a collection. Best, Marius
Hi Marius,
I think you're right in that len($input_type.input_bam) is inconsistent, we can implement __len__ for the collection case, but that is not done yet.
ThumbsUp! Would be for the tool developer convenience.
That said, unless your example is a toy example for a more complex scenario the switch seems unnecessary, a multiple="true" data paramater can take either multiple datasets or a collection.
You are right, still you could replace the list with a paired list or list list. Cheers, Matthias -- ------------------------------------------- Matthias Bernt Bioinformatics Service Molekulare Systembiologie (MOLSYB) Helmholtz-Zentrum für Umweltforschung GmbH - UFZ/ Helmholtz Centre for Environmental Research GmbH - UFZ Permoserstraße 15, 04318 Leipzig, Germany Phone +49 341 235 482296, m.bernt@ufz.de, www.ufz.de Sitz der Gesellschaft/Registered Office: Leipzig Registergericht/Registration Office: Amtsgericht Leipzig Handelsregister Nr./Trade Register Nr.: B 4703 Vorsitzender des Aufsichtsrats/Chairman of the Supervisory Board: MinDirig Wilfried Kraus Wissenschaftlicher Geschäftsführer/Scientific Managing Director: Prof. Dr. Dr. h.c. Georg Teutsch -------------------------------------------
participants (2)
-
Marius van den Beek
-
Matthias Bernt