Patch the genbank parser automata

This commit is contained in:
Eric Coissac
2025-06-17 08:52:45 +02:00
parent 7b23985693
commit 38dcd98d4a
3 changed files with 10 additions and 9 deletions

1
ecoprimers Submodule

Submodule ecoprimers added at b7552200bd

View File

@ -56,7 +56,7 @@ func GenbankChunkParser(withFeatureTable bool) func(string, io.Reader) (obiseq.B
case strings.HasPrefix(line, "LOCUS "): case strings.HasPrefix(line, "LOCUS "):
if state != inHeader { 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] id = strings.SplitN(line[12:], " ", 2)[0]
match_length := _seqlenght_rx.FindStringSubmatch(line) 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 "): case strings.HasPrefix(line, "DEFINITION "):
if state != inEntry { 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:])) defBytes.WriteString(strings.TrimSpace(line[12:]))
state = inDefinition state = inDefinition
@ -93,29 +93,29 @@ func GenbankChunkParser(withFeatureTable bool) func(string, io.Reader) (obiseq.B
case strings.HasPrefix(line, "SOURCE "): case strings.HasPrefix(line, "SOURCE "):
if state != inEntry { 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:]) scientificName = strings.TrimSpace(line[12:])
processed = true processed = true
case strings.HasPrefix(line, "FEATURES "): case strings.HasPrefix(line, "FEATURES "):
if state != inEntry { 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) featBytes.WriteString(line)
state = inFeature state = inFeature
processed = true processed = true
case strings.HasPrefix(line, "ORIGIN"): case strings.HasPrefix(line, "ORIGIN"):
if state != inFeature { 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 = inSequence state = inSequence
processed = true processed = true
case strings.HasPrefix(line, "CONTIG"): case strings.HasPrefix(line, "CONTIG"):
if state != inFeature && state != inContig { 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 state = inContig
processed = true processed = true
@ -123,7 +123,7 @@ func GenbankChunkParser(withFeatureTable bool) func(string, io.Reader) (obiseq.B
case line == "//": case line == "//":
if state != inSequence && state != inContig { 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) // log.Debugln("Total lines := ", nl)
if id == "" { if id == "" {

View File

@ -8,7 +8,7 @@ import (
// corresponds to the last commit, and not the one when the file will be // corresponds to the last commit, and not the one when the file will be
// commited // commited
var _Commit = "d31e677" var _Commit = "7b23985"
var _Version = "Release 4.4.0" var _Version = "Release 4.4.0"
// Version returns the version of the obitools package. // Version returns the version of the obitools package.