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: - biotool (
tooldog.biotool_model.Biotool
) – Biotool object. - args (
argparse.ArgumentParser
) – Parsed arguments.
- biotool (
-
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.
- biotool (
-
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.
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.
- biotool (
-
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 (
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:- functions: list of
tooldog.biotool_model.Function
- topics: list of
tooldog.biotool_model.Topic
More information (
tooldog.biotool_model.Informations
object) can be specified usingtooldog.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.
-
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.
-
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:- inputs: list of
tooldog.biotool_model.Input
- outputs: list of
tooldog.biotool_model.Output
- inputs: list of
-
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:- publications: list of
tooldog.biotool_model.Publication
- documentations: list of
tooldog.biotool_model.Documentation
- contacts: list of
tooldog.biotool_model.Contact
- tool_credits: list of
tooldog.biotool_model.Credit
- language: list of coding language
- link: list of
tooldog.biotool_model.Link
- publications: list of
-
-
class
tooldog.biotool_model.
Input
(data_type, formats, description=None)[source]¶ Input of a described function.
-
class
tooldog.biotool_model.
Link
(link)[source]¶ 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.
Output
(data_type, formats, description=None)[source]¶ Output of a described function.
-
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.
-
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.
-
__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
-
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
- biotool (
-
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
-
-
class
tooldog.analyse.language_analyzer.
PythonAnalyzer
(gen_format, source_code)[source]¶ Object to specifically analyze Python source code.
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.
-
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.
-
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.
-
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.
-
-
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
-