Change the API of workers

Former-commit-id: 9b07306edd8cf28266f86f95823948fa99d39ea9
This commit is contained in:
2024-03-02 16:03:46 -04:00
parent 4a0b20484f
commit 0f3871d203
19 changed files with 194 additions and 120 deletions

View File

@@ -28,16 +28,18 @@ func Expression(expression string) func(*BioSequence) (interface{}, error) {
func EditIdWorker(expression string) SeqWorker {
e := Expression(expression)
f := func(sequence *BioSequence) *BioSequence {
f := func(sequence *BioSequence) (BioSequenceSlice, error) {
v, err := e(sequence)
if err != nil {
log.Fatalf("Expression '%s' cannot be evaluated on sequence %s",
if err == nil {
sequence.SetId(fmt.Sprintf("%v", v))
} else {
err = fmt.Errorf("Expression '%s' cannot be evaluated on sequence %s : %v",
expression,
sequence.Id())
sequence.Id(),
err)
}
sequence.SetId(fmt.Sprintf("%v", v))
return sequence
return BioSequenceSlice{sequence}, err
}
return f
@@ -45,16 +47,18 @@ func EditIdWorker(expression string) SeqWorker {
func EditAttributeWorker(key string, expression string) SeqWorker {
e := Expression(expression)
f := func(sequence *BioSequence) *BioSequence {
f := func(sequence *BioSequence) (BioSequenceSlice, error) {
v, err := e(sequence)
if err != nil {
log.Fatalf("Expression '%s' cannot be evaluated on sequence %s",
if err == nil {
sequence.SetAttribute(key, v)
} else {
err = fmt.Errorf("Expression '%s' cannot be evaluated on sequence %s : %v",
expression,
sequence.Id())
sequence.Id(),
err)
}
sequence.SetAttribute(key, v)
return sequence
return BioSequenceSlice{sequence}, err
}
return f