1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
15 "git.arvados.org/arvados.git/sdk/go/arvados"
18 type manhattanPlot struct{}
20 //go:embed manhattan.py
21 var manhattanPy string
23 func (cmd *manhattanPlot) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
27 fmt.Fprintf(stderr, "%s\n", err)
30 flags := flag.NewFlagSet("", flag.ContinueOnError)
31 flags.SetOutput(stderr)
32 projectUUID := flags.String("project", "", "project `UUID` for output data")
33 inputDirectory := flags.String("i", "-", "input `directory` (output of slice-numpy -single-onehot)")
34 outputFilename := flags.String("o", "", "output `filename` (e.g., './plot.png')")
35 csvOutputFilename := flags.String("csv-output", "", "csv output `filename` (e.g., './tile-locations-pvalues.csv')")
36 csvOutputThreshold := flags.Float64("csv-output-threshold", 0, "logpvalue threshold for csv output (0 for none)")
37 priority := flags.Int("priority", 500, "container request priority")
38 runlocal := flags.Bool("local", false, "run on local host (default: run in an arvados container)")
39 err = flags.Parse(args)
40 if err == flag.ErrHelp {
43 } else if err != nil {
45 } else if flags.NArg() > 0 {
46 err = fmt.Errorf("errant command line arguments after parsed flags: %v", flags.Args())
50 runner := arvadosContainerRunner{
51 Name: "lightning manhattan",
52 Client: arvados.NewClientFromEnv(),
53 ProjectUUID: *projectUUID,
57 Mounts: map[string]map[string]interface{}{
58 "/manhattan.py": map[string]interface{}{
60 "content": manhattanPy,
65 err = runner.TranslatePaths(inputDirectory)
69 *outputFilename = "/mnt/output/plot.png"
70 *csvOutputFilename = "/mnt/output/tile-locations-pvalues.csv"
75 fmt.Sprintf("%g", *csvOutputThreshold),
79 if *outputFilename == "" {
80 fmt.Fprintln(stderr, "error: must specify -o filename.png in local mode (or try -help)")
83 cmd := exec.Command("python3", append([]string{"-"}, args...)...)
84 cmd.Stdin = strings.NewReader(manhattanPy)
93 runner.Prog = "python3"
94 runner.Args = append([]string{"/manhattan.py"}, args...)
96 output, err = runner.Run()
100 fmt.Fprintln(stdout, output+"/plot.png")