diff --git a/fqcnt/Makefile b/fqcnt/Makefile index 0da94ee..6d1eecf 100644 --- a/fqcnt/Makefile +++ b/fqcnt/Makefile @@ -21,6 +21,11 @@ fqcnt_nim1_klib:fqcnt_nim1_klib.nim ../lib/klib.nim fqcnt_go1:fqcnt_go1.go $(GO) build $< +fqcnt_go2:fqcnt_go2.go + $(GO) get -u github.com/shenwei356/bio + $(GO) mod tidy + CGO_ENABLED=0 $(GO) build -tags netgo -ldflags '-w -s' -asmflags '-trimpath' $< + .PHONY: fqcnt_rs fqcnt_rs: $(CARGO) install --path $(PROJECT_ROOT) --force --bin fqcnt_rustbio --bin fqcnt_needletail --root . @@ -49,3 +54,4 @@ fqcnt_scala_jar_fgbio: scala/tools/src/com/github/biofast/FgBio.scala clean: rm -fr *.dSYM $(PROG) + rm -fr go.sum diff --git a/fqcnt/README.md b/fqcnt/README.md index a60e197..b30a660 100644 --- a/fqcnt/README.md +++ b/fqcnt/README.md @@ -12,6 +12,7 @@ |[fqcnt\_js1\_k8.js](fqcnt_js1_k8.js) |Javascript| | 17.5| 9.4|kseq.h port| |[fqcnt\_py7x\_pysam.py](fqcnt_py7x_pysam.py) |Python |[pysam][pysam] | 18.5| 12.7|kseq.h binding| |[fqcnt\_go1.go](fqcnt_go1.go) |Go | | 19.1| 2.8|4-line only| +|[fqcnt\_go2.go](fqcnt_go2.go) |Go |[bio][bio] | | |bio | |[fqcnt\_jl2x\_fastx.jl](fqcnt_jl2x_fastx.jl) |Julia |[Fastx.jl][fx.jl] | 19.5| 2.6|4-line only; no startup| |[fqcnt\_lua2\_4l.lua](fqcnt_lua2_4l.lua) |LuaJIT | | 22.8| 10.4|4-line only| |[fqcnt\_py8x\_fx.py](fqcnt_py8x_fx.py) |Python |[Fastx][fx.py]; cffi | 24.2| 15.9|kseq.h binding| @@ -62,4 +63,5 @@ [nt]: https://github.com/onecodex/needletail [fgbio]: http://fulcrumgenomics.github.io/fgbio/ [commons.io]: https://javadoc.io/static/com.fulcrumgenomics/commons_2.12/1.0.0/com/fulcrumgenomics/commons/io/Io$.html#readLinesFromResource(name:String):Iterator[String] -[ammnoite]: http://ammonite.io/ \ No newline at end of file +[ammnoite]: http://ammonite.io/ +[bio]: https://github.com/shenwei356/bio diff --git a/fqcnt/fqcnt_go2.go b/fqcnt/fqcnt_go2.go new file mode 100644 index 0000000..815624b --- /dev/null +++ b/fqcnt/fqcnt_go2.go @@ -0,0 +1,46 @@ +package main + +import ( + "fmt" + "io" + "os" + + "github.com/shenwei356/bio/seq" + "github.com/shenwei356/bio/seqio/fastx" +) + +func main() { + if len(os.Args) == 1 { + fmt.Println("Usage: fqcnt_go2 in.fq.gz") + os.Exit(1) + } + fn := os.Args[1] + + n, slen, qlen := 0, 0, 0 + + seq.ValidateSeq = false // do not check bases + fastxReader, err := fastx.NewDefaultReader(fn) + if err != nil { + fmt.Println(err) + os.Exit(1) + } + + var record *fastx.Record + for { + record, err = fastxReader.Read() + if err != nil { + if err == io.EOF { + break + } + fmt.Println(err) + os.Exit(1) + break + } + + n++ + slen += len(record.Seq.Seq) + qlen += len(record.Seq.Qual) + } + + fmt.Printf("%v\t%v\t%v\n", n, slen, qlen) +} diff --git a/fqcnt/go.mod b/fqcnt/go.mod new file mode 100644 index 0000000..f39d378 --- /dev/null +++ b/fqcnt/go.mod @@ -0,0 +1,13 @@ +module github.com/shenwei356/biofast + +go 1.17 + +require github.com/shenwei356/bio v0.3.3 + +require ( + github.com/klauspost/compress v1.13.6 // indirect + github.com/klauspost/pgzip v1.2.5 // indirect + github.com/shenwei356/bpool v0.0.0-20160710042833-f9e0ee4d0403 // indirect + github.com/shenwei356/util v0.4.0 // indirect + github.com/shenwei356/xopen v0.1.0 // indirect +)