first tool integration with planemo, help needed

Hi,

This is a complete beginner question and this probably belongs to the RTFM section. However, there is obviously a logic that I do not understand in galaxy xml.

What I want to do (independently of whether or not you can do that with existing tools in galaxy), is to give a list of bed files to my tool, and output a tab like:

#filename        #nb of lines
file1                  4645464
...                      ......
filen                  346354345

Here is my xml file:

<tool id="bedcounts_summary" name="Counts and summarizes line number for each bed file of a list" version="0.1.0">
    <requirements>
    </requirements>
    <command>                                                                                                                                
      bash $__tool_directory__/bedcounts_summary.sh #for $key in $bedlist.keys() # $key $bedlist[$key] #end for                              
      >> $outputtab                                                                                                                          
    </command>
    <inputs>
      <param type="data_collection" format="bed" name="bedlist"/>
    </inputs>
    <outputs>
      <data name="outputtab" format="tabular"/>
    </outputs>
    <help><![CDATA[                                                                                                                          
        TODO: Fill in help.                                                                                                                  
    ]]></help>
</tool>

Here is the bash script:

#!/bin/bash                                                                                                                                  

bedfilename=$1
bedfile=$2

countslines=`wc -l < $bedfile`

echo -e "$bedfilename\t$countslines"

This is returning only the first line. I managed to have all lines using a simple echo but that is not the point, obviously.

If you can point to my logic/programming error that would be very helpful!

Thanks!

1 Like

Do you want it to specifically be a tool?
bgruening’s awk tool in the main toolshed will readily do this.

I have a more feature rich version that is pending a PR to that linked repo that you might be interested in.

yes I would like to understand why it is not working, not to leave it unsolved. I might end using awk indeed.

1 Like

by the way, I was able to do the same thing using:

  1. Line/Word/Character count of a dataset (Galaxy Version 1.0.0), taking care of not including the header
  2. Collapse Collection into single dataset in order of the collection (Galaxy Version 4.0), enabling the option “Append file name”

But if one see the mistake in the code above, it would be useful to know.

1 Like

It is because you are passing your script two arguments per collection element but your script only takes two arguments.
You need to wrap the entire call to your script in the #for block.

Look at the command in the Info section of the tools output. You will see your mistake.

2 Likes