-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcore.py
53 lines (42 loc) · 1.54 KB
/
core.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
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
import sys
import shutil
import configparser
from pathlib import Path
from celery import Celery
from assembly import Assembly
from sra import SequenceReadArchive
config = configparser.ConfigParser()
config.read('config.txt')
profiling_program = config['Config']['profiling']
celery_backend = config['Config']['backend']
celery_broker = config['Config']['broker']
sys.path.append(profiling_program)
from src.algorithms import profiling
app = Celery(backend=celery_backend, broker=celery_broker)
@app.task
def sra_download_and_split(accession, outdir):
sra_outdir = Path(outdir, 'sra')
fastq_dir = Path(outdir, 'fastq', accession)
sra = SequenceReadArchive(accession=accession, outdir=sra_outdir)
sra.make_url()
sra.download()
sra.split(fastq_dir)
sra.remove()
return accession, fastq_dir, outdir
@app.task
def genome_assembly(args):
accession, fastq_dir, outdir = args
contig_dir = Path(outdir, 'contig', accession)
assembly = Assembly(accession=accession, reads_path=fastq_dir, outdir=outdir)
assembly.denovo()
assembly.move_contig(contig_dir)
shutil.rmtree(fastq_dir)
shutil.rmtree(assembly.outdir)
return accession, contig_dir, outdir
@app.task
def profile(args, database):
accession, contig_dir, outdir = args
profile_dir = Path(outdir, 'profile', accession)
Path.mkdir(profile_dir, parents=True, exist_ok=True)
profiling.profiling(profile_dir, contig_dir, database, threads=1, occr_level=0,
enable_adding_new_alleles=True, generate_profiles=True, debug=False)