forked from lvrcek/GNNome-assembly
-
Notifications
You must be signed in to change notification settings - Fork 0
/
la_jolla.py
39 lines (28 loc) · 1.42 KB
/
la_jolla.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
import subprocess
from pathlib import Path
from typeguard import typechecked
from assembler import Assembler
from cmd_utils import compose_cmd_params, get_read_files
class LaJolla(Assembler):
@typechecked
def _install(self, vendor_dir: Path) -> Path:
assembler_root = vendor_dir / 'LJA'
if not assembler_root.exists():
print(f'SETUP::generate:: Download La Jolla Assembler')
subprocess.run('git clone https://github.com/AntonBankevich/LJA.git', shell=True, cwd=str(vendor_dir))
subprocess.run('cmake .', shell=True, cwd=str(assembler_root))
subprocess.run('make -j 8', shell=True, cwd=str(assembler_root))
return assembler_root
@typechecked
def _construct_exec_cmd(self, reads_path: Path, output_path: Path) -> list[str]:
read_files = get_read_files(reads_path)
reads_cmd_params = ' '.join([f'--reads {str(read_file)}' for read_file in read_files])
out_cmd_param = f'-o {str(output_path)}'
option_params = compose_cmd_params(self.cfg)
asm_executable = self.assembler_root / 'bin/lja'
return [f'{asm_executable} {option_params} {reads_cmd_params} {out_cmd_param}']
@typechecked
def run(self, raw_path: Path, tmp_path: Path, save_path: Path, *args, **kwargs):
commands = self._construct_exec_cmd(raw_path, tmp_path)
for cmd in commands:
subprocess.run(cmd, shell=True)