From 8eb3ae93b17218a7bdb194d37578baa138050052 Mon Sep 17 00:00:00 2001 From: Tom Clegg Date: Mon, 2 Mar 2020 09:36:03 -0500 Subject: [PATCH] Don't require reference data when all inputs are fasta. Arvados-DCO-1.1-Signed-off-by: Tom Clegg --- import.go | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/import.go b/import.go index 2f9888ce39..a38abc6861 100644 --- a/import.go +++ b/import.go @@ -4,6 +4,7 @@ import ( "bufio" "compress/gzip" "encoding/gob" + "errors" "flag" "fmt" "io" @@ -46,8 +47,8 @@ func (cmd *importer) RunCommand(prog string, args []string, stdin io.Reader, std return 0 } else if err != nil { return 2 - } else if cmd.refFile == "" || cmd.tagLibraryFile == "" { - fmt.Fprintln(os.Stderr, "cannot run without -tag-library and -ref arguments") + } else if cmd.tagLibraryFile == "" { + fmt.Fprintln(os.Stderr, "cannot import without -tag-library argument") return 2 } else if flags.NArg() == 0 { flags.Usage() @@ -76,7 +77,7 @@ func (cmd *importer) RunCommand(prog string, args []string, stdin io.Reader, std }() w := bufio.NewWriter(stdout) cmd.encoder = gob.NewEncoder(w) - err = cmd.tileGVCFs(tilelib, infiles) + err = cmd.tileInputs(tilelib, infiles) if err != nil { return 1 } @@ -174,7 +175,7 @@ func listInputFiles(paths []string) (files []string, err error) { return } -func (cmd *importer) tileGVCFs(tilelib *tileLibrary, infiles []string) error { +func (cmd *importer) tileInputs(tilelib *tileLibrary, infiles []string) error { starttime := time.Now() errs := make(chan error, 1) todo := make(chan func() error, len(infiles)*2) @@ -275,6 +276,10 @@ func (cmd *importer) tileGVCFs(tilelib *tileLibrary, infiles []string) error { } func (cmd *importer) tileGVCF(tilelib *tileLibrary, infile string, phase int) (tileseq tileSeq, err error) { + if cmd.refFile == "" { + err = errors.New("cannot import vcf: reference data (-ref) not specified") + return + } args := []string{"bcftools", "consensus", "--fasta-ref", cmd.refFile, "-H", fmt.Sprint(phase + 1), infile} indexsuffix := ".tbi" if _, err := os.Stat(infile + ".csi"); err == nil { -- 2.30.2