File tree Expand file tree Collapse file tree 1 file changed +10
-0
lines changed
Expand file tree Collapse file tree 1 file changed +10
-0
lines changed Original file line number Diff line number Diff line change @@ -3,6 +3,7 @@ package ggd_utils
33
44import (
55 "bytes"
6+ "fmt"
67 "io"
78 "regexp"
89 "strconv"
@@ -33,6 +34,8 @@ func ReadGenomeFile(path string) (*GenomeFile, error) {
3334 defer rdr .Close ()
3435
3536 space := regexp .MustCompile ("\\ s+" )
37+ // allow us to bypass a header. found indicates when we have a usable line.
38+ found := false
3639
3740 for {
3841 line , err := rdr .ReadBytes ('\n' )
@@ -56,11 +59,18 @@ func ReadGenomeFile(path string) (*GenomeFile, error) {
5659 chrom := toks [0 ]
5760 length , err := strconv .Atoi (toks [1 ])
5861 if err != nil {
62+ if ! found {
63+ continue
64+ }
5965 return nil , err
6066 }
67+ found = true
6168 gf .Lengths [chrom ] = length
6269 gf .Order [chrom ] = len (gf .Order )
6370
6471 }
72+ if ! found {
73+ return nil , fmt .Errorf ("no usable lengths found for %s\n " , path )
74+ }
6575 return gf , nil
6676}
You can’t perform that action at this time.
0 commit comments