Skip to content

Commit

Permalink
refactor: modify tests
Browse files Browse the repository at this point in the history
  • Loading branch information
deliaBlue committed Jan 12, 2025
1 parent 85090da commit c40efce
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions scripts/tests/test_iso_name_tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,6 @@ def alns():
aln1.set_tag("NH", 2)
aln1.set_tag("HI", 1)

# Alignment with 3 insertions
aln2 = pysam.AlignedSegment()
aln2.cigarstring = "21M"
aln2.query_name = "8-2_1"
Expand Down Expand Up @@ -275,9 +274,9 @@ def test_get_tags_within_shift_range_1_extn(self, alns, intersect_dicts):
out_name, out_id_alias, out_ext_3 = intersect_dicts

tags = get_tags(
intersecting_mirna=out_name[aln_1.query_name],
intersecting_feat=out_name[aln_1.query_name],
alignment=aln_1,
extend=1,
shift=1,
)
expected = "hsa-miR-524-3p|1|1|21M|21|GAAGGCGCTTCCCTTTGGAGT"

Expand All @@ -289,9 +288,9 @@ def test_get_tags_out_shift_range(self, alns, intersect_dicts):
out_name, out_id_alias, out_ext_3 = intersect_dicts

tags = get_tags(
intersecting_mirna=out_name[aln_1.query_name],
intersecting_feat=out_name[aln_1.query_name],
alignment=aln_2,
extend=0,
shift=0,
)
assert tags == set()

Expand Down Expand Up @@ -368,6 +367,8 @@ def test_all_input(self, monkeypatch, bed_sam):
"alias",
"--extension",
"6",
"--shift",
"6",
],
)
args = parse_arguments().parse_args()
Expand Down Expand Up @@ -398,7 +399,7 @@ def test_main_empty_bed_file(
main(args)
captured = capsys.readouterr()

with open(empty_sam, "r") as out_file:
with open(empty_sam, encoding="utf-8") as out_file:
assert captured.out == out_file.read()

def test_main_empty_sam_file(
Expand All @@ -423,7 +424,7 @@ def test_main_empty_sam_file(
main(args)
captured = capsys.readouterr()

with open(empty_sam, "r") as out_file:
with open(empty_sam, encoding="utf-8") as out_file:
assert captured.out == out_file.read()

def test_main_bed_sam_file(self, monkeypatch, capsys, bed_sam):
Expand All @@ -445,13 +446,13 @@ def test_main_bed_sam_file(self, monkeypatch, capsys, bed_sam):
main(args)
captured = capsys.readouterr()

with open(output, "r") as out_file:
with open(output, encoding="utf-8") as out_file:
assert captured.out == out_file.read()

def test_main_bed_sam_extension_file(
self, monkeypatch, capsys, bed_sam_extension
):
"""Test main function with extension equals 6."""
"""Test main function with extension and allowed shit equal to 6."""
in_bed, in_sam, output = bed_sam_extension

monkeypatch.setattr(
Expand All @@ -465,13 +466,15 @@ def test_main_bed_sam_extension_file(
str(in_sam),
"--extension",
"6",
"--shift",
"6",
],
)
args = parse_arguments().parse_args()
main(args)
captured = capsys.readouterr()

with open(output, "r") as out_file:
with open(output, encoding="utf-8") as out_file:
assert captured.out == out_file.read()

def test_main_bed_sam_file_id(self, monkeypatch, capsys, bed_sam_id):
Expand All @@ -495,5 +498,5 @@ def test_main_bed_sam_file_id(self, monkeypatch, capsys, bed_sam_id):
main(args)
captured = capsys.readouterr()

with open(output, "r") as out_file:
with open(output, encoding="utf-8") as out_file:
assert captured.out == out_file.read()

0 comments on commit c40efce

Please sign in to comment.