Skip to content

Commit

Permalink
Merge branch 'main' into version_4.54
Browse files Browse the repository at this point in the history
  • Loading branch information
northwestwitch authored Jun 9, 2022
2 parents d1136d0 + 56509a7 commit 6f39d72
Show file tree
Hide file tree
Showing 4 changed files with 24 additions and 8 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,7 @@ About changelog [here](https://keepachangelog.com/en/1.0.0/)
- Variants pagination after pressing "Filter variants" or "Clinical filter"
- Layout of buttons Matchmaker submission panel (case page)
- Removing cases from Matchmaker (simplified code and fixed functionality)
- Reintroduce check for missing alignment files purged from server

## [4.53]
### Added
Expand Down
10 changes: 8 additions & 2 deletions scout/server/blueprints/variant/controllers.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import logging
import os
from base64 import b64encode
from datetime import date

Expand Down Expand Up @@ -132,8 +133,13 @@ def has_rna_tracks(case_obj):
# Display junctions track if available for any of the individuals
for ind in case_obj.get("individuals", []):
# Track contains 2 files and they should both be present
if all([ind.get("splice_junctions_bed"), ind.get("rna_coverage_bigwig")]):
return True
splicej_bed = ind.get("splice_junctions_bed")
rna_cov_bw = ind.get("rna_coverage_bigwig")
if None in [splicej_bed, rna_cov_bw]:
continue
if False in [os.path.exists(splicej_bed), os.path.exists(rna_cov_bw)]:
continue
return True
return False


Expand Down
6 changes: 4 additions & 2 deletions scout/server/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -181,7 +181,8 @@ def case_has_alignments(case_obj):
"""
case_obj["bam_files"] = False # Availability of alignments for autosomal chromosomes
for ind in case_obj.get("individuals"):
if ind.get("bam_file") and ind.get("bam_file") != "":
bam_path = ind.get("bam_file")
if bam_path and os.path.exists(bam_path):
case_obj["bam_files"] = True
return

Expand All @@ -194,7 +195,8 @@ def case_has_mt_alignments(case_obj):
"""
case_obj["mt_bams"] = False # Availability of alignments for MT chromosome
for ind in case_obj.get("individuals"):
if ind.get("mt_bam") and ind.get("mt_bam") != "":
mt_bam_path = ind.get("mt_bam")
if mt_bam_path and os.path.exists(mt_bam_path):
case_obj["mt_bams"] = True
return

Expand Down
15 changes: 11 additions & 4 deletions tests/server/blueprints/variant/test_variant_controllers.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,16 +84,23 @@ def test_tx_overview(app):
assert key in tx


def test_has_rna_tracks(case_obj):
def test_has_rna_tracks(case_obj, tmpdir):
"""Test the function that returns True if any individual of a case has RNA tracks available"""

# GIVEN a case with an individual with RNA tracks:
# GIVEN an individual with splice junctions bed file and rna coverage track
splicej_bed = tmpdir.join("test.bed")
rna_cov_bw = tmpdir.join("test.BigWig")
splicej_bed.write("content")
rna_cov_bw.write("content")

for ind in case_obj["individuals"]:
if ind["phenotype"] == 1: # Lets's assume only the affected individuals has RNA data
continue
ind["splice_junctions_bed"] = "test.bed"
ind["rna_coverage_bigwig"] = "test.BigWig"

ind["splice_junctions_bed"] = str(splicej_bed)
ind["rna_coverage_bigwig"] = str(rna_cov_bw)

# THEN case should result having RNA tracks
assert has_rna_tracks(case_obj) is True


Expand Down

0 comments on commit 6f39d72

Please sign in to comment.