1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
14 "git.arvados.org/arvados.git/sdk/go/arvados"
17 type pythonPlot struct{}
22 func (cmd *pythonPlot) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
26 fmt.Fprintf(stderr, "%s\n", err)
29 flags := flag.NewFlagSet("", flag.ContinueOnError)
30 flags.SetOutput(stderr)
31 projectUUID := flags.String("project", "", "project `UUID` for output data")
32 inputFilename := flags.String("i", "-", "input `file`")
33 sampleListFilename := flags.String("samples", "", "use second column of `samples.csv` as complete list of sample IDs")
34 phenotypeFilename := flags.String("phenotype", "", "use `phenotype.csv` as id->phenotype mapping (column 0 is sample id)")
35 phenotypeColumn := flags.Int("phenotype-column", 1, "0-based column `index` of phenotype in phenotype.csv file")
36 priority := flags.Int("priority", 500, "container request priority")
37 err = flags.Parse(args)
38 if err == flag.ErrHelp {
41 } else if err != nil {
45 runner := arvadosContainerRunner{
46 Name: "lightning plot",
47 Client: arvados.NewClientFromEnv(),
48 ProjectUUID: *projectUUID,
52 Mounts: map[string]map[string]interface{}{
53 "/plot.py": map[string]interface{}{
55 "content": plotscript,
59 err = runner.TranslatePaths(inputFilename, sampleListFilename, phenotypeFilename)
63 runner.Prog = "python3"
64 runner.Args = []string{"/plot.py", *inputFilename, *sampleListFilename, *phenotypeFilename, fmt.Sprintf("%d", *phenotypeColumn), "/mnt/output/plot.png"}
66 output, err = runner.Run()
70 fmt.Fprintln(stdout, output+"/plot.png")