|
| 1 | +package main |
| 2 | + |
| 3 | +import ( |
| 4 | + "flag" |
| 5 | + "os" |
| 6 | + |
| 7 | + sp "github.com/scipipe/scipipe" |
| 8 | + spc "github.com/scipipe/scipipe/components" |
| 9 | +) |
| 10 | + |
| 11 | +func main() { |
| 12 | + // ---------------------------------------------------------------- |
| 13 | + // Define input parameters to the workflow as command line flags |
| 14 | + // ---------------------------------------------------------------- |
| 15 | + refPath := flag.String("ref", "", "Reference file") |
| 16 | + leftPath := flag.String("left", "", "The first reads file") |
| 17 | + rightPath := flag.String("right", "", "The second reads file") |
| 18 | + outDirPath := flag.String("outdir", "", "Output directory") |
| 19 | + flag.Parse() |
| 20 | + |
| 21 | + // ---------------------------------------------------------------- |
| 22 | + // Ensure flags are set |
| 23 | + // ---------------------------------------------------------------- |
| 24 | + if *refPath == "" || *leftPath == "" || *rightPath == "" || *outDirPath == "" { |
| 25 | + flag.PrintDefaults() |
| 26 | + os.Exit(1) |
| 27 | + } |
| 28 | + |
| 29 | + // ---------------------------------------------------------------- |
| 30 | + // Initialize workflow with 4 workers |
| 31 | + // ---------------------------------------------------------------- |
| 32 | + wf := sp.NewWorkflow("example-workflow", 4) |
| 33 | + |
| 34 | + // We need to create workflow processes to feed the files to downstream |
| 35 | + // processes as IPs (information packets) |
| 36 | + refSrc := spc.NewFileSource(wf, "ref-file", *refPath) |
| 37 | + leftSrc := spc.NewFileSource(wf, "left", *leftPath) |
| 38 | + rightSrc := spc.NewFileSource(wf, "right", *rightPath) |
| 39 | + |
| 40 | + // ---------------------------------------------------------------- |
| 41 | + // Salmon indexing process |
| 42 | + // ---------------------------------------------------------------- |
| 43 | + salmonIndex := wf.NewProc("salmon-index", "salmon index -t {i:ref} -i {o:index}") |
| 44 | + salmonIndex.In("ref").From(refSrc.Out()) |
| 45 | + salmonIndex.SetOut("index", "data/salmon-index") |
| 46 | + |
| 47 | + // ---------------------------------------------------------------- |
| 48 | + // Transcriptome alignment and quantification using Salmon |
| 49 | + // ---------------------------------------------------------------- |
| 50 | + salmonAlignQuant := wf.NewProc("salmon-align-quant", "salmon quant -i {i:index} -l A -1 '{i:left}' -2 '{i:right}' --validateMappings -o {o:quant}") |
| 51 | + salmonAlignQuant.In("index").From(salmonIndex.Out("index")) |
| 52 | + salmonAlignQuant.In("left").From(leftSrc.Out()) |
| 53 | + salmonAlignQuant.In("right").From(rightSrc.Out()) |
| 54 | + salmonAlignQuant.SetOut("quant", *outDirPath) |
| 55 | + |
| 56 | + // ---------------------------------------------------------------- |
| 57 | + // Quality control using FastQC |
| 58 | + // ---------------------------------------------------------------- |
| 59 | + fastQC := wf.NewProc("fastqc", "mkdir -p {o:qcdir} && fastqc --quiet '{i:left}' '{i:right}' --outdir {o:qcdir}") |
| 60 | + fastQC.In("left").From(leftSrc.Out()) |
| 61 | + fastQC.In("right").From(rightSrc.Out()) |
| 62 | + fastQC.SetOut("qcdir", "data/qc") |
| 63 | + |
| 64 | + // ---------------------------------------------------------------- |
| 65 | + // Run workflow |
| 66 | + // ---------------------------------------------------------------- |
| 67 | + wf.Run() |
| 68 | +} |
0 commit comments