Skip to content

Commit

Permalink
Fixed a bug in the fasta parser.
Browse files Browse the repository at this point in the history
If you see an error message that says "panic: runtime error: slice bounds out of range"
that refers to a location in github.com/exascience/elprep/v4/fasta.OpenElfasta, then
please recreate the corresponding .elfasta file with the fasta-to-elfasta command to
fix this error.
  • Loading branch information
Pascal Costanza committed Nov 8, 2018
1 parent 995f176 commit ee54a8d
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
2 changes: 1 addition & 1 deletion cmd/util.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ const (
// ProgramName is "elprep"
ProgramName = "elprep"
// ProgramVersion is the version of the elprep binary
ProgramVersion = "4.0.0"
ProgramVersion = "4.0.1"
// ProgramURL is the repository for the elprep source code
ProgramURL = "http://github.com/exascience/elprep"
)
Expand Down
10 changes: 8 additions & 2 deletions fasta/fasta-files.go
Original file line number Diff line number Diff line change
Expand Up @@ -94,10 +94,16 @@ func ParseFai(filename string) (fai map[string]FaiReference, err error) {

func contigFromHeader(b []byte) string {
i := 1
for ; (i < len(b)) && b[i] == ' '; i++ {
for ; i < len(b); i++ {
if c := b[i]; c >= '!' && c <= '~' {
break
}
}
j := i + 1
for ; (j < len(b)) && b[j] != ' '; j++ {
for ; j < len(b); j++ {
if c := b[j]; c < '!' || c > '~' {
break
}
}
return string(b[i:j])
}
Expand Down

0 comments on commit ee54a8d

Please sign in to comment.