mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Refactoring related to iterators
This commit is contained in:
@ -14,9 +14,9 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
fs, _ := obiconvert.ReadBioSequencesBatch(args...)
|
fs, _ := obiconvert.ReadBioSequences(args...)
|
||||||
|
|
||||||
cleaned := obiclean.IOBIClean(fs)
|
cleaned := obiclean.IOBIClean(fs)
|
||||||
|
|
||||||
obiconvert.WriteBioSequencesBatch(cleaned, true)
|
obiconvert.WriteBioSequences(cleaned, true)
|
||||||
}
|
}
|
||||||
|
@ -14,8 +14,8 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
fs, _ := obiconvert.ReadBioSequencesBatch(args...)
|
fs, _ := obiconvert.ReadBioSequences(args...)
|
||||||
|
|
||||||
comp := fs.MakeIWorker(obiiter.ReverseComplementWorker(true))
|
comp := fs.MakeIWorker(obiiter.ReverseComplementWorker(true))
|
||||||
obiconvert.WriteBioSequencesBatch(comp, true)
|
obiconvert.WriteBioSequences(comp, true)
|
||||||
}
|
}
|
||||||
|
@ -13,6 +13,6 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
fs, _ := obiconvert.ReadBioSequencesBatch(args...)
|
fs, _ := obiconvert.ReadBioSequences(args...)
|
||||||
obiconvert.WriteBioSequencesBatch(fs, true)
|
obiconvert.WriteBioSequences(fs, true)
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
fs, _ := obiconvert.ReadBioSequencesBatch(args...)
|
fs, _ := obiconvert.ReadBioSequences(args...)
|
||||||
nvariant, nread, nsymbol := fs.Count(true)
|
nvariant, nread, nsymbol := fs.Count(true)
|
||||||
|
|
||||||
if obicount.CLIIsPrintingVariantCount() {
|
if obicount.CLIIsPrintingVariantCount() {
|
||||||
|
@ -14,6 +14,6 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
fs, _ := obiconvert.ReadBioSequencesBatch(args...)
|
fs, _ := obiconvert.ReadBioSequences(args...)
|
||||||
obidistribute.DistributeSequence(fs)
|
obidistribute.DistributeSequence(fs)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
sequences, _ := obiconvert.ReadBioSequencesBatch(args...)
|
sequences, _ := obiconvert.ReadBioSequences(args...)
|
||||||
selected := obigrep.IFilterSequence(sequences)
|
selected := obigrep.IFilterSequence(sequences)
|
||||||
obiconvert.WriteBioSequencesBatch(selected, true)
|
obiconvert.WriteBioSequences(selected, true)
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime/pprof"
|
"runtime/pprof"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obioptions"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obioptions"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obimultiplex"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obimultiplex"
|
||||||
@ -30,8 +31,8 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
sequences, _ := obiconvert.ReadBioSequencesBatch(args...)
|
sequences, _ := obiconvert.ReadBioSequences(args...)
|
||||||
amplicons, _ := obimultiplex.IExtractBarcodeBatches(sequences)
|
amplicons, _ := obimultiplex.IExtractBarcode(sequences)
|
||||||
obiconvert.WriteBioSequencesBatch(amplicons, true)
|
obiconvert.WriteBioSequences(amplicons, true)
|
||||||
amplicons.Wait()
|
amplicons.Wait()
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,11 @@
|
|||||||
package main
|
package main
|
||||||
|
|
||||||
import (
|
import (
|
||||||
log "github.com/sirupsen/logrus"
|
|
||||||
"os"
|
"os"
|
||||||
"runtime/trace"
|
"runtime/trace"
|
||||||
|
|
||||||
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obioptions"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obioptions"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obipairing"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obipairing"
|
||||||
@ -40,5 +41,5 @@ func main() {
|
|||||||
obipairing.WithStats(),
|
obipairing.WithStats(),
|
||||||
obioptions.CLIParallelWorkers(),
|
obioptions.CLIParallelWorkers(),
|
||||||
)
|
)
|
||||||
obiconvert.WriteBioSequencesBatch(paired, true)
|
obiconvert.WriteBioSequences(paired, true)
|
||||||
}
|
}
|
||||||
|
@ -33,7 +33,7 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
sequences, _ := obiconvert.ReadBioSequencesBatch(args...)
|
sequences, _ := obiconvert.ReadBioSequences(args...)
|
||||||
amplicons, _ := obipcr.PCR(sequences)
|
amplicons, _ := obipcr.PCR(sequences)
|
||||||
obiconvert.WriteBioSequencesBatch(amplicons, true)
|
obiconvert.WriteBioSequences(amplicons, true)
|
||||||
}
|
}
|
||||||
|
@ -14,9 +14,9 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
fs, _ := obiconvert.ReadBioSequencesBatch(args...)
|
fs, _ := obiconvert.ReadBioSequences(args...)
|
||||||
indexed := obirefidx.IndexReferenceDB(fs)
|
indexed := obirefidx.IndexReferenceDB(fs)
|
||||||
|
|
||||||
written, _ := obiconvert.WriteBioSequencesBatch(indexed, false)
|
written, _ := obiconvert.WriteBioSequences(indexed, false)
|
||||||
written.Consume()
|
written.Consume()
|
||||||
}
|
}
|
||||||
|
@ -33,8 +33,8 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
fs, _ := obiconvert.ReadBioSequencesBatch(args...)
|
fs, _ := obiconvert.ReadBioSequences(args...)
|
||||||
identified := obitag.AssignTaxonomy(fs)
|
identified := obitag.AssignTaxonomy(fs)
|
||||||
|
|
||||||
obiconvert.WriteBioSequencesBatch(identified, true)
|
obiconvert.WriteBioSequences(identified, true)
|
||||||
}
|
}
|
||||||
|
@ -36,7 +36,7 @@ func main() {
|
|||||||
|
|
||||||
_, args, _ := optionParser(os.Args)
|
_, args, _ := optionParser(os.Args)
|
||||||
|
|
||||||
sequences, _ := obiconvert.ReadBioSequencesBatch(args...)
|
sequences, _ := obiconvert.ReadBioSequences(args...)
|
||||||
unique := obiuniq.Unique(sequences)
|
unique := obiuniq.Unique(sequences)
|
||||||
obiconvert.WriteBioSequencesBatch(unique, true)
|
obiconvert.WriteBioSequences(unique, true)
|
||||||
}
|
}
|
||||||
|
@ -13,7 +13,7 @@ func ReadSequencesBatchFromFiles(filenames []string,
|
|||||||
options ...WithOption) obiiter.IBioSequenceBatch {
|
options ...WithOption) obiiter.IBioSequenceBatch {
|
||||||
|
|
||||||
if reader == nil {
|
if reader == nil {
|
||||||
reader = ReadSequencesBatchFromFile
|
reader = ReadSequencesFromFile
|
||||||
}
|
}
|
||||||
|
|
||||||
batchiter := obiiter.MakeIBioSequenceBatch(0)
|
batchiter := obiiter.MakeIBioSequenceBatch(0)
|
||||||
|
@ -119,7 +119,7 @@ func __read_ecopcr_bioseq__(file *__ecopcr_file__) (*obiseq.BioSequence, error)
|
|||||||
return bseq, nil
|
return bseq, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadEcoPCRBatch(reader io.Reader, options ...WithOption) obiiter.IBioSequenceBatch {
|
func ReadEcoPCR(reader io.Reader, options ...WithOption) obiiter.IBioSequenceBatch {
|
||||||
tag := make([]byte, 11)
|
tag := make([]byte, 11)
|
||||||
n, _ := reader.Read(tag)
|
n, _ := reader.Read(tag)
|
||||||
|
|
||||||
@ -224,5 +224,5 @@ func ReadEcoPCRBatchFromFile(filename string, options ...WithOption) (obiiter.IB
|
|||||||
reader = greader
|
reader = greader
|
||||||
}
|
}
|
||||||
|
|
||||||
return ReadEcoPCRBatch(reader, options...), nil
|
return ReadEcoPCR(reader, options...), nil
|
||||||
}
|
}
|
||||||
|
@ -201,7 +201,7 @@ func _ReadFlatFileChunk(reader io.Reader, readers chan _FileChunk) {
|
|||||||
// 6 5 43 2 1
|
// 6 5 43 2 1
|
||||||
//
|
//
|
||||||
// <CR>?<LF>//<CR>?<LF>
|
// <CR>?<LF>//<CR>?<LF>
|
||||||
func ReadEMBLBatch(reader io.Reader, options ...WithOption) obiiter.IBioSequenceBatch {
|
func ReadEMBL(reader io.Reader, options ...WithOption) obiiter.IBioSequenceBatch {
|
||||||
opt := MakeOptions(options)
|
opt := MakeOptions(options)
|
||||||
entry_channel := make(chan _FileChunk, opt.BufferSize())
|
entry_channel := make(chan _FileChunk, opt.BufferSize())
|
||||||
|
|
||||||
@ -224,7 +224,7 @@ func ReadEMBLBatch(reader io.Reader, options ...WithOption) obiiter.IBioSequence
|
|||||||
return newIter
|
return newIter
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadEMBLBatchFromFile(filename string, options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
func ReadEMBLFromFile(filename string, options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
var greader io.Reader
|
var greader io.Reader
|
||||||
var err error
|
var err error
|
||||||
@ -242,5 +242,5 @@ func ReadEMBLBatchFromFile(filename string, options ...WithOption) (obiiter.IBio
|
|||||||
reader = greader
|
reader = greader
|
||||||
}
|
}
|
||||||
|
|
||||||
return ReadEMBLBatch(reader, options...), nil
|
return ReadEMBL(reader, options...), nil
|
||||||
}
|
}
|
||||||
|
@ -87,7 +87,7 @@ func _FastseqReader(seqfile C.fast_kseq_p,
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadFastSeqBatchFromFile(filename string, options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
func ReadFastSeqFromFile(filename string, options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
opt := MakeOptions(options)
|
opt := MakeOptions(options)
|
||||||
|
|
||||||
name := C.CString(filename)
|
name := C.CString(filename)
|
||||||
@ -132,7 +132,7 @@ func ReadFastSeqBatchFromFile(filename string, options ...WithOption) (obiiter.I
|
|||||||
return newIter, err
|
return newIter, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadFastSeqBatchFromStdin(options ...WithOption) obiiter.IBioSequenceBatch {
|
func ReadFastSeqFromStdin(options ...WithOption) obiiter.IBioSequenceBatch {
|
||||||
opt := MakeOptions(options)
|
opt := MakeOptions(options)
|
||||||
newIter := obiiter.MakeIBioSequenceBatch(opt.BufferSize())
|
newIter := obiiter.MakeIBioSequenceBatch(opt.BufferSize())
|
||||||
|
|
||||||
|
@ -61,7 +61,7 @@ func FormatFastaBatch(batch obiiter.BioSequenceBatch, formater FormatHeader) []b
|
|||||||
return bs.Bytes()
|
return bs.Bytes()
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteFastaBatch(iterator obiiter.IBioSequenceBatch,
|
func WriteFasta(iterator obiiter.IBioSequenceBatch,
|
||||||
file io.Writer,
|
file io.Writer,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
opt := MakeOptions(options)
|
opt := MakeOptions(options)
|
||||||
@ -136,13 +136,13 @@ func WriteFastaBatch(iterator obiiter.IBioSequenceBatch,
|
|||||||
return newIter, nil
|
return newIter, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteFastaBatchToStdout(iterator obiiter.IBioSequenceBatch,
|
func WriteFastaToStdout(iterator obiiter.IBioSequenceBatch,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
options = append(options, OptionDontCloseFile())
|
options = append(options, OptionDontCloseFile())
|
||||||
return WriteFastaBatch(iterator, os.Stdout, options...)
|
return WriteFasta(iterator, os.Stdout, options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteFastaBatchToFile(iterator obiiter.IBioSequenceBatch,
|
func WriteFastaToFile(iterator obiiter.IBioSequenceBatch,
|
||||||
filename string,
|
filename string,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
|
|
||||||
@ -155,5 +155,5 @@ func WriteFastaBatchToFile(iterator obiiter.IBioSequenceBatch,
|
|||||||
|
|
||||||
options = append(options, OptionCloseFile())
|
options = append(options, OptionCloseFile())
|
||||||
|
|
||||||
return WriteFastaBatch(iterator, file, options...)
|
return WriteFasta(iterator, file, options...)
|
||||||
}
|
}
|
||||||
|
@ -51,7 +51,7 @@ type FileChunck struct {
|
|||||||
order int
|
order int
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteFastqBatch(iterator obiiter.IBioSequenceBatch,
|
func WriteFastq(iterator obiiter.IBioSequenceBatch,
|
||||||
file io.Writer,
|
file io.Writer,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
opt := MakeOptions(options)
|
opt := MakeOptions(options)
|
||||||
@ -129,13 +129,13 @@ func WriteFastqBatch(iterator obiiter.IBioSequenceBatch,
|
|||||||
return newIter, nil
|
return newIter, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteFastqBatchToStdout(iterator obiiter.IBioSequenceBatch,
|
func WriteFastqToStdout(iterator obiiter.IBioSequenceBatch,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
options = append(options, OptionDontCloseFile())
|
options = append(options, OptionDontCloseFile())
|
||||||
return WriteFastqBatch(iterator, os.Stdout, options...)
|
return WriteFastq(iterator, os.Stdout, options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteFastqBatchToFile(iterator obiiter.IBioSequenceBatch,
|
func WriteFastqToFile(iterator obiiter.IBioSequenceBatch,
|
||||||
filename string,
|
filename string,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
|
|
||||||
@ -148,5 +148,5 @@ func WriteFastqBatchToFile(iterator obiiter.IBioSequenceBatch,
|
|||||||
|
|
||||||
options = append(options, OptionCloseFile())
|
options = append(options, OptionCloseFile())
|
||||||
|
|
||||||
return WriteFastqBatch(iterator, file, options...)
|
return WriteFastq(iterator, file, options...)
|
||||||
}
|
}
|
||||||
|
@ -20,10 +20,10 @@ type gbstate int
|
|||||||
|
|
||||||
const (
|
const (
|
||||||
inHeader gbstate = 0
|
inHeader gbstate = 0
|
||||||
inEntry = 1
|
inEntry gbstate = 1
|
||||||
inDefinition = 2
|
inDefinition gbstate = 2
|
||||||
inFeature = 3
|
inFeature gbstate = 3
|
||||||
inSequence = 4
|
inSequence gbstate = 4
|
||||||
)
|
)
|
||||||
|
|
||||||
func _ParseGenbankFile(input <-chan _FileChunk, out obiiter.IBioSequenceBatch) {
|
func _ParseGenbankFile(input <-chan _FileChunk, out obiiter.IBioSequenceBatch) {
|
||||||
@ -107,7 +107,7 @@ func _ParseGenbankFile(input <-chan _FileChunk, out obiiter.IBioSequenceBatch) {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadGenbankBatch(reader io.Reader, options ...WithOption) obiiter.IBioSequenceBatch {
|
func ReadGenbank(reader io.Reader, options ...WithOption) obiiter.IBioSequenceBatch {
|
||||||
opt := MakeOptions(options)
|
opt := MakeOptions(options)
|
||||||
entry_channel := make(chan _FileChunk, opt.BufferSize())
|
entry_channel := make(chan _FileChunk, opt.BufferSize())
|
||||||
|
|
||||||
@ -130,7 +130,7 @@ func ReadGenbankBatch(reader io.Reader, options ...WithOption) obiiter.IBioSeque
|
|||||||
return newIter
|
return newIter
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadGenbankBatchFromFile(filename string, options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
func ReadGenbankFromFile(filename string, options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
var greader io.Reader
|
var greader io.Reader
|
||||||
var err error
|
var err error
|
||||||
@ -148,5 +148,5 @@ func ReadGenbankBatchFromFile(filename string, options ...WithOption) (obiiter.I
|
|||||||
reader = greader
|
reader = greader
|
||||||
}
|
}
|
||||||
|
|
||||||
return ReadGenbankBatch(reader, options...), nil
|
return ReadGenbank(reader, options...), nil
|
||||||
}
|
}
|
||||||
|
@ -42,7 +42,7 @@ func GuessSeqFileType(firstline string) string {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadSequencesBatchFromFile(filename string,
|
func ReadSequencesFromFile(filename string,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
var file *os.File
|
var file *os.File
|
||||||
var reader io.Reader
|
var reader io.Reader
|
||||||
@ -85,14 +85,14 @@ func ReadSequencesBatchFromFile(filename string,
|
|||||||
switch filetype {
|
switch filetype {
|
||||||
case "fastq", "fasta":
|
case "fastq", "fasta":
|
||||||
file.Close()
|
file.Close()
|
||||||
is, _ := ReadFastSeqBatchFromFile(filename, options...)
|
is, _ := ReadFastSeqFromFile(filename, options...)
|
||||||
return is, nil
|
return is, nil
|
||||||
case "ecopcr":
|
case "ecopcr":
|
||||||
return ReadEcoPCRBatch(reader, options...), nil
|
return ReadEcoPCR(reader, options...), nil
|
||||||
case "embl":
|
case "embl":
|
||||||
return ReadEMBLBatch(reader, options...), nil
|
return ReadEMBL(reader, options...), nil
|
||||||
case "genbank":
|
case "genbank":
|
||||||
return ReadGenbankBatch(reader, options...), nil
|
return ReadGenbank(reader, options...), nil
|
||||||
default:
|
default:
|
||||||
log.Fatalf("File %s has guessed format %s which is not yet implemented",
|
log.Fatalf("File %s has guessed format %s which is not yet implemented",
|
||||||
filename, filetype)
|
filename, filetype)
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obiiter"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WriteSequenceBatch(iterator obiiter.IBioSequenceBatch,
|
func WriteSequence(iterator obiiter.IBioSequenceBatch,
|
||||||
file io.Writer,
|
file io.Writer,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
|
|
||||||
@ -27,12 +27,12 @@ func WriteSequenceBatch(iterator obiiter.IBioSequenceBatch,
|
|||||||
|
|
||||||
if len(batch.Slice()) > 0 {
|
if len(batch.Slice()) > 0 {
|
||||||
if batch.Slice()[0].HasQualities() {
|
if batch.Slice()[0].HasQualities() {
|
||||||
newIter, err = WriteFastqBatch(iterator, file, options...)
|
newIter, err = WriteFastq(iterator, file, options...)
|
||||||
} else {
|
} else {
|
||||||
newIter, err = WriteFastaBatch(iterator, file, options...)
|
newIter, err = WriteFasta(iterator, file, options...)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
newIter, err = WriteFastaBatch(iterator, file, options...)
|
newIter, err = WriteFasta(iterator, file, options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
return newIter, err
|
return newIter, err
|
||||||
@ -45,13 +45,13 @@ func WriteSequenceBatch(iterator obiiter.IBioSequenceBatch,
|
|||||||
return obiiter.NilIBioSequenceBatch, fmt.Errorf("input iterator not ready")
|
return obiiter.NilIBioSequenceBatch, fmt.Errorf("input iterator not ready")
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteSequencesBatchToStdout(iterator obiiter.IBioSequenceBatch,
|
func WriteSequencesToStdout(iterator obiiter.IBioSequenceBatch,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
options = append(options, OptionDontCloseFile())
|
options = append(options, OptionDontCloseFile())
|
||||||
return WriteSequenceBatch(iterator, os.Stdout, options...)
|
return WriteSequence(iterator, os.Stdout, options...)
|
||||||
}
|
}
|
||||||
|
|
||||||
func WriteSequencesBatchToFile(iterator obiiter.IBioSequenceBatch,
|
func WriteSequencesToFile(iterator obiiter.IBioSequenceBatch,
|
||||||
filename string,
|
filename string,
|
||||||
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
options ...WithOption) (obiiter.IBioSequenceBatch, error) {
|
||||||
|
|
||||||
@ -63,5 +63,5 @@ func WriteSequencesBatchToFile(iterator obiiter.IBioSequenceBatch,
|
|||||||
}
|
}
|
||||||
|
|
||||||
options = append(options, OptionCloseFile())
|
options = append(options, OptionCloseFile())
|
||||||
return WriteSequenceBatch(iterator, file, options...)
|
return WriteSequence(iterator, file, options...)
|
||||||
}
|
}
|
||||||
|
@ -631,7 +631,7 @@ func (iterator IBioSequenceBatch) FilterOn(predicate obiseq.SequencePredicate,
|
|||||||
return trueIter.Rebatch(size)
|
return trueIter.Rebatch(size)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Load every sequences availables from an IBioSequenceBatch iterator into
|
// Load all sequences availables from an IBioSequenceBatch iterator into
|
||||||
// a large obiseq.BioSequenceSlice.
|
// a large obiseq.BioSequenceSlice.
|
||||||
func (iterator IBioSequenceBatch) Load() obiseq.BioSequenceSlice {
|
func (iterator IBioSequenceBatch) Load() obiseq.BioSequenceSlice {
|
||||||
|
|
||||||
@ -656,12 +656,12 @@ func IBatchOver(data obiseq.BioSequenceSlice,
|
|||||||
buffsize = sizes[1]
|
buffsize = sizes[1]
|
||||||
}
|
}
|
||||||
|
|
||||||
trueIter := MakeIBioSequenceBatch(buffsize)
|
newIter := MakeIBioSequenceBatch(buffsize)
|
||||||
|
|
||||||
trueIter.Add(1)
|
newIter.Add(1)
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
trueIter.WaitAndClose()
|
newIter.WaitAndClose()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
@ -673,12 +673,12 @@ func IBatchOver(data obiseq.BioSequenceSlice,
|
|||||||
if next > ldata {
|
if next > ldata {
|
||||||
next = ldata
|
next = ldata
|
||||||
}
|
}
|
||||||
trueIter.Push(MakeBioSequenceBatch(batchid, data[i:next]))
|
newIter.Push(MakeBioSequenceBatch(batchid, data[i:next]))
|
||||||
batchid++
|
batchid++
|
||||||
}
|
}
|
||||||
|
|
||||||
trueIter.Done()
|
newIter.Done()
|
||||||
}()
|
}()
|
||||||
|
|
||||||
return trueIter
|
return newIter
|
||||||
}
|
}
|
||||||
|
@ -67,7 +67,7 @@ func _ExpandListOfFiles(check_ext bool, filenames ...string) ([]string, error) {
|
|||||||
return list_of_files, nil
|
return list_of_files, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func ReadBioSequencesBatch(filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
func ReadBioSequences(filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
||||||
var iterator obiiter.IBioSequenceBatch
|
var iterator obiiter.IBioSequenceBatch
|
||||||
var reader func(string, ...obiformats.WithOption) (obiiter.IBioSequenceBatch, error)
|
var reader func(string, ...obiformats.WithOption) (obiiter.IBioSequenceBatch, error)
|
||||||
|
|
||||||
@ -97,13 +97,13 @@ func ReadBioSequencesBatch(filenames ...string) (obiiter.IBioSequenceBatch, erro
|
|||||||
log.Printf("Reading sequences from stdin in %s\n", CLIInputFormat())
|
log.Printf("Reading sequences from stdin in %s\n", CLIInputFormat())
|
||||||
switch CLIInputFormat() {
|
switch CLIInputFormat() {
|
||||||
case "ecopcr":
|
case "ecopcr":
|
||||||
iterator = obiformats.ReadEcoPCRBatch(os.Stdin, opts...)
|
iterator = obiformats.ReadEcoPCR(os.Stdin, opts...)
|
||||||
case "embl":
|
case "embl":
|
||||||
iterator = obiformats.ReadEMBLBatch(os.Stdin, opts...)
|
iterator = obiformats.ReadEMBL(os.Stdin, opts...)
|
||||||
case "genbank":
|
case "genbank":
|
||||||
iterator = obiformats.ReadGenbankBatch(os.Stdin, opts...)
|
iterator = obiformats.ReadGenbank(os.Stdin, opts...)
|
||||||
default:
|
default:
|
||||||
iterator = obiformats.ReadFastSeqBatchFromStdin(opts...)
|
iterator = obiformats.ReadFastSeqFromStdin(opts...)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
|
|
||||||
@ -116,11 +116,11 @@ func ReadBioSequencesBatch(filenames ...string) (obiiter.IBioSequenceBatch, erro
|
|||||||
case "ecopcr":
|
case "ecopcr":
|
||||||
reader = obiformats.ReadEcoPCRBatchFromFile
|
reader = obiformats.ReadEcoPCRBatchFromFile
|
||||||
case "embl":
|
case "embl":
|
||||||
reader = obiformats.ReadEMBLBatchFromFile
|
reader = obiformats.ReadEMBLFromFile
|
||||||
case "genbank":
|
case "genbank":
|
||||||
reader = obiformats.ReadGenbankBatchFromFile
|
reader = obiformats.ReadGenbankFromFile
|
||||||
default:
|
default:
|
||||||
reader = obiformats.ReadSequencesBatchFromFile
|
reader = obiformats.ReadSequencesFromFile
|
||||||
}
|
}
|
||||||
|
|
||||||
if len(list_of_files) > 1 {
|
if len(list_of_files) > 1 {
|
||||||
|
@ -8,7 +8,7 @@ import (
|
|||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obioptions"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obioptions"
|
||||||
)
|
)
|
||||||
|
|
||||||
func WriteBioSequencesBatch(iterator obiiter.IBioSequenceBatch,
|
func WriteBioSequences(iterator obiiter.IBioSequenceBatch,
|
||||||
terminalAction bool, filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
terminalAction bool, filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
||||||
|
|
||||||
var newIter obiiter.IBioSequenceBatch
|
var newIter obiiter.IBioSequenceBatch
|
||||||
@ -43,20 +43,20 @@ func WriteBioSequencesBatch(iterator obiiter.IBioSequenceBatch,
|
|||||||
if len(filenames) == 0 {
|
if len(filenames) == 0 {
|
||||||
switch CLIOutputFormat() {
|
switch CLIOutputFormat() {
|
||||||
case "fastq":
|
case "fastq":
|
||||||
newIter, err = obiformats.WriteFastqBatchToStdout(iterator, opts...)
|
newIter, err = obiformats.WriteFastqToStdout(iterator, opts...)
|
||||||
case "fasta":
|
case "fasta":
|
||||||
newIter, err = obiformats.WriteFastaBatchToStdout(iterator, opts...)
|
newIter, err = obiformats.WriteFastaToStdout(iterator, opts...)
|
||||||
default:
|
default:
|
||||||
newIter, err = obiformats.WriteSequencesBatchToStdout(iterator, opts...)
|
newIter, err = obiformats.WriteSequencesToStdout(iterator, opts...)
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch CLIOutputFormat() {
|
switch CLIOutputFormat() {
|
||||||
case "fastq":
|
case "fastq":
|
||||||
newIter, err = obiformats.WriteFastqBatchToFile(iterator, filenames[0], opts...)
|
newIter, err = obiformats.WriteFastqToFile(iterator, filenames[0], opts...)
|
||||||
case "fasta":
|
case "fasta":
|
||||||
newIter, err = obiformats.WriteFastaBatchToFile(iterator, filenames[0], opts...)
|
newIter, err = obiformats.WriteFastaToFile(iterator, filenames[0], opts...)
|
||||||
default:
|
default:
|
||||||
newIter, err = obiformats.WriteSequencesBatchToFile(iterator, filenames[0], opts...)
|
newIter, err = obiformats.WriteSequencesToFile(iterator, filenames[0], opts...)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -40,11 +40,11 @@ func DistributeSequence(sequences obiiter.IBioSequenceBatch) {
|
|||||||
|
|
||||||
switch obiconvert.CLIOutputFormat() {
|
switch obiconvert.CLIOutputFormat() {
|
||||||
case "fastq":
|
case "fastq":
|
||||||
formater = obiformats.WriteFastqBatchToFile
|
formater = obiformats.WriteFastqToFile
|
||||||
case "fasta":
|
case "fasta":
|
||||||
formater = obiformats.WriteFastaBatchToFile
|
formater = obiformats.WriteFastaToFile
|
||||||
default:
|
default:
|
||||||
formater = obiformats.WriteSequencesBatchToFile
|
formater = obiformats.WriteSequencesToFile
|
||||||
}
|
}
|
||||||
|
|
||||||
dispatcher := sequences.Distribute(CLISequenceClassifier(),
|
dispatcher := sequences.Distribute(CLISequenceClassifier(),
|
||||||
|
@ -22,7 +22,7 @@ func IFilterSequence(iterator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBat
|
|||||||
obioptions.CLIBatchSize())
|
obioptions.CLIBatchSize())
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
_, err := obiconvert.WriteBioSequencesBatch(discarded,
|
_, err := obiconvert.WriteBioSequences(discarded,
|
||||||
true,
|
true,
|
||||||
CLIDiscardedFileName())
|
CLIDiscardedFileName())
|
||||||
|
|
||||||
|
@ -10,7 +10,7 @@ import (
|
|||||||
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
"git.metabarcoding.org/lecasofts/go/obitools/pkg/obitools/obiconvert"
|
||||||
)
|
)
|
||||||
|
|
||||||
func IExtractBarcodeBatches(iterator obiiter.IBioSequenceBatch) (obiiter.IBioSequenceBatch, error) {
|
func IExtractBarcode(iterator obiiter.IBioSequenceBatch) (obiiter.IBioSequenceBatch, error) {
|
||||||
|
|
||||||
opts := make([]obingslibrary.WithOption, 0, 10)
|
opts := make([]obingslibrary.WithOption, 0, 10)
|
||||||
|
|
||||||
@ -44,7 +44,7 @@ func IExtractBarcodeBatches(iterator obiiter.IBioSequenceBatch) (obiiter.IBioSeq
|
|||||||
obioptions.CLIBatchSize())
|
obioptions.CLIBatchSize())
|
||||||
|
|
||||||
go func() {
|
go func() {
|
||||||
_, err := obiconvert.WriteBioSequencesBatch(unidentified,
|
_, err := obiconvert.WriteBioSequences(unidentified,
|
||||||
true,
|
true,
|
||||||
CLIUnidentifiedFileName())
|
CLIUnidentifiedFileName())
|
||||||
|
|
||||||
|
@ -47,12 +47,12 @@ func OptionSet(options *getoptions.GetOpt) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func IBatchPairedSequence() (obiiter.IPairedBioSequenceBatch, error) {
|
func IBatchPairedSequence() (obiiter.IPairedBioSequenceBatch, error) {
|
||||||
forward, err := obiconvert.ReadBioSequencesBatch(_ForwardFiles...)
|
forward, err := obiconvert.ReadBioSequences(_ForwardFiles...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return obiiter.NilIPairedBioSequenceBatch, err
|
return obiiter.NilIPairedBioSequenceBatch, err
|
||||||
}
|
}
|
||||||
|
|
||||||
reverse, err := obiconvert.ReadBioSequencesBatch(_ReverseFiles...)
|
reverse, err := obiconvert.ReadBioSequences(_ReverseFiles...)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return obiiter.NilIPairedBioSequenceBatch, err
|
return obiiter.NilIPairedBioSequenceBatch, err
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ func CLIRefDBName() string {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func CLIRefDB() obiseq.BioSequenceSlice {
|
func CLIRefDB() obiseq.BioSequenceSlice {
|
||||||
refdb, err := obiformats.ReadSequencesBatchFromFile(_RefDB)
|
refdb, err := obiformats.ReadSequencesFromFile(_RefDB)
|
||||||
|
|
||||||
if err != nil {
|
if err != nil {
|
||||||
log.Panicf("Cannot open the reference library file : %s\n", _RefDB)
|
log.Panicf("Cannot open the reference library file : %s\n", _RefDB)
|
||||||
|
Reference in New Issue
Block a user