mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-04-30 12:00:39 +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...)
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user