14 "git.arvados.org/arvados.git/sdk/go/arvados"
15 log "github.com/sirupsen/logrus"
20 func (cmd *dumpGob) RunCommand(prog string, args []string, stdin io.Reader, stdout, stderr io.Writer) int {
24 fmt.Fprintf(stderr, "%s\n", err)
27 flags := flag.NewFlagSet("", flag.ContinueOnError)
28 flags.SetOutput(stderr)
29 pprof := flags.String("pprof", "", "serve Go profile data at http://`[addr]:port`")
30 runlocal := flags.Bool("local", false, "run on local host (default: run in an arvados container)")
31 projectUUID := flags.String("project", "", "project `UUID` for output data")
32 priority := flags.Int("priority", 500, "container request priority")
33 inputFilename := flags.String("i", "-", "input `file` (library)")
34 outputFilename := flags.String("o", "-", "output `file`")
35 err = flags.Parse(args)
36 if err == flag.ErrHelp {
39 } else if err != nil {
45 log.Println(http.ListenAndServe(*pprof, nil))
50 if *outputFilename != "-" {
51 err = errors.New("cannot specify output file in container mode: not implemented")
54 runner := arvadosContainerRunner{
55 Name: "lightning dumpgob",
56 Client: arvados.NewClientFromEnv(),
57 ProjectUUID: *projectUUID,
62 err = runner.TranslatePaths(inputFilename)
66 runner.Args = []string{"dumpgob", "-local=true", fmt.Sprintf("-pprof=%v", *pprof), "-i", *inputFilename, "-o", "/mnt/output/dumpgob.txt"}
68 output, err = runner.Run()
72 fmt.Fprintln(stdout, output+"/dumpgob.txt")
76 input, err := open(*inputFilename)
81 output, err := os.OpenFile(*outputFilename, os.O_CREATE|os.O_WRONLY, 0644)
86 bufw := bufio.NewWriterSize(output, 8*1024*1024)
88 var n, nCG, nCS, nTV int
89 err = DecodeLibrary(input, strings.HasSuffix(*inputFilename, ".gz"), func(ent *LibraryEntry) error {
91 fmt.Fprintf(stderr, "ent %d\n", n)
94 if len(ent.TagSet) > 0 {
95 fmt.Fprintf(bufw, "ent %d: TagSet, len %d, taglen %d\n", n, len(ent.TagSet), len(ent.TagSet[0]))
97 for _, cg := range ent.CompactGenomes {
99 fmt.Fprintf(bufw, "ent %d: CompactGenome, name %q, len(Variants) %d\n", n, cg.Name, len(cg.Variants))
101 for _, cs := range ent.CompactSequences {
103 fmt.Fprintf(bufw, "ent %d: CompactSequence, name %q, len(TileSequences) %d\n", n, cs.Name, len(cs.TileSequences))
105 for _, tv := range ent.TileVariants {
107 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))
114 fmt.Fprintf(bufw, "total: ents %d, CompactGenomes %d, CompactSequences %d, TileVariants %d\n", n, nCG, nCS, nTV)