mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
rename the iterator class
This commit is contained in:
2
pkg/obitools/obiannotate/obiannotate.go
Normal file
2
pkg/obitools/obiannotate/obiannotate.go
Normal file
@@ -0,0 +1,2 @@
|
||||
package obiannotate
|
||||
|
||||
@@ -19,7 +19,7 @@ type seqPCR struct {
|
||||
SonCount int
|
||||
AddedSons int
|
||||
Edges []Edge
|
||||
Cluster map[int]bool // used as the set of head sequences associated to that sequence
|
||||
Cluster map[int]bool // used as the set of head sequences associated to that sequence
|
||||
}
|
||||
|
||||
// buildSamples sorts the sequences by samples
|
||||
@@ -58,7 +58,7 @@ func buildSamples(dataset obiseq.BioSequenceSlice,
|
||||
|
||||
func annotateOBIClean(dataset obiseq.BioSequenceSlice,
|
||||
sample map[string]*([]*seqPCR),
|
||||
tag, NAValue string) obiiter.IBioSequenceBatch {
|
||||
tag, NAValue string) obiiter.IBioSequence {
|
||||
batchsize := 1000
|
||||
var annot = func(data obiseq.BioSequenceSlice) obiseq.BioSequenceSlice {
|
||||
|
||||
@@ -207,7 +207,6 @@ func GetCluster(sequence *obiseq.BioSequence) map[string]string {
|
||||
return cluster
|
||||
}
|
||||
|
||||
|
||||
// func Cluster(sample map[string]*([]*seqPCR)) {
|
||||
// for _, graph := range sample {
|
||||
// for _, s := range *graph {
|
||||
@@ -215,7 +214,7 @@ func GetCluster(sequence *obiseq.BioSequence) map[string]string {
|
||||
// if len(s.Edges) > 0 {
|
||||
// for _, f := range s.Edges {
|
||||
|
||||
// }
|
||||
// }
|
||||
// } else {
|
||||
// cluster
|
||||
// }
|
||||
@@ -286,7 +285,7 @@ func Weight(sequence *obiseq.BioSequence) map[string]int {
|
||||
return weight
|
||||
}
|
||||
|
||||
func IOBIClean(itertator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBatch {
|
||||
func IOBIClean(itertator obiiter.IBioSequence) obiiter.IBioSequence {
|
||||
|
||||
db := itertator.Load()
|
||||
|
||||
@@ -318,7 +317,6 @@ func IOBIClean(itertator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBatch {
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Mutation(samples)
|
||||
|
||||
pbopt := make([]progressbar.Option, 0, 5)
|
||||
@@ -352,7 +350,6 @@ func IOBIClean(itertator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBatch {
|
||||
EmpiricalDistCsv(RatioTableFilename(), all_ratio)
|
||||
}
|
||||
|
||||
|
||||
iter := annotateOBIClean(db, samples, SampleAttribute(), "NA")
|
||||
|
||||
if OnlyHead() {
|
||||
|
||||
@@ -67,9 +67,9 @@ func _ExpandListOfFiles(check_ext bool, filenames ...string) ([]string, error) {
|
||||
return list_of_files, nil
|
||||
}
|
||||
|
||||
func ReadBioSequences(filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
||||
var iterator obiiter.IBioSequenceBatch
|
||||
var reader func(string, ...obiformats.WithOption) (obiiter.IBioSequenceBatch, error)
|
||||
func ReadBioSequences(filenames ...string) (obiiter.IBioSequence, error) {
|
||||
var iterator obiiter.IBioSequence
|
||||
var reader func(string, ...obiformats.WithOption) (obiiter.IBioSequence, error)
|
||||
|
||||
opts := make([]obiformats.WithOption, 0, 10)
|
||||
|
||||
@@ -109,7 +109,7 @@ func ReadBioSequences(filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
||||
|
||||
list_of_files, err := _ExpandListOfFiles(false, filenames...)
|
||||
if err != nil {
|
||||
return obiiter.NilIBioSequenceBatch, err
|
||||
return obiiter.NilIBioSequence, err
|
||||
}
|
||||
|
||||
switch CLIInputFormat() {
|
||||
@@ -140,7 +140,7 @@ func ReadBioSequences(filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
||||
iterator, err = reader(list_of_files[0], opts...)
|
||||
|
||||
if err != nil {
|
||||
return obiiter.NilIBioSequenceBatch, err
|
||||
return obiiter.NilIBioSequence, err
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ import (
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obioptions"
|
||||
)
|
||||
|
||||
func WriteBioSequences(iterator obiiter.IBioSequenceBatch,
|
||||
terminalAction bool, filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
||||
func WriteBioSequences(iterator obiiter.IBioSequence,
|
||||
terminalAction bool, filenames ...string) (obiiter.IBioSequence, error) {
|
||||
|
||||
var newIter obiiter.IBioSequenceBatch
|
||||
var newIter obiiter.IBioSequence
|
||||
|
||||
opts := make([]obiformats.WithOption, 0, 10)
|
||||
|
||||
@@ -62,12 +62,12 @@ func WriteBioSequences(iterator obiiter.IBioSequenceBatch,
|
||||
|
||||
if err != nil {
|
||||
log.Fatalf("Write file error: %v", err)
|
||||
return obiiter.NilIBioSequenceBatch, err
|
||||
return obiiter.NilIBioSequence, err
|
||||
}
|
||||
|
||||
if terminalAction {
|
||||
newIter.Recycle()
|
||||
return obiiter.NilIBioSequenceBatch, nil
|
||||
return obiiter.NilIBioSequence, nil
|
||||
}
|
||||
|
||||
return newIter, nil
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
||||
)
|
||||
|
||||
func DistributeSequence(sequences obiiter.IBioSequenceBatch) {
|
||||
func DistributeSequence(sequences obiiter.IBioSequence) {
|
||||
|
||||
opts := make([]obiformats.WithOption, 0, 10)
|
||||
|
||||
|
||||
@@ -8,14 +8,14 @@ import (
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
||||
)
|
||||
|
||||
func IFilterSequence(iterator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBatch {
|
||||
var newIter obiiter.IBioSequenceBatch
|
||||
func IFilterSequence(iterator obiiter.IBioSequence) obiiter.IBioSequence {
|
||||
var newIter obiiter.IBioSequence
|
||||
|
||||
predicate := CLISequenceSelectionPredicate()
|
||||
|
||||
if predicate != nil {
|
||||
if CLISaveDiscardedSequences() {
|
||||
var discarded obiiter.IBioSequenceBatch
|
||||
var discarded obiiter.IBioSequence
|
||||
|
||||
log.Printf("Discarded sequences saved in file: %s\n", CLIDiscardedFileName())
|
||||
newIter, discarded = iterator.DivideOn(predicate,
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
||||
)
|
||||
|
||||
func IExtractBarcode(iterator obiiter.IBioSequenceBatch) (obiiter.IBioSequenceBatch, error) {
|
||||
func IExtractBarcode(iterator obiiter.IBioSequence) (obiiter.IBioSequence, error) {
|
||||
|
||||
opts := make([]obingslibrary.WithOption, 0, 10)
|
||||
|
||||
@@ -37,7 +37,7 @@ func IExtractBarcode(iterator obiiter.IBioSequenceBatch) (obiiter.IBioSequenceBa
|
||||
newIter = newIter.Rebatch(obioptions.CLIBatchSize())
|
||||
}
|
||||
|
||||
var unidentified obiiter.IBioSequenceBatch
|
||||
var unidentified obiiter.IBioSequence
|
||||
if CLIUnidentifiedFileName() != "" {
|
||||
log.Printf("Unassigned sequences saved in file: %s\n", CLIUnidentifiedFileName())
|
||||
unidentified, newIter = newIter.DivideOn(obiseq.HasAttribute("demultiplex_error"),
|
||||
|
||||
@@ -206,7 +206,7 @@ func AssemblePESequences(seqA, seqB *obiseq.BioSequence,
|
||||
func IAssemblePESequencesBatch(iterator obiiter.IPairedBioSequenceBatch,
|
||||
gap float64, delta, minOverlap int,
|
||||
minIdentity float64,
|
||||
withStats bool, sizes ...int) obiiter.IBioSequenceBatch {
|
||||
withStats bool, sizes ...int) obiiter.IBioSequence {
|
||||
|
||||
nworkers := runtime.NumCPU() * 3 / 2
|
||||
buffsize := iterator.BufferSize()
|
||||
@@ -219,7 +219,7 @@ func IAssemblePESequencesBatch(iterator obiiter.IPairedBioSequenceBatch,
|
||||
buffsize = sizes[1]
|
||||
}
|
||||
|
||||
newIter := obiiter.MakeIBioSequenceBatch(buffsize)
|
||||
newIter := obiiter.MakeIBioSequence(buffsize)
|
||||
|
||||
newIter.Add(nworkers)
|
||||
|
||||
|
||||
@@ -9,7 +9,7 @@ import (
|
||||
// PCR iterates over sequences provided by a obiseq.IBioSequenceBatch
|
||||
// and returns an other obiseq.IBioSequenceBatch distributing
|
||||
// obiseq.BioSequenceBatch containing the selected amplicon sequences.
|
||||
func PCR(iterator obiiter.IBioSequenceBatch) (obiiter.IBioSequenceBatch, error) {
|
||||
func PCR(iterator obiiter.IBioSequence) (obiiter.IBioSequence, error) {
|
||||
|
||||
opts := make([]obiapat.WithOption, 0, 10)
|
||||
|
||||
|
||||
@@ -32,7 +32,7 @@ func IndexSequence(seqidx int,
|
||||
// r := 0
|
||||
// w := 0
|
||||
for i, ref := range references {
|
||||
lcs, alilength := obialign.FastLCSScore(sequence, ref, -1 , &matrix)
|
||||
lcs, alilength := obialign.FastLCSScore(sequence, ref, -1, &matrix)
|
||||
score[i] = alilength - lcs
|
||||
}
|
||||
|
||||
@@ -88,7 +88,7 @@ func IndexSequence(seqidx int,
|
||||
return obitag_index
|
||||
}
|
||||
|
||||
func IndexReferenceDB(iterator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBatch {
|
||||
func IndexReferenceDB(iterator obiiter.IBioSequence) obiiter.IBioSequence {
|
||||
|
||||
references := iterator.Load()
|
||||
refcounts := make(
|
||||
@@ -118,7 +118,7 @@ func IndexReferenceDB(iterator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBa
|
||||
bar := progressbar.NewOptions(len(references), pbopt...)
|
||||
|
||||
limits := make(chan [2]int)
|
||||
indexed := obiiter.MakeIBioSequenceBatch()
|
||||
indexed := obiiter.MakeIBioSequence()
|
||||
go func() {
|
||||
for i := 0; i < len(references); i += 10 {
|
||||
limits <- [2]int{i, goutils.MinInt(i+10, len(references))}
|
||||
|
||||
@@ -171,7 +171,7 @@ func IdentifySeqWorker(references obiseq.BioSequenceSlice,
|
||||
}
|
||||
}
|
||||
|
||||
func AssignTaxonomy(iterator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBatch {
|
||||
func AssignTaxonomy(iterator obiiter.IBioSequence) obiiter.IBioSequence {
|
||||
|
||||
references := CLIRefDB()
|
||||
refcounts := make(
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obioptions"
|
||||
)
|
||||
|
||||
func Unique(sequences obiiter.IBioSequenceBatch) obiiter.IBioSequenceBatch {
|
||||
func Unique(sequences obiiter.IBioSequence) obiiter.IBioSequence {
|
||||
|
||||
options := make([]obichunk.WithOption, 0, 30)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user