Skip to content

Commit

Permalink
don't export what shouldn't be exported
Browse files Browse the repository at this point in the history
  • Loading branch information
mailund committed Jul 2, 2021
1 parent cd27502 commit 7a284ef
Showing 1 changed file with 11 additions and 11 deletions.
22 changes: 11 additions & 11 deletions gostr/exact.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,26 +16,26 @@ var exactAlgos = map[string]func(x, p string, fn func(int)){
"bmh": gostr.Bmh,
}

type ExactArgs struct {
type exactArgs struct {
Algo cli.Choice `flag:"algo" short:"a" descr:"choice of algorithm to use"`
Out cli.OutFile `flag:"out" short:"o" descr:"output file"`
Genome cli.InFile `pos:"genome" descr:"FASTA file containing the genome"`
Reads cli.InFile `pos:"reads" descr:"FASTQ file containing the reads"`
}

func InitArgs() interface{} {
func initExactArgs() interface{} {
exactAlgKeys := []string{}
for k := range exactAlgos {
exactAlgKeys = append(exactAlgKeys, k)
}

return &ExactArgs{
return &exactArgs{
Out: cli.OutFile{Writer: os.Stdout},
Algo: cli.Choice{Choice: "border", Options: exactAlgKeys},
}
}

func GetFastaRecords(f cli.InFile) map[string]string {
func getFastaRecords(f cli.InFile) map[string]string {
defer f.Close()

recs, err := biof.ReadFasta(f)
Expand All @@ -46,20 +46,20 @@ func GetFastaRecords(f cli.InFile) map[string]string {
return recs
}

func MapFastq(f cli.InFile, fn func(*biof.FastqRecord)) error {
func mapFastq(f cli.InFile, fn func(*biof.FastqRecord)) error {
defer f.Close()

return biof.ScanFastq(f, fn)
}

func ExactMapping(i interface{}) {
args, ok := i.(*ExactArgs)
func exactMapping(i interface{}) {
args, ok := i.(*exactArgs)
if !ok {
panic("Unexpected arguments to ExactMapping")
}

algo := exactAlgos[args.Algo.Choice]
recs := GetFastaRecords(args.Genome)
recs := getFastaRecords(args.Genome)

mapper := func(rec *biof.FastqRecord) {
for rname, seq := range recs {
Expand All @@ -72,7 +72,7 @@ func ExactMapping(i interface{}) {
}
}

if err := MapFastq(args.Reads, mapper); err != nil {
if err := mapFastq(args.Reads, mapper); err != nil {
fmt.Fprintf(os.Stderr, "Error scanning reads: %s\n", err)
}
}
Expand All @@ -81,6 +81,6 @@ var exact = cli.NewCommand(cli.CommandSpec{
Name: "exact",
Short: "exact pattern matching",
Long: "Search for exact matches of reads in a genome.",
Init: InitArgs,
Action: ExactMapping,
Init: initExactArgs,
Action: exactMapping,
})

0 comments on commit 7a284ef

Please sign in to comment.