From 38dcd98d4a339010c82702e516ced20b0ec511b1 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Tue, 17 Jun 2025 08:52:45 +0200 Subject: [PATCH] Patch the genbank parser automata --- ecoprimers | 1 + pkg/obiformats/genbank_read.go | 16 ++++++++-------- pkg/obioptions/version.go | 2 +- 3 files changed, 10 insertions(+), 9 deletions(-) create mode 160000 ecoprimers diff --git a/ecoprimers b/ecoprimers new file mode 160000 index 0000000..b755220 --- /dev/null +++ b/ecoprimers @@ -0,0 +1 @@ +Subproject commit b7552200bd876851f0655a0573bcb49388811e2e diff --git a/pkg/obiformats/genbank_read.go b/pkg/obiformats/genbank_read.go index 4d57235..6c23ef6 100644 --- a/pkg/obiformats/genbank_read.go +++ b/pkg/obiformats/genbank_read.go @@ -56,7 +56,7 @@ func GenbankChunkParser(withFeatureTable bool) func(string, io.Reader) (obiseq.B case strings.HasPrefix(line, "LOCUS "): if state != inHeader { - log.Fatalf("Unexpected state %d while reading LOCUS: %s", state, line) + log.Fatalf("Line %d - Unexpected state %d while reading LOCUS: %s", nl, state, line) } id = strings.SplitN(line[12:], " ", 2)[0] match_length := _seqlenght_rx.FindStringSubmatch(line) @@ -76,7 +76,7 @@ func GenbankChunkParser(withFeatureTable bool) func(string, io.Reader) (obiseq.B case strings.HasPrefix(line, "DEFINITION "): if state != inEntry { - log.Fatalf("Unexpected state %d while reading DEFINITION: %s", state, line) + log.Fatalf("Line %d - Unexpected state %d while reading DEFINITION: %s", nl, state, line) } defBytes.WriteString(strings.TrimSpace(line[12:])) state = inDefinition @@ -93,29 +93,29 @@ func GenbankChunkParser(withFeatureTable bool) func(string, io.Reader) (obiseq.B case strings.HasPrefix(line, "SOURCE "): if state != inEntry { - log.Fatalf("Unexpected state %d while reading SOURCE: %s", state, line) + log.Fatalf("Line %d - Unexpected state %d while reading SOURCE: %s", nl, state, line) } scientificName = strings.TrimSpace(line[12:]) processed = true case strings.HasPrefix(line, "FEATURES "): if state != inEntry { - log.Fatalf("Unexpected state %d while reading FEATURES: %s", state, line) + log.Fatalf("Line %d - Unexpected state %d while reading FEATURES: %s", nl, state, line) } featBytes.WriteString(line) state = inFeature processed = true case strings.HasPrefix(line, "ORIGIN"): - if state != inFeature { - log.Fatalf("Unexpected state %d while reading ORIGIN: %s", state, line) + if state != inFeature && state != inContig { + log.Fatalf("Line %d - Unexpected state %d while reading ORIGIN: %s", nl, state, line) } state = inSequence processed = true case strings.HasPrefix(line, "CONTIG"): if state != inFeature && state != inContig { - log.Fatalf("Unexpected state %d while reading ORIGIN: %s", state, line) + log.Fatalf("Line %d - Unexpected state %d while reading ORIGIN: %s", nl, state, line) } state = inContig processed = true @@ -123,7 +123,7 @@ func GenbankChunkParser(withFeatureTable bool) func(string, io.Reader) (obiseq.B case line == "//": if state != inSequence && state != inContig { - log.Fatalf("Unexpected state %d while reading end of record %s", state, id) + log.Fatalf("Line %d - Unexpected state %d while reading end of record %s", nl, state, id) } // log.Debugln("Total lines := ", nl) if id == "" { diff --git a/pkg/obioptions/version.go b/pkg/obioptions/version.go index fa7137f..20de387 100644 --- a/pkg/obioptions/version.go +++ b/pkg/obioptions/version.go @@ -8,7 +8,7 @@ import ( // corresponds to the last commit, and not the one when the file will be // commited -var _Commit = "d31e677" +var _Commit = "7b23985" var _Version = "Release 4.4.0" // Version returns the version of the obitools package.