Skip to content

annotate

omnitax annotate [FILE] [--column NAME|N] [--by id|name|link] [--kind KIND] [--add COLUMNS] [--sep CHAR] [--prefix TEXT] [--no-header]
                 [--ambiguous empty|first] [--gca-gcf] [--source LABEL]... [-o FILE]   [WHERE]

Reads a delimited table (a file, or standard input), takes the taxa that one column names, appends columns about them and writes the table (standard output, or -o). Nothing is interactive, so it works in a pipe:

omnitax annotate counts.tsv --column taxid --add name,genus,species -o counts.annotated.tsv
cut -f1 reads.tsv | omnitax annotate --by name --no-header --add id,rank
omnitax annotate mags.csv --column genome --by link --source ncbi-assemblies --add lineage_string
Option Meaning
FILE the table [standard input; - too]
--column NAME\|N the column with the taxa: its header name, or its number from 1 [1]
--kind KIND for --by link: what the keys are: genome, seq (sequence accessions), or the kind of a taxonomy (ncbi) [genome]
--by id\|name\|link what it holds [id]: id (an old, merged id gives the current node), name (an exact name, as lookup and search --match exact find it: any class, case and the like do not matter), link (a key of --kind, genome accessions by default, with --gca-gcf and --source as for link)
--add COLUMNS the columns to append, comma separated [id,name,rank]: id, name, rank, lineage (ids, \|), lineage_string (GTDB's d__...;s__...), or the name of a rank of the taxonomy (genus, species, ...: the name of the node's ancestor of that rank, empty if there is none)
--sep CHAR the delimiter, also of the output [a tab if the first line has one, else a comma]; \t spells a tab
--prefix TEXT put TEXT before every added column name. Without it the names are as given, except one the table already has (an input column id and --add id), which becomes omnitax_id so that headers stay unique
--no-header the first line is data (no header is written either)
--ambiguous empty\|first a name of several nodes (homonyms such as Morus), or an accession of several versions or sources that disagree: leave the cells empty, or take the best [empty]
-o, --output FILE write there

Values that are empty, or that name no taxon, give empty cells; at the end a line on standard error says how many rows there were and how many resolved, were empty, were not found or were ambiguous (annotate: 4 rows, 2 resolved, 1 ids not found, 1 ambiguous (left empty); a warning when something was left empty). Of homonyms --ambiguous first takes the best by the usual ranking, then the smaller id (numerically for ids of digits). The table is read and answered a thousand rows at a time: the batch is one many, one exact-name lookup or one link lookup and one ancestors call for the lineages, so against a server it costs a few requests per thousand rows, not one per row. The table is not kept in memory. Other columns, rows with fewer cells than the column, and quoting (the csv module's) are left as they are.

A column the table does not have (--column 5 of a table with three), an unknown --add column and a file that is not UTF-8 text are errors (exit status 1) before anything is written.

There is also a Python function.