<commit_before>package main

import (
	"fmt"
	"gongs/arger"
	"gongs/biofile/fastq"
	"os"
)

const countName = "count"
const countDesc = "count reads from fastq file"

var countArger = arger.New(mainName, countName)

func countRunner(args ...string) {
	if len(args) == 0 {
		fmt.Fprintln(os.Stderr, mainName, countName, ": no input given!")
		os.Exit(1)
	}
	for _, file := range args {
		fmt.Println("file:", file)
		fqfile, err := fastq.Open(file)
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
			os.Exit(1)
		}
		cc := 0
		for _ = range fqfile.Load() {
			cc++
		}
		fmt.Println(file, "contain Reads:", cc)
	}
}
<commit_msg>update count.go<commit_after>package main

import (
	"fmt"
	"gongs/argparser"
	"gongs/biofile/fastq"
	"os"
	"runtime"
	"sync"
)

const countName = "count"
const countDesc = "count reads from fastq file"

var countArger = argparser.New(mainName, countName)

func countRunner(filenames ...string) {
	if len(filenames) == 0 {
		fmt.Fprintln(os.Stderr, mainName, countName, ": no input given!")
		os.Exit(1)
	}

	// setting multi-threads
	runtime.GOMAXPROCS(runtime.NumCPU())

	fqfiles := make([]*fastq.FastqFile, len(filenames))
	for i, filename := range filenames {
		fqfile, err := fastq.Open(filename)
		if err != nil {
			fmt.Fprintln(os.Stderr, err)
			os.Exit(1)
		}
		fqfiles[i] = fqfile
	}

	chCount := make(chan int, len(filenames))
	go func(chCount chan int, fqfiles []*fastq.FastqFile) {
		wg := &sync.WaitGroup{}
		for _, fqfile := range fqfiles {
			wg.Add(1)
			go func(wg *sync.WaitGroup, fqfile *fastq.FastqFile, chCount chan int) {
				count := 0
				for fqfile.Next() {
					count++
				}
				chCount <- count
				fmt.Println(fqfile.Name, "contain Reads:", count)
				wg.Done()
			}(wg, fqfile, chCount)
		}
		wg.Wait()
		close(chCount)
	}(chCount, fqfiles)

	var tot int
	for c := range chCount {
		tot += c
	}
	fmt.Println("Total Reads:", tot)
}

{'fraction_non_alphanumeric': 0.1559196617336152, 'fraction_numerical': 0.0047568710359408035, 'mean_word_length': 3.475177304964539, 'pattern_counts': {'":': 2, '<': 4, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3264778', 'n_tokens_mistral': 843, 'n_tokens_neox': 766, 'n_words': 174}