Skip to content

Commit

Permalink
mixclone/preprocess/data.py, mixclone/preprocess/utils.py: chrom_idxs…
Browse files Browse the repository at this point in the history
… bug fixed
  • Loading branch information
yil8 committed Dec 4, 2015
1 parent 97dddd3 commit 7239369
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
4 changes: 2 additions & 2 deletions mixclone/preprocess/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ def load_segments(self, normal_bam, tumor_bam, bed_file_name):

sam_SQ = normal_bam.header['SQ']
sam_chrom_format = get_chrom_format(map(lambda x:x['SN'], sam_SQ))
chrom_lens = get_chrom_lens(chrom_idx_list, sam_SQ)
chrom_lens, chrom_idxs = get_chrom_lens_idxs(chrom_idx_list, sam_SQ)

bed_chroms, bed_starts, bed_ends = BEDParser(bed_file_name)
bed_chrom_format = get_chrom_format(bed_chroms)
Expand All @@ -69,7 +69,7 @@ def load_segments(self, normal_bam, tumor_bam, bed_file_name):
sys.stdout.flush()
continue

chrom_lst_idx = chrom_idx_list.index(chrom_idx)
chrom_lst_idx = chrom_idxs.index(chrom_idx)

if bed_starts[i] < chrom_start or bed_ends[i] > chrom_lens[chrom_lst_idx]:
print 'Out of range chromsome {0}, segment {1} excluded...'.format(bed_chroms[i], seg_name)
Expand Down
6 changes: 4 additions & 2 deletions mixclone/preprocess/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,17 +84,19 @@ def get_chrom_format(chroms):
else:
return format

def get_chrom_lens(chrom_idx_list, sam_SQ):
def get_chrom_lens_idxs(chrom_idx_list, sam_SQ):
chrom_lens = []
chrom_idxs = []
for i in range(0, len(chrom_idx_list)):
chrom_idx = chrom_idx_list[i]

for j in range(0, len(sam_SQ)):
if chrom_idx == chrom_name_to_idx(sam_SQ[j]['SN']):
chrom_lens.append(int(sam_SQ[j]['LN']))
chrom_idxs.append(chrom_idx)
break

return chrom_lens
return (chrom_lens, chrom_idxs)

def get_segment_name(chrom_name, start, end):

Expand Down

0 comments on commit 7239369

Please sign in to comment.