pallassgj / bpipe

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

segment does not see implicit input variable #66

Closed GoogleCodeExporter closed 9 years ago

GoogleCodeExporter commented 9 years ago
This script fails because one_two cannot see input. I find this to be
confusing because stage_one and stage_two can both see the implicit variable
input, but the segment cannot. I want to create a new variable from input in
one_two and pass that variable on to stage_one and stage_two with
stage_one.using(something: new_variable), for example. Right now I am forced
to copy the same code to stage_one and stage_two instead. Or, I can define
a function once and then invoke it in each stage.

I imagine there could be other uses for segments to see the implicit
variables.

- - -

stage_one = {
    println input;
}

stage_two = {
    println input;
}

one_two = segment {
    println input;
    stage_one + stage_two
}

Bpipe.run {
    one_two
}

- - -

bpipe run test_segment.groovy test

Pipeline Failed!

A variable referred to in your script on line 9, 'input' was not defined.  

Please check that all pipeline stages or other variables you have referenced by 
this name are defined.

Original issue reported on code.google.com by kslowiko...@gmail.com on 20 Nov 2012 at 3:04

GoogleCodeExporter commented 9 years ago
I ran into the same issue. This affects the Bpipe.run stage as well.
Ideally, what I would like to do is define a segment that uses different 
modules depending on the type of the input file, e.g. if I have a FASTA file, 
call module X, but if I have FASTQ, call module Y.

Original comment by florent....@gmail.com on 14 Mar 2014 at 5:46

GoogleCodeExporter commented 9 years ago
Sorry I never looked at this until now!

Actually, when I look at this I see the problem is the reference to 'input' 
within the 'segment' statement. If you just delete that reference the pipeline 
should work. The segment statement defines the logic of joining the pipeline 
stages together rather than how to specifically process some individual inputs, 
so it does not have a reference to the input variable.

Original comment by ssade...@gmail.com on 25 May 2014 at 11:34

GoogleCodeExporter commented 9 years ago
Now that you've explained that referencing the 'input' within a segment is not 
allowed, I see that my issue is a bug in my eyes and a feature to your eyes. 
That's fine, but this should be documented clearly so that others understand 
your intent.

I was led to believe that the issue *is* a bug and is not a feature because the 
documentation says:

"The segment then behaves just like a normal pipeline stage itself."

The only way I could have solved this issue myself is if I had -- for some 
unknown reason -- decided to delete "println input" from this test script. 
Since my intention was to access and potentially modify 'input' on the the 
"print input" line, I had no reason to delete that line.

Before I gave up on bpipe, I wrote ~15 bpipe scripts solely for the purpose of 
learning what bpipe will do if I write this or that. I gave up because there is 
too much magic to learn (for my taste), and I did not find examples with 
exhaustive documentation.

Original comment by kslowiko...@gmail.com on 25 May 2014 at 1:32

GoogleCodeExporter commented 9 years ago
See related: https://code.google.com/p/bpipe/issues/detail?id=67

Original comment by kslowiko...@gmail.com on 25 May 2014 at 1:34