19527: Enable choose-samples to work without case/control info.
authorTom Clegg <tom@curii.com>
Fri, 11 Nov 2022 17:35:09 +0000 (12:35 -0500)
committerTom Clegg <tom@curii.com>
Wed, 16 Nov 2022 20:23:46 +0000 (15:23 -0500)
refs #19527

Arvados-DCO-1.1-Signed-off-by: Tom Clegg <tom@curii.com>

choosesamples.go

index ad5643723f487608cd275392b9025de40e589438..db87d29a339b1814c7690adaa11ab292e95c8f4f 100644 (file)
@@ -55,11 +55,8 @@ func (cmd *chooseSamples) run(prog string, args []string, stdin io.Reader, stdou
        } else if err != nil {
                return err
        }
-       if *caseControlFilename == "" {
-               return errors.New("must provide -case-control-file")
-       }
-       if *caseControlColumn == "" {
-               return errors.New("must provide -case-control-column")
+       if (*caseControlFilename == "") != (*caseControlColumn == "") {
+               return errors.New("must provide both -case-control-file and -case-control-column, or neither")
        }
 
        if *pprof != "" {
@@ -221,6 +218,14 @@ func (cmd *chooseSamples) run(prog string, args []string, stdin io.Reader, stdou
 // Read case/control file(s). Returned map m has m[i]==true if
 // sampleIDs[i] is case, m[i]==false if sampleIDs[i] is control.
 func (cmd *chooseSamples) loadCaseControlFiles(path, colname string, sampleIDs []string) (map[int]bool, error) {
+       if path == "" {
+               // all samples are control group
+               cc := make(map[int]bool, len(sampleIDs))
+               for i := range sampleIDs {
+                       cc[i] = false
+               }
+               return cc, nil
+       }
        infiles, err := allFiles(path, nil)
        if err != nil {
                return nil, err