mirror of
https://github.com/metabarcoding/obitools4.git
synced 2025-12-09 01:00:26 +00:00
First commit
This commit is contained in:
18
cmd/obitools/obiconvert/main.go
Normal file
18
cmd/obitools/obiconvert/main.go
Normal file
@@ -0,0 +1,18 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obitools/obiconvert"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obioptions"
|
||||
)
|
||||
|
||||
func main() {
|
||||
option_parser := obioptions.GenerateOptionParser(obiconvert.OptionSet)
|
||||
|
||||
_, args, _ := option_parser(os.Args)
|
||||
|
||||
fs, _ := obiconvert.ReadBioSequences(args...)
|
||||
obiconvert.WriteBioSequences(fs)
|
||||
}
|
||||
65
cmd/obitools/obicount/main.go
Normal file
65
cmd/obitools/obicount/main.go
Normal file
@@ -0,0 +1,65 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"runtime/trace"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obitools/obiconvert"
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obitools/obicount"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obioptions"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// f, err := os.Create("cpu.pprof")
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// pprof.StartCPUProfile(f)
|
||||
// defer pprof.StopCPUProfile()
|
||||
|
||||
ftrace, err := os.Create("cpu.trace")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
trace.Start(ftrace)
|
||||
defer trace.Stop()
|
||||
|
||||
option_parser := obioptions.GenerateOptionParser(
|
||||
obiconvert.InputOptionSet,
|
||||
obicount.OptionSet,
|
||||
)
|
||||
|
||||
_, args, _ := option_parser(os.Args)
|
||||
|
||||
fs, _ := obiconvert.ReadBioSequences(args...)
|
||||
nread := 0
|
||||
nvariant := 0
|
||||
nsymbol := 0
|
||||
for fs.Next() {
|
||||
s := fs.Get()
|
||||
if s.IsNil() {
|
||||
log.Panicln("Read sequence is nil")
|
||||
}
|
||||
nread += s.Count()
|
||||
nvariant++
|
||||
nsymbol += s.Length()
|
||||
}
|
||||
|
||||
if obicount.IsPrintingVariantCount() {
|
||||
fmt.Printf(" %d", nvariant)
|
||||
}
|
||||
|
||||
if obicount.IsPrintingReadCount() {
|
||||
fmt.Printf(" %d", nread)
|
||||
}
|
||||
|
||||
if obicount.IsPrintingSymbolCount() {
|
||||
fmt.Printf(" %d", nsymbol)
|
||||
}
|
||||
|
||||
fmt.Printf("\n")
|
||||
}
|
||||
68
cmd/obitools/obifind/main.go
Normal file
68
cmd/obitools/obifind/main.go
Normal file
@@ -0,0 +1,68 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obioptions"
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obitools/obifind"
|
||||
)
|
||||
|
||||
func main() {
|
||||
option_parser := obioptions.GenerateOptionParser(obifind.OptionSet)
|
||||
|
||||
_, args, _ := option_parser(os.Args)
|
||||
|
||||
//prof, _ := os.Create("obifind.prof")
|
||||
//pprof.StartCPUProfile(prof)
|
||||
|
||||
restrictions, err := obifind.ITaxonRestrictions()
|
||||
if err != nil {
|
||||
fmt.Printf("%+v", err)
|
||||
}
|
||||
|
||||
switch {
|
||||
case obifind.RequestsPathForTaxid() >= 0:
|
||||
taxonomy, err := obifind.LoadSelectedTaxonomy()
|
||||
if err != nil {
|
||||
fmt.Printf("%+v", err)
|
||||
}
|
||||
|
||||
taxon, err := taxonomy.Taxon(obifind.RequestsPathForTaxid())
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("%+v", err)
|
||||
}
|
||||
|
||||
s, err := taxon.Path()
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("%+v", err)
|
||||
}
|
||||
|
||||
obifind.TaxonWriter(s.Iterator(),
|
||||
fmt.Sprintf("path:%d", taxon.Taxid()))
|
||||
|
||||
case len(args) == 0:
|
||||
taxonomy, err := obifind.LoadSelectedTaxonomy()
|
||||
if err != nil {
|
||||
fmt.Printf("%+v", err)
|
||||
}
|
||||
|
||||
obifind.TaxonWriter(restrictions(taxonomy.Iterator()), "")
|
||||
|
||||
default:
|
||||
matcher, err := obifind.ITaxonNameMatcher()
|
||||
|
||||
if err != nil {
|
||||
fmt.Printf("%+v", err)
|
||||
}
|
||||
|
||||
for _, pattern := range args {
|
||||
s := restrictions(matcher(pattern))
|
||||
obifind.TaxonWriter(s, pattern)
|
||||
}
|
||||
}
|
||||
|
||||
//pprof.StopCPUProfile()
|
||||
}
|
||||
38
cmd/obitools/obipairing/main.go
Normal file
38
cmd/obitools/obipairing/main.go
Normal file
@@ -0,0 +1,38 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"log"
|
||||
"os"
|
||||
"runtime/pprof"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obiformats"
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obioptions"
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obitools/obipairing"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// go tool pprof -http=":8000" ./obipairing ./cpu.pprof
|
||||
f, err := os.Create("cpu.pprof")
|
||||
if err != nil {
|
||||
log.Fatal(err)
|
||||
}
|
||||
pprof.StartCPUProfile(f)
|
||||
defer pprof.StopCPUProfile()
|
||||
|
||||
// go tool trace cpu.trace
|
||||
// ftrace, err := os.Create("cpu.trace")
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// trace.Start(ftrace)
|
||||
// defer trace.Stop()
|
||||
|
||||
option_parser := obioptions.GenerateOptionParser(obipairing.OptionSet)
|
||||
|
||||
option_parser(os.Args)
|
||||
pairs, _ := obipairing.IBatchPairedSequence()
|
||||
paired := obipairing.IAssemblePESequencesBatch(pairs, 2, 50, 20, true)
|
||||
written, _ := obiformats.WriteFastqBatchToStdout(paired)
|
||||
written.Destroy()
|
||||
}
|
||||
34
cmd/obitools/obipcr/main.go
Normal file
34
cmd/obitools/obipcr/main.go
Normal file
@@ -0,0 +1,34 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"os"
|
||||
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obioptions"
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obitools/obiconvert"
|
||||
"git.metabarcoding.org/lecasofts/go/oa2/pkg/obitools/obipcr"
|
||||
)
|
||||
|
||||
func main() {
|
||||
|
||||
// f, err := os.Create("cpu.pprof")
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// pprof.StartCPUProfile(f)
|
||||
// defer pprof.StopCPUProfile()
|
||||
|
||||
// ftrace, err := os.Create("cpu.trace")
|
||||
// if err != nil {
|
||||
// log.Fatal(err)
|
||||
// }
|
||||
// trace.Start(ftrace)
|
||||
// defer trace.Stop()
|
||||
|
||||
option_parser := obioptions.GenerateOptionParser(obipcr.OptionSet)
|
||||
|
||||
_, args, _ := option_parser(os.Args)
|
||||
|
||||
sequences, _ := obiconvert.ReadBioSequencesBatch(args...)
|
||||
amplicons, _ := obipcr.PCR(sequences)
|
||||
obiconvert.WriteBioSequences(amplicons)
|
||||
}
|
||||
Reference in New Issue
Block a user