2023-02-23 23:35:58 +01:00
|
|
|
package obiiter
|
|
|
|
|
|
|
|
import (
|
2024-08-05 10:48:28 +02:00
|
|
|
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obioptions"
|
2024-03-06 12:52:22 -03:00
|
|
|
log "github.com/sirupsen/logrus"
|
2023-02-23 23:35:58 +01:00
|
|
|
)
|
|
|
|
|
|
|
|
func (b BioSequenceBatch) IsPaired() bool {
|
|
|
|
return b.slice.IsPaired()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b BioSequenceBatch) PairedWith() BioSequenceBatch {
|
2024-08-02 12:35:46 +02:00
|
|
|
return MakeBioSequenceBatch(
|
|
|
|
b.Source(),
|
|
|
|
b.order,
|
|
|
|
*b.slice.PairedWith(),
|
|
|
|
)
|
2023-02-23 23:35:58 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
func (b *BioSequenceBatch) PairTo(p *BioSequenceBatch) {
|
|
|
|
|
|
|
|
if b.order != p.order {
|
|
|
|
log.Fatalf("both batches are not synchronized : (%d,%d)",
|
|
|
|
b.order, p.order,
|
|
|
|
)
|
|
|
|
}
|
|
|
|
|
|
|
|
b.slice.PairTo(&p.slice)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (b *BioSequenceBatch) UnPair() {
|
|
|
|
b.slice.UnPair()
|
|
|
|
}
|
|
|
|
|
|
|
|
func (iter IBioSequence) MarkAsPaired() {
|
|
|
|
iter.pointer.paired = true
|
|
|
|
}
|
|
|
|
|
|
|
|
func (iter IBioSequence) PairTo(p IBioSequence) IBioSequence {
|
|
|
|
|
|
|
|
newIter := MakeIBioSequence()
|
|
|
|
|
2024-08-05 10:48:28 +02:00
|
|
|
iter = iter.SortBatches().Rebatch(obioptions.CLIBatchSize())
|
|
|
|
p = p.SortBatches().Rebatch(obioptions.CLIBatchSize())
|
2023-02-23 23:35:58 +01:00
|
|
|
|
|
|
|
newIter.Add(1)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
newIter.WaitAndClose()
|
|
|
|
}()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
|
|
|
|
for iter.Next() {
|
|
|
|
p.Next()
|
|
|
|
batch := iter.Get()
|
|
|
|
pbatch := p.Get()
|
|
|
|
batch.PairTo(&pbatch)
|
|
|
|
newIter.Push(batch)
|
|
|
|
}
|
|
|
|
|
|
|
|
newIter.Done()
|
|
|
|
}()
|
|
|
|
|
|
|
|
newIter.MarkAsPaired()
|
|
|
|
return newIter
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (iter IBioSequence) PairedWith() IBioSequence {
|
|
|
|
|
|
|
|
newIter := MakeIBioSequence()
|
|
|
|
|
|
|
|
newIter.Add(1)
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
newIter.WaitAndClose()
|
|
|
|
}()
|
|
|
|
|
|
|
|
go func() {
|
|
|
|
|
|
|
|
for iter.Next() {
|
|
|
|
batch := iter.Get().PairedWith()
|
|
|
|
newIter.Push(batch)
|
|
|
|
}
|
|
|
|
|
|
|
|
newIter.Done()
|
|
|
|
}()
|
|
|
|
|
|
|
|
newIter.MarkAsPaired()
|
|
|
|
return newIter
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
func (iter IBioSequence) IsPaired() bool {
|
|
|
|
return iter.pointer.paired
|
|
|
|
}
|