"fmt"
"io"
_ "net/http/pprof"
+ "os/exec"
+ "strings"
"git.arvados.org/arvados.git/sdk/go/arvados"
)
flags.SetOutput(stderr)
projectUUID := flags.String("project", "", "project `UUID` for output data")
inputFilename := flags.String("i", "-", "input `file`")
+ outputFilename := flags.String("o", "", "output `filename` (e.g., './plot.png')")
sampleListFilename := flags.String("samples", "", "use second column of `samples.csv` as complete list of sample IDs")
phenotypeFilename := flags.String("phenotype", "", "use `phenotype.csv` as id->phenotype mapping (column 0 is sample id)")
+ phenotypeCategoryColumn := flags.Int("phenotype-category-column", -1, "0-based column `index` of 2nd category in phenotype.csv file")
phenotypeColumn := flags.Int("phenotype-column", 1, "0-based column `index` of phenotype in phenotype.csv file")
priority := flags.Int("priority", 500, "container request priority")
+ runlocal := flags.Bool("local", false, "run on local host (default: run in an arvados container)")
err = flags.Parse(args)
if err == flag.ErrHelp {
err = nil
},
},
}
- err = runner.TranslatePaths(inputFilename, sampleListFilename, phenotypeFilename)
- if err != nil {
- return 1
+ if !*runlocal {
+ err = runner.TranslatePaths(inputFilename, sampleListFilename, phenotypeFilename)
+ if err != nil {
+ return 1
+ }
+ *outputFilename = "/mnt/output/plot.png"
+ }
+ args = []string{*inputFilename, *sampleListFilename, *phenotypeFilename, fmt.Sprintf("%d", *phenotypeCategoryColumn), fmt.Sprintf("%d", *phenotypeColumn), *outputFilename}
+ if *runlocal {
+ if *outputFilename == "" {
+ fmt.Fprintln(stderr, "error: must specify -o filename.png in local mode (or try -help)")
+ return 1
+ }
+ cmd := exec.Command("python3", append([]string{"-"}, args...)...)
+ cmd.Stdin = strings.NewReader(plotscript)
+ cmd.Stdout = stdout
+ cmd.Stderr = stderr
+ err = cmd.Run()
+ if err != nil {
+ return 1
+ }
+ return 0
}
runner.Prog = "python3"
- runner.Args = []string{"/plot.py", *inputFilename, *sampleListFilename, *phenotypeFilename, fmt.Sprintf("%d", *phenotypeColumn), "/mnt/output/plot.png"}
+ runner.Args = append([]string{"/plot.py"}, args...)
var output string
output, err = runner.Run()
if err != nil {