1 // Copyright (C) The Lightning Authors. All rights reserved.
3 // SPDX-License-Identifier: AGPL-3.0
18 "git.arvados.org/arvados.git/sdk/go/arvados"
19 log "github.com/sirupsen/logrus"
24 func (cmd *dumpGob) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
28 fmt.Fprintf(stderr, "%s\n", err)
31 flags := flag.NewFlagSet("", flag.ContinueOnError)
32 flags.SetOutput(stderr)
33 pprof := flags.String("pprof", "", "serve Go profile data at http://`[addr]:port`")
34 runlocal := flags.Bool("local", false, "run on local host (default: run in an arvados container)")
35 projectUUID := flags.String("project", "", "project `UUID` for output data")
36 priority := flags.Int("priority", 500, "container request priority")
37 inputFilename := flags.String("i", "-", "input `file` (library)")
38 outputFilename := flags.String("o", "-", "output `file`")
39 err = flags.Parse(args)
40 if err == flag.ErrHelp {
43 } else if err != nil {
49 log.Println(http.ListenAndServe(*pprof, nil))
54 if *outputFilename != "-" {
55 err = errors.New("cannot specify output file in container mode: not implemented")
58 runner := arvadosContainerRunner{
59 Name: "lightning dumpgob",
60 Client: arvados.NewClientFromEnv(),
61 ProjectUUID: *projectUUID,
66 err = runner.TranslatePaths(inputFilename)
70 runner.Args = []string{"dumpgob", "-local=true", fmt.Sprintf("-pprof=%v", *pprof), "-i", *inputFilename, "-o", "/mnt/output/dumpgob.txt"}
72 output, err = runner.Run()
76 fmt.Fprintln(stdout, output+"/dumpgob.txt")
80 input, err := open(*inputFilename)
85 output, err := os.OpenFile(*outputFilename, os.O_CREATE|os.O_WRONLY, 0644)
90 bufw := bufio.NewWriterSize(output, 8*1024*1024)
92 var n, nCG, nCS, nTV int
93 err = DecodeLibrary(input, strings.HasSuffix(*inputFilename, ".gz"), func(ent *LibraryEntry) error {
95 fmt.Fprintf(stderr, "ent %d\n", n)
98 if len(ent.TagSet) > 0 {
99 fmt.Fprintf(bufw, "ent %d: TagSet, len %d, taglen %d\n", n, len(ent.TagSet), len(ent.TagSet[0]))
101 for _, cg := range ent.CompactGenomes {
103 fmt.Fprintf(bufw, "ent %d: CompactGenome, name %q, len(Variants) %d\n", n, cg.Name, len(cg.Variants))
105 for _, cs := range ent.CompactSequences {
107 fmt.Fprintf(bufw, "ent %d: CompactSequence, name %q, len(TileSequences) %d\n", n, cs.Name, len(cs.TileSequences))
109 for _, tv := range ent.TileVariants {
111 fmt.Fprintf(bufw, "ent %d: TileVariant, tag %d, variant %d, hash %x, len(seq) %d\n", n, tv.Tag, tv.Variant, tv.Blake2b, len(tv.Sequence))
118 fmt.Fprintf(bufw, "total: ents %d, CompactGenomes %d, CompactSequences %d, TileVariants %d\n", n, nCG, nCS, nTV)