pallassgj / bpipe

Automatically exported from code.google.com/p/bpipe
0 stars 1 forks source link

trying to detect multiple inputs #77

Open GoogleCodeExporter opened 9 years ago

GoogleCodeExporter commented 9 years ago
Hello, 

I'm trying to write a pipeline that executes tophat either for single end or 
paired end data. I'm passing in the input(s) as parameters at the command line 
and would like bpipe to execute a piece of code if there are two inputs and 
execute a different piece if there's just one input. I've tried several if 
statements in the bpipe step to get this to work, but nothing seems to work. 
I'd appreciate your suggestions on this issue. 

Here are a couple examples of what I've tried: 
readMapping = {
if ($input2 != null)
{
exec "echo $input2"
}
else
exec 
{
"echo no second input"
}
} 

This works fine if there is an input2. If input 2 is absent it gives the 
following error: Expected 2 or more inputs but fewer provided

I've also tried various permutations of this: 
if (new File($input2).exists())
{
exec "echo $input2"
}
else
exec 
{
"echo no second input"
}
} 

This also does not work. Does bpipe have a straigtforward way to assess the 
presence of multiple inputs? 

Thanks!

Original issue reported on code.google.com by Chitra....@gmail.com on 23 May 2013 at 8:08

GoogleCodeExporter commented 9 years ago
Hi Chitra

The variable input is an object of the class pipelineInput. The pipelineInput 
class has a member list "input" whose size corresponds to the size of the 
number of inputs.

You can try something like this

if(input.input.size == 2){
           exec "echo $input2"
}
else{
           exec "No second input"
}

You can also use a for loop to iterate over individual input files:

for (myFile in input.input){
    println (myFile)
}

Hope this helps
-Vivek

Original comment by machosav...@gmail.com on 20 Mar 2015 at 8:57