Skip to content

Commit

Permalink
fix cases when chromosome shared by 2 but not all
Browse files Browse the repository at this point in the history
  • Loading branch information
lldelisle committed Sep 26, 2023
1 parent d5ff676 commit f0c8223
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions deeptools/writeBedGraph_bam_and_bw.py
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,7 @@ def writeBedGraph(
chromNamesAndSize, __ = getCommonChrNames(bamHandles, verbose=verbose)
else:
genomeChunkLength = int(10e6)
cCommon = []
cCommon_number = {}
chromNamesAndSize = {}
for fileName, fileFormat in bamOrBwFileList:
if fileFormat == 'bigwig':
Expand All @@ -180,7 +180,7 @@ def writeBedGraph(

for chromName, size in list(fh.chroms().items()):
if chromName in chromNamesAndSize:
cCommon.append(chromName)
cCommon_number[chromName] += 1
if chromNamesAndSize[chromName] != size:
print("\nWARNING\n"
"Chromosome {} length reported in the "
Expand All @@ -193,14 +193,16 @@ def writeBedGraph(
chromNamesAndSize[chromName], size)
else:
chromNamesAndSize[chromName] = size
cCommon_number[chromName] = 1
fh.close()

# get the list of common chromosome names and sizes
if len(bamOrBwFileList) == 1:
chromNamesAndSize = [(k, v) for k, v in chromNamesAndSize.items()]
else:
chromNamesAndSize = [(k, v) for k, v in chromNamesAndSize.items()
if k in cCommon]
if k in cCommon_number and
cCommon_number[k] == len(bamOrBwFileList)]

if region:
# in case a region is used, append the tilesize
Expand Down

0 comments on commit f0c8223

Please sign in to comment.