mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
A first prototype for the space of sequences
Former-commit-id: 07dc6ef044b5b6a6fb45dc2acb01dffe71a96195
This commit is contained in:
@@ -12,6 +12,7 @@ package obiseq
|
||||
|
||||
import (
|
||||
"crypto/md5"
|
||||
"sync"
|
||||
"sync/atomic"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiutils"
|
||||
@@ -58,6 +59,7 @@ type BioSequence struct {
|
||||
feature []byte
|
||||
paired *BioSequence // A pointer to the paired sequence
|
||||
annotations Annotation
|
||||
annot_lock sync.Mutex
|
||||
}
|
||||
|
||||
// MakeEmptyBioSequence() creates a new BioSequence object with no data
|
||||
@@ -79,6 +81,7 @@ func MakeEmptyBioSequence(preallocate int) BioSequence {
|
||||
feature: nil,
|
||||
paired: nil,
|
||||
annotations: nil,
|
||||
annot_lock: sync.Mutex{},
|
||||
}
|
||||
}
|
||||
|
||||
@@ -142,6 +145,8 @@ func (s *BioSequence) Copy() *BioSequence {
|
||||
newSeq.feature = CopySlice(s.feature)
|
||||
|
||||
if len(s.annotations) > 0 {
|
||||
defer s.annot_lock.Unlock()
|
||||
s.annot_lock.Lock()
|
||||
newSeq.annotations = GetAnnotation(s.annotations)
|
||||
}
|
||||
|
||||
@@ -206,6 +211,14 @@ func (s *BioSequence) Annotations() Annotation {
|
||||
return s.annotations
|
||||
}
|
||||
|
||||
func (s *BioSequence) AnnotationsLock() {
|
||||
s.annot_lock.Lock()
|
||||
}
|
||||
|
||||
func (s *BioSequence) AnnotationsUnlock() {
|
||||
s.annot_lock.Unlock()
|
||||
}
|
||||
|
||||
// Checking if the BioSequence has a source.
|
||||
func (s *BioSequence) HasSource() bool {
|
||||
return len(s.source) > 0
|
||||
|
||||
Reference in New Issue
Block a user