-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added in checks and tb-profiler installation
- Loading branch information
1 parent
04d5e6d
commit 5329ee2
Showing
4 changed files
with
91 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
|
||
import pathlib, subprocess, re,json | ||
from collections import namedtuple | ||
from tbtamr.CustomLog import logger | ||
# from tbtamr.RunProfiler import RunProfiler | ||
|
||
# version_pat_3 = | ||
|
||
def _run_cmd(cmd): | ||
p = subprocess.run(f"{cmd}", capture_output=True, encoding = "utf-8", shell = True) | ||
return p | ||
|
||
def version_pattern(): | ||
return re.compile(r'\bv?(?P<major>[0-9]+)\.(?P<minor>[0-9]+)(?:\.(?P<release>[0-9]+)*)?(?:\.(?P<build>[0-9]+)*)?\b') | ||
|
||
def _run_check(_input, sft): | ||
p = _run_cmd(cmd=_input) | ||
_str = p.stdout | ||
v = version_pattern().search(_str.strip()) | ||
if v: | ||
v = v.group(0) | ||
logger.info(f"{sft} version {v} detected.") | ||
elif sft == "snpEff" and p.returncode == 0: | ||
logger.info(f"{' '.join(p.stdout.split())} detected.") | ||
elif sft == "tb-profiler": | ||
logger.warning(f"It seems that {sft} is not installed correctly.") | ||
res = input("Would you like to install it now? (y/n): ") | ||
if res.lower() == 'y': | ||
_install_tbprofiler() | ||
elif res.lower() == 'n': | ||
logger.critical(f"{sft} is required - please run 'tbtamr setup' now to proceed.") | ||
raise SystemExit | ||
else: | ||
logger.critical(f"{sft} is not installed.") | ||
raise SystemExit | ||
|
||
def check_deps(): | ||
|
||
with open(f"{pathlib.Path(__file__).parent / 'dep_config.json'}", "r") as j: | ||
|
||
software = json.load(j) | ||
logger.info(f"Checking that dependencies are installed and recording version.") | ||
|
||
for sft in software: | ||
_run_check(_input =software[sft], sft = sft) | ||
|
||
return True | ||
|
||
def _install_tbprofiler(): | ||
|
||
pp = _run_cmd(cmd="pip3 install git+https://github.com/MDU-PHL/pathogen-profiler") | ||
if pp.returncode == 0: | ||
logger.info(f"pathogen-profiler from https://github.com/MDU-PHL/ installed.") | ||
tbp = _run_cmd(cmd = "pip3 install git+https://github.com/MDU-PHL/TBProfiler") | ||
if tbp.returncode == 0: | ||
logger.info(f"TB-profiler https://github.com/MDU-PHL/ installed. You should now be good to go.") | ||
|
||
def check(): | ||
|
||
check_deps() | ||
return True | ||
|
||
def install(): | ||
_install_tbprofiler() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"tb-profiler": "tb-profiler version 2>&1", | ||
"samtools": "samtools --version 2>&1", | ||
"bwa":"bwa 2>&1", | ||
"snpEff":"snpEff -version 2>&1", | ||
"samclip":"samclip --version 2>&1", | ||
"freebayes":"freebayes --version 2>&1", | ||
"bcftools":"bcftools --version 2>&1", | ||
"bedtools":"bedtools --version 2>&1", | ||
"delly":"delly --version 2>&1" | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters