Skip to content
Commits on Source (2)
......@@ -11,7 +11,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
# encoding: utf-8
"""
@@ -195,11 +195,11 @@ GFF_T_VER = 209 #GFF parser version
@@ -195,11 +195,11 @@
#mapping types:
......@@ -25,7 +25,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
stageNames = ["start", "prep_reads", "map_start", "map_segments", "find_juncs", "juncs_db", "map2juncs", "tophat_reports", "alldone"]
# 0 1 2 3 4 5 6 7 , 8
runStages = dict([(stageNames[st], st) for st in range(0, 9)])
@@ -214,7 +214,7 @@ def getResumeStage(rlog):
@@ -214,7 +214,7 @@
#first line must be the actual tophat command used
thcmd=None
try:
......@@ -34,7 +34,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
except StopIteration:
die("Error: cannot resume, run.log is empty.")
oldargv=thcmd.split()
@@ -257,7 +257,7 @@ def doResume(odir):
@@ -257,7 +257,7 @@
best_stage = r0stage
best_argv = r0argv[:]
if best_stage == _stage_alldone:
......@@ -43,16 +43,16 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
sys.exit(1)
global resumeStage
@@ -266,7 +266,7 @@ def doResume(odir):
@@ -266,7 +266,7 @@
def setRunStage(stnum):
global currentStage
- print >> run_log, "#>"+stageNames[stnum]+":"
+ print("#>"+stageNames[stnum]+":", file=run_log)
+ print("#>"+stageNames[stnum]+":", file=run_log, flush=True)
currentStage = stnum
def init_logger(log_fname):
@@ -1000,7 +1000,7 @@ class TopHatParams:
@@ -1000,7 +1000,7 @@
"b2-score-min=",
"b2-D=",
"b2-R="])
......@@ -61,7 +61,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
raise Usage(msg)
self.splice_constraints.parse_options(opts)
@@ -1023,7 +1023,7 @@ class TopHatParams:
@@ -1023,7 +1023,7 @@
# option processing
for option, value in opts:
if option in ("-v", "--version"):
......@@ -70,7 +70,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
sys.exit(0)
if option in ("-h", "--help"):
raise Usage(use_message)
@@ -1224,9 +1224,9 @@ def th_log(out_str):
@@ -1224,9 +1224,9 @@
tophat_logger.info(out_str)
def th_logp(out_str=""):
......@@ -82,7 +82,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
def die(msg=None):
if msg is not None:
@@ -1253,7 +1253,7 @@ def prepare_output_dir():
@@ -1253,7 +1253,7 @@
else:
try:
os.makedirs(tmp_dir)
......@@ -91,7 +91,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
die("\nError creating directory %s (%s)" % (tmp_dir, o))
@@ -1287,7 +1287,7 @@ def check_bowtie_index(idx_prefix, is_bo
@@ -1287,7 +1287,7 @@
os.path.exists(idx_rev_1) and \
os.path.exists(idx_rev_2):
if os.path.exists(idx_prefix + ".1.ebwt") and os.path.exists(idx_prefix + ".1.bt2"):
......@@ -100,7 +100,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
return
else:
if is_bowtie2:
@@ -1317,7 +1317,7 @@ def check_bowtie_index(idx_prefix, is_bo
@@ -1317,7 +1317,7 @@
os.path.exists(bwtidx_env+idx_rev_1) and \
os.path.exists(bwtidx_env+idx_rev_2):
if os.path.exists(bwtidx_env + idx_prefix + ".1.ebwt") and os.path.exists(bwtidx_env + idx_prefix + ".1.bt2"):
......@@ -109,7 +109,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
return
else:
die(bwtidxerr)
@@ -1350,7 +1350,7 @@ def bowtie_idx_to_fa(idx_prefix, is_bowt
@@ -1350,7 +1350,7 @@
die(fail_str+"Error: bowtie-inspect returned an error\n"+log_tail(logging_dir + "bowtie_inspect_recons.log"))
# Bowtie not found
......@@ -118,7 +118,18 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
die(fail_str+"Error: bowtie-inspect not found on this system. Did you forget to include it in your PATH?")
@@ -1406,7 +1406,7 @@ def get_bowtie_version():
@@ -1397,16 +1397,16 @@
bowtie_version = None
if not stdout_value: stdout_value=''
bowtie_out = stdout_value.splitlines()[0]
- version_str=" version "
+ version_str=b' version '
ver_str_idx = bowtie_out.find(version_str)
if ver_str_idx != -1:
version_val = bowtie_out[(ver_str_idx + len(version_str)):]
- bvers=re.findall(r'\d+', version_val)
+ bvers=re.findall(r'\d+', version_val.decode('utf-8'))
bowtie_version = [int(x) for x in bvers]
while len(bowtie_version)<4:
bowtie_version.append(0)
return bowtie_version
......@@ -127,7 +138,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
errmsg=fail_str+str(o)+"\n"
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
errmsg+="Error: bowtie not found on this system"
@@ -1471,7 +1471,7 @@ def get_index_sam_header(params, idx_pre
@@ -1471,7 +1471,7 @@
else:
preamble.append(line)
......@@ -136,7 +147,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
if read_params.read_group_id and read_params.sample_id:
rg_str = "@RG\tID:%s\tSM:%s" % (read_params.read_group_id,
read_params.sample_id)
@@ -1490,20 +1490,20 @@ def get_index_sam_header(params, idx_pre
@@ -1490,20 +1490,20 @@
if read_params.seq_platform:
rg_str += "\tPL:%s" % read_params.seq_platform
......@@ -144,7 +155,8 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
+ print(rg_str, file=bowtie_sam_header_file)
if not params.keep_fasta_order:
sq_dict_lines.sort(lambda x,y: cmp(x[0],y[0]))
- sq_dict_lines.sort(lambda x,y: cmp(x[0],y[0]))
+ sq_dict_lines.sort(key=lambda x: x[0])
for [name, line] in sq_dict_lines:
- print >> bowtie_sam_header_file, line
......@@ -161,7 +173,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
errmsg=fail_str+str(o)+"\n"
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
errmsg+="Error: bowtie not found on this system"
@@ -1559,7 +1559,7 @@ def get_samtools_version():
@@ -1559,7 +1559,7 @@
samtools_version_arr.append(0)
return version_match.group(), samtools_version_arr
......@@ -170,7 +182,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
errmsg=fail_str+str(o)+"\n"
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
errmsg+="Error: samtools not found on this system"
@@ -1668,7 +1668,7 @@ class FastxReader:
@@ -1668,7 +1668,7 @@
if seq_len != qstrlen :
raise ValueError("Length mismatch between sequence and quality strings "+ \
"for %s (%i vs %i)." % (seqid, seq_len, qstrlen))
......@@ -179,7 +191,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
die("\nError encountered parsing file "+self.fname+":\n "+str(err))
#return the record
self.numrecords+=1
@@ -1705,7 +1705,7 @@ class FastxReader:
@@ -1705,7 +1705,7 @@
if seq_len < 3:
raise ValueError("Read %s too short (%i)." \
% (seqid, seq_len))
......@@ -188,7 +200,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
die("\nError encountered parsing fasta file "+self.fname+"\n "+str(err))
#return the record and continue
self.numrecords+=1
@@ -1744,7 +1744,7 @@ def fa_write(fhandle, seq_id, seq):
@@ -1744,7 +1744,7 @@
"""
line_len = 60
fhandle.write(">" + seq_id + "\n")
......@@ -197,16 +209,16 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
start = i * line_len
#end = (i+1) * line_len if (i+1) * line_len < len(seq) else len(seq)
if (i+1) * line_len < len(seq):
@@ -2085,7 +2085,7 @@ def prep_reads(params, l_reads_list, l_q
@@ -2085,7 +2085,7 @@
if not use_bam: shell_cmd += ' >' +kept_reads_filename
retcode = None
try:
- print >> run_log, shell_cmd
+ print(shell_cmd, file=run_log)
+ print(shell_cmd, file=run_log, flush=True)
if do_use_zpacker:
filter_proc = subprocess.Popen(prep_cmd,
stdout=subprocess.PIPE,
@@ -2108,7 +2108,7 @@ def prep_reads(params, l_reads_list, l_q
@@ -2108,7 +2108,7 @@
if retcode:
die(fail_str+"Error running 'prep_reads'\n"+log_tail(log_fname))
......@@ -215,7 +227,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
errmsg=fail_str+str(o)
die(errmsg+"\n"+log_tail(log_fname))
@@ -2197,7 +2197,7 @@ def bowtie(params,
@@ -2197,7 +2197,7 @@
os.remove(unmapped_reads_fifo)
try:
os.mkfifo(unmapped_reads_fifo)
......@@ -224,25 +236,25 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
die(fail_str+"Error at mkfifo("+unmapped_reads_fifo+'). '+str(o))
# Launch Bowtie
@@ -2231,7 +2231,7 @@ def bowtie(params,
@@ -2231,7 +2231,7 @@
unm_zipcmd=[ params.system_params.zipper ]
unm_zipcmd.extend(params.system_params.zipper_opts)
unm_zipcmd+=['-c']
- print >> run_log, ' '.join(unm_zipcmd)+' < '+ unmapped_reads_fifo + ' > '+ unmapped_reads_out + ' & '
+ print(' '.join(unm_zipcmd)+' < '+ unmapped_reads_fifo + ' > '+ unmapped_reads_out + ' & ', file=run_log)
+ print(' '.join(unm_zipcmd)+' < '+ unmapped_reads_fifo + ' > '+ unmapped_reads_out + ' & ', file=run_log, flush=True)
fifo_pid=os.fork()
if fifo_pid==0:
def on_sig_exit(sig, func=None):
@@ -2440,7 +2440,7 @@ def bowtie(params,
@@ -2440,7 +2440,7 @@
bowtie_proc.stdout.close()
pipeline_proc = fix_order_proc
- print >> run_log, shellcmd
+ print(shellcmd, file=run_log)
+ print(shellcmd, file=run_log, flush=True)
retcode = None
if pipeline_proc:
pipeline_proc.communicate()
@@ -2457,7 +2457,7 @@ def bowtie(params,
@@ -2457,7 +2457,7 @@
pass
if retcode:
die(fail_str+"Error running:\n"+shellcmd)
......@@ -251,7 +263,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
die(fail_str+"Error: "+str(o))
# Success
@@ -2491,7 +2491,7 @@ def get_gtf_juncs(gff_annotation):
@@ -2491,7 +2491,7 @@
gtf_juncs_cmd=[prog_path("gtf_juncs"), gff_annotation]
try:
......@@ -260,7 +272,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
retcode = subprocess.call(gtf_juncs_cmd,
stderr=gtf_juncs_log,
stdout=gtf_juncs_out)
@@ -2503,7 +2503,7 @@ def get_gtf_juncs(gff_annotation):
@@ -2503,7 +2503,7 @@
die(fail_str+"Error: GTF junction extraction failed with err ="+str(retcode))
# cvg_islands not found
......@@ -269,12 +281,12 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
errmsg=fail_str+str(o)+"\n"
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
errmsg+="Error: gtf_juncs not found on this system"
@@ -2528,13 +2528,13 @@ def build_juncs_bwt_index(is_bowtie2, ex
@@ -2528,13 +2528,13 @@
bowtie_build_cmd += [external_splice_prefix + ".fa",
external_splice_prefix]
try:
- print >> run_log, " ".join(bowtie_build_cmd)
+ print(" ".join(bowtie_build_cmd), file=run_log)
+ print(" ".join(bowtie_build_cmd), file=run_log, flush=True)
retcode = subprocess.call(bowtie_build_cmd,
stdout=bowtie_build_log)
......@@ -285,7 +297,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
errmsg=fail_str+str(o)+"\n"
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
errmsg+="Error: bowtie-build not found on this system"
@@ -2580,7 +2580,7 @@ def build_juncs_index(is_bowtie2,
@@ -2580,7 +2580,7 @@
fusions_file_list,
reference_fasta]
try:
......@@ -294,7 +306,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
retcode = subprocess.call(juncs_db_cmd,
stderr=juncs_db_log,
stdout=external_splices_out)
@@ -2588,7 +2588,7 @@ def build_juncs_index(is_bowtie2,
@@ -2588,7 +2588,7 @@
if retcode != 0:
die(fail_str+"Error: Splice sequence retrieval failed with err ="+str(retcode))
# juncs_db not found
......@@ -303,12 +315,12 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
errmsg=fail_str+str(o)+"\n"
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
errmsg+="Error: juncs_db not found on this system"
@@ -2621,14 +2621,14 @@ def build_idx_from_fa(is_bowtie2, fasta_
@@ -2621,14 +2621,14 @@
bwt_idx_path]
try:
th_log("Building Bowtie index from " + os.path.basename(fasta_fname))
- print >> run_log, " ".join(bowtie_idx_cmd)
+ print(" ".join(bowtie_idx_cmd), file=run_log)
+ print(" ".join(bowtie_idx_cmd), file=run_log, flush=True)
retcode = subprocess.call(bowtie_idx_cmd,
stdout=open(os.devnull, "w"),
stderr=open(os.devnull, "w"))
......@@ -320,7 +332,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
errmsg=fail_str+str(o)+"\n"
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
errmsg+="Error: bowtie-build not found on this system"
@@ -2639,7 +2639,7 @@ def build_idx_from_fa(is_bowtie2, fasta_
@@ -2639,7 +2639,7 @@
# Print out the sam header, embedding the user's specified library properties.
# FIXME: also needs SQ dictionary lines
def write_sam_header(read_params, sam_file):
......@@ -329,7 +341,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
if read_params.read_group_id and read_params.sample_id:
rg_str = "@RG\tID:%s\tSM:%s" % (read_params.read_group_id,
read_params.sample_id)
@@ -2658,8 +2658,8 @@ def write_sam_header(read_params, sam_fi
@@ -2658,8 +2658,8 @@
if read_params.seq_platform:
rg_str += "\tPL:%s" % read_params.seq_platform
......@@ -340,53 +352,53 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
# Write final TopHat output, via tophat_reports and wiggles
def compile_reports(params, sam_header_filename, ref_fasta, mappings, readfiles, gff_annotation):
@@ -2727,7 +2727,7 @@ def compile_reports(params, sam_header_f
@@ -2727,7 +2727,7 @@
report_cmd.append(right_reads)
try:
- print >> run_log, " ".join(report_cmd)
+ print(" ".join(report_cmd), file=run_log)
+ print(" ".join(report_cmd), file=run_log, flush=True)
report_proc=subprocess.call(report_cmd,
preexec_fn=subprocess_setup,
stderr=report_log)
@@ -2753,8 +2753,7 @@ def compile_reports(params, sam_header_f
@@ -2753,8 +2753,7 @@
bam_parts[i],
"-o",
sorted_bam_parts[i]]
-
- print >> run_log, " ".join(bamsort_cmd)
+ print(" ".join(bamsort_cmd), file=run_log)
+ print(" ".join(bamsort_cmd), file=run_log, flush=True)
if i + 1 < num_bam_parts:
pid = os.fork()
@@ -2791,7 +2790,7 @@ def compile_reports(params, sam_header_f
@@ -2791,7 +2790,7 @@
if params.report_params.convert_bam:
bammerge_cmd += ["%s.bam" % accepted_hits]
bammerge_cmd += bam_parts
- print >> run_log, " ".join(bammerge_cmd)
+ print(" ".join(bammerge_cmd), file=run_log)
+ print(" ".join(bammerge_cmd), file=run_log, flush=True)
subprocess.call(bammerge_cmd,
stderr=open(logging_dir + "reports.merge_bam.log", "w"))
else: #make .sam
@@ -2807,7 +2806,7 @@ def compile_reports(params, sam_header_f
@@ -2807,7 +2806,7 @@
stderr=open(logging_dir + "accepted_hits_bam_to_sam.log", "w"))
merge_proc.stdout.close()
shellcmd = " ".join(bammerge_cmd) + " | " + " ".join(bam2sam_cmd)
- print >> run_log, shellcmd
+ print(shellcmd, file=run_log)
+ print(shellcmd, file=run_log, flush=True)
sam_proc.communicate()
retcode = sam_proc.returncode
if retcode:
@@ -2820,7 +2819,7 @@ def compile_reports(params, sam_header_f
@@ -2820,7 +2819,7 @@
#just convert to .sam
bam2sam_cmd = [samtools_path, "view", "-h", accepted_hits+".bam"]
shellcmd = " ".join(bam2sam_cmd) + " > " + accepted_hits + ".sam"
- print >> run_log, shellcmd
+ print(shellcmd, file=run_log)
+ print(shellcmd, file=run_log, flush=True)
r = subprocess.call(bam2sam_cmd,
stdout=open(accepted_hits + ".sam", "w"),
stderr=open(logging_dir + "accepted_hits_bam_to_sam.log", "w"))
@@ -2828,7 +2827,7 @@ def compile_reports(params, sam_header_f
@@ -2828,7 +2827,7 @@
die(fail_str+"Error running: "+shellcmd)
os.remove(accepted_hits+".bam")
......@@ -395,16 +407,16 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
die(fail_str+"Error: "+str(o)+"\n"+log_tail(log_fname))
try:
@@ -2851,7 +2850,7 @@ def compile_reports(params, sam_header_f
@@ -2851,7 +2850,7 @@
merge_cmd=[prog_path("bam_merge"), "-Q",
"--sam-header", sam_header_filename, um_merged]
merge_cmd += um_parts
- print >> run_log, " ".join(merge_cmd)
+ print(" ".join(merge_cmd), file=run_log)
+ print(" ".join(merge_cmd), file=run_log, flush=True)
ret = subprocess.call( merge_cmd,
stderr=open(logging_dir + "bam_merge_um.log", "w") )
if ret != 0:
@@ -2859,7 +2858,7 @@ def compile_reports(params, sam_header_f
@@ -2859,7 +2858,7 @@
for um_part in um_parts:
os.remove(um_part)
......@@ -413,7 +425,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
die(fail_str+"Error: "+str(o)+"\n"+log_tail(log_fname))
return junctions
@@ -2945,15 +2944,15 @@ def split_reads(reads_filename,
@@ -2945,15 +2944,15 @@
while seg_num + 1 < len(offsets):
f = out_segf[seg_num].file
seg_seq = read_seq[last_seq_offset+color_offset:offsets[seg_num + 1]+color_offset]
......@@ -434,16 +446,25 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
seg_num += 1
last_seq_offset = offsets[seg_num]
@@ -3049,7 +3048,7 @@ def junctions_from_closures(params,
@@ -2972,7 +2971,7 @@
read_seq = line.strip()
read_length = len(read_seq)
- tmp_num_segments = read_length / segment_length
+ tmp_num_segments = read_length // segment_length
offsets = [segment_length * i for i in range(0, tmp_num_segments + 1)]
# Bowtie's minimum read length here is 20bp, so if the last segment
@@ -3049,7 +3048,7 @@
left_maps,
right_maps])
try:
- print >> run_log, ' '.join(juncs_cmd)
+ print(' '.join(juncs_cmd), file=run_log)
+ print(' '.join(juncs_cmd), file=run_log, flush=True)
retcode = subprocess.call(juncs_cmd,
stderr=juncs_log)
@@ -3057,7 +3056,7 @@ def junctions_from_closures(params,
@@ -3057,7 +3056,7 @@
if retcode != 0:
die(fail_str+"Error: closure-based junction search failed with err ="+str(retcode))
# cvg_islands not found
......@@ -452,7 +473,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
th_logp(fail_str + "Error: closure_juncs not found on this system")
die(str(o))
@@ -3088,8 +3087,8 @@ def junctions_from_segments(params,
@@ -3088,8 +3087,8 @@
return [juncs_out, insertions_out, deletions_out, fusions_out]
th_log("Searching for junctions via segment mapping")
if params.coverage_search == True:
......@@ -463,16 +484,16 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
left_maps = ','.join(left_seg_maps)
log_fname = logging_dir + "segment_juncs.log"
@@ -3111,7 +3110,7 @@ def junctions_from_segments(params,
@@ -3111,7 +3110,7 @@
right_maps = ','.join(right_seg_maps)
segj_cmd.extend([right_reads, right_reads_map, right_maps])
try:
- print >> run_log, " ".join(segj_cmd)
+ print(" ".join(segj_cmd), file=run_log)
+ print(" ".join(segj_cmd), file=run_log, flush=True)
retcode = subprocess.call(segj_cmd,
preexec_fn=subprocess_setup,
stderr=segj_log)
@@ -3121,7 +3120,7 @@ def junctions_from_segments(params,
@@ -3121,7 +3120,7 @@
die(fail_str+"Error: segment-based junction search failed with err ="+str(retcode)+"\n"+log_tail(log_fname))
# cvg_islands not found
......@@ -481,12 +502,12 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
if o.errno == errno.ENOTDIR or o.errno == errno.ENOENT:
th_logp(fail_str + "Error: segment_juncs not found on this system")
die(str(o))
@@ -3191,12 +3190,12 @@ def join_mapped_segments(params,
@@ -3191,12 +3190,12 @@
align_cmd.append(spliced_seg_maps)
try:
- print >> run_log, " ".join(align_cmd)
+ print(" ".join(align_cmd), file=run_log)
+ print(" ".join(align_cmd), file=run_log, flush=True)
ret = subprocess.call(align_cmd,
stderr=align_log)
if ret:
......@@ -496,12 +517,12 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
die(fail_str+"Error: "+str(o))
# This class collects spliced and unspliced alignments for each of the
@@ -3234,13 +3233,13 @@ def m2g_convert_coords(params, sam_heade
@@ -3234,13 +3233,13 @@
try:
th_log("Converting " + fbasename + " to genomic coordinates (map2gtf)")
- print >> run_log, " ".join(m2g_cmd) + " > " + m2g_log
+ print(" ".join(m2g_cmd) + " > " + m2g_log, file=run_log)
+ print(" ".join(m2g_cmd) + " > " + m2g_log, file=run_log, flush=True)
ret = subprocess.call(m2g_cmd,
stdout=open(m2g_log, "w"),
stderr=open(m2g_err, "w"))
......@@ -512,12 +533,12 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
err_msg = fail_str + str(o)
die(err_msg + "\n")
@@ -3269,17 +3268,17 @@ def gtf_to_fasta(params, trans_gtf, geno
@@ -3269,17 +3268,17 @@
g2f_err = logging_dir + "g2f.err"
try:
- print >> run_log, " ".join(g2f_cmd)+" > " + g2f_log
+ print(" ".join(g2f_cmd)+" > " + g2f_log, file=run_log)
+ print(" ".join(g2f_cmd)+" > " + g2f_log, file=run_log, flush=True)
ret = subprocess.call(g2f_cmd,
stdout = open(g2f_log, "w"),
stderr = open(g2f_err, "w"))
......@@ -533,16 +554,16 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
fver.close()
return out_fname
@@ -3391,7 +3390,7 @@ def get_preflt_data(params, ri, target_r
@@ -3391,7 +3390,7 @@
shell_cmd += ' >' + out_unmapped
retcode=0
try:
- print >> run_log, shell_cmd
+ print(shell_cmd, file=run_log)
+ print(shell_cmd, file=run_log, flush=True)
if do_use_zpacker:
prep_proc = subprocess.Popen(prep_cmd,
stdout=subprocess.PIPE,
@@ -3414,7 +3413,7 @@ def get_preflt_data(params, ri, target_r
@@ -3414,7 +3413,7 @@
if retcode:
die(fail_str+"Error running 'prep_reads'\n"+log_tail(log_fname))
......@@ -551,7 +572,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
errmsg=fail_str+str(o)
die(errmsg+"\n"+log_tail(log_fname))
if not out_bam: um_reads.close()
@@ -3809,7 +3808,7 @@ def get_version():
@@ -3809,7 +3808,7 @@
return "__VERSION__"
def mlog(msg):
......@@ -560,7 +581,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
def test_input_file(filename):
try:
@@ -3835,7 +3834,7 @@ def validate_transcriptome(params):
@@ -3835,7 +3834,7 @@
inf.close()
dlst = fline.split()
if len(dlst)>2:
......@@ -569,16 +590,20 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
else:
return False
tlst=tfa+".tlst"
@@ -3899,7 +3898,7 @@ def main(argv=None):
run_log = open(logging_dir + "run.log", "w", 0)
@@ -3896,10 +3895,10 @@
th_logp("-----------------------------------------------")
global run_log
- run_log = open(logging_dir + "run.log", "w", 0)
+ run_log = open(logging_dir + "run.log", "w")
global run_cmd
run_cmd = " ".join(run_argv)
- print >> run_log, run_cmd
+ print(run_cmd, file=run_log)
+ print(run_cmd, file=run_log, flush=True)
check_bowtie(params)
check_samtools()
@@ -4097,7 +4096,7 @@ def main(argv=None):
@@ -4097,7 +4096,7 @@
th_log("A summary of the alignment counts can be found in %salign_summary.txt" % output_dir)
th_log("Run complete: %s elapsed" % formatTD(duration))
......@@ -595,7 +620,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
# encoding: utf-8
"""
bed_to_juncs.py
@@ -32,7 +32,7 @@ def main(argv=None):
@@ -32,7 +32,7 @@
try:
try:
opts, args = getopt.getopt(argv[1:], "h", ["help"])
......@@ -604,7 +629,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
raise Usage(msg)
for option, value in opts:
@@ -45,8 +45,8 @@ def main(argv=None):
@@ -45,8 +45,8 @@
cols = line.split()
line_num += 1
if len(cols) < 12:
......@@ -615,7 +640,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
continue
chromosome = cols[0]
orientation = cols[5]
@@ -56,12 +56,12 @@ def main(argv=None):
@@ -56,12 +56,12 @@
right_pos = int(cols[1]) + block_starts[1]
#print "%s\t%d\t%d\t%s" % (chromosome, left_pos, right_pos, orientation)
counts = cols[4]
......@@ -640,7 +665,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
# encoding: utf-8
"""
contig_to_chr_coords.py
@@ -30,7 +30,7 @@ def main(argv=None):
@@ -30,7 +30,7 @@
try:
try:
opts, args = getopt.getopt(argv[1:], "ho:vbg", ["help", "output=", "bed", "gff"])
......@@ -649,7 +674,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
raise Usage(msg)
arg_is_splice = False
@@ -49,7 +49,7 @@ def main(argv=None):
@@ -49,7 +49,7 @@
arg_is_gff = True
if (arg_is_splice == False and arg_is_gff == False) or (arg_is_splice == True and arg_is_gff == True):
......@@ -658,7 +683,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
raise Usage(help_message)
if len(args) < 1:
@@ -76,7 +76,7 @@ def main(argv=None):
@@ -76,7 +76,7 @@
gff_file = open(args[1])
lines = gff_file.readlines()
......@@ -667,7 +692,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
for line in lines[1:]:
line = line.strip()
cols = line.split('\t')
@@ -97,7 +97,7 @@ def main(argv=None):
@@ -97,7 +97,7 @@
left_pos = contig[1] + int(cols[3])
right_pos = contig[1] + int(cols[4])
......@@ -676,7 +701,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
#print >>sys.stderr, "%s\t%d\t%d\t%s\t%s\t%s\t%s" % (contig[0], left_pos, right_pos,cols[3],cols[6],cols[0],cols[1])
@@ -105,7 +105,7 @@ def main(argv=None):
@@ -105,7 +105,7 @@
splice_file = open(args[1])
lines = splice_file.readlines()
......@@ -685,7 +710,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
for line in lines[1:]:
line = line.strip()
cols = line.split('\t')
@@ -123,11 +123,11 @@ def main(argv=None):
@@ -123,11 +123,11 @@
left_pos = contig[1] + int(cols[1])
right_pos = contig[1] + int(cols[2])
......@@ -709,7 +734,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
"""
sra_to_solid.py
@@ -23,8 +23,8 @@ if __name__ == "__main__":
@@ -23,8 +23,8 @@
if expect_qual % 4 == 3:
line = line[1:]
......@@ -728,7 +753,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
"""
@@ -116,12 +116,12 @@ class TopHatFusionParams:
@@ -116,12 +116,12 @@
"tex-table",
"gtf-file=",
"fusion-pair-dist="])
......@@ -743,7 +768,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
sys.exit(0)
if option in ("-h", "--help"):
raise Usage(use_message)
@@ -242,7 +242,7 @@ def prepare_output_dir():
@@ -242,7 +242,7 @@
else:
try:
os.makedirs(tmp_dir)
......@@ -752,7 +777,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
die("\nError creating directory %s (%s)" % (tmp_dir, o))
@@ -269,7 +269,7 @@ def check_samples():
@@ -269,7 +269,7 @@
if prev_list != curr_list:
sample_list = open(sample_list_filename, 'w')
for sample in curr_list:
......@@ -761,7 +786,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
sample_list.close()
return True
else:
@@ -303,9 +303,9 @@ def map_fusion_kmer(bwt_idx_prefix, para
@@ -303,9 +303,9 @@
fusion_file.close()
fusion_seq_fa = open(output_dir + "fusion_seq.fa", 'w')
......@@ -774,7 +799,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
fusion_seq_fa.close()
@@ -322,14 +322,14 @@ def map_fusion_kmer(bwt_idx_prefix, para
@@ -322,14 +322,14 @@
bwtout_file.close()
kmer_map = open(fusion_kmer_file_name, 'w')
......@@ -793,7 +818,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
fusion_kmer_file_name = output_dir + "fusion_seq.map"
@@ -547,7 +547,7 @@ def filter_fusion(bwt_idx_prefix, params
@@ -547,7 +547,7 @@
tmaps.add_map(1, startR, endR, '-', fusion.posR)
tmaps.add_map(1, startR, endR, '+', fusion.posR)
......@@ -802,7 +827,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
if len(m)==0:
raise Exception()
@@ -698,7 +698,7 @@ def filter_fusion(bwt_idx_prefix, params
@@ -698,7 +698,7 @@
return min_value
......@@ -811,7 +836,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
sample_name = fusion.split("/")[0][len("tophat_"):]
data = os.getcwd().split('/')[-1]
@@ -894,7 +894,7 @@ def filter_fusion(bwt_idx_prefix, params
@@ -894,7 +894,7 @@
fusion_file.close()
......@@ -820,7 +845,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
seq_chr_dic = {}
seq_chr_file = open(output_dir + "fusion_seq.map", 'r')
@@ -976,7 +976,7 @@ def filter_fusion(bwt_idx_prefix, params
@@ -976,7 +976,7 @@
juncs_file = file + '/junctions.bed'
if not os.path.exists(juncs_file):
juncs_file = None
......@@ -829,7 +854,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
ref_file = "refGene.txt"
if not os.path.exists(ref_file):
@@ -987,20 +987,20 @@ def filter_fusion(bwt_idx_prefix, params
@@ -987,20 +987,20 @@
ens_file = None
if juncs_file is None and ref_file is None and ens_file is None:
......@@ -854,7 +879,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
@@ -1035,7 +1035,7 @@ def wait_pids(pids):
@@ -1035,7 +1035,7 @@
def do_blast(params):
......@@ -863,7 +888,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
file_name = output_dir + "potential_fusion.txt"
blast_genomic_out = output_dir + "blast_genomic"
@@ -1111,7 +1111,7 @@ def do_blast(params):
@@ -1111,7 +1111,7 @@
blast(blast_nt, seq, blast_nt_out)
if not os.path.exists(output_dir + "blast_nt/" + seq ):
......@@ -872,7 +897,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
if params.num_threads <= 1:
work()
else:
@@ -1437,7 +1437,7 @@ def read_dist(params):
@@ -1437,7 +1437,7 @@
for i in range(len(alignments_list)):
output_region(sample_name, alignments_list[i], reads_list[i])
......@@ -881,7 +906,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
file_name = output_dir + "potential_fusion.txt"
file = open(file_name, 'r')
@@ -1465,7 +1465,7 @@ def read_dist(params):
@@ -1465,7 +1465,7 @@
pids = [0 for i in range(params.num_threads)]
......@@ -890,7 +915,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
bam_file_name = 'tophat_%s/accepted_hits.bam' % sample_name
if not os.path.exists(bam_file_name):
continue
@@ -1473,11 +1473,11 @@ def read_dist(params):
@@ -1473,11 +1473,11 @@
increment = 50
for i in range((len(list) + increment - 1) / increment):
temp_list = list[i*increment:(i+1)*increment]
......@@ -904,7 +929,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
fusion = fusion.split()
alignments_list.append([fusion[0], int(fusion[1]), int(fusion[2]), fusion[3]])
@@ -2010,7 +2010,7 @@ def generate_html(params):
@@ -2010,7 +2010,7 @@
num_fusions = 0
num_alternative_splicing_with_same_fusion = 0
......@@ -913,7 +938,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
num_fusions += 1
num_alternative_splicing_with_same_fusion += (value - 1)
@@ -2215,20 +2215,20 @@ def generate_html(params):
@@ -2215,20 +2215,20 @@
indices_list += c["index"]
indices_list = sorted(indices_list)
......@@ -944,7 +969,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
html_prev.append(r'<HTML>')
html_prev.append(r'<HEAD>')
@@ -2261,7 +2261,7 @@ def generate_html(params):
@@ -2261,7 +2261,7 @@
chr1, chr2 = cluster["chr"].split('-')
if params.tex_table:
......@@ -953,7 +978,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
html_post.append(r'<P><P><P><BR>')
html_post.append(r'%d. %s %s' % (c+1, cluster["chr"], cluster["dir"]))
@@ -2287,16 +2287,16 @@ def generate_html(params):
@@ -2287,16 +2287,16 @@
else:
sample_name2 = "testes"
......@@ -973,7 +998,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
(sample_name,
fusion["gene1"],
chr1,
@@ -2307,7 +2307,7 @@ def generate_html(params):
@@ -2307,7 +2307,7 @@
stats[0],
stats[1],
stats[2],
......@@ -982,7 +1007,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
html_post.append(r'<TR><TD ALIGN="LEFT"><a href="#fusion_%d">%s</a></TD>' % (i, sample_name))
html_post.append(r'<TD ALIGN="LEFT">%s</TD>' % fusion["gene1"])
@@ -2534,7 +2534,7 @@ def generate_html(params):
@@ -2534,7 +2534,7 @@
chr2_exon_list = combine_exon_list(chr2_exon_list)
max_intron_length = 100
......@@ -991,7 +1016,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
exon = exon_list[0]
chr_length = exon[1] - exon[0] + 1
if x <= exon[1]:
@@ -2784,19 +2784,19 @@ def generate_html(params):
@@ -2784,19 +2784,19 @@
html_body.append(r'<BODY text="#000000" bgcolor="#FFFFFF" onload="%s">' % fusion_gene_draw_str)
for line in html_prev + javascript + html_body + html_post:
......@@ -1016,7 +1041,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
# Cufflinks-Fusion
fusion_gene_list = []
@@ -2833,7 +2833,7 @@ def tmp_name():
@@ -2833,7 +2833,7 @@
def die(msg=None):
if msg is not None:
......@@ -1025,7 +1050,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
sys.exit(1)
@@ -2881,8 +2881,8 @@ def main(argv=None):
@@ -2881,8 +2881,8 @@
bwt_idx_prefix = args[0]
......@@ -1036,7 +1061,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
start_time = datetime.now()
prepare_output_dir()
@@ -2907,16 +2907,16 @@ def main(argv=None):
@@ -2907,16 +2907,16 @@
run_log = open(logging_dir + "run.log", "w", 0)
global run_cmd
run_cmd = " ".join(argv)
......@@ -1061,7 +1086,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
--- a/configure.ac
+++ b/configure.ac
@@ -7,7 +7,7 @@ AC_CONFIG_HEADERS([config.h])
@@ -7,7 +7,7 @@
# AC_CONFIG_AUX_DIR([build-aux])
AM_INIT_AUTOMAKE
......@@ -1070,7 +1095,7 @@ Last-Update: Fri, 11 Oct 2019 09:54:16 +0200
# Make sure CXXFLAGS is defined so that AC_PROG_CXX doesn't set it.
CXXFLAGS="$CXXFLAGS"
@@ -131,6 +131,6 @@ echo \
@@ -131,6 +131,6 @@
"
if test x"${PYTHON}" = x":" || ! test -x "${PYTHON}"; then
......