thapbi_pict.versions module

Helper code to get command line tool versions.

Defines various functions to check a tool is on the $PATH and if so, return the tool version as a short string (sometimes including a date).

These functions are called from various THAPBI-PICT subcommands which call external tools to ensure a clear missing dependency message, and to log the version of the external tool used.

If the tool is not on the path, the commands all return None.

If we cannot parse the output, again the commands return None - which is likely an indication of a major version change, meaning the tool ought to be re-evaluated for use with THAPBI-PICT.

thapbi_pict.versions.check_rapidfuzz() str

Check can import rapidfuzz and confirm recent enough.

thapbi_pict.versions.check_tools(names: list[str], debug: bool) list[str]

Verify the named tools are present, log versions if debug=True.

Argument names should be an interable of tool binary names.

If all the tools are present, returns a list of version strings.

If any tools are missing (or have a version we could not parse), aborts.

thapbi_pict.versions.version_blast(cmd: str = 'blastn') str | None

Return the version of the NCBI BLAST+ suite’s blastn (as a short string).

In the absence of a built in version switch like -v, this works by parsing the short help output with -h (which does vary between the tools in the suite):

$ makeblastdb -h | grep BLAST
Application to create BLAST databases, version 2.7.1+

$ blastn -h | grep BLAST
Nucleotide-Nucleotide BLAST 2.7.1+

In the above examples, it would behave as follows:

>>> version_blast("makeblastdb")
'2.7.1+'
>>> version_blast("blastn")
'2.7.1+'

If the command is not on the path, returns None.

thapbi_pict.versions.version_cutadapt(cmd: str = 'cutadapt') str | None

Return the version of cutadapt (as a short string).

Uses the output with --version:

$ cutadapt --version
1.18

It would capture this:

>>> version_cutadapt()
'1.18'

If the command is not on the path, returns None.

thapbi_pict.versions.version_flash(cmd: str = 'flash') str | None

Return the version of flash (as a short string).

Parses the output with -v:

$ flash -v | head -n 1
FLASH v1.2.11

It would capture the version from the first line as follows:

>>> version_flash()
'v1.2.11'

If the command is not on the path, returns None.

thapbi_pict.versions.version_usearch(cmd: str = 'usearch') str | None

Return the version of usearch (as a short string).

Uses the output with --version:

$ usearch --version
usearch v11.0.667_i86linux32

It would capture this:

>>> version_vsearch()
'v11.0.667'

If the command is not on the path, returns None.

thapbi_pict.versions.version_vsearch(cmd: str = 'vsearch') str | None

Return the version of vsearch (as a short string).

Uses the output with --version:

$ vsearch --version
...
vsearch v2.22.1_macos_x86_64, 8.0GB RAM, 8 cores
...

It would capture this:

>>> version_vsearch()
'v2.22.1'

If the command is not on the path, returns None.