API documentation

main.py

Main functions used by ToolDog.

tooldog.main.analyse(biotool, args)[source]

Run analysis of the source code from bio.tools or given locally.

Parameters:
tooldog.main.annotate(biotool, args, existing_desc=None)[source]

Run annotation (generated by analysis or existing_desc).

Parameters:
  • biotool (tooldog.biotool_model.Biotool) – Biotool object.
  • args (argparse.ArgumentParser) – Parsed arguments.
  • existing_desc (STRING) – Existing tool descriptor path.
tooldog.main.config_logger(write_logs, log_level, log_file, verbose)[source]

Initialize the logger for ToolDog. By default, only WARNING, ERROR and CRITICAL are written on STDERR. You can also write logs to a log file.

Parameters:
  • write_logs (BOOLEAN) – Decide to write logs to output log file.
  • log_level (STRING) – Select the level of logs. ‘debug’, ‘info’ or ‘warn’. Other value is considered as ‘warn’.
  • log_file (STRING) – path to output log file.
Returns:

Config dictionnary for logger.

Return type:

DICT

tooldog.main.json_from_biotools(tool_id, tool_version='latest')[source]

Import JSON of a tool from https://bio.tools.

Parameters:
  • tool_id (STRING) – ID of the tool.
  • tool_version (STRING) – Version of the tool.
Returns:

dictionnary corresponding to the JSON from https://bio.tools.

Return type:

DICT

tooldog.main.json_from_file(json_file)[source]

Import JSON of a tool from a local JSON file.

Parameters:json_file (STRING) – path to the file
Returns:dictionnary corresponding to the JSON.
Return type:DICT
tooldog.main.json_to_biotool(json_file)[source]

Takes JSON file from bio.tools description and loads its content to tooldog.model.Biotool object.

Parameters:json_file (DICT) – dictionnary of JSON file from bio.tools description.
Returns:Biotool object.
Return type:tooldog.biotool_model.Biotool
tooldog.main.parse_arguments()[source]

Defines parser for ToolDog.

tooldog.main.run()[source]

Running function called by tooldog command line.

tooldog.main.write_cwl(biotool, outfile=None, existing_tool=None)[source]

This function uses tooldog.cwl.CwlToolGen to write CWL using cwlgen. CWL is generated on STDOUT by default.

Parameters:
  • biotool (tooldog.biotool_model.Biotool) – Biotool object.
  • outfile (STRING) – path to output file to write the CWL.
  • existing_tool (STRING) – local path to existing CWL tool description.
tooldog.main.write_xml(biotool, outfile=None, galaxy_url=None, edam_url=None, mapping_json=None, existing_tool=None, inout_biotool=False)[source]

This function uses tooldog.galaxy.GalaxyToolGen to write XML using galaxyxml library.

Parameters:
  • biotool (tooldog.biotool_model.Biotool) – Biotool object.
  • outfile (STRING) – path to output file to write the XML.
  • galaxy_url (STRING) – link to galaxy instance.
  • edam_url (STRING) – link to EDAM owl.
  • mapping_json (STRING) – local JSON mapping between EDAM and Galaxy datatypes.
  • existing_tool (STRING) – local path to existing Galaxy XML tool description.
  • inout_biotool (BOOLEAN) – add input and outputs description from https://bio.tools.

biotool_model.py

Model used to process information contained in JSON from https://bio.tools description.

The content of a description on https://bio.tools is contained in a JSON file and this model aims to store the different information.

class tooldog.biotool_model.Biotool(name, tool_id, version, description, homepage)[source]

This class correspond to an entry from https://bio.tools.

__init__(name, tool_id, version, description, homepage)[source]
Parameters:
  • name (STRING) – Name of the tool.
  • tool_id (STRING) – ID of the tool entry.
  • version (STRING) – Version of the tool entry.
  • description (STRING) – Description of the tool entry.
  • homepage (STRING) – URL to homepage.

tooldog.biotool_model.Biotool object is also initialized with two empty list of objects:

More information (tooldog.biotool_model.Informations object) can be specified using tooldog.biotool_model.Biotool.set_informations().

add_functions(functions)[source]

Add tooldog.biotool_model.Function objects to the list of functions of the Biotool object.

Parameters:functions (LIST of DICT) – list of functions description from https://bio.tools.
add_topics(topics)[source]

Add tooldog.biotool_model.Topic objects to the list of topics of the Biotool object.

Parameters:topics (LIST of DICT) – list of topics description from https://bio.tools.
generate_cwl_doc()[source]

Generate a doc from the different informations found on the tool.

Returns:a doc for CWL tool description.
Return type:STRING
generate_galaxy_help()[source]

Generate a help message from the different informations found on the tool.

Returns:a help message for Galaxy XML.
Return type:STRING
set_informations(tool_credits, contacts, publications, docs, language, links, download)[source]

Add an tooldog.biotool_model.Informations object to the Biotool.

Parameters:
  • tool_credits (LIST of DICT) – list of different tool_credits.
  • contacts (LIST of DICT) – list of different contacts.
  • publications (LIST of DICT) – list of different IDs for publications.
  • doc (LIST of DICT) – list of different documentations.
class tooldog.biotool_model.Contact(contact)[source]

Class to store one contact information.

__init__(contact)[source]
Parameters:contact (DICT) – contact part of the JSON from http://bio.tools.
class tooldog.biotool_model.Credit(credit)[source]

Class to store a credit information.

__init__(credit)[source]
Parameters:credit (DICT) – credit part of the JSON from http://bio.tools.
class tooldog.biotool_model.Data(data_type, formats, description=None)[source]

Data described by EDAM ontology.

__init__(data_type, formats, description=None)[source]
Parameters:
  • data_type (DICT) – EDAM ontology for the data type with uri and term.
  • formats (LIST of DICT) – EDAM ontology for data formats with uri and term.
  • description (STRING) – description of the data (DEPRECATED)
class tooldog.biotool_model.DataType(edam)[source]

EDAM data associated to either input or output.

__init__(edam)[source]
Parameters:edam (DICT) – EDAM ontology with uri and term.
class tooldog.biotool_model.Documentation(documentation)[source]

Class to store one documentation information.

__init__(documentation)[source]
Parameters:documentation (DICT) – documentation part of the JSON from http://bio.tools.
class tooldog.biotool_model.Edam(edam)[source]

Edam annotation with the uri and its corresponding term.

__init__(edam)[source]
Parameters:edam (DICT) – EDAM ontology with uri and term.
get_edam_id()[source]

Get the EDAM id from the uri.

Returns:EDAM id from the uri.
Return type:STRING
class tooldog.biotool_model.Format(edam)[source]

EDAM format associated to either input or output.

__init__(edam)[source]
Parameters:edam (DICT) – EDAM ontology with uri and term.
class tooldog.biotool_model.Function(edams)[source]

Correspond to one function of the entry with the corresponding inputs and outputs.

__init__(edams)[source]
Parameters:edams (LIST of DICT) – EDAM ontology for operation(s) with uri and term.

tooldog.biotool_model.Function object is initialized with two empty list of objects:

add_inputs(inputs)[source]

Add inputs to the tooldog.biotool_model.Function object.

Parameters:inputs (LIST of DICT) – inputs part of one function from http://bio.tools.
add_outputs(outputs)[source]

Add outputs to the tooldog.biotool_model.Function object.

Parameters:outputs (LIST of DICT) – inputs part of one function from http://bio.tools.
class tooldog.biotool_model.Informations[source]

Class to describe different information concerning a bio.tool entry.

__init__()[source]

tooldog.biotool_model.Informations object is initialized with four empty list of objects:

class tooldog.biotool_model.Input(data_type, formats, description=None)[source]

Input of a described function.

__init__(data_type, formats, description=None)[source]
Parameters:
  • data_type (DICT) – EDAM ontology for the data type with uri and term.
  • formats (LIST of DICT) – EDAM ontology for data formats with uri and term.
  • description (STRING) – description of the data (DEPRECATED)

Class to store download and links content.

__init__(link)[source]
Parameters:link (DICT) – links or download content of the JSON from http://bio.tools.
class tooldog.biotool_model.Operation(edam)[source]

EDAM operation associated to a function.

__init__(edam)[source]
Parameters:edam (DICT) – EDAM ontology with uri and term.
class tooldog.biotool_model.Output(data_type, formats, description=None)[source]

Output of a described function.

__init__(data_type, formats, description=None)[source]
Parameters:
  • data_type (DICT) – EDAM ontology for the data type with uri and term.
  • formats (LIST of DICT) – EDAM ontology for data formats with uri and term.
  • description (STRING) – description of the data (DEPRECATED)
class tooldog.biotool_model.Publication(publication)[source]

Class to store one publication information.

__init__(publication)[source]
Parameters:publication (DICT) – publication part of the JSON from http://bio.tools.
class tooldog.biotool_model.Topic(edam)[source]

EDAM topic associated to the entry.

__init__(edam)[source]
Parameters:edam (DICT) – EDAM ontology with uri and term.

analyse/code_collector.py

class tooldog.analyse.code_collector.CodeCollector(biotool)[source]

Class to download source code from a https://bio.tools entry

__init__(biotool)[source]
Parameters:biotool (tooldog.biotool_model.Biotool) – Biotool object
get_source()[source]

Retrieve source code of the tool using links provided in https://bio.tools

analyse/container.py

Wrapper for docker-py low-level client API. Allow creating container and using it within with statement.

class tooldog.analyse.container.Container(image, command, environment=None)[source]

Class to represent docker container and expose simple API to it.

__enter__()[source]

Start the container and make a with context.

__exit__(exc_type, exc_val, exc_tb)[source]

Stop the container and clean up.

__init__(image, command, environment=None)[source]

Create the container. Not the same as docker run, need to be started after the creation.

Parameters:
  • image (STRING) – the image to run
  • command (STRING or LIST) – the command to be run in the container
  • environment (DICT or LIST) – A dictionary or a list of strings in the following format {“TEST”: “123”} or [“TEST=123”].
  • mount (STRING) – absolute path to file to mount
exec(command)[source]

Execute the command inside container cid

Parameters:command (str) – String representation of bash command
Returns:Returns a generator of output of the result of running bash command in bytes
Return type:iter
inspect()[source]
Returns:Description of the container ans its status
Return type:DICT
kill()[source]

Kill the container.

logs()[source]
Returns:Returns a stream of the STDOUT and STDERR
Return type:iter
pull(image)[source]

Pull image :param image: the image to pull :type image: STRING

remove()[source]

Remove the container and associated volumes.

run(image, command, environment=None)[source]

Do real work of __init__.

start()[source]

Start the container.

stop()[source]

Stop the container.

analyse/tool_analyzer.py

class tooldog.analyse.tool_analyzer.ToolAnalyzer(biotool, gen_format, language=None, source_code=None)[source]

Class to perform appropriate source code analysis of a tool.

__init__(biotool, gen_format, language=None, source_code=None)[source]
Parameters:
  • biotool (tooldog.biotool_model.Biotool) – Biotool object
  • gen_format (STRING) – tool descriptor language (Galaxy XML or CWL)
  • language (STRING) – language of the tool
  • source_code (STRING) – path to source code
get_source()[source]

Get source code to give to analyzer.

run_analysis()[source]

Method to run analysis of source code of the entry.

set_language()[source]

Set the language attribute of the object based on the https://bio.tools description.

analyse/language_analyzer.py

class tooldog.analyse.language_analyzer.LanguageAnalyzer(biotool)[source]

This should be the abstract class for all analyzer.

__init__(biotool)[source]
Parameters:biotool (tooldog.biotool_model.Biotool) – Biotool object
analyse()[source]

Run source code analysis.

class tooldog.analyse.language_analyzer.PythonAnalyzer(gen_format, source_code)[source]

Object to specifically analyze Python source code.

__init__(gen_format, source_code)[source]
Parameters:
  • gen_format (STRING) – tool description language (Galaxy XML or CWL)
  • source_code (STRING) – path to source code.
analyse()[source]

Run source code analysis.

annotate/galaxy.py

Generation of XML for Galaxy from https://bio.tools based on the Tooldog model using galaxyxml library.

class tooldog.annotate.galaxy.GalaxyToolGen(biotool, galaxy_url=None, edam_url=None, mapping_json=None, existing_tool=None)[source]

Class to support generation of XML from tooldog.biotool_model.Biotool object.

__init__(biotool, galaxy_url=None, edam_url=None, mapping_json=None, existing_tool=None)[source]

Initialize a [Tool] object from galaxyxml with the minimal information (a name, an id, a version, a description, the command, the command version and a help).

Parameters:biotool (tooldog.biotool_model.Biotool) – Biotool object of an entry from https://bio.tools.
add_citation(publication)[source]

Add publication(s) to the tool (XML: <citations>).

Parameters:publication (tooldog.biotool_model.Publication) – Publication object.
add_edam_operation(operation)[source]

Add the EDAM operation to the tool (XML: <edam_operations>).

Parameters:topic (tooldog.biotool_model.Operation) – Operation object.
add_edam_topic(topic)[source]

Add the EDAM topic to the tool (XML: <edam_topics>).

Parameters:topic (tooldog.biotool_model.Topic) – Topic object.
add_input_file(input_obj)[source]

Add an input to the tool (XML: <inputs>).

Parameters:input_obj (tooldog.biotool_model.Input) – Input object.
add_output_file(output)[source]

Add an output to the tool (XML: <outputs>).

Parameters:output (tooldog.biotool_model.Output) – Output object.
write_xml(out_file=None, index=None, keep_old_command=False)[source]

Write CWL to STDOUT or out_file(s).

Parameters:
  • out_file (STRING) – path to output file.
  • index (INT) – Index in case more than one function is described.

annotate/cwl.py

Generation of CWL tool from https://bio.tools based on the ToolDog model using cwlgen library.

class tooldog.annotate.cwl.CwlToolGen(biotool, existing_tool=None)[source]

Class to support generation of CWL from tooldog.biotool_model.Biotool object.

__init__(biotool, existing_tool=None)[source]

Initialize a [CommandLineTool] object from cwlgen.

Parameters:biotool (tooldog.biotool_model.Biotool) – Biotool object of an entry from https://bio.tools.
add_edam_operation(operation)[source]

Add the EDAM operation to the tool (CWL: s:operation).

Parameters:operation (tooldog.biotool_model.Operation) – Operation object.
add_edam_topic(topic)[source]

Add the EDAM topic to the tool (CWL: s:topic).

Parameters:topic (tooldog.biotool_model.Topic) – Topic object.
add_input_file(input_obj)[source]

Add an input to the CWL tool.

Parameters:input_obj (tooldog.biotool_model.Input) – Input object.
add_output_file(output)[source]

Add an output to the CWL tool.

Parameters:output (tooldog.biotool_model.Output) – Output object.
add_publication(publication)[source]

Add publication to the tool (CWL: s:publication).

Parameters:publication (tooldog.biotool_model.Publication) – Publication object.
write_cwl(out_file=None, index=None)[source]

Write CWL to STDOUT or out_file(s).

Parameters:
  • out_file (STRING) – path to output file.
  • index (INT) – Index in case more than one function is described.

annotate/edam_to_galaxy.py

Gather different information from a Galaxy server (by default https://usegalaxy.org) and EDAM ontology (by default from http://edamontology.org/EDAM.owl)

class tooldog.annotate.edam_to_galaxy.EdamInfo(edam_url)[source]

Contains the given EDAM ontology.

It is also possible to generate several dictionnaries to help interrogating the ontology for a faster access.

__init__(edam_url)[source]
Parameters:edam_url (STRING) – path to EDAM.owl file

All the EDAM ontology will be contained in a dictionnary (self.edam_ontology).

generate_hierarchy()[source]

Generates two dictionnaries of the EDAM hierarchy (format and data) with the following structure:

DICT[edam_uri] -> LIST of edam_uri from parents

The dictionnary can be accessed via self.edam_format_hierarchy

class tooldog.annotate.edam_to_galaxy.EdamToGalaxy(galaxy_url=None, edam_url=None, mapping_json=None)[source]

Class to make the link between EDAM ontology terms (edam_format and edam_data) and Galaxy datatypes.

__init__(galaxy_url=None, edam_url=None, mapping_json=None)[source]
Parameters:
  • galaxy_url (STRING) – URL of the galaxy instance.
  • edam_url (STRING) – path to EDAM.owl file (URL or local path).
  • mapping_json (STRING) – path to personnalized EDAM mapping to Galaxy.
export_info(export_file)[source]

Method to export mapping of this object to a JSON file.

Parameters:export_file (STRING) – path to the file.
generate_mapping()[source]

Generates mapping between edam_format and edam_data to Galaxy datatypes based on the information of the Galaxy instance and the EDAM ontology.

Every edam_format and edam_data will be given a datatype.

get_datatype(edam_data=None, edam_format=None)[source]

Get datatype from EDAM terms. :param edam_data: EDAM data term. :type edam_data: STRING :param edam_format: EDAM format term. :type edam_format: STRING :return: datatype corresponding to given EDAM ontologies. :rtype: STRING

load_local_mapping(local_file)[source]

Method to load (from JSON file) mapping previously generated and exported in the local_file.

Parameters:local_file (STRING) – path to the mapping local file.
class tooldog.annotate.edam_to_galaxy.GalaxyInfo(galaxy_url)[source]

Class to gather different information about a Galaxy instance.

By default, if the galaxy_url is None, information is loaded from local files located in the data/ folder corresponding to https://usegalaxy.org.

__init__(galaxy_url)[source]
Parameters:galaxy_url (STRING) – URL of the Galaxy instance.

tooldog.edam_to_galaxy.GalaxyInfo object is initialized with several information from the given Galaxy instance. It contains:

Parameters:
  • self.version (STRING) – version of the Galaxy instance.
  • self.edam_formats (DICT) – mapping edam_format to LIST of extension of datatypes.
  • self.edam_data (DICT) – mapping edam_data to LIST of extension of datatypes.
  • self.hierarchy – class_to_classes part of the /api/mapping.json which maps

the parental classes of each classes. :type self.hierarchy: DICT :param self.class_names: ext_to_class_name part of the /api/mapping.json which maps the extension of a datatype to its class in Galaxy. :type self.class_names: DICT

select_root(datatypes)[source]

Select the root datatype from all given datatypes.

Parameters:datatypes (list of STRING) – list of different datatypes.
Returns:root datatype.
Return type:STRING