Skip to content

Commit

Permalink
Merge pull request #109 from lldelisle/smallStuffs
Browse files Browse the repository at this point in the history
Small stuffs
  • Loading branch information
bgruening authored Oct 23, 2019
2 parents f634dc6 + d5dfa88 commit 42e4815
Show file tree
Hide file tree
Showing 7 changed files with 37 additions and 5 deletions.
34 changes: 33 additions & 1 deletion pygenometracks/readBed.py
Original file line number Diff line number Diff line change
Expand Up @@ -188,7 +188,7 @@ def get_bed_interval(self, bed_line):
"not have 8 fields.".format(self.line_number, bed_line)

elif self.file_type == 'bed6':
# It is possible that the number of fields was standard.
# It is possible that the number of fields was not standard.
# To be able to process it as bed6, the extra-fields are removed.
line_data = line_data[:6]

Expand Down Expand Up @@ -270,6 +270,8 @@ def get_bed_interval(self, bed_line):
"Start position larger or equal than end" \
" for line #{}:\n{}\n".format(self.line_number,
bed_line)
if len(line_values) == 12:
check_bed12(line_values, self.line_number, bed_line)

if len(line_values) < 6:
assert len(line_values) > 2, \
Expand All @@ -285,3 +287,33 @@ def get_bed_interval(self, bed_line):
for i in range(6)]

return self.BedInterval._make(line_values)


def check_bed12(line_values, line_number, bed_line):
block_counts = line_values[9]
block_sizes = line_values[10]
block_relative_starts = line_values[11]
assert len(block_sizes) == block_counts, \
"The number of blocks: {} does not correspond to" \
"the number of blocks sizes: {}\nline #{}:\n" \
"{}".format(block_counts, str(block_sizes),
line_number, bed_line)
assert len(block_relative_starts) == block_counts, \
"The number of blocks: {} does not correspond to" \
"the number of blocks relative starts: {}\nline #{}:\n" \
"{}".format(block_counts, str(block_relative_starts),
line_number, bed_line)
for i in range(block_counts):
block_start = line_values[1] + block_relative_starts[i]
block_end = block_start + block_sizes[i]
assert block_start <= line_values[2], \
"The block number {} of line {} has a starting position " \
"greater than the end of the feature:\n{}The" \
" 12th field of a bed12 should contains relative start" \
" positions of blocks.".format(i, line_number, bed_line)
assert block_end <= line_values[2], \
"The block number {} of line {} has an ending position " \
"greater than the end of the feature:\n{}The" \
" 12th field of a bed12 should contains relative start" \
" positions of blocks and the 11th field should contains" \
" the length of each block.".format(i, line_number, bed_line)
Binary file modified pygenometracks/tests/test_data/master_narrowPeak.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file modified pygenometracks/tests/test_data/master_narrowPeak2.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 1 addition & 1 deletion pygenometracks/tests/test_data/narrow_peak.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ show labels = no
color = #0000FF80
use summit = no
width adjust = 4
title = show labels=no;width adjust=3
title = show labels=no;use summit=no;width adjust=4

[spacer]

Expand Down
2 changes: 1 addition & 1 deletion pygenometracks/tests/test_data/narrow_peak2.ini
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ show labels = no
color = #0000FF80
use summit = no
width adjust = 4
title = show labels=no;width adjust=3
title = show labels=no;use summit=no;width adjust=4

[spacer]

Expand Down
2 changes: 1 addition & 1 deletion pygenometracks/tests/test_narrowPeakTrack.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@
color = #0000FF80
use summit = no
width adjust = 4
title = show labels=no;width adjust=3
title = show labels=no;use summit=no;width adjust=4
[spacer]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
numpy >=1.16
matplotlib >=3.0
intervaltree >=2.1.0
pybigwig >=0.3.4
pybigwig >=0.3.16
future >=0.17.0
hicmatrix >=9
pysam >=0.14
Expand Down

0 comments on commit 42e4815

Please sign in to comment.