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 "anno2vcf": &anno2vcf{},
37 "numpy-comvar": &numpyComVar{},
38 "filter": &filtercmd{},
39 "build-docker-image": &buildDockerImage{},
41 "pca-py": &pythonPCA{},
42 "plot": &pythonPlot{},
43 "diff-fasta": &diffFasta{},
46 "dumpgob": &dumpGob{},
51 if os.Getenv("GOGC") == "" {
52 debug.SetGCPercent(30)
57 if !isatty.IsTerminal(os.Stderr.Fd()) {
58 logrus.StandardLogger().Formatter = &logrus.TextFormatter{DisableTimestamp: true}
60 if len(os.Args) >= 2 && !strings.HasSuffix(os.Args[1], "version") {
61 cmd.Version.RunCommand("lightning", nil, nil, os.Stderr, os.Stderr)
63 os.Exit(handler.RunCommand(os.Args[0], os.Args[1:], os.Stdin, os.Stdout, os.Stderr))
66 type buildDockerImage struct{}
68 func (cmd *buildDockerImage) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
69 tmpdir, err := ioutil.TempDir("", "")
71 fmt.Fprint(stderr, err)
74 defer os.RemoveAll(tmpdir)
75 err = ioutil.WriteFile(tmpdir+"/Dockerfile", []byte(`FROM debian:bullseye
76 RUN DEBIAN_FRONTEND=noninteractive \
78 apt-get dist-upgrade -y && \
79 apt-get install -y --no-install-recommends bcftools bedtools samtools python2 python3-sklearn python3-matplotlib ca-certificates && \
83 fmt.Fprint(stderr, err)
86 docker := exec.Command("docker", "build", "--tag=lightning-runtime", tmpdir)
87 docker.Stdout = stdout
88 docker.Stderr = stderr
93 fmt.Fprintf(stderr, "built and tagged new docker image, lightning-runtime\n")