package main

import (
	str "strings"

	sp "github.com/scipipe/scipipe"
)

const (
	workDir = "/scipipe-data/"
)

func main() {
	prun := sp.NewPipelineRunner()

	peakPicker := sp.NewFromShell("PeakPicker", "PeakPickerHiRes -in {i:sample} -out {o:out} -ini {p:ini}")
	peakPicker.PathFormatters["out"] = func(t *sp.SciTask) string {
		parts := str.Split(t.GetInPath("sample"), ".")
		outPath := "results/" + str.Join(parts[:len(parts)-1], "_") + ".peaks"
		return outPath
	}

	prun.AddProcess(peakPicker)

	prun.Run()
}

package main

import sp "github.com/scipipe/scipipe"

const (
	workDir = "/scipipe-data/"
)

func main() {
	prun := sp.NewPipelineRunner()

	peakPicker := sp.NewFromShell("PeakPicker", "PeakPickerHiRes -in {i:sample} -out {o:out} -ini {p:ini}")
	peakPicker.PathFormatters["out"] = func(t *sp.SciTask) string {
		//         filename = basename("{0}_{2}.{1}".format(*self.sampleFile.rsplit('.', 1) + ["peaks"]))
		//         return luigi.LocalTarget("results/"+filename)
		return "todo_implement_path_formatting.txt"
	}

	prun.AddProcess(peakPicker)

	prun.Run()
}

--- 
+++ 
@@ -1,6 +1,10 @@
 package main
 
-import sp "github.com/scipipe/scipipe"
+import (
+	str "strings"
+
+	sp "github.com/scipipe/scipipe"
+)
 
 const (
 	workDir = "/scipipe-data/"
@@ -11,9 +15,9 @@
 
 	peakPicker := sp.NewFromShell("PeakPicker", "PeakPickerHiRes -in {i:sample} -out {o:out} -ini {p:ini}")
 	peakPicker.PathFormatters["out"] = func(t *sp.SciTask) string {
-		//         filename = basename("{0}_{2}.{1}".format(*self.sampleFile.rsplit('.', 1) + ["peaks"]))
-		//         return luigi.LocalTarget("results/"+filename)
-		return "todo_implement_path_formatting.txt"
+		parts := str.Split(t.GetInPath("sample"), ".")
+		outPath := "results/" + str.Join(parts[:len(parts)-1], "_") + ".peaks"
+		return outPath
 	}
 
 	prun.AddProcess(peakPicker)
Improve path formatting in k8s openms example
