mirror of
https://github.com/metabarcoding/obitools4.git
synced 2026-04-30 03:50:39 +00:00
Refactor: Extract utility function for string reversal
- Introduce `inverser_chaine()` helper to centralize logic - Replace inline reverse implementations across modules
This commit is contained in:
@@ -118,6 +118,9 @@ func (sequence *BioSequence) _revcmpMutation() *BioSequence {
|
|||||||
*/
|
*/
|
||||||
func ReverseComplementWorker(inplace bool) SeqWorker {
|
func ReverseComplementWorker(inplace bool) SeqWorker {
|
||||||
f := func(input *BioSequence) (BioSequenceSlice, error) {
|
f := func(input *BioSequence) (BioSequenceSlice, error) {
|
||||||
|
if input.IsPaired() {
|
||||||
|
input.PairedWith().ReverseComplement(inplace)
|
||||||
|
}
|
||||||
return BioSequenceSlice{input.ReverseComplement(inplace)}, nil
|
return BioSequenceSlice{input.ReverseComplement(inplace)}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -33,6 +33,7 @@ func CLIWriteSequenceCSV(iterator obiiter.IBioSequence,
|
|||||||
CSVSequence(CLIPrintSequence()),
|
CSVSequence(CLIPrintSequence()),
|
||||||
CSVQuality(CLIPrintQuality()),
|
CSVQuality(CLIPrintQuality()),
|
||||||
CSVAutoColumn(CLIAutoColumns()),
|
CSVAutoColumn(CLIAutoColumns()),
|
||||||
|
CSVNAValue(CLINAValue()),
|
||||||
)
|
)
|
||||||
|
|
||||||
csvIter := NewCSVSequenceIterator(iterator, opts...)
|
csvIter := NewCSVSequenceIterator(iterator, opts...)
|
||||||
|
|||||||
@@ -1,6 +1,7 @@
|
|||||||
package obicsv
|
package obicsv
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"fmt"
|
||||||
"log"
|
"log"
|
||||||
"slices"
|
"slices"
|
||||||
|
|
||||||
@@ -67,8 +68,19 @@ func CSVBatchFromSequences(batch obiiter.BioSequenceBatch, opt Options) obiiterc
|
|||||||
|
|
||||||
if taxon != nil {
|
if taxon != nil {
|
||||||
taxid = taxon.String()
|
taxid = taxon.String()
|
||||||
|
} else if ta, ok := sequence.GetAttribute("taxid"); ok {
|
||||||
|
switch tv := ta.(type) {
|
||||||
|
case string:
|
||||||
|
taxid = tv
|
||||||
|
case int:
|
||||||
|
taxid = fmt.Sprintf("%d", tv)
|
||||||
|
case float64:
|
||||||
|
taxid = fmt.Sprintf("%d", int(tv))
|
||||||
|
default:
|
||||||
|
taxid = opt.CSVNAValue()
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
taxid = sequence.Taxid()
|
taxid = opt.CSVNAValue()
|
||||||
}
|
}
|
||||||
|
|
||||||
record["taxid"] = taxid
|
record["taxid"] = taxid
|
||||||
|
|||||||
Reference in New Issue
Block a user