From 6acce603a1a9b82f69aab4427acef9b52d049100 Mon Sep 17 00:00:00 2001 From: Eric Coissac Date: Thu, 5 Oct 2023 07:48:47 +0200 Subject: [PATCH] Patch a bug in the new version of setDefinition() Former-commit-id: 9a382d9891e158dd3d445bfb4053691739ca9fdb --- pkg/obiseq/biosequence.go | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/pkg/obiseq/biosequence.go b/pkg/obiseq/biosequence.go index f147549..5f82658 100644 --- a/pkg/obiseq/biosequence.go +++ b/pkg/obiseq/biosequence.go @@ -324,7 +324,21 @@ func (s *BioSequence) SetId(id string) { // // It takes a string parameter 'definition' and assigns it to the 'definition' field of the BioSequence struct. func (s *BioSequence) SetDefinition(definition string) { - s.SetAttribute("definition", definition) + if definition != "" { + s.SetAttribute("definition", definition) + } else { + s.RemoveAttribute("definition") + } +} + +func (s *BioSequence) RemoveAttribute(key string) { + if s.HasAnnotation() { + if s.HasAttribute(key) { + defer s.AnnotationsUnlock() + s.AnnotationsLock() + delete(s.annotations, key) + } + } } // SetSource sets the source of the BioSequence.