2022-01-13 23:27:39 +01:00
|
|
|
package obiformats
|
|
|
|
|
|
|
|
import (
|
|
|
|
"strings"
|
|
|
|
|
2023-11-29 12:14:37 +01:00
|
|
|
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiiter"
|
|
|
|
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiseq"
|
2022-01-13 23:27:39 +01:00
|
|
|
)
|
|
|
|
|
2023-08-14 15:21:30 +02:00
|
|
|
// ParseGuessedFastSeqHeader parses the guessed fast sequence header.
|
|
|
|
//
|
|
|
|
// The function takes a pointer to a BioSequence object as its parameter.
|
|
|
|
// It determines whether the sequence definition starts with "{" or not.
|
|
|
|
// If it does, it calls the ParseFastSeqJsonHeader function.
|
|
|
|
// If it doesn't, it calls the ParseFastSeqOBIHeader function.
|
2022-02-21 19:00:23 +01:00
|
|
|
func ParseGuessedFastSeqHeader(sequence *obiseq.BioSequence) {
|
2022-01-13 23:27:39 +01:00
|
|
|
if strings.HasPrefix(sequence.Definition(), "{") {
|
2023-08-14 15:21:30 +02:00
|
|
|
// Sequence definition starts with "{"
|
2022-01-13 23:27:39 +01:00
|
|
|
ParseFastSeqJsonHeader(sequence)
|
|
|
|
} else {
|
2023-08-14 15:21:30 +02:00
|
|
|
// Sequence definition does not start with "{"
|
2022-01-13 23:27:39 +01:00
|
|
|
ParseFastSeqOBIHeader(sequence)
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-08-14 15:21:30 +02:00
|
|
|
// IParseFastSeqHeaderBatch is a function that processes a batch of biosequences and returns an iterator of biosequences.
|
|
|
|
//
|
|
|
|
// It takes an iterator of biosequences as the first parameter and accepts optional options as variadic arguments.
|
|
|
|
// The function returns an iterator of biosequences.
|
2023-01-22 22:04:17 +01:00
|
|
|
func IParseFastSeqHeaderBatch(iterator obiiter.IBioSequence,
|
|
|
|
options ...WithOption) obiiter.IBioSequence {
|
2022-01-13 23:27:39 +01:00
|
|
|
opt := MakeOptions(options)
|
2023-01-22 22:39:13 +01:00
|
|
|
return iterator.MakeIWorker(obiseq.AnnotatorToSeqWorker(opt.ParseFastSeqHeader()),
|
2024-03-02 16:03:46 -04:00
|
|
|
false,
|
2023-03-07 11:12:13 +07:00
|
|
|
opt.ParallelWorkers())
|
2022-01-13 23:27:39 +01:00
|
|
|
}
|