From ce2930fca5e42f985c90dc2bef6c6f67f644800a Mon Sep 17 00:00:00 2001 From: Frederic Lemoine Date: Sat, 14 Oct 2023 12:21:50 +0200 Subject: [PATCH] Authorize comments in posfile of command goalign replace --- cmd/replace.go | 39 +++++++++++++++++++++------------------ 1 file changed, 21 insertions(+), 18 deletions(-) diff --git a/cmd/replace.go b/cmd/replace.go index 3de1a08..1a52cee 100644 --- a/cmd/replace.go +++ b/cmd/replace.go @@ -149,26 +149,29 @@ func readreplacefile(file string) (replace []repchar, err error) { l, e := utils.Readln(r) for e == nil { - cols := strings.Split(l, "\t") - if cols == nil || len(cols) < 3 { - err = errors.New("bad format from replace char file: There should be 3 columns: seqname\\tsite\\tnewchar") - return - } + // Authorize comments + if !strings.HasPrefix("#") { + cols := strings.Split(l, "\t") + if cols == nil || len(cols) < 3 { + err = errors.New("bad format from replace char file: There should be 3 columns: seqname\\tsite\\tnewchar") + return + } - seqname = cols[0] - if site, err = strconv.Atoi(cols[1]); err != nil { - err = fmt.Errorf("cannot convert site index to int") - return + seqname = cols[0] + if site, err = strconv.Atoi(cols[1]); err != nil { + err = fmt.Errorf("cannot convert site index to int") + return + } + newchar = uint8(cols[2][0]) + + replace = append( + replace, + repchar{ + seqname: seqname, + site: site, + newchar: newchar, + }) } - newchar = uint8(cols[2][0]) - - replace = append( - replace, - repchar{ - seqname: seqname, - site: site, - newchar: newchar, - }) l, e = utils.Readln(r) } return