mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Start to use leveled log
This commit is contained in:
@ -34,7 +34,7 @@ func main() {
|
|||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
fs, _ := obiconvert.ReadBioSequencesBatch(args...)
|
fs, _ := obiconvert.ReadBioSequencesBatch(args...)
|
||||||
nread, nvariant, nsymbol := fs.Count(true)
|
nvariant, nread, nsymbol := fs.Count(true)
|
||||||
|
|
||||||
if obicount.CLIIsPrintingVariantCount() {
|
if obicount.CLIIsPrintingVariantCount() {
|
||||||
fmt.Printf(" %d", nvariant)
|
fmt.Printf(" %d", nvariant)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
"runtime/trace"
|
"runtime/trace"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
"runtime/trace"
|
"runtime/trace"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obialign
|
package obialign
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obikmer"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obikmer"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obiapat
|
package obiapat
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
|
@ -3,10 +3,11 @@ package obichunk
|
|||||||
import (
|
import (
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"io/ioutil"
|
"io/ioutil"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiformats"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiformats"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
@ -55,7 +56,7 @@ func ISequenceChunkOnDisk(iterator obiiter.IBioSequenceBatch,
|
|||||||
go func() {
|
go func() {
|
||||||
defer func() {
|
defer func() {
|
||||||
os.RemoveAll(dir)
|
os.RemoveAll(dir)
|
||||||
log.Println("Clear the cache directory")
|
log.Debugln("Clear the cache directory")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
newIter.Wait()
|
newIter.Wait()
|
||||||
@ -68,7 +69,8 @@ func ISequenceChunkOnDisk(iterator obiiter.IBioSequenceBatch,
|
|||||||
)
|
)
|
||||||
|
|
||||||
fileNames := find(dir, ".fastx")
|
fileNames := find(dir, ".fastx")
|
||||||
log.Println("batch count ", len(fileNames))
|
nbatch := len(fileNames)
|
||||||
|
log.Infof("Data splitted over %d batches", nbatch)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
||||||
@ -88,6 +90,8 @@ func ISequenceChunkOnDisk(iterator obiiter.IBioSequenceBatch,
|
|||||||
}
|
}
|
||||||
|
|
||||||
newIter.Push(obiiter.MakeBioSequenceBatch(order, chunck))
|
newIter.Push(obiiter.MakeBioSequenceBatch(order, chunck))
|
||||||
|
log.Infof("Start processing of batch %d/%d : %d sequences",
|
||||||
|
order, nbatch, len(chunck))
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obichunk
|
package obichunk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
|
@ -9,6 +9,7 @@ type __options__ struct {
|
|||||||
bufferSize int
|
bufferSize int
|
||||||
batchSize int
|
batchSize int
|
||||||
parallelWorkers int
|
parallelWorkers int
|
||||||
|
noSingleton bool
|
||||||
}
|
}
|
||||||
|
|
||||||
type Options struct {
|
type Options struct {
|
||||||
@ -27,6 +28,7 @@ func MakeOptions(setters []WithOption) Options {
|
|||||||
bufferSize: 2,
|
bufferSize: 2,
|
||||||
batchSize: 5000,
|
batchSize: 5000,
|
||||||
parallelWorkers: 4,
|
parallelWorkers: 4,
|
||||||
|
noSingleton: false,
|
||||||
}
|
}
|
||||||
|
|
||||||
opt := Options{&o}
|
opt := Options{&o}
|
||||||
@ -79,6 +81,10 @@ func (opt Options) SortOnDisk() bool {
|
|||||||
return opt.pointer.cacheOnDisk
|
return opt.pointer.cacheOnDisk
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func (opt Options) NoSingleton() bool {
|
||||||
|
return opt.pointer.noSingleton
|
||||||
|
}
|
||||||
|
|
||||||
func OptionSortOnDisk() WithOption {
|
func OptionSortOnDisk() WithOption {
|
||||||
f := WithOption(func(opt Options) {
|
f := WithOption(func(opt Options) {
|
||||||
opt.pointer.cacheOnDisk = true
|
opt.pointer.cacheOnDisk = true
|
||||||
@ -149,3 +155,19 @@ func OptionsBufferSize(size int) WithOption {
|
|||||||
|
|
||||||
return f
|
return f
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func OptionsNoSingleton() WithOption {
|
||||||
|
f := WithOption(func(opt Options) {
|
||||||
|
opt.pointer.noSingleton = true
|
||||||
|
})
|
||||||
|
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
|
||||||
|
func OptionsWithSingleton() WithOption {
|
||||||
|
f := WithOption(func(opt Options) {
|
||||||
|
opt.pointer.noSingleton = false
|
||||||
|
})
|
||||||
|
|
||||||
|
return f
|
||||||
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package obichunk
|
package obichunk
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
|
||||||
"sort"
|
"sort"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
)
|
)
|
||||||
@ -100,7 +101,7 @@ func ISequenceSubChunk(iterator obiiter.IBioSequenceBatch,
|
|||||||
classifier.Reset()
|
classifier.Reset()
|
||||||
|
|
||||||
if cap(ordered) < batch.Length() {
|
if cap(ordered) < batch.Length() {
|
||||||
log.Println("Allocate a new ordered sequences : ", batch.Length())
|
log.Debugln("Allocate a new ordered sequences : ", batch.Length())
|
||||||
ordered = make([]sSS, batch.Length())
|
ordered = make([]sSS, batch.Length())
|
||||||
} else {
|
} else {
|
||||||
ordered = ordered[:batch.Length()]
|
ordered = ordered[:batch.Length()]
|
||||||
|
@ -3,6 +3,8 @@ package obichunk
|
|||||||
import (
|
import (
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
)
|
)
|
||||||
@ -16,6 +18,10 @@ func IUniqueSequence(iterator obiiter.IBioSequenceBatch,
|
|||||||
|
|
||||||
iUnique := obiiter.MakeIBioSequenceBatch(opts.BufferSize())
|
iUnique := obiiter.MakeIBioSequenceBatch(opts.BufferSize())
|
||||||
|
|
||||||
|
iterator = iterator.Speed("Splitting data set")
|
||||||
|
|
||||||
|
log.Infoln("Starting data splitting")
|
||||||
|
|
||||||
if opts.SortOnDisk() {
|
if opts.SortOnDisk() {
|
||||||
nworkers = 1
|
nworkers = 1
|
||||||
iterator, err = ISequenceChunkOnDisk(iterator,
|
iterator, err = ISequenceChunkOnDisk(iterator,
|
||||||
@ -36,6 +42,8 @@ func IUniqueSequence(iterator obiiter.IBioSequenceBatch,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.Infoln("End of the data splitting")
|
||||||
|
|
||||||
iUnique.Add(nworkers)
|
iUnique.Add(nworkers)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@ -83,7 +91,12 @@ func IUniqueSequence(iterator obiiter.IBioSequenceBatch,
|
|||||||
batch := input.Get()
|
batch := input.Get()
|
||||||
|
|
||||||
if icat < 0 || len(batch.Slice()) == 1 {
|
if icat < 0 || len(batch.Slice()) == 1 {
|
||||||
|
if opts.NoSingleton() && len(batch.Slice()) == 1 && batch.Slice()[0].Count() == 1 {
|
||||||
|
batch.Slice()[0].Recycle()
|
||||||
|
batch.Recycle()
|
||||||
|
} else {
|
||||||
iUnique.Push(batch.Reorder(nextOrder()))
|
iUnique.Push(batch.Reorder(nextOrder()))
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
next.Push(batch.Reorder(o))
|
next.Push(batch.Reorder(o))
|
||||||
o++
|
o++
|
||||||
@ -111,5 +124,5 @@ func IUniqueSequence(iterator obiiter.IBioSequenceBatch,
|
|||||||
opts.BufferSize(),
|
opts.BufferSize(),
|
||||||
)
|
)
|
||||||
|
|
||||||
return iMerged.Speed(), nil
|
return iMerged.Speed("Variants identified"), nil
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,7 @@ package obiformats
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
"strconv"
|
"strconv"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obiformats
|
package obiformats
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
|
@ -8,10 +8,11 @@ import "C"
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"unsafe"
|
"unsafe"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/cutils"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/cutils"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
@ -100,7 +101,7 @@ func ReadFastSeqBatchFromFile(filename string, options ...WithOption) (obiiter.I
|
|||||||
fi, err := os.Stat(filename)
|
fi, err := os.Stat(filename)
|
||||||
if err == nil {
|
if err == nil {
|
||||||
size = fi.Size()
|
size = fi.Size()
|
||||||
log.Printf("File size of %s is %d bytes\n", filename, size)
|
log.Debugf("File size of %s is %d bytes\n", filename, size)
|
||||||
} else {
|
} else {
|
||||||
size = -1
|
size = -1
|
||||||
}
|
}
|
||||||
@ -110,10 +111,10 @@ func ReadFastSeqBatchFromFile(filename string, options ...WithOption) (obiiter.I
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
newIter.WaitAndClose()
|
newIter.WaitAndClose()
|
||||||
log.Println("End of the fastq file reading")
|
log.Debugln("End of the fastq file reading")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
log.Println("Start of the fastq file reading")
|
log.Debugln("Start of the fastq file reading")
|
||||||
|
|
||||||
go _FastseqReader(pointer, newIter, opt.BatchSize())
|
go _FastseqReader(pointer, newIter, opt.BatchSize())
|
||||||
parser := opt.ParseFastSeqHeader()
|
parser := opt.ParseFastSeqHeader()
|
||||||
|
@ -4,10 +4,11 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
)
|
)
|
||||||
@ -114,6 +115,7 @@ func WriteFastaBatch(iterator obiiter.IBioSequenceBatch,
|
|||||||
go func() {
|
go func() {
|
||||||
newIter.WaitAndClose()
|
newIter.WaitAndClose()
|
||||||
close(chunkchan)
|
close(chunkchan)
|
||||||
|
log.Debugln("End of the fasta file writing")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ff := func(iterator obiiter.IBioSequenceBatch) {
|
ff := func(iterator obiiter.IBioSequenceBatch) {
|
||||||
@ -128,7 +130,7 @@ func WriteFastaBatch(iterator obiiter.IBioSequenceBatch,
|
|||||||
newIter.Done()
|
newIter.Done()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Start of the fasta file writing")
|
log.Debugln("Start of the fasta file writing")
|
||||||
go ff(iterator)
|
go ff(iterator)
|
||||||
for i := 0; i < nwriters-1; i++ {
|
for i := 0; i < nwriters-1; i++ {
|
||||||
go ff(iterator.Split())
|
go ff(iterator.Split())
|
||||||
|
@ -4,10 +4,11 @@ import (
|
|||||||
"bytes"
|
"bytes"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
)
|
)
|
||||||
@ -114,6 +115,7 @@ func WriteFastqBatch(iterator obiiter.IBioSequenceBatch,
|
|||||||
time.Sleep(time.Millisecond)
|
time.Sleep(time.Millisecond)
|
||||||
}
|
}
|
||||||
close(chunkchan)
|
close(chunkchan)
|
||||||
|
log.Debugln("End of the fastq file writing")
|
||||||
}()
|
}()
|
||||||
|
|
||||||
ff := func(iterator obiiter.IBioSequenceBatch) {
|
ff := func(iterator obiiter.IBioSequenceBatch) {
|
||||||
@ -129,7 +131,7 @@ func WriteFastqBatch(iterator obiiter.IBioSequenceBatch,
|
|||||||
newIter.Done()
|
newIter.Done()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Start of the fastq file writing")
|
log.Debugln("Start of the fastq file writing")
|
||||||
go ff(iterator)
|
go ff(iterator)
|
||||||
for i := 0; i < nwriters-1; i++ {
|
for i := 0; i < nwriters-1; i++ {
|
||||||
go ff(iterator.Split())
|
go ff(iterator.Split())
|
||||||
|
@ -5,7 +5,7 @@ import (
|
|||||||
"encoding/csv"
|
"encoding/csv"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
"path"
|
"path"
|
||||||
"strconv"
|
"strconv"
|
||||||
|
@ -4,10 +4,11 @@ import (
|
|||||||
"bufio"
|
"bufio"
|
||||||
"compress/gzip"
|
"compress/gzip"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -57,7 +58,7 @@ func ReadSequencesBatchFromFile(filename string,
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
file.Seek(0, 0)
|
file.Seek(0, 0)
|
||||||
} else {
|
} else {
|
||||||
log.Printf("File %s is gz compressed ", filename)
|
log.Debugf("File %s is gz compressed ", filename)
|
||||||
reader = greader
|
reader = greader
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -72,7 +73,7 @@ func ReadSequencesBatchFromFile(filename string,
|
|||||||
}
|
}
|
||||||
|
|
||||||
filetype := GuessSeqFileType(string(tag))
|
filetype := GuessSeqFileType(string(tag))
|
||||||
log.Printf("File guessed format : %s (tag: %s)",
|
log.Debug("File guessed format : %s (tag: %s)",
|
||||||
filetype, (strings.Split(string(tag), "\n"))[0])
|
filetype, (strings.Split(string(tag), "\n"))[0])
|
||||||
reader = breader
|
reader = breader
|
||||||
|
|
||||||
|
@ -3,7 +3,7 @@ package obiformats
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"io"
|
"io"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
|
@ -2,11 +2,12 @@ package obiiter
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"sync"
|
"sync"
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
"time"
|
"time"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
"github.com/tevino/abool/v2"
|
"github.com/tevino/abool/v2"
|
||||||
)
|
)
|
||||||
@ -413,7 +414,7 @@ func (iterator IBioSequenceBatch) Rebatch(size int, sizes ...int) IBioSequenceBa
|
|||||||
|
|
||||||
func (iterator IBioSequenceBatch) Recycle() {
|
func (iterator IBioSequenceBatch) Recycle() {
|
||||||
|
|
||||||
log.Println("Start recycling of Bioseq objects")
|
log.Debugln("Start recycling of Bioseq objects")
|
||||||
recycled := 0
|
recycled := 0
|
||||||
for iterator.Next() {
|
for iterator.Next() {
|
||||||
// iterator.Get()
|
// iterator.Get()
|
||||||
@ -424,7 +425,7 @@ func (iterator IBioSequenceBatch) Recycle() {
|
|||||||
}
|
}
|
||||||
batch.Recycle()
|
batch.Recycle()
|
||||||
}
|
}
|
||||||
log.Printf("End of the recycling of %d Bioseq objects", recycled)
|
log.Debugf("End of the recycling of %d Bioseq objects", recycled)
|
||||||
}
|
}
|
||||||
|
|
||||||
func (iterator IBioSequenceBatch) Count(recycle bool) (int, int, int) {
|
func (iterator IBioSequenceBatch) Count(recycle bool) (int, int, int) {
|
||||||
@ -432,7 +433,7 @@ func (iterator IBioSequenceBatch) Count(recycle bool) (int, int, int) {
|
|||||||
reads := 0
|
reads := 0
|
||||||
nucleotides := 0
|
nucleotides := 0
|
||||||
|
|
||||||
log.Println("Start counting of Bioseq objects")
|
log.Debugln("Start counting of Bioseq objects")
|
||||||
for iterator.Next() {
|
for iterator.Next() {
|
||||||
// iterator.Get()
|
// iterator.Get()
|
||||||
batch := iterator.Get()
|
batch := iterator.Get()
|
||||||
@ -447,7 +448,7 @@ func (iterator IBioSequenceBatch) Count(recycle bool) (int, int, int) {
|
|||||||
}
|
}
|
||||||
batch.Recycle()
|
batch.Recycle()
|
||||||
}
|
}
|
||||||
log.Printf("End of the counting of %d Bioseq objects", variants)
|
log.Debugf("End of the counting of %d Bioseq objects", variants)
|
||||||
return variants, reads, nucleotides
|
return variants, reads, nucleotides
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obiiter
|
package obiiter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
|
@ -6,7 +6,7 @@ import (
|
|||||||
"github.com/schollz/progressbar/v3"
|
"github.com/schollz/progressbar/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
func (iterator IBioSequenceBatch) Speed() IBioSequenceBatch {
|
func (iterator IBioSequenceBatch) Speed(message ...string) IBioSequenceBatch {
|
||||||
newIter := MakeIBioSequenceBatch()
|
newIter := MakeIBioSequenceBatch()
|
||||||
|
|
||||||
newIter.Add(1)
|
newIter.Add(1)
|
||||||
@ -15,13 +15,25 @@ func (iterator IBioSequenceBatch) Speed() IBioSequenceBatch {
|
|||||||
newIter.WaitAndClose()
|
newIter.WaitAndClose()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
bar := progressbar.NewOptions(
|
pbopt := make([]progressbar.Option, 0, 5)
|
||||||
-1,
|
pbopt = append(pbopt,
|
||||||
progressbar.OptionSetWriter(os.Stderr),
|
progressbar.OptionSetWriter(os.Stderr),
|
||||||
progressbar.OptionSetWidth(15),
|
progressbar.OptionSetWidth(15),
|
||||||
progressbar.OptionShowCount(),
|
progressbar.OptionShowCount(),
|
||||||
progressbar.OptionShowIts(),
|
progressbar.OptionShowIts(),
|
||||||
progressbar.OptionSetDescription("[Sequence Processing]"))
|
)
|
||||||
|
|
||||||
|
if len(message) > 0 {
|
||||||
|
pbopt = append(pbopt,
|
||||||
|
progressbar.OptionSetDescription(message[0]),
|
||||||
|
)
|
||||||
|
} else {
|
||||||
|
pbopt = append(pbopt,
|
||||||
|
progressbar.OptionSetDescription("[Sequence Processing]"),
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
|
bar := progressbar.NewOptions(-1, pbopt...)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
|
|
||||||
@ -38,7 +50,6 @@ func (iterator IBioSequenceBatch) Speed() IBioSequenceBatch {
|
|||||||
return newIter
|
return newIter
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
func SpeedPipe() Pipeable {
|
func SpeedPipe() Pipeable {
|
||||||
f := func(iterator IBioSequenceBatch) IBioSequenceBatch {
|
f := func(iterator IBioSequenceBatch) IBioSequenceBatch {
|
||||||
return iterator.Speed()
|
return iterator.Speed()
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obiiter
|
package obiiter
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
)
|
)
|
||||||
@ -39,7 +39,7 @@ func (iterator IBioSequenceBatch) MakeIWorker(worker SeqWorker, sizes ...int) IB
|
|||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
newIter.WaitAndClose()
|
newIter.WaitAndClose()
|
||||||
log.Println("End of the batch workers")
|
log.Debugln("End of the batch workers")
|
||||||
|
|
||||||
}()
|
}()
|
||||||
|
|
||||||
@ -54,7 +54,7 @@ func (iterator IBioSequenceBatch) MakeIWorker(worker SeqWorker, sizes ...int) IB
|
|||||||
newIter.Done()
|
newIter.Done()
|
||||||
}
|
}
|
||||||
|
|
||||||
log.Println("Start of the batch workers")
|
log.Debugln("Start of the batch workers")
|
||||||
for i := 0; i < nworkers-1; i++ {
|
for i := 0; i < nworkers-1; i++ {
|
||||||
go f(iterator.Split())
|
go f(iterator.Split())
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,7 @@ package obingslibrary
|
|||||||
import (
|
import (
|
||||||
"errors"
|
"errors"
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiapat"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiapat"
|
||||||
|
@ -2,10 +2,11 @@ package obioptions
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/DavidGamba/go-getoptions"
|
"github.com/DavidGamba/go-getoptions"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -43,10 +44,21 @@ func GenerateOptionParser(optionset ...func(*getoptions.GetOpt)) ArgumentParser
|
|||||||
log.Printf("CPU number limited to %d", _MaxAllowedCPU)
|
log.Printf("CPU number limited to %d", _MaxAllowedCPU)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if options.Called("no-singleton") {
|
||||||
|
log.Printf("No singleton option set")
|
||||||
|
}
|
||||||
|
|
||||||
if options.Called("help") {
|
if options.Called("help") {
|
||||||
fmt.Fprint(os.Stderr, options.Help())
|
fmt.Fprint(os.Stderr, options.Help())
|
||||||
os.Exit(1)
|
os.Exit(1)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
log.SetLevel(log.InfoLevel)
|
||||||
|
if options.Called("debug") {
|
||||||
|
log.SetLevel(log.DebugLevel)
|
||||||
|
log.Debugln("Switch to debug level logging")
|
||||||
|
}
|
||||||
|
|
||||||
return options, remaining, err
|
return options, remaining, err
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,9 +2,10 @@ package obiseq
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/md5"
|
"crypto/md5"
|
||||||
"log"
|
|
||||||
"sync/atomic"
|
"sync/atomic"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/goutils"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -15,7 +16,7 @@ var _MaxInMemSeq = int32(0)
|
|||||||
var _BioLogRate = int(100000)
|
var _BioLogRate = int(100000)
|
||||||
|
|
||||||
func LogBioSeqStatus() {
|
func LogBioSeqStatus() {
|
||||||
log.Printf("@@@@>>>> Created seq : %d Destroyed : %d In Memory : %d", _NewSeq, _RecycleSeq, _InMemSeq)
|
log.Debugf("Created seq : %d Destroyed : %d In Memory : %d", _NewSeq, _RecycleSeq, _InMemSeq)
|
||||||
}
|
}
|
||||||
|
|
||||||
type Quality []uint8
|
type Quality []uint8
|
||||||
|
@ -3,7 +3,7 @@ package obiseq
|
|||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"hash/crc32"
|
"hash/crc32"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"strconv"
|
"strconv"
|
||||||
"sync"
|
"sync"
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,7 @@ package obiseq
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"strings"
|
"strings"
|
||||||
)
|
)
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package obiseq
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"context"
|
"context"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"github.com/PaesslerAG/gval"
|
"github.com/PaesslerAG/gval"
|
||||||
)
|
)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obitax
|
package obitax
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
)
|
)
|
||||||
|
@ -2,7 +2,7 @@ package obitax
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
)
|
)
|
||||||
|
|
||||||
type TaxName struct {
|
type TaxName struct {
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obiconvert
|
package obiconvert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"os"
|
"os"
|
||||||
"path/filepath"
|
"path/filepath"
|
||||||
"strings"
|
"strings"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obiconvert
|
package obiconvert
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiformats"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiformats"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obidistribute
|
package obidistribute
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiformats"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiformats"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
|
@ -2,7 +2,7 @@ package obidistribute
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiseq"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obimultiplex
|
package obimultiplex
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obingslibrary"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obingslibrary"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obipairing
|
package obipairing
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
"math"
|
"math"
|
||||||
"os"
|
"os"
|
||||||
"runtime"
|
"runtime"
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obipcr
|
package obipcr
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiapat"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiapat"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
||||||
|
@ -10,22 +10,29 @@ var _Keys = make([]string, 0, 10)
|
|||||||
var _OnDisk = false
|
var _OnDisk = false
|
||||||
var _chunks = 100
|
var _chunks = 100
|
||||||
var _NAValue = "NA"
|
var _NAValue = "NA"
|
||||||
|
var _NoSingleton = false
|
||||||
|
|
||||||
func UniqueOptionSet(options *getoptions.GetOpt) {
|
func UniqueOptionSet(options *getoptions.GetOpt) {
|
||||||
options.StringSliceVar(&_StatsOn, "merge",
|
options.StringSliceVar(&_StatsOn, "merge",
|
||||||
1, 1,
|
1, 1,
|
||||||
options.Alias("m"),
|
options.Alias("m"),
|
||||||
|
options.ArgName("KEY"),
|
||||||
options.Description("Adds a merged attribute containing the list of sequence record ids merged within this group."))
|
options.Description("Adds a merged attribute containing the list of sequence record ids merged within this group."))
|
||||||
|
|
||||||
options.StringSliceVar(&_Keys, "category-attribute",
|
options.StringSliceVar(&_Keys, "category-attribute",
|
||||||
1, 1,
|
1, 1,
|
||||||
options.Alias("c"),
|
options.Alias("c"),
|
||||||
|
options.ArgName("CATEGORY"),
|
||||||
options.Description("Adds one attribute to the list of attributes used to define sequence groups (this option can be used several times)."))
|
options.Description("Adds one attribute to the list of attributes used to define sequence groups (this option can be used several times)."))
|
||||||
|
|
||||||
options.StringVar(&_NAValue, "na-value", _NAValue,
|
options.StringVar(&_NAValue, "na-value", _NAValue,
|
||||||
|
options.ArgName("NA_NAME"),
|
||||||
options.Description("Value used when the classifier tag is not defined for a sequence."))
|
options.Description("Value used when the classifier tag is not defined for a sequence."))
|
||||||
|
|
||||||
options.BoolVar(&_OnDisk, "on-disk", true,
|
options.BoolVar(&_NoSingleton, "no-singleton", _NoSingleton,
|
||||||
|
options.Description("If set, sequences occurring a single time in the data set are discarded."))
|
||||||
|
|
||||||
|
options.BoolVar(&_OnDisk, "on-disk", _OnDisk,
|
||||||
options.Description("Allows for using a disk cache during the dereplication process. "))
|
options.Description("Allows for using a disk cache during the dereplication process. "))
|
||||||
|
|
||||||
options.IntVar(&_chunks, "chunk-count", _chunks,
|
options.IntVar(&_chunks, "chunk-count", _chunks,
|
||||||
@ -49,7 +56,7 @@ func CLIKeys() []string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CLIUniqueInMemory() bool {
|
func CLIUniqueInMemory() bool {
|
||||||
return _OnDisk
|
return !_OnDisk
|
||||||
}
|
}
|
||||||
|
|
||||||
func CLINumberOfChunks() int {
|
func CLINumberOfChunks() int {
|
||||||
@ -63,3 +70,7 @@ func CLINumberOfChunks() int {
|
|||||||
func CLINAValue() string {
|
func CLINAValue() string {
|
||||||
return _NAValue
|
return _NAValue
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func CLINoSingleton() bool {
|
||||||
|
return _NoSingleton
|
||||||
|
}
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
package obiuniq
|
package obiuniq
|
||||||
|
|
||||||
import (
|
import (
|
||||||
"log"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obichunk"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obichunk"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
@ -24,6 +24,13 @@ func Unique(sequences obiiter.IBioSequenceBatch) obiiter.IBioSequenceBatch {
|
|||||||
options = append(options, obichunk.OptionSortOnDisk())
|
options = append(options, obichunk.OptionSortOnDisk())
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if CLINoSingleton() {
|
||||||
|
log.Printf("Removing sigletons from the output")
|
||||||
|
options = append(options, obichunk.OptionsNoSingleton())
|
||||||
|
} else {
|
||||||
|
log.Printf("Keep sigletons in the output")
|
||||||
|
}
|
||||||
|
|
||||||
options = append(options,
|
options = append(options,
|
||||||
obichunk.OptionStatOn(CLIStatsOn()...))
|
obichunk.OptionStatOn(CLIStatsOn()...))
|
||||||
|
|
||||||
|
Reference in New Issue
Block a user