Package: vezzo
vezzo:  a small library to parse version strings from binfie toolsIt is a common pattern when running binfie tools to run checks on the versions
of the tool's dependencies. For example, the tool might depend onblastnbeing
of version 2.10.0 or higher. This library provides a simple way to parse the
version from the output of runningblastn -versionand compare it to the minimum
version required. To run the comparison, we use thesemverlibrary.UsageThe main function provided by the library isvezzo.verify_from_config. This
function takes in the path to a YAML file that specifies the version requirements and checks them against the observed versions installed in the enviroment. It expects the dependencies to be in the path. The YAML file should be a list of dictionaries, where each dictionary specifies the requirements for a single tool. The dictionary should have the following fields:-name:blastnreq_version:">=2.10.0"version_flag:-versionexit_code:0-name:samtoolsreq_version:">=1.16.0"version_flag:--versionexit_code:0Thenamefield is the name of the tool. Thereq_versionfield that specifies
the requirements in terms of the version of the tool. This takes one the following
format:
- <1.2.3: the observed version must be less than 1.2.3
- <=1.2.3: the observed version must be less than or equal to 1.2.3
- >1.2.3: the observed version must be greater than 1.2.3
- >=1.2.3: the observed version must be greater than or equal to 1.2.3
- ==1.2.3: the observed version must be equal to 1.2.3
- !=1.2.3: the observed version must not be equal to 1.2.3Theversion_flagfield specifies the flag to pass to the tool to get the version
string. This can be empty string, as is the case forbwa, which does not have a flag.Theexit_codefield specifies the exit code that the tool returns when the version
string is returned. The majority of cases this is 0, butbwa, for instance, returnsBy specifying all the version requirements in a YAML config file that ships with your
package it is easy to check dependencies and modify requirement all in one location.A full working example is provided in theexampledirectory. To run the example,
simply runpython example/example1.py.The output from the example is (the exact output will depend on the versions you have, and any tweaks you make to the example config file):blastnversion2.13.0DOESNOTmatchrequirements>=2.14.0....❌samtoolsversion1.17.0matchesrequirements>=1.16.0....✔Therewas1toolthatfailedtheversionrequirements.Pleaseensurethesearecorrectedbeforeproceeding.😢The basic code might look like this:foris_match,obs_version,exp_version,toolinvezzo.verify_from_config(config):ifis_match:sys.stderr.write(f"\033[32m{tool}version{obs_version}matches requirements{exp_version}....\u2714\033[0m\n")else:sys.stderr.write(f"\033[31m{tool}version{obs_version}DOES NOT matches requirements{exp_version}....\u274C\033[0m\n")fails+=1iffails>0:sys.stderr.write(f"\033[31m There{'was'iffails==1else'were'}{fails}tool{'s'iffails>0else''}that failed the version requirements. Please ensure these are corrected before proceeding.\U0001F622\033[0m\n")sys.exit(1)As as can be seen, the function returns a generator that yields a tuple of the following
format:(is_match, obs_version, exp_version, tool). Theis_matchfield is a boolean
that indicates whether the observed version matches the expected version criteria.
Theobs_versionfield is the observed version string. Theexp_versionfield is the
expected string requirement in the format outlined above. Thetoolfield is the name of the tool.InstallationThe library can be installed viapip:pipinstallvezzoAuthorAnders Goncalves da Silva (@andersgs)