Skip to content

Commit

Permalink
name2taxid: support besides . #9
Browse files Browse the repository at this point in the history
  • Loading branch information
shenwei356 committed Feb 5, 2018
1 parent 186df6b commit d4fac1c
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion taxonkit/cmd/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -96,6 +96,21 @@ var nameParseFunc = func(line string) (interface{}, bool, error) {
return Taxon{Taxid: int32(id), Name: items[2]}, true, nil
}

var nameParseFunc2 = func(line string) (interface{}, bool, error) {
items := strings.Split(line, "\t")
if len(items) < 7 {
return nil, false, nil
}
if !(items[6] == "scientific name" || items[6] == "synonym") {
return nil, false, nil
}
id, e := strconv.Atoi(items[0])
if e != nil {
return nil, false, e
}
return Taxon{Taxid: int32(id), Name: items[2]}, true, nil
}

func getTaxonNames(file string, bufferSize int, chunkSize int) map[int32]string {
reader, err := breader.NewBufferedReader(file, bufferSize, chunkSize, nameParseFunc)
checkError(err)
Expand All @@ -114,7 +129,7 @@ func getTaxonNames(file string, bufferSize int, chunkSize int) map[int32]string
}

func getTaxonName2Taxids(file string, bufferSize int, chunkSize int) map[string][]int32 {
reader, err := breader.NewBufferedReader(file, bufferSize, chunkSize, nameParseFunc)
reader, err := breader.NewBufferedReader(file, bufferSize, chunkSize, nameParseFunc2)
checkError(err)

var taxon Taxon
Expand Down

0 comments on commit d4fac1c

Please sign in to comment.