Metadata-Version: 2.4
Name: bio_tool_version_manager
Version: 1.2.0
Summary: Allows management of tool and workflow version in database and json
Home-page: https://github.com/ages-bioinformatics/bio_tool_version_manager
Author: Patrick Hyden
Author-email: patrick.hyden@ages.at
Classifier: Programming Language :: Python :: 3
Classifier: License :: OSI Approved :: MIT License
Classifier: Operating System :: OS Independent
Requires-Python: >=3.6
Description-Content-Type: text/markdown
License-File: LICENSE
Dynamic: author
Dynamic: author-email
Dynamic: classifier
Dynamic: description
Dynamic: description-content-type
Dynamic: home-page
Dynamic: license-file
Dynamic: requires-python
Dynamic: summary

# Workflow Tool Manager

**Workflow Tool Manager** is a python package to create a json file during a bioinformatic workflow (e.g. written in nextflow) to track the software tools, versions, parameters and database by incrementally adding new entries in each process.

## Installation

Installable via `pip`:

```bash
pip install bio_tool_version_manager
```

## Usage

### CLI

1. **Incrementally add new tools to the "workflowfile"**:

```
bio_tool_version_manager add -h
usage: bio_tool_version_manager add [-h] [-n WORKFLOW_NAME] [--wf_version WF_VERSION] [-t TOOL_NAME]
                                    [--tool_version TOOL_VERSION] [-p TOOL_PARAMETER] [-f JSON_FILE]
                                    [--db_name DB_NAME] [--db_version DB_VERSION]

options:
  -h, --help            show this help message and exit
  -n WORKFLOW_NAME
  --wf_version WF_VERSION
                        workflow version
  -t TOOL_NAME
  --tool_version TOOL_VERSION
  -p TOOL_PARAMETER
  -f, --file JSON_FILE  Path to input JSON file
  --db_name DB_NAME
  --db_version DB_VERSION

```

2. **Insert into a database (requires sqlalchemy, sqlite or mariadb-database)**:

```
bio_tool_version_manager insert -h
usage: bio_tool_version_manager insert [-h] -f JSON_FILE --pid PROCESS_ID [-d DATABASE] [-H HOSTNAME] [-u DBUSER] [--finish]
                                       [-p MARIADBPASSWORD]

options:
  -h, --help            show this help message and exit
  -f, --file JSON_FILE  Path to input JSON file
  --finish              set process status to finished and finished_at timestamp
  --pid PROCESS_ID      Process ID to store
  -d, --database DATABASE
                        mysql database name or path to sqlite-db [./agres.db]
  -H, --hostname HOSTNAME
                        mysql hostname; if not provided sqlite-db will be used
  -u, --user DBUSER     mysql database username
  -p, --password MARIADBPASSWORD
                        mysql password
```

3. **Dump versions/workflow from database for specified process**:

```
bio_tool_version_manager dump -h
usage: bio_tool_version_manager dump [-h] --pid PROCESS_ID [-f JSON_FILE] [-d DATABASE] [-H HOSTNAME] [-u DBUSER] [-p MARIADBPASSWORD]

options:
  -h, --help            show this help message and exit
  --pid PROCESS_ID      Process ID to create JSON from
  -f, --file JSON_FILE  Path to output JSON file
  -d, --database DATABASE
                        mysql database name or path to sqlite-db [./agres.db]
  -H, --hostname HOSTNAME
                        mysql hostname; if not provided sqlite-db will be used
  -u, --user DBUSER     mysql database username
  -p, --password MARIADBPASSWORD
                        mysql password
```

### Python-API

The the package can also be imported and used within python:

```python
from workflow_tool_manager.insert import get_or_create_tool, get_or_create_workflow
from sqlalchemy.orm import sessionmaker


# Create session to your engine (assume you already have a db connection as sqlalchemy-engine)
Session = sessionmaker(bind=engine)  
session = Session()  

tool1_dict = {
  'name':'blastn', 
  'version':'2.10.1', 
  'parameter':'-evalue 0.01',
  'database': {
    'name': 'mynt',
    'version': '0.1a',
  },
}

tool2_dict = {
  'name':'Tool2', 
  'version':'2.0', 
  'parameter':'--fast',
}

tool1 = get_or_create_tool(session, tool1_dict)  
tool2 = get_or_create_tool(session, tool2_dict)  
workflow = get_or_create_workflow(session, name='myworkflow', version='1.0', tools=[tool1, tool2])  

```

## License

This project is licensed under MIT license
