Skip to content

Commit

Permalink
On branch temp
Browse files Browse the repository at this point in the history
data.py, utils.py: get_chrom_format(chrom) -> get_chrom_format(chroms)
instead of taking one chrom string, now takes a list of all the chroms
  • Loading branch information
yil8 committed Jan 9, 2014
1 parent be15d17 commit 1dfa9af
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 12 deletions.
6 changes: 3 additions & 3 deletions pyloh/preprocess/data.py
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ def segmentation_by_chrom(self, normal_bam, tumor_bam):
chrom_num = len(chrom_ID_list)

sam_SQ = normal_bam.header['SQ']
sam_chrom_format = get_chrom_format(sam_SQ[0]['SN'])
sam_chrom_format = get_chrom_format(map(lambda x:x['SN'], sam_SQ))
chrom_lens = self._get_chrom_lens(chrom_ID_list, sam_SQ)

for i in range(0, chrom_num):
Expand All @@ -128,11 +128,11 @@ def segmentation_by_bed(self, normal_bam, tumor_bam, bed_file_name):
chrom_start = constants.CHROM_START

sam_SQ = normal_bam.header['SQ']
sam_chrom_format = get_chrom_format(sam_SQ[0]['SN'])
sam_chrom_format = get_chrom_format(map(lambda x:x['SN'], sam_SQ))
chrom_lens = self._get_chrom_lens(chrom_ID_list, sam_SQ)

bed_chroms, bed_starts, bed_ends = BEDParser(bed_file_name)
bed_chrom_format = get_chrom_format(bed_chroms[0])
bed_chrom_format = get_chrom_format(bed_chroms)
bed_num = len(bed_chroms)

for i in range(0, bed_num):
Expand Down
28 changes: 19 additions & 9 deletions pyloh/preprocess/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,16 +54,26 @@ def chrom_name_to_ID(chrom_name):

return ID

def get_chrom_format(chrom):
if chrom[0:3] == 'chr':
return 'UCSC'
def get_chrom_format(chroms):
format = 'NONE'

for chrom in chroms:
if chrom[0:3] == 'chr':
format = 'UCSC'
break
else:
try:
ID = int(chrom)
format = 'ENSEMBL'
break
except:
pass

if format == 'NONE':
print 'Error: %s not supported' % (chrom)
sys.exit(-1)
else:
try:
ID = int(chrom)
return 'ENSEMBL'
except:
print 'Error: %s not supported' % (chrom)
sys.exit(-1)
return format

def normal_heterozygous_filter(counts):
BAF_N_MAX = constants.BAF_N_MAX
Expand Down

0 comments on commit 1dfa9af

Please sign in to comment.