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"
16 log "github.com/sirupsen/logrus"
19 type flakecmd struct {
23 func (cmd *flakecmd) 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 pprof := flags.String("pprof", "", "serve Go profile data at http://`[addr]:port`")
33 runlocal := flags.Bool("local", false, "run on local host (default: run in an arvados container)")
34 projectUUID := flags.String("project", "", "project `UUID` for output data")
35 priority := flags.Int("priority", 500, "container request priority")
36 inputDir := flags.String("input-dir", "./in", "input `directory`")
37 outputDir := flags.String("output-dir", "./out", "output `directory`")
38 cmd.filter.Flags(flags)
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())
52 log.Println(http.ListenAndServe(*pprof, nil))
57 runner := arvadosContainerRunner{
58 Name: "lightning flake",
59 Client: arvados.NewClientFromEnv(),
60 ProjectUUID: *projectUUID,
67 err = runner.TranslatePaths(inputDir)
71 runner.Args = []string{"flake", "-local=true",
73 "-input-dir", *inputDir,
74 "-output-dir", "/mnt/output",
75 "-max-variants", fmt.Sprintf("%d", cmd.filter.MaxVariants),
76 "-min-coverage", fmt.Sprintf("%f", cmd.filter.MinCoverage),
77 "-max-tag", fmt.Sprintf("%d", cmd.filter.MaxTag),
80 output, err = runner.Run()
84 fmt.Fprintln(stdout, output)
88 tilelib := &tileLibrary{
90 retainTileSequences: true,
91 compactGenomes: map[string][]tileVariantID{},
93 err = tilelib.LoadDir(context.Background(), *inputDir)
99 cmd.filter.Apply(tilelib)
102 err = tilelib.WriteDir(*outputDir)