mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
change the model for representing paired reads and extend its usage to other commands
This commit is contained in:
58
pkg/obiseq/paired_reads.go
Normal file
58
pkg/obiseq/paired_reads.go
Normal file
@@ -0,0 +1,58 @@
|
||||
package obiseq
|
||||
|
||||
import log "github.com/sirupsen/logrus"
|
||||
|
||||
func (s *BioSequence) IsPaired() bool {
|
||||
return s.paired != nil
|
||||
}
|
||||
|
||||
func (s *BioSequence) PairedWith() *BioSequence {
|
||||
return s.paired
|
||||
}
|
||||
|
||||
func (s *BioSequence) PairTo(p *BioSequence) {
|
||||
s.paired = p
|
||||
if p != nil {
|
||||
p.paired = s
|
||||
}
|
||||
}
|
||||
|
||||
func (s *BioSequence) UnPair() {
|
||||
if s.paired != nil {
|
||||
s.paired.paired = nil
|
||||
}
|
||||
s.paired = nil
|
||||
}
|
||||
|
||||
func (s *BioSequenceSlice) IsPaired() bool {
|
||||
return (*s)[0].paired != nil
|
||||
}
|
||||
|
||||
func (s *BioSequenceSlice) PairedWith() *BioSequenceSlice {
|
||||
ps := NewBioSequenceSlice(len(*s))
|
||||
for i, seq := range *s {
|
||||
(*ps)[i] = seq.PairedWith()
|
||||
}
|
||||
|
||||
return ps
|
||||
}
|
||||
|
||||
func (s *BioSequenceSlice) PairTo(p *BioSequenceSlice) {
|
||||
|
||||
if len(*s) != len(*p) {
|
||||
log.Fatalf("Pairing of iterators: both batches have not the same length : (%d,%d)",
|
||||
len(*s), len(*p),
|
||||
)
|
||||
}
|
||||
|
||||
for i, seq := range *s {
|
||||
seq.PairTo((*p)[i])
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
func (s *BioSequenceSlice) UnPair() {
|
||||
for _, seq := range *s {
|
||||
seq.UnPair()
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user