Patch a bug on compressed output

This commit is contained in:
Eric Coissac
2025-02-05 14:18:24 +01:00
parent ceca33998b
commit 773e54965d
8 changed files with 44 additions and 7 deletions

View File

@ -8,7 +8,7 @@ import (
// corresponds to the last commit, and not the one when the file will be
// commited
var _Commit = "b9bee5f"
var _Commit = "ceca339"
var _Version = "Release 4.2.0"
// Version returns the version of the obitools package.

View File

@ -1 +1,38 @@
package obitax
import (
"strings"
"github.com/TuftsBCB/io/newick"
)
func (taxonomy *Taxonomy) Newick() string {
if taxonomy == nil {
return ""
}
iterator := taxonomy.AsTaxonSet().Sort().Iterator()
nodes := make(map[*string]*newick.Tree, taxonomy.Len())
trees := make([]*newick.Tree, 0)
for iterator.Next() {
taxon := iterator.Get()
tree := &newick.Tree{Label: taxon.String()}
nodes[taxon.Node.id] = tree
if parent, ok := nodes[taxon.Parent().Node.id]; ok {
parent.Children = append(parent.Children, *tree)
} else {
trees = append(trees, tree)
}
}
rep := strings.Builder{}
for _, tree := range trees {
rep.WriteString(tree.String())
rep.WriteString("\n")
}
return rep.String()
}

View File

@ -0,0 +1 @@
package obitax

View File

@ -163,10 +163,6 @@ func CLIOutputFormat() string {
}
}
func CLICompressed() bool {
return __compressed__
}
func CLISkipEmpty() bool {
return __skip_empty__
}

View File

@ -58,7 +58,7 @@ func CLIWriteBioSequences(iterator obiiter.IBioSequence,
opts = append(opts, obiformats.OptionsParallelWorkers(nworkers))
opts = append(opts, obiformats.OptionsBatchSize(obidefault.BatchSize()))
opts = append(opts, obiformats.OptionsCompressed(CLICompressed()))
opts = append(opts, obiformats.OptionsCompressed(obidefault.CompressOutput()))
var err error

View File

@ -33,7 +33,7 @@ func CLIDistributeSequence(sequences obiiter.IBioSequence) {
opts = append(opts, obiformats.OptionsParallelWorkers(nworkers),
obiformats.OptionsBatchSize(obidefault.BatchSize()),
obiformats.OptionsAppendFile(CLIAppendSequences()),
obiformats.OptionsCompressed(obiconvert.CLICompressed()))
obiformats.OptionsCompressed(obidefault.CompressOutput()))
var formater obiformats.SequenceBatchWriterToFile