mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Patch a tricky bug in parsing of json header and save the last sequence from files
Former-commit-id: bfe3d0e9eb8e65113699d535bd1d9a5fe0d3ce1d
This commit is contained in:
@ -12,7 +12,6 @@ import (
|
||||
)
|
||||
|
||||
func _parse_json_header_(header string, annotations obiseq.Annotation) string {
|
||||
|
||||
start := -1
|
||||
stop := -1
|
||||
level := 0
|
||||
@ -58,6 +57,9 @@ func _parse_json_header_(header string, annotations obiseq.Annotation) string {
|
||||
if vt == math.Floor(vt) {
|
||||
annotations[k] = int(vt)
|
||||
}
|
||||
{
|
||||
annotations[k] = vt
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,8 +71,18 @@ func _parse_json_header_(header string, annotations obiseq.Annotation) string {
|
||||
}
|
||||
|
||||
func ParseFastSeqJsonHeader(sequence *obiseq.BioSequence) {
|
||||
sequence.SetDefinition(_parse_json_header_(sequence.Definition(),
|
||||
sequence.Annotations()))
|
||||
definition := sequence.Definition()
|
||||
sequence.SetDefinition("")
|
||||
|
||||
definition_part := _parse_json_header_(
|
||||
definition,
|
||||
sequence.Annotations())
|
||||
if len(definition_part) > 0 {
|
||||
if sequence.HasDefinition() {
|
||||
definition_part = sequence.Definition() + " " + definition_part
|
||||
}
|
||||
sequence.SetDefinition(definition_part)
|
||||
}
|
||||
}
|
||||
|
||||
func FormatFastSeqJsonHeader(sequence *obiseq.BioSequence) string {
|
||||
@ -80,7 +92,7 @@ func FormatFastSeqJsonHeader(sequence *obiseq.BioSequence) string {
|
||||
text, err := obiutils.JsonMarshal(sequence.Annotations())
|
||||
|
||||
if err != nil {
|
||||
panic(err)
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
return string(text)
|
||||
|
@ -285,11 +285,17 @@ func ParseOBIFeatures(text string, annotations obiseq.Annotation) string {
|
||||
|
||||
func ParseFastSeqOBIHeader(sequence *obiseq.BioSequence) {
|
||||
annotations := sequence.Annotations()
|
||||
definition := sequence.Definition()
|
||||
sequence.SetDefinition("")
|
||||
|
||||
definition := ParseOBIFeatures(sequence.Definition(),
|
||||
annotations)
|
||||
definition = ParseOBIFeatures(definition, annotations)
|
||||
|
||||
sequence.SetDefinition(definition)
|
||||
if len(definition) > 0 {
|
||||
if sequence.HasDefinition() {
|
||||
definition = sequence.Definition() + " " + definition
|
||||
}
|
||||
sequence.SetDefinition(definition)
|
||||
}
|
||||
}
|
||||
|
||||
func FormatFastSeqOBIHeader(sequence *obiseq.BioSequence) string {
|
||||
|
@ -106,6 +106,16 @@ func ReadSeqFileChunk(reader io.Reader,
|
||||
}
|
||||
}
|
||||
|
||||
if err != nil && err != io.EOF && err != io.ErrUnexpectedEOF {
|
||||
log.Fatalf("Error reading data from file : %s", err)
|
||||
}
|
||||
|
||||
// Send the last chunk to the channel
|
||||
if len(buff) > 0 {
|
||||
io := bytes.NewBuffer(slices.Clone(buff))
|
||||
chunk_channel <- SeqFileChunk{io, i}
|
||||
}
|
||||
|
||||
// Close the readers channel when the end of the file is reached
|
||||
close(chunk_channel)
|
||||
}()
|
||||
|
@ -7,7 +7,7 @@ import (
|
||||
// TODO: The version number is extracted from git. This induces that the version
|
||||
// corresponds to the last commit, and not the one when the file will be
|
||||
// commited
|
||||
var _Commit = "f4fcc19"
|
||||
var _Commit = "b842d60"
|
||||
var _Version = "Release 4.2.0"
|
||||
|
||||
// Version returns the version of the obitools package.
|
||||
|
Reference in New Issue
Block a user