Skip to content

Commit

Permalink
reformat: better warning message and tips
Browse files Browse the repository at this point in the history
  • Loading branch information
shenwei356 committed Jul 26, 2018
1 parent 5c03577 commit b3e61ff
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
2 changes: 1 addition & 1 deletion taxonkit/cmd/helper.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ import (
)

// VERSION of csvtk
const VERSION = "0.2.5-dev2"
const VERSION = "0.2.5-dev3"

// Config is the struct containing all global flags
type Config struct {
Expand Down
14 changes: 7 additions & 7 deletions taxonkit/cmd/reformat.go
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ column by flag "-t/--show-lineage-taxids".
}
data := strings.Split(line, "\t")
if len(data) < field+1 {
return nil, false, fmt.Errorf("lineage-field (%d) out of range (%d)", field+1, len(data))
return nil, false, fmt.Errorf("lineage-field (%d) out of range (%d):%s", field+1, len(data), line)
}

// names and weights
Expand All @@ -151,20 +151,20 @@ column by flag "-t/--show-lineage-taxids".
name = lname

if _, ok = name2taxid[name]; !ok { // unofficial name
checkError(fmt.Errorf("unofficial taxon name detected: %s. Possible reasons: 1) lineages were produced with different taxonomy data files, please re-run taxonkit lineage; 2) lineages were manually edited", name))
// currentWeight += 0.1
// weights[i] = currentWeight
continue
log.Warningf(`unofficial taxon name detected: %s. Possible reasons: 1) lineages were produced with different taxonomy data files, please re-run taxonkit lineage; 2) some taxon names contain semicolon (";"), please re-run taxonkit lineage and taxonkit reformat with different flag value of -d, e.g., -d /`, name)
return line2flineage{line, "", ""}, true, nil
}

if i == 0 {
rank = taxid2taxon[name2taxid[name]].Rank
} else {
plname = strings.ToLower(names2[i-1])
if _, ok = name2parent2taxid[name]; !ok {
checkError(fmt.Errorf("unofficial taxon name detected: %s. Possible reasons: 1) lineages were produced with different taxonomy data files, please re-run taxonkit lineage; 2) lineages were manually edited", name))
log.Warningf(`unofficial taxon name detected: %s. Possible reasons: 1) lineages were produced with different taxonomy data files, please re-run taxonkit lineage; 2) some taxon names contain semicolon (";"), please re-run taxonkit lineage and taxonkit reformat with different flag value of -d, e.g., -d /`, name)
return line2flineage{line, "", ""}, true, nil
} else if _, ok = name2parent2taxid[name][plname]; !ok {
checkError(fmt.Errorf("unofficial taxon name detected: %s. Possible reasons: 1) lineages were produced with different taxonomy data files, please re-run taxonkit lineage; 2) lineages were manually edited", plname))
log.Warningf(`unofficial taxon name detected: %s. Possible reasons: 1) lineages were produced with different taxonomy data files, please re-run taxonkit lineage; 2) some taxon names contain semicolon (";"), please re-run taxonkit lineage and taxonkit reformat with different flag value of -d, e.g., -d /`, plname)
return line2flineage{line, "", ""}, true, nil
}
rank = taxid2taxon[name2parent2taxid[name][plname]].Rank
}
Expand Down

0 comments on commit b3e61ff

Please sign in to comment.