Scale keep cache to 2*(openfiles+1).
[lightning.git] / exportnumpy.go
index 00165b3db73fabab03f5dcc883e8af20c7973b57..39f228a1b0cecc3823128a15183e2b0bdcba62d1 100644 (file)
@@ -95,11 +95,9 @@ func (cmd *exportNumpy) RunCommand(prog string, args []string, stdin io.Reader,
                        "-output-labels", "/mnt/output/labels.csv",
                        "-regions", *regionsFilename,
                        "-expand-regions", fmt.Sprintf("%d", *expandRegions),
-                       "-max-variants", fmt.Sprintf("%d", cmd.filter.MaxVariants),
-                       "-min-coverage", fmt.Sprintf("%f", cmd.filter.MinCoverage),
-                       "-max-tag", fmt.Sprintf("%d", cmd.filter.MaxTag),
                        "-chunks", fmt.Sprintf("%d", *chunks),
                }
+               runner.Args = append(runner.Args, cmd.filter.Args()...)
                var output string
                output, err = runner.Run()
                if err != nil {
@@ -114,7 +112,7 @@ func (cmd *exportNumpy) RunCommand(prog string, args []string, stdin io.Reader,
                retainTileSequences: true,
                compactGenomes:      map[string][]tileVariantID{},
        }
-       err = tilelib.LoadDir(context.Background(), *inputDir, nil)
+       err = tilelib.LoadDir(context.Background(), *inputDir)
        if err != nil {
                return 1
        }
@@ -253,19 +251,23 @@ func (cmd *exportNumpy) RunCommand(prog string, args []string, stdin io.Reader,
                                return
                        }
                        defer f.Close()
-                       npw, err := gonpy.NewWriter(f)
+                       // gonpy closes our writer and ignores errors. Give it a nopCloser so we can close f properly.
+                       npw, err := gonpy.NewWriter(nopCloser{f})
                        if err != nil {
                                lastErr.Store(err)
                                return
                        }
                        npw.Shape = []int{len(names), len(pdis) * 2}
-                       npw.WriteInt8(data)
-                       // gonpy closes f and ignores errors, doh.
-                       // err = f.Close()
-                       // if err != nil {
-                       //      lastErr.Store(err)
-                       //      return
-                       // }
+                       err = npw.WriteInt8(data)
+                       if err != nil {
+                               lastErr.Store(err)
+                               return
+                       }
+                       err = f.Close()
+                       if err != nil {
+                               lastErr.Store(err)
+                               return
+                       }
                }()
        }
        wg.Wait()