-
Notifications
You must be signed in to change notification settings - Fork 243
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[hail] add contig_recoding to import_bed and import_locus_intervals #7013
Merged
Merged
Changes from 5 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
5f82d1c
[hail] add contig_recoding to import_bed and import_locus_intervals
53e5d08
fix
8fb9664
fix
60a50b1
address comments
ba4aa70
simplify
a79f9c7
fix test
6ca3ae4
banish assertTrue(... == ...)
18b72e6
more comments addressed
a5b81ce
fix
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -1223,6 +1223,15 @@ def test_import_locus_intervals_no_reference_specified(self): | |
self.assertTrue(t.count() == 2) | ||
self.assertEqual(t.interval.dtype.point_type, hl.tstruct(contig=hl.tstr, position=hl.tint32)) | ||
|
||
def test_import_locus_intervals_recoding(self): | ||
interval_file = resource('annotinterall.grch38.no.chr.interval_list') | ||
t = hl.import_locus_intervals(interval_file, | ||
contig_recoding={str(i): f'chr{i}' for i in [*range(1, 23), 'X', 'Y', 'M']}, | ||
reference_genome='GRCh38') | ||
t._force_count() | ||
self.assertTrue(t.count() == 3) | ||
self.assertEqual(t.interval.dtype.point_type, hl.tlocus('GRCh38')) | ||
|
||
def test_import_locus_intervals_badly_defined_intervals(self): | ||
interval_file = resource('example3.interval_list') | ||
t = hl.import_locus_intervals(interval_file, reference_genome='GRCh37', skip_invalid_intervals=True) | ||
|
@@ -1263,6 +1272,14 @@ def test_import_bed(self): | |
|
||
self.assertEqual(t.interval.collect(), hl.eval(expected)) | ||
|
||
def test_import_bed_recoding(self): | ||
bed_file = resource('some-missing-chr-grch38.bed') | ||
bed = hl.import_bed(bed_file, | ||
reference_genome='GRCh38', | ||
contig_recoding={str(i): f'chr{i}' for i in [*range(1, 23), 'X', 'Y', 'M']}) | ||
self.assertEqual(bed._force_count(), 3) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Shouldn't this be 5? |
||
self.assertEqual(bed.interval.dtype.point_type, hl.tlocus('GRCh38')) | ||
|
||
def test_import_bed_no_reference_specified(self): | ||
bed_file = resource('example1.bed') | ||
t = hl.import_bed(bed_file, reference_genome=None) | ||
|
3 changes: 3 additions & 0 deletions
3
hail/src/test/resources/annotinterall.grch38.no.chr.interval_list
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,3 @@ | ||
22 17333902 17370919 + A | ||
22 17348324 17348324 + B | ||
chr22 17348326 17348330 + B |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
track name="BedTest" | ||
20 2 10 gene0 | ||
20 1 14000000 gene1 | ||
20 17000000 18000000 gene2 | ||
chr20 63025510 63025520 gene3 | ||
chr20 5 5 gene4 |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You can combine these two lines as you did below.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
also, don't use assertTrue. use assertEqual, but standard python
assert t.count() == 3
is preferred with pytestThere was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I removed every occurrence of
assertTrue(... == ...)
from this file.