Bump exportnumpy memory.
[lightning.git] / cmd.go
1 package lightning
2
3 import (
4         "fmt"
5         "io"
6         "io/ioutil"
7         "os"
8         "os/exec"
9
10         "git.arvados.org/arvados.git/lib/cmd"
11         "github.com/mattn/go-isatty"
12         "github.com/sirupsen/logrus"
13 )
14
15 var (
16         handler = cmd.Multi(map[string]cmd.Handler{
17                 "version":   cmd.Version,
18                 "-version":  cmd.Version,
19                 "--version": cmd.Version,
20
21                 "ref2genome":         &ref2genome{},
22                 "vcf2fasta":          &vcf2fasta{},
23                 "import":             &importer{},
24                 "annotate":           &annotatecmd{},
25                 "export":             &exporter{},
26                 "export-numpy":       &exportNumpy{},
27                 "numpy-comvar":       &numpyComVar{},
28                 "filter":             &filtercmd{},
29                 "build-docker-image": &buildDockerImage{},
30                 "pca-go":             &goPCA{},
31                 "pca-py":             &pythonPCA{},
32                 "plot":               &pythonPlot{},
33                 "diff-fasta":         &diffFasta{},
34                 "stats":              &statscmd{},
35                 "merge":              &merger{},
36                 "dumpgob":            &dumpGob{},
37         })
38 )
39
40 func Main() {
41         if !isatty.IsTerminal(os.Stderr.Fd()) {
42                 logrus.StandardLogger().Formatter = &logrus.TextFormatter{DisableTimestamp: true}
43         }
44         os.Exit(handler.RunCommand(os.Args[0], os.Args[1:], os.Stdin, os.Stdout, os.Stderr))
45 }
46
47 type buildDockerImage struct{}
48
49 func (cmd *buildDockerImage) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
50         tmpdir, err := ioutil.TempDir("", "")
51         if err != nil {
52                 fmt.Fprint(stderr, err)
53                 return 1
54         }
55         defer os.RemoveAll(tmpdir)
56         err = ioutil.WriteFile(tmpdir+"/Dockerfile", []byte(`FROM debian:bullseye
57 RUN DEBIAN_FRONTEND=noninteractive \
58   apt-get update && \
59   apt-get dist-upgrade -y && \
60   apt-get install -y --no-install-recommends bcftools bedtools samtools python2 python3-sklearn python3-matplotlib ca-certificates && \
61   apt-get clean
62 `), 0644)
63         if err != nil {
64                 fmt.Fprint(stderr, err)
65                 return 1
66         }
67         docker := exec.Command("docker", "build", "--tag=lightning-runtime", tmpdir)
68         docker.Stdout = stdout
69         docker.Stderr = stderr
70         err = docker.Run()
71         if err != nil {
72                 return 1
73         }
74         fmt.Fprintf(stderr, "built and tagged new docker image, lightning-runtime\n")
75         return 0
76 }