Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
// Workflow written in SciPipe.
// For more information about SciPipe, see:
package main
import sp ""
func main() {
// Create a workflow, using 4 cpu cores
wf := sp.NewWorkflow("my_workflow", 4)
// Initialize processes
foo := wf.NewProc("fooer", "echo foo > {o:foo}")
foo.SetOut("foo", "foo.txt")
filter := NewFilterNonexistent(wf, "filter_nonexistent")
cp := wf.NewProc("copy", "cat {i:in} > {o:out}")
cp.SetOut("out", "{i:in}.copy")
// Run the workflow
// NewFilterNonexistent initializes and returns a new
// FilterNonexistent process
func NewFilterNonexistent(wf *sp.Workflow, name string) *FilterNonexistent {
p := &FilterNonexistent{
BaseProcess: sp.NewBaseProcess(wf, name),
p.InitInPort(p, "in")
p.InitOutPort(p, "out")
return p
// FilterNonexistent checks each file retreived on the in-port and sends it
// unchanged on the in-port if that particular path does exist
type FilterNonexistent struct {
// In returns the (only) in-port
func (p *FilterNonexistent) In() *sp.InPort { return p.InPort("in") }
// Out returns the (only) out-port
func (p *FilterNonexistent) Out() *sp.OutPort { return p.OutPort("out") }
// Run runs the process
func (p *FilterNonexistent) Run() {
defer p.CloseAllOutPorts()
for inIP := range p.In().Chan {
// Forward all files which do exist
if inIP.Exists() {
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.