-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathbowtie.py
executable file
·27 lines (24 loc) · 1.4 KB
/
bowtie.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
__author__ = 'alipirani'
import os
from modules.log_modules import keep_logging
from modules.logging_subprocess import *
#################################################### Bowtie Alignment ############################################
def align_bowtie(base_cmd, forward_clean, reverse_clean, forward_unpaired, reverse_unpaired, out_path, reference, split_field, analysis, files_to_delete, logger, Config, type, parameters):
if type == "PE":
cmd = "%s -x %s -1 %s -2 %s -S %s/%s_PE_aln.sam -t -p 8 %s %s" % (base_cmd, reference, forward_clean, reverse_clean, out_path, analysis, parameters, split_field)
out_sam = "%s/%s_PE_aln.sam" % (out_path, analysis)
else:
cmd = "%s -x %s -U %s -S %s/%s_SE_aln.sam -t -p 8 %s %s" % (base_cmd, reference, forward_clean, out_path, analysis, parameters, split_field)
out_sam = "%s/%s_SE_aln.sam" % (out_path, analysis)
keep_logging("COMMAND: " + cmd, cmd, logger, 'debug')
try:
call(cmd, logger)
except sp.CalledProcessError:
keep_logging('Error in Alignment step. Exiting.', 'Error in Alignment step. Exiting.', logger, 'exception')
sys.exit(1)
files_to_delete.append(out_sam)
if not os.path.isfile(out_sam):
keep_logging('Problem in BWA alignment. SAM file was not generated.', 'Problem in BWA alignment. SAM file was not generated', logger, 'exception')
exit()
else:
return out_sam