mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-08 16:50:27 +00:00
Refactoring related to iterators
This commit is contained in:
@@ -67,7 +67,7 @@ func _ExpandListOfFiles(check_ext bool, filenames ...string) ([]string, error) {
|
||||
return list_of_files, nil
|
||||
}
|
||||
|
||||
func ReadBioSequencesBatch(filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
||||
func ReadBioSequences(filenames ...string) (obiiter.IBioSequenceBatch, error) {
|
||||
var iterator obiiter.IBioSequenceBatch
|
||||
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())
|
||||
switch CLIInputFormat() {
|
||||
case "ecopcr":
|
||||
iterator = obiformats.ReadEcoPCRBatch(os.Stdin, opts...)
|
||||
iterator = obiformats.ReadEcoPCR(os.Stdin, opts...)
|
||||
case "embl":
|
||||
iterator = obiformats.ReadEMBLBatch(os.Stdin, opts...)
|
||||
iterator = obiformats.ReadEMBL(os.Stdin, opts...)
|
||||
case "genbank":
|
||||
iterator = obiformats.ReadGenbankBatch(os.Stdin, opts...)
|
||||
iterator = obiformats.ReadGenbank(os.Stdin, opts...)
|
||||
default:
|
||||
iterator = obiformats.ReadFastSeqBatchFromStdin(opts...)
|
||||
iterator = obiformats.ReadFastSeqFromStdin(opts...)
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -116,11 +116,11 @@ func ReadBioSequencesBatch(filenames ...string) (obiiter.IBioSequenceBatch, erro
|
||||
case "ecopcr":
|
||||
reader = obiformats.ReadEcoPCRBatchFromFile
|
||||
case "embl":
|
||||
reader = obiformats.ReadEMBLBatchFromFile
|
||||
reader = obiformats.ReadEMBLFromFile
|
||||
case "genbank":
|
||||
reader = obiformats.ReadGenbankBatchFromFile
|
||||
reader = obiformats.ReadGenbankFromFile
|
||||
default:
|
||||
reader = obiformats.ReadSequencesBatchFromFile
|
||||
reader = obiformats.ReadSequencesFromFile
|
||||
}
|
||||
|
||||
if len(list_of_files) > 1 {
|
||||
|
||||
@@ -8,7 +8,7 @@ import (
|
||||
"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) {
|
||||
|
||||
var newIter obiiter.IBioSequenceBatch
|
||||
@@ -43,20 +43,20 @@ func WriteBioSequencesBatch(iterator obiiter.IBioSequenceBatch,
|
||||
if len(filenames) == 0 {
|
||||
switch CLIOutputFormat() {
|
||||
case "fastq":
|
||||
newIter, err = obiformats.WriteFastqBatchToStdout(iterator, opts...)
|
||||
newIter, err = obiformats.WriteFastqToStdout(iterator, opts...)
|
||||
case "fasta":
|
||||
newIter, err = obiformats.WriteFastaBatchToStdout(iterator, opts...)
|
||||
newIter, err = obiformats.WriteFastaToStdout(iterator, opts...)
|
||||
default:
|
||||
newIter, err = obiformats.WriteSequencesBatchToStdout(iterator, opts...)
|
||||
newIter, err = obiformats.WriteSequencesToStdout(iterator, opts...)
|
||||
}
|
||||
} else {
|
||||
switch CLIOutputFormat() {
|
||||
case "fastq":
|
||||
newIter, err = obiformats.WriteFastqBatchToFile(iterator, filenames[0], opts...)
|
||||
newIter, err = obiformats.WriteFastqToFile(iterator, filenames[0], opts...)
|
||||
case "fasta":
|
||||
newIter, err = obiformats.WriteFastaBatchToFile(iterator, filenames[0], opts...)
|
||||
newIter, err = obiformats.WriteFastaToFile(iterator, filenames[0], opts...)
|
||||
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() {
|
||||
case "fastq":
|
||||
formater = obiformats.WriteFastqBatchToFile
|
||||
formater = obiformats.WriteFastqToFile
|
||||
case "fasta":
|
||||
formater = obiformats.WriteFastaBatchToFile
|
||||
formater = obiformats.WriteFastaToFile
|
||||
default:
|
||||
formater = obiformats.WriteSequencesBatchToFile
|
||||
formater = obiformats.WriteSequencesToFile
|
||||
}
|
||||
|
||||
dispatcher := sequences.Distribute(CLISequenceClassifier(),
|
||||
|
||||
@@ -22,7 +22,7 @@ func IFilterSequence(iterator obiiter.IBioSequenceBatch) obiiter.IBioSequenceBat
|
||||
obioptions.CLIBatchSize())
|
||||
|
||||
go func() {
|
||||
_, err := obiconvert.WriteBioSequencesBatch(discarded,
|
||||
_, err := obiconvert.WriteBioSequences(discarded,
|
||||
true,
|
||||
CLIDiscardedFileName())
|
||||
|
||||
|
||||
@@ -10,7 +10,7 @@ import (
|
||||
"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)
|
||||
|
||||
@@ -44,7 +44,7 @@ func IExtractBarcodeBatches(iterator obiiter.IBioSequenceBatch) (obiiter.IBioSeq
|
||||
obioptions.CLIBatchSize())
|
||||
|
||||
go func() {
|
||||
_, err := obiconvert.WriteBioSequencesBatch(unidentified,
|
||||
_, err := obiconvert.WriteBioSequences(unidentified,
|
||||
true,
|
||||
CLIUnidentifiedFileName())
|
||||
|
||||
|
||||
@@ -47,12 +47,12 @@ func OptionSet(options *getoptions.GetOpt) {
|
||||
}
|
||||
|
||||
func IBatchPairedSequence() (obiiter.IPairedBioSequenceBatch, error) {
|
||||
forward, err := obiconvert.ReadBioSequencesBatch(_ForwardFiles...)
|
||||
forward, err := obiconvert.ReadBioSequences(_ForwardFiles...)
|
||||
if err != nil {
|
||||
return obiiter.NilIPairedBioSequenceBatch, err
|
||||
}
|
||||
|
||||
reverse, err := obiconvert.ReadBioSequencesBatch(_ReverseFiles...)
|
||||
reverse, err := obiconvert.ReadBioSequences(_ReverseFiles...)
|
||||
if err != nil {
|
||||
return obiiter.NilIPairedBioSequenceBatch, err
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ func CLIRefDBName() string {
|
||||
}
|
||||
|
||||
func CLIRefDB() obiseq.BioSequenceSlice {
|
||||
refdb, err := obiformats.ReadSequencesBatchFromFile(_RefDB)
|
||||
refdb, err := obiformats.ReadSequencesFromFile(_RefDB)
|
||||
|
||||
if err != nil {
|
||||
log.Panicf("Cannot open the reference library file : %s\n", _RefDB)
|
||||
|
||||
Reference in New Issue
Block a user