mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-13 02:30:26 +00:00
Patch a small bug on json write
This commit is contained in:
@@ -273,31 +273,31 @@ func CLIAnnotationWorker() obiseq.SeqWorker {
|
||||
}
|
||||
|
||||
if CLIHasTaxonAtRank() {
|
||||
taxo := obigrep.CLILoadSelectedTaxonomy()
|
||||
taxo := obitax.DefaultTaxonomy()
|
||||
w := AddTaxonAtRankWorker(taxo, CLITaxonAtRank()...)
|
||||
annotator = annotator.ChainWorkers(w)
|
||||
}
|
||||
|
||||
if CLISetTaxonomicPath() {
|
||||
taxo := obigrep.CLILoadSelectedTaxonomy()
|
||||
taxo := obitax.DefaultTaxonomy()
|
||||
w := obiseq.MakeSetPathWorker(taxo)
|
||||
annotator = annotator.ChainWorkers(w)
|
||||
}
|
||||
|
||||
if CLISetTaxonomicRank() {
|
||||
taxo := obigrep.CLILoadSelectedTaxonomy()
|
||||
taxo := obitax.DefaultTaxonomy()
|
||||
w := AddTaxonRankWorker(taxo)
|
||||
annotator = annotator.ChainWorkers(w)
|
||||
}
|
||||
|
||||
if CLISetScientificName() {
|
||||
taxo := obigrep.CLILoadSelectedTaxonomy()
|
||||
taxo := obitax.DefaultTaxonomy()
|
||||
w := AddScientificNameWorker(taxo)
|
||||
annotator = annotator.ChainWorkers(w)
|
||||
}
|
||||
|
||||
if CLIHasAddLCA() {
|
||||
taxo := obigrep.CLILoadSelectedTaxonomy()
|
||||
taxo := obitax.DefaultTaxonomy()
|
||||
w := obiseq.AddLCAWorker(taxo, CLILCASlotName(), CLILCAThreshold())
|
||||
annotator = annotator.ChainWorkers(w)
|
||||
}
|
||||
|
||||
@@ -11,6 +11,7 @@ import (
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obioptions"
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiseq"
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obistats"
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obitax"
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obitools/obigrep"
|
||||
)
|
||||
|
||||
@@ -245,7 +246,7 @@ func ICleanDB(itertator obiiter.IBioSequence) obiiter.IBioSequence {
|
||||
log.Fatal(err)
|
||||
}
|
||||
|
||||
taxonomy := obigrep.CLILoadSelectedTaxonomy()
|
||||
taxonomy := obitax.DefaultTaxonomy()
|
||||
|
||||
if len(obigrep.CLIRequiredRanks()) > 0 {
|
||||
rankPredicate = obigrep.CLIHasRankDefinedPredicate()
|
||||
|
||||
@@ -3,6 +3,7 @@ package obiconvert
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obioptions"
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"github.com/DavidGamba/go-getoptions"
|
||||
@@ -115,6 +116,7 @@ func PairedFilesOptionSet(options *getoptions.GetOpt) {
|
||||
}
|
||||
|
||||
func OptionSet(options *getoptions.GetOpt) {
|
||||
obioptions.LoadTaxonomyOptionSet(options, false, false)
|
||||
InputOptionSet(options)
|
||||
OutputOptionSet(options)
|
||||
PairedFilesOptionSet(options)
|
||||
|
||||
@@ -6,7 +6,7 @@ import (
|
||||
log "github.com/sirupsen/logrus"
|
||||
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiapat"
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiformats/ncbitaxdump"
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obioptions"
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obiseq"
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obitax"
|
||||
"git.metabarcoding.org/obitools/obitools4/obitools4/pkg/obitools/obiconvert"
|
||||
@@ -33,7 +33,6 @@ var _Predicats = make([]string, 0)
|
||||
var _IdList = ""
|
||||
|
||||
var _Taxdump = ""
|
||||
var _Taxonomy = (*obitax.Taxonomy)(nil)
|
||||
|
||||
var _RequiredAttributes = make([]string, 0)
|
||||
var _AttributePatterns = make(map[string]string, 0)
|
||||
@@ -49,10 +48,7 @@ var _pattern_indel = false
|
||||
var _pattern_only_forward = false
|
||||
|
||||
func TaxonomySelectionOptionSet(options *getoptions.GetOpt) {
|
||||
|
||||
options.StringVar(&_Taxdump, "taxdump", _Taxdump,
|
||||
options.Alias("t"),
|
||||
options.Description("Points to the directory containing the NCBI Taxonomy database dump."))
|
||||
obioptions.LoadTaxonomyOptionSet(options, false, false)
|
||||
|
||||
options.StringSliceVar(&_BelongTaxa, "restrict-to-taxon", 1, 1,
|
||||
options.Alias("r"),
|
||||
@@ -246,31 +242,12 @@ func CLIPatternBothStrand() bool {
|
||||
return !_pattern_only_forward
|
||||
}
|
||||
|
||||
func CLILoadSelectedTaxonomy() *obitax.Taxonomy {
|
||||
if CLISelectedNCBITaxDump() != "" {
|
||||
if _Taxonomy == nil {
|
||||
var err error
|
||||
_Taxonomy, err = ncbitaxdump.LoadNCBITaxDump(CLISelectedNCBITaxDump(), true)
|
||||
if err != nil {
|
||||
log.Fatalf("cannot load taxonomy %s : %v",
|
||||
CLISelectedNCBITaxDump(), err)
|
||||
return nil
|
||||
}
|
||||
}
|
||||
return _Taxonomy
|
||||
}
|
||||
|
||||
log.Fatalln("no NCBI taxdump selected using option -t|--taxdump")
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func CLIRestrictTaxonomyPredicate() obiseq.SequencePredicate {
|
||||
var p obiseq.SequencePredicate
|
||||
var p2 obiseq.SequencePredicate
|
||||
|
||||
if len(_BelongTaxa) > 0 {
|
||||
taxonomy := CLILoadSelectedTaxonomy()
|
||||
taxonomy := obitax.DefaultTaxonomy()
|
||||
|
||||
taxon := taxonomy.Taxon(_BelongTaxa[0])
|
||||
if taxon == nil {
|
||||
@@ -300,7 +277,7 @@ func CLIAvoidTaxonomyPredicate() obiseq.SequencePredicate {
|
||||
var p2 obiseq.SequencePredicate
|
||||
|
||||
if len(_NotBelongTaxa) > 0 {
|
||||
taxonomy := CLILoadSelectedTaxonomy()
|
||||
taxonomy := obitax.DefaultTaxonomy()
|
||||
|
||||
taxon := taxonomy.Taxon(_NotBelongTaxa[0])
|
||||
if taxon == nil {
|
||||
@@ -329,7 +306,7 @@ func CLIAvoidTaxonomyPredicate() obiseq.SequencePredicate {
|
||||
func CLIHasRankDefinedPredicate() obiseq.SequencePredicate {
|
||||
|
||||
if len(_RequiredRanks) > 0 {
|
||||
taxonomy := CLILoadSelectedTaxonomy()
|
||||
taxonomy := obitax.DefaultTaxonomy()
|
||||
p := obiseq.HasRequiredRank(taxonomy, _RequiredRanks[0])
|
||||
|
||||
for _, rank := range _RequiredRanks[1:] {
|
||||
|
||||
@@ -70,11 +70,7 @@ func GeomIndexSesquence(seqidx int,
|
||||
new_lca, _ := lca.LCA(taxa.Taxon(o))
|
||||
if new_lca.SameAs(lca) {
|
||||
lca = new_lca
|
||||
index[int(seq_dist[o])] = fmt.Sprintf(
|
||||
"%s@%s",
|
||||
lca.String(),
|
||||
lca.Rank(),
|
||||
)
|
||||
index[int(seq_dist[o])] = lca.String()
|
||||
|
||||
if lca.IsRoot() {
|
||||
break
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package obirefidx
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
log "github.com/sirupsen/logrus"
|
||||
@@ -172,11 +171,7 @@ func IndexSequence(seqidx int,
|
||||
for i, d := range closest {
|
||||
if i < (len(closest)-1) && d < closest[i+1] {
|
||||
current_taxon := pseq.Taxon(i)
|
||||
obitag_index[d] = fmt.Sprintf(
|
||||
"%s@%s",
|
||||
current_taxon.String(),
|
||||
current_taxon.Rank(),
|
||||
)
|
||||
obitag_index[d] = current_taxon.String()
|
||||
}
|
||||
}
|
||||
|
||||
@@ -197,9 +192,10 @@ func IndexReferenceDB(iterator obiiter.IBioSequence) obiiter.IBioSequence {
|
||||
source, references := iterator.Load()
|
||||
log.Infof("Done. Database contains %d sequences", len(references))
|
||||
|
||||
taxo, error := obioptions.CLILoadSelectedTaxonomy()
|
||||
if error != nil {
|
||||
log.Panicln(error)
|
||||
taxo := obitax.DefaultTaxonomy()
|
||||
|
||||
if taxo == nil {
|
||||
log.Fatal("No taxonomy loaded.")
|
||||
}
|
||||
|
||||
log.Infoln("Indexing sequence taxids...")
|
||||
|
||||
Reference in New Issue
Block a user