Skip to content

Commit

Permalink
fix sequence ID parsing for a rare case
Browse files Browse the repository at this point in the history
  • Loading branch information
shenwei356 committed Sep 5, 2024
1 parent 40a859e commit da8442f
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 15 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
# Changelog

### v0.13.5 - 2024-09-05

- fix sequence ID parsing with the default regular expression (in this case, we actually use bytes.Index instead) for a rare case: "xxx\tyyy zzz" was wrongly parsed as "xxx\tyyy".

### v0.13.4 - 2024-07-15

- fix seq.SubSeq for (-start,-end), where start > len(seq).
Expand Down
30 changes: 15 additions & 15 deletions seqio/fastx/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,24 +481,24 @@ func ParseHeadID(idRegexp *regexp.Regexp, head []byte) []byte {

var emptyByteSlice = []byte{}

// var tabspace string = "\t "

func parseHeadIDAndDesc(idRegexp *regexp.Regexp, head []byte) ([]byte, []byte) {
if isUsingDefaultIDRegexp {
if i := bytes.IndexByte(head, ' '); i > 0 {
e := len(head)
j := i + 1
for ; j < e; j++ {
if head[j] == ' ' || head[j] == '\t' {
j++
} else {
break
}
}
if j >= e {
return head[0:i], emptyByteSlice
}
return head[0:i], head[j:]
// i := bytes.IndexAny(head, tabspace) // slower

iTab := bytes.IndexByte(head, '\t')
iSpace := bytes.IndexByte(head, ' ')

i := -1
if iTab >= 0 {
i = iTab
}
if i := bytes.IndexByte(head, '\t'); i > 0 {
if iSpace >= 0 && iSpace < i {
i = iSpace
}

if i >= 0 {
e := len(head)
j := i + 1
for ; j < e; j++ {
Expand Down

0 comments on commit da8442f

Please sign in to comment.