Skip to content

Commit

Permalink
make CodeCoverage happy
Browse files Browse the repository at this point in the history
  • Loading branch information
Bribak committed Feb 18, 2025
1 parent 8f80e89 commit 1039d88
Showing 1 changed file with 25 additions and 1 deletion.
26 changes: 25 additions & 1 deletion tests/test_core_functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -771,6 +771,7 @@ def test_canonicalize_iupac():
assert canonicalize_iupac("WURCS=2.0/5,7,6/[u2122h_2*NCC/3=O][a2122h-1b_1-5_2*NCC/3=O][a1122h-1b_1-5][a1122h-1a_1-5][a2112h-1b_1-5_2*NCC/3=O_4*OSO/3=O/3=O]/1-2-3-4-2-5-4/a4-b1_b4-c1_c3-d1_c6-g1_d2-e1_e4-f1") == "GalNAc4S(b1-4)GlcNAc(b1-2)Man(a1-3)[Man(a1-6)]Man(b1-4)GlcNAc(b1-4)GlcNAc"
assert canonicalize_iupac("WURCS=2.0/8,15,14/[u2122h_2*NCC/3=O][a2122h-1b_1-5_2*NCC/3=O][a1122h-1b_1-5][a1122h-1a_1-5][a1221m-1a_1-5][a2112h-1b_1-5][Aad21122h-2a_2-6_5*NCCO/3=O][Aad21122h-2a_2-6_5*NCC/3=O]/1-2-3-4-2-5-6-7-8-4-2-5-6-8-5/a4-b1_a6-o1_b4-c1_c3-d1_c6-j1_d2-e1_e3-f1_e4-g1_h8-i2_j2-k1_k3-l1_k4-m1_h2-g3|g6_n2-m3|m6 ") == "Neu5Ac(a2-8)Neu5Gc(a2-3/6)Gal(b1-4)[Fuc(a1-3)]GlcNAc(b1-2)Man(a1-3)[Neu5Ac(a2-3/6)Gal(b1-4)[Fuc(a1-3)]GlcNAc(b1-2)Man(a1-6)]Man(b1-4)GlcNAc(b1-4)[Fuc(a1-6)]GlcNAc"
assert canonicalize_iupac("WURCS=2.0/3,5,4/[a2122h-1b_1-5_2*NCC/3=O][a1122h-1b_1-5][a1122h-1a_1-5]/1-1-2-3-3/a4-b1_b4-c1_c3-d1_c6-e1") == "Man(a1-3)[Man(a1-6)]Man(b1-4)GlcNAc(b1-4)GlcNAc"
assert canonicalize_iupac("WURCS=2.0/3,5,4/[a2122h-1b_1-5_2*NCC/3=O][a1221m-1b_1-5][a1122h-1a_1-5]/1-1-2-3-3/a4-b1_b4-c1_c3-d1_c6-e1") == "Man(a1-3)[Man(a1-6)]Fuc(b1-4)GlcNAc(b1-4)GlcNAc"
assert canonicalize_iupac("WURCS=2.0/5,19,18/[a2122h-1x_1-5_2*NCC/3=O][a1122h-1x_1-5][a2112h-1x_1-5][Aad21122h-2x_2-6_5*NCC/3=O][a1221m-1x_1-5]/1-1-2-2-1-3-4-1-3-4-2-1-3-4-1-3-4-5-4/a?-b1_a?-r1_b?-c1_c?-d1_c?-k1_d?-e1_d?-h1_e?-f1_f?-g2_h?-i1_i?-j2_k?-l1_k?-o1_l?-m1_m?-n2_o?-p1_p?-q2_s2-a?|b?|c?|d?|e?|f?|g?|h?|i?|j?|k?|l?|m?|n?|o?|p?|q?|r?}") == "{Neu5Ac(a2-?)}Neu5Ac(a2-?)Gal(?1-?)GlcNAc(?1-?)[Neu5Ac(a2-?)Gal(?1-?)GlcNAc(?1-?)]Man(?1-?)[Neu5Ac(a2-?)Gal(?1-?)GlcNAc(?1-?)[Neu5Ac(a2-?)Gal(?1-?)GlcNAc(?1-?)]Man(?1-?)]Man(?1-?)GlcNAc(?1-?)[Fuc(a1-?)]GlcNAc"
assert canonicalize_iupac("WURCS=2.0/4,8,7/[u2122h_2*NCC/3=O][a2121A-1a_1-5][a2122h-1a_1-5_2*NCC/3=O][a2122A-1b_1-5]/1-2-3-4-3-2-3-4/a4-b1_b4-c1_c4-d1_d4-e1_e4-f1_f4-g1_g4-h1") == "GlcA(b1-4)GlcNAc(a1-4)IdoA(a1-4)GlcNAc(a1-4)GlcA(b1-4)GlcNAc(a1-4)IdoA(a1-4)GlcNAc"
assert canonicalize_iupac("WURCS=2.0/6,9,8/[a2122h-1a_1-5_2*NCC/3=O][a1221m-1a_1-5][a2122h-1b_1-5_2*NCC/3=O][a1122h-1b_1-5][a212h-1b_1-5][a1122h-1a_1-5]/1-2-3-4-5-6-3-6-3/a3-b1_a4-c1_c4-d1_d2-e1_d3-f1_d6-h1_f2-g1_h2-i1") == "GlcNAc(b1-2)Man(a1-3)[GlcNAc(b1-2)Man(a1-6)][Xyl(b1-2)]Man(b1-4)GlcNAc(b1-4)[Fuc(a1-3)]GlcNAc"
Expand Down Expand Up @@ -1118,6 +1119,14 @@ def test_get_matching_indices2():
assert result[0] == (1, 2, 0)
# Test unmatched brackets
assert len(list(get_matching_indices("[a[b", '[', ']'))) == 0
# Test escaped delimiters
assert len(list(get_matching_indices(r"[a\[b]", '[', ']'))) == 1
assert list(get_matching_indices(r"[a\[b]", '[', ']'))[0] == (1, 5, 0)
# Test extraneous closing delimiter
assert len(list(get_matching_indices("]abc[", '[', ']'))) == 0
# Test escaped closing delimiter
assert len(list(get_matching_indices(r"[a\]b]", '[', ']'))) == 1
assert list(get_matching_indices(r"[a\]b]", '[', ']'))[0] == (1, 5, 0)


def test_choose_correct_isoform():
Expand Down Expand Up @@ -1194,6 +1203,21 @@ def test_IUPAC_to_SMILES():
IUPAC_to_SMILES("Gal(b1-4)GlcNAc") # Should be list
except ImportError:
pytest.skip("glyles package not installed")
# Mock ImportError for chem dependencies
import builtins
original_import = builtins.__import__

def mock_import(name, *args, **kwargs):
if name == 'glyles':
raise ImportError()
return original_import(name, *args, **kwargs)

try:
builtins.__import__ = mock_import
with pytest.raises(ImportError, match=r"You must install the 'chem' dependencies to use this feature\. Try 'pip install glycowork\[chem\]'\."):
IUPAC_to_SMILES(["Gal(b1-4)GlcNAc"])
finally:
builtins.__import__ = original_import


def test_unwrap():
Expand Down Expand Up @@ -3683,7 +3707,7 @@ def test_get_lectin_array_ec_file_extension(extension):
})
group1 = ['sample1', 'sample2', 'sample3']
group2 = ['sample4', 'sample5', 'sample6']

tmp_dir = Path("test_tmp")
tmp_dir.mkdir(exist_ok=True)
filepath = tmp_dir / f"df.{extension}"
Expand Down

0 comments on commit 1039d88

Please sign in to comment.