mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-06-29 16:20:46 +00:00
Generate the ratio file as compressed if -Z option enabled.
This commit is contained in:
@ -8,7 +8,7 @@ import (
|
|||||||
// corresponds to the last commit, and not the one when the file will be
|
// corresponds to the last commit, and not the one when the file will be
|
||||||
// commited
|
// commited
|
||||||
|
|
||||||
var _Commit = "db284f1"
|
var _Commit = "6245d7f"
|
||||||
var _Version = "Release 4.2.0"
|
var _Version = "Release 4.2.0"
|
||||||
|
|
||||||
// Version returns the version of the obitools package.
|
// Version returns the version of the obitools package.
|
||||||
|
@ -13,6 +13,7 @@ import (
|
|||||||
log "github.com/sirupsen/logrus"
|
log "github.com/sirupsen/logrus"
|
||||||
|
|
||||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obialign"
|
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obialign"
|
||||||
|
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiutils"
|
||||||
"github.com/schollz/progressbar/v3"
|
"github.com/schollz/progressbar/v3"
|
||||||
)
|
)
|
||||||
|
|
||||||
@ -56,12 +57,15 @@ func makeEdge(father, dist, pos int, from, to byte) Edge {
|
|||||||
// and writes a CSV file with the first column being the
|
// and writes a CSV file with the first column being the
|
||||||
// first nucleotide, the second column being the second nucleotide, and the third column being the
|
// first nucleotide, the second column being the second nucleotide, and the third column being the
|
||||||
// ratio
|
// ratio
|
||||||
func EmpiricalDistCsv(filename string, data [][]Ratio) {
|
func EmpiricalDistCsv(filename string, data [][]Ratio, compressed bool) {
|
||||||
file, err := os.Create(filename)
|
file, err := os.Create(filename)
|
||||||
|
|
||||||
|
defer file.Close()
|
||||||
|
|
||||||
|
destfile, err := obiutils.CompressStream(file, true, true)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
fmt.Println(err)
|
fmt.Println(err)
|
||||||
}
|
}
|
||||||
defer file.Close()
|
|
||||||
|
|
||||||
pbopt := make([]progressbar.Option, 0, 5)
|
pbopt := make([]progressbar.Option, 0, 5)
|
||||||
pbopt = append(pbopt,
|
pbopt = append(pbopt,
|
||||||
@ -74,11 +78,11 @@ func EmpiricalDistCsv(filename string, data [][]Ratio) {
|
|||||||
|
|
||||||
bar := progressbar.NewOptions(len(data), pbopt...)
|
bar := progressbar.NewOptions(len(data), pbopt...)
|
||||||
|
|
||||||
fmt.Fprintln(file, "Sample,Father_id,Father_status,From,To,Weight_from,Weight_to,Count_from,Count_to,Position,length,A,C,G,T")
|
fmt.Fprintln(destfile, "Sample,Father_id,Father_status,From,To,Weight_from,Weight_to,Count_from,Count_to,Position,length,A,C,G,T")
|
||||||
for code, dist := range data {
|
for code, dist := range data {
|
||||||
a1, a2 := intToNucPair(code)
|
a1, a2 := intToNucPair(code)
|
||||||
for _, ratio := range dist {
|
for _, ratio := range dist {
|
||||||
fmt.Fprintf(file, "%s,%s,%s,%c,%c,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
|
fmt.Fprintf(destfile, "%s,%s,%s,%c,%c,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d\n",
|
||||||
ratio.Sample,
|
ratio.Sample,
|
||||||
ratio.SeqID,
|
ratio.SeqID,
|
||||||
ratio.status,
|
ratio.status,
|
||||||
|
@ -390,7 +390,7 @@ func CLIOBIClean(itertator obiiter.IBioSequence) obiiter.IBioSequence {
|
|||||||
|
|
||||||
if IsSaveRatioTable() {
|
if IsSaveRatioTable() {
|
||||||
all_ratio := EstimateRatio(samples, MinCountToEvalMutationRate())
|
all_ratio := EstimateRatio(samples, MinCountToEvalMutationRate())
|
||||||
EmpiricalDistCsv(RatioTableFilename(), all_ratio)
|
EmpiricalDistCsv(RatioTableFilename(), all_ratio, obidefault.CompressOutput())
|
||||||
}
|
}
|
||||||
|
|
||||||
iter := annotateOBIClean(source, db)
|
iter := annotateOBIClean(source, db)
|
||||||
|
Reference in New Issue
Block a user