Skip to content

Commit 4c7566c

Browse files
committed
modified: TIDDIT.py
modified: src/TIDDIT.cpp modified: src/TIDDIT_calling.py modified: src/TIDDIT_coverage.py modified: src/TIDDIT_signals.py
1 parent 93c7778 commit 4c7566c

File tree

5 files changed

+22
-21
lines changed

5 files changed

+22
-21
lines changed

TIDDIT.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
sys.path.insert(0, '{}/src/'.format(wd))
88
import TIDDIT_calling
99

10-
version = "2.6.0"
10+
version = "2.7.0"
1111
parser = argparse.ArgumentParser("""TIDDIT-{}""".format(version),add_help=False)
1212
parser.add_argument('--sv' , help="call structural variation", required=False, action="store_true")
1313
parser.add_argument('--cov' , help="generate a coverage bed file", required=False, action="store_true")
@@ -37,14 +37,14 @@
3737
args= parser.parse_args()
3838
args.wd=os.path.dirname(os.path.realpath(__file__))
3939
if args.l < 2:
40-
print "error, too low --l value!"
40+
print ("error, too low --l value!")
4141
quit()
4242
if args.ref:
4343
if not os.path.isfile(args.ref):
44-
print "error, could not find the reference file"
44+
print ("error, could not find the reference file")
4545
quit()
4646
if not os.path.isfile(args.bam):
47-
print "error, could not find the bam file"
47+
print ("error, could not find the bam file")
4848
quit()
4949

5050
command_str="{}/bin/TIDDIT --sv -b {} -o {} -p {} -r {} -q {} -n {} -s {}".format(args.wd,args.bam,args.o,args.p,args.r,args.q,args.n,args.s)

src/TIDDIT.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ int main(int argc, char **argv) {
4545
int min_variant_size= 100;
4646
int sample = 100000000;
4747
string outputFileHeader ="output";
48-
string version = "2.6.0";
48+
string version = "2.7.0";
4949

5050
//collect all options as a vector
5151
vector<string> arguments(argv, argv + argc);

src/TIDDIT_calling.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -212,11 +212,11 @@ def cluster(args):
212212
if not args.e:
213213
args.e=int(math.sqrt(library_stats["MeanInsertSize"]*2)*12)
214214
n=1
215-
print "clustering signals on chromosome:"
215+
print ("clustering signals on chromosome:")
216216
calls={}
217217
for chrA in chromosomes:
218218
calls[chrA] =[]
219-
print "{}".format(chrA)
219+
print ("{}".format(chrA))
220220
for chrB in chromosomes:
221221
signal_data=numpy.array([ [hit[0],hit[1],hit[2],hit[3],hit[4],hit[5],hit[6],hit[7]] for hit in args.c.execute('SELECT posA,posB,forwardA,qualA,forwardB,qualB,resolution,name FROM TIDDITcall WHERE chrA == \'{}\' AND chrB == \'{}\''.format(chrA,chrB)).fetchall()])
222222

@@ -292,8 +292,8 @@ def cluster(args):
292292
output="\t".join(output)+"\n"
293293
outfile.write(output)
294294

295-
print "variant clustering completed in {}".format(time.time()-start_time)
296-
print "Work complete!"
295+
print ("variant clustering completed in {}".format(time.time()-start_time))
296+
print ("Work complete!")
297297
os.remove("{}.db".format(args.o))
298298
return()
299299

src/TIDDIT_coverage.py

Lines changed: 10 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ def coverage(args):
1616
coverage_data={}
1717
chromosome_index={}
1818
for chromosome in chromosome_size:
19-
coverage_data[chromosome]=numpy.zeros( (chromosome_size[chromosome],3) )
19+
coverage_data[chromosome]=numpy.zeros( (chromosome_size[chromosome],3), dtype=numpy.float32 )
2020
chromosome_index[chromosome]=0
2121

2222
for line in open(args.o+".tab"):
@@ -35,7 +35,8 @@ def determine_ploidy(args,chromosomes,coverage_data,Ncontent,library_stats):
3535
library_stats["chr_cov"]={}
3636
ploidies={}
3737
avg_coverage=[]
38-
cov=[]
38+
39+
cov=numpy.array([],dtype=numpy.float32)
3940
for chromosome in chromosomes:
4041
try:
4142
if args.ref:
@@ -46,17 +47,16 @@ def determine_ploidy(args,chromosomes,coverage_data,Ncontent,library_stats):
4647

4748
if len(chr_cov):
4849
chromosomal_average=numpy.median(chr_cov)
49-
cov+= list(chr_cov)
50+
cov = numpy.append(cov,chr_cov)
5051
else:
5152
chromosomal_average=0
5253
library_stats["chr_cov"][chromosome]=chromosomal_average
5354

5455
except:
55-
print "error: reference mismatch!"
56-
print "make sure that the contigs of the bam file and the reference match"
56+
print ("error: reference mismatch!")
57+
print ("make sure that the contigs of the bam file and the reference match")
5758
quit()
5859

59-
cov=numpy.array(cov)
6060
if len(cov):
6161
coverage_norm=numpy.median(cov)
6262
else:
@@ -93,7 +93,7 @@ def determine_ploidy(args,chromosomes,coverage_data,Ncontent,library_stats):
9393

9494
#normalise the coverage based on GC content
9595
def gc_norm(args,median_coverage,normalising_chromosomes,coverage_data,Ncontent):
96-
gc_vals=[0., 0.01, 0.02, 0.03, 0.04, 0.05, 0.06, 0.07, 0.08, 0.09, 0.1 , 0.11, 0.12, 0.13, 0.14, 0.15, 0.16, 0.17, 0.18, 0.19, 0.2 , 0.21, 0.22, 0.23, 0.24, 0.25, 0.26, 0.27, 0.28, 0.29, 0.3 , 0.31, 0.32, 0.33, 0.34, 0.35, 0.36, 0.37, 0.38, 0.39, 0.4 , 0.41, 0.42, 0.43, 0.44, 0.45, 0.46, 0.47, 0.48, 0.49, 0.5 , 0.51, 0.52, 0.53, 0.54, 0.55, 0.56, 0.57, 0.58, 0.59, 0.6 , 0.61, 0.62, 0.63, 0.64, 0.65, 0.66, 0.67, 0.68, 0.69, 0.7 , 0.71, 0.72, 0.73, 0.74, 0.75, 0.76, 0.77, 0.78, 0.79, 0.8 , 0.81, 0.82, 0.83, 0.84, 0.85, 0.86, 0.87, 0.88, 0.89, 0.9 , 0.91, 0.92, 0.93, 0.94, 0.95, 0.96, 0.97, 0.98, 0.99, 1]
96+
gc_vals=range(0,101)
9797
gc_dict={}
9898

9999
for gc in gc_vals:
@@ -130,7 +130,7 @@ def retrieve_N_content(args):
130130
Ncontent={}
131131
chromosome_index={}
132132
for chromosome in chromosome_size:
133-
Ncontent[chromosome]=numpy.zeros( chromosome_size[chromosome] )
133+
Ncontent[chromosome]=numpy.zeros( chromosome_size[chromosome],dtype=numpy.int8 )
134134
chromosome_index[chromosome]=0
135135

136136
for line in open(args.o+".gc.tab"):
@@ -139,7 +139,8 @@ def retrieve_N_content(args):
139139

140140
content=line.strip().split()
141141
contig=content[0]
142-
gc=round(float(content[-2]),2)
142+
143+
gc=int(round(float(content[-2])*100))
143144
n=float(content[-1])
144145
if n > args.n_mask:
145146
Ncontent[contig][chromosome_index[contig]]=-1

src/TIDDIT_signals.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def sample(args,coverage_data,library_stats,samfile):
3636
index=numpy.random.randint(low=1000, high=len(coverage_data[chromosome][:,0])-1000,size=n)
3737
for i in range(0,n):
3838

39-
median_coverage=numpy.median(coverage_data[chromosome][index[i]:index[i]+region/bin_size,0])
39+
median_coverage=numpy.median(coverage_data[chromosome][index[i]:index[i]+int( math.floor(region/bin_size) ),0])
4040
roi=[index[i]*bin_size,index[i]*bin_size+region]
4141
if median_coverage == 0 or median_coverage > library_stats["Coverage"]*5:
4242
continue
@@ -239,15 +239,15 @@ def read_cigar(cigar):
239239

240240
if SC[i*2+1] == "M":
241241
length += int( SC[i*2] )
242-
bases=range(0,int( SC[i*2] ))
242+
bases=list(range(0,int( SC[i*2] )))
243243
for j in range(0,len(bases)):
244244
bases[j] += current_pos
245245

246246
aligned_range += bases
247247
current_pos += int( SC[i*2] )
248248
elif SC[i*2+1] == "I":
249249
insertions+=1
250-
bases=range(0,int( SC[i*2] ))
250+
bases=list(range(0,int( SC[i*2] )))
251251
for j in range(0,len(bases)):
252252
bases[j] += current_pos
253253
aligned_range += bases

0 commit comments

Comments
 (0)