1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
16 "git.arvados.org/arvados.git/lib/cmd"
17 "github.com/mattn/go-isatty"
18 "github.com/sirupsen/logrus"
22 handler = cmd.Multi(map[string]cmd.Handler{
23 "version": cmd.Version,
24 "-version": cmd.Version,
25 "--version": cmd.Version,
27 "ref2genome": &ref2genome{},
28 "vcf2fasta": &vcf2fasta{},
29 "import": &importer{},
30 "annotate": &annotatecmd{},
31 "export": &exporter{},
32 "export-numpy": &exportNumpy{},
35 "slice-numpy": &sliceNumpy{},
36 "tiling-stats": &tilingStats{},
37 "anno2vcf": &anno2vcf{},
38 "numpy-comvar": &numpyComVar{},
39 "filter": &filtercmd{},
40 "build-docker-image": &buildDockerImage{},
41 "plot": &pythonPlot{},
42 "pca-plot": &pythonPlot{},
43 "manhattan-plot": &manhattanPlot{},
44 "diff-fasta": &diffFasta{},
48 "dumpgob": &dumpGob{},
49 "choose-samples": &chooseSamples{},
54 if os.Getenv("GOGC") == "" {
55 debug.SetGCPercent(30)
60 if !isatty.IsTerminal(os.Stderr.Fd()) {
61 logrus.StandardLogger().Formatter = &logrus.TextFormatter{DisableTimestamp: true}
63 if len(os.Args) >= 2 && !strings.HasSuffix(os.Args[1], "version") {
64 // print version (then run subcommand)
65 cmd.Version.RunCommand("lightning", nil, nil, os.Stderr, os.Stderr)
67 os.Exit(handler.RunCommand(os.Args[0], os.Args[1:], os.Stdin, os.Stdout, os.Stderr))
70 type buildDockerImage struct{}
72 func (cmd *buildDockerImage) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
73 tmpdir, err := ioutil.TempDir("", "")
75 fmt.Fprint(stderr, err)
78 defer os.RemoveAll(tmpdir)
79 err = ioutil.WriteFile(tmpdir+"/Dockerfile", []byte(`FROM debian:bullseye
80 RUN DEBIAN_FRONTEND=noninteractive \
82 apt-get dist-upgrade -y && \
83 apt-get install -y --no-install-recommends bcftools bedtools samtools python2 python3-sklearn python3-matplotlib python3-pip ca-certificates && \
88 fmt.Fprint(stderr, err)
91 docker := exec.Command("docker", "build", "--tag=lightning-runtime", tmpdir)
92 docker.Stdout = stdout
93 docker.Stderr = stderr
98 fmt.Fprintf(stderr, "built and tagged new docker image, lightning-runtime\n")