Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 44 additions & 3 deletions api/tests/integration/ref/formats/biln.py.out
Original file line number Diff line number Diff line change
@@ -1,10 +1,51 @@
*** BILN interop ***
biln_bracketed_alias:BILN->HELM SUCCEED
biln_cap:BILN->HELM SUCCEED
biln_disulfides:BILN->HELM SUCCEED
biln_explicit_backbone:BILN->HELM SUCCEED
biln_large_bond_id:BILN->HELM SUCCEED
biln_star_alias:BILN->HELM SUCCEED
biln_three_chains:BILN->HELM SUCCEED
biln_two_backbones:BILN->HELM SUCCEED
biln_underscore_alias:BILN->HELM SUCCEED
biln_alphabetic_order:BILN->BILN SUCCEED
biln_amino_acid_count_order:BILN->BILN SUCCEED
biln_backbone_order:BILN->BILN SUCCEED
biln_bracketed_no_hyphen:BILN->BILN SUCCEED
biln_cycle_best:BILN->BILN SUCCEED
biln_cycle_reverse_rotation:BILN->BILN SUCCEED
biln_cycle_rotation:BILN->BILN SUCCEED
biln_cycle_with_external_bond_order:BILN->BILN SUCCEED
biln_cycle_with_extra_bond_order:BILN->BILN SUCCEED
biln_equal_chain_topology_order:BILN->BILN SUCCEED
biln_library_alias:BILN->BILN SUCCEED
biln_multiple_nonbackbone_order:BILN->BILN SUCCEED
biln_short_chain_order:BILN->BILN SUCCEED
biln_valid_large_bond_ids:BILN->BILN SUCCEED
helm_alias_to_biln_alias:HELM->BILN SUCCEED
helm_bracketed_alias:HELM->BILN SUCCEED
helm_cap:HELM->BILN SUCCEED
helm_chem_backbone:HELM->BILN SUCCEED
helm_chem_with_biln_code:HELM->BILN SUCCEED
helm_cycle:HELM->BILN SUCCEED
helm_star_alias:HELM->BILN SUCCEED
helm_three_chains:HELM->BILN SUCCEED
Test 'A(1,3)-C': got expected error 'Invalid BILN bond 1: expected two endpoints but found 1.'
Test 'A--C': got expected error 'Invalid BILN string: empty monomer.'
Test 'A-C(1,4)': got expected error 'Invalid BILN bond 1: expected two endpoints but found 1.'
helm_underscore_alias:HELM->BILN SUCCEED
Test 'CHEM1{[qweqwe]}$$$$V2.0': got expected error 'Only amino acids and CHEMs with BILN codes can get exported to BILN.'
Test 'PEPTIDE1{A}|RNA1{R(A)P}$$$$V2.0': got expected error 'Only amino acids and CHEMs with BILN codes can get exported to BILN.'
Test 'PEPTIDE1{[Abu].[Sar].[NMeL].V.[NMeL].A.[DAla].[NMeL].[NMeL].[NMeV].[NMeThr4RBut2enyl]}$PEPTIDE1,PEPTIDE1,1:R1-11:R2$$$V2.0': got expected error 'Only amino acids and CHEMs with BILN codes can get exported to BILN.'
Test 'PEPTIDE1{[Ac]}|PEPTIDE2{K}$PEPTIDE1,PEPTIDE2,1:R1-1:R3$$$V2.0': got expected error 'Cannot save in BILN format - unsupported attachment point 'R1'.'
Test KET 'custom_chem_without_biln_code': got expected error 'Only amino acids and CHEMs with BILN codes can get exported to BILN.'
Test KET 'unresolved_cap_invalid_attachment': got expected error 'Cannot save in BILN format - unsupported attachment point 'R1'.'
Test 'A(1,3)-C': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'A--C': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'A-C(-1,3)-D(2,3)-E.F-G-H(-1,3)-I-K(2,3)': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'A-C(1,3)-D(1,3)-E.F-G-H(1,3)-I-K(2,3)': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'A-C(1,4)': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'A-C(1,4)-D(2,3)-E.F-G-H(1,3)-I-K(2,3)': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'A-C(1.25,3)-D(2,3)-E.F-G-H(1.25,3)-I-K(2,3)': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'Ac(1,1).K(1,3)': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'Ac(1,4).K(1,3)': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'Cys_SEt': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test 'D-2Thi-D-D-gGlu-meF-G-Lys-al': got expected error 'The string cannot be interpreted as a valid BILN string.'
Test '[D-Cit](1,2)-aThr(1,1)(2,2)-meS(2,1)': got expected error 'The string cannot be interpreted as a valid BILN string.'
206 changes: 199 additions & 7 deletions api/tests/integration/tests/formats/biln.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,13 +25,39 @@
)

biln_to_helm = {
# Legacy integration coverage: terminal caps must keep their explicit
# non-backbone BILN bonds during import/export roundtrip.
"biln_cap": (
"Ac(1,2).A-K(1,3)",
"PEPTIDE1{[Ac]}|PEPTIDE2{A.K}$PEPTIDE1,PEPTIDE2,1:R2-2:R3$$$V2.0",
"PEPTIDE1{[ac]}|PEPTIDE2{A.K}$PEPTIDE1,PEPTIDE2,1:R2-2:R3$$$V2.0",
),
"biln_three_chains": (
"Ac(1,2).A-K(1,3)(2,2).Me(2,1)",
"PEPTIDE1{[Ac]}|PEPTIDE2{A.K}|PEPTIDE3{[Me]}$PEPTIDE1,PEPTIDE2,1:R2-2:R3|PEPTIDE2,PEPTIDE3,2:R2-1:R1$$$V2.0",
"PEPTIDE1{[ac]}|PEPTIDE2{A.K}|PEPTIDE3{[-Me]}$PEPTIDE1,PEPTIDE2,1:R2-2:R3|PEPTIDE2,PEPTIDE3,2:R2-1:R1$$$V2.0",
),
"biln_two_backbones": (
"A-C-D.E-F-G",
"PEPTIDE1{A.C.D}|PEPTIDE2{E.F.G}$$$$V2.0",
),
"biln_underscore_alias": (
"A-1Nal-Cys_Bn-C",
"PEPTIDE1{A.[1Nal].[Cys_Bn].C}$$$$V2.0",
),
"biln_bracketed_alias": (
"A-[D-1Nal]-[Cys_Bn]-[C]",
"PEPTIDE1{A.[D-1Nal].[Cys_Bn].C}$$$$V2.0",
),
"biln_star_alias": (
"A-D*-C",
"PEPTIDE1{A.[D*].C}$$$$V2.0",
),
"biln_large_bond_id": (
"A-C(7563,3).C(7563,3)",
"PEPTIDE1{A.C}|PEPTIDE2{C}$PEPTIDE1,PEPTIDE2,2:R3-1:R3$$$V2.0",
),
"biln_explicit_backbone": (
"[D-Cit](1,2).aThr(1,1)(2,2).meS(2,1)",
"PEPTIDE1{[D-Cit].[aThr].[meS]}$$$$V2.0",
),
"biln_disulfides": (
"D-T-H-F-P-I-C(1,3)-I-F-C(2,3)-C(3,3)-G-C(2,3)-C(4,3)-H-R-S-K-C(3,3)-G-M-C(4,3)-C(1,3)-K-T",
Expand All @@ -53,6 +79,79 @@
except IndigoException as e:
print(name + ":FAILED - " + getIndigoExceptionText(e))

biln_to_biln = {
"biln_cycle_best": (
"A(1,1)-C-D-E(1,2)",
"A(1,1)-C-D-E(1,2)",
),
"biln_cycle_rotation": (
"C(1,1)-D-E-A(1,2)",
"A(1,1)-C-D-E(1,2)",
),
"biln_cycle_reverse_rotation": (
"D(1,2)-C-A-E(1,1)",
"A(1,1)-C-D-E(1,2)",
),
"biln_bracketed_no_hyphen": (
"[D-2Thi]-[D]-[D-gGlu]-[meF]-[G]-[Lys-al]",
"[D-2Thi]-D-[D-gGlu]-meF-G-[Lys-al]",
),
"biln_backbone_order": (
"A-A-A-A-A-A.C-C-C-C.[PEG-2]-C-C-C-C-[PEG-2]",
"A-A-A-A-A-A.[PEG-2]-C-C-C-C-[PEG-2].C-C-C-C",
),
"biln_short_chain_order": (
"A-A-A6OH-A6OH-A6OH.C-C-C-C-C",
"A-A-A6OH-A6OH-A6OH.C-C-C-C-C",
),
"biln_amino_acid_count_order": (
"C-C-A6OH-A6OH-C-C.C-C-C-C-C-A6OH",
"C-C-C-C-C-A6OH.C-C-A6OH-A6OH-C-C",
),
"biln_alphabetic_order": (
"C-D-E-F-G-A6OH.A-C-D-E-F-A6OH",
"A-C-D-E-F-A6OH.C-D-E-F-G-A6OH",
),
"biln_multiple_nonbackbone_order": (
"A-[Test-6-Ch](1,4)(2,3)-C.D(2,1).E(1,2)",
"A-[Test-6-Ch](1,3)(2,4)-C.D(1,1).E(2,2)",
),
"biln_cycle_with_extra_bond_order": (
"C(1,1)(2,3)-C-C(2,3)-C(1,2)",
"C(1,1)-C(2,3)-C-C(1,2)(2,3)",
),
"biln_cycle_with_external_bond_order": (
"C(1,1)-C(2,3)-C(1,2).C(2,3)",
"C(1,1)(2,3)-C-C(1,2).C(2,3)",
),
"biln_equal_chain_topology_order": (
"C(1,3).C(1,1)",
"C(1,1).C(1,3)",
),
"biln_library_alias": (
"Edc",
"Edc",
),
"biln_valid_large_bond_ids": (
"A-C(7563,3)-D(3,3)-E.F-G-H(7563,3)-I-K(3,3)",
"F-G-H(1,3)-I-K(2,3).A-C(1,3)-D(2,3)-E",
),
}

for name in sorted(biln_to_biln.keys()):
biln, biln_ref = biln_to_biln[name]
try:
doc = indigo.loadBiln(biln, lib)
canonical_biln = doc.biln(lib)
diff = find_diff(biln_ref, canonical_biln)
if diff:
print(name + ":FAILED")
print(diff)
else:
print(name + ":BILN->BILN SUCCEED")
except IndigoException as e:
print(name + ":FAILED - " + getIndigoExceptionText(e))

helm_to_biln = {
"helm_cap": (
"PEPTIDE1{[Ac]}|PEPTIDE2{A.K}$PEPTIDE1,PEPTIDE2,1:R2-2:R3$$$V2.0",
Expand All @@ -62,9 +161,33 @@
"PEPTIDE1{[Ac]}|PEPTIDE2{A.K}|PEPTIDE3{[Me]}$PEPTIDE1,PEPTIDE2,1:R2-2:R3|PEPTIDE2,PEPTIDE3,2:R2-1:R1$$$V2.0",
"Ac(1,2).A-K(1,3)(2,2).Me(2,1)",
),
"helm_underscore_alias": (
"PEPTIDE1{A.[1Nal].[Cys_Bn].C}$$$$V2.0",
"A-1Nal-Cys_Bn-C",
),
"helm_bracketed_alias": (
"PEPTIDE1{A.[D-1Nal].[Cys_Bn].C}$$$$V2.0",
"A-[D-1Nal]-Cys_Bn-C",
),
"helm_star_alias": (
"PEPTIDE1{A.[D*].C}$$$$V2.0",
"A-D*-C",
),
"helm_cycle": (
"PEPTIDE1{[Abu].[Sar].[NMeL].V.[NMeL].A.[DAla].[NMeL].[NMeL].[NMeV].[NMeThr4RBut2enyl]}$PEPTIDE1,PEPTIDE1,1:R1-11:R2$$$V2.0",
"Abu(1,1)-Sar-NMeL-V-NMeL-A-DAla-NMeL-NMeL-NMeV-NMeThr4RBut2enyl(1,2)",
"PEPTIDE1{A.C.D.E}$PEPTIDE1,PEPTIDE1,1:R1-4:R2$$$V2.0",
"A(1,1)-C-D-E(1,2)",
),
"helm_chem_backbone": (
"PEPTIDE1{A.A.A.A.A.A}|CHEM1{[PEG-2]}|PEPTIDE2{C.C.C.C}|CHEM2{[PEG-2]}$PEPTIDE1,CHEM1,6:R2-1:R1|CHEM1,PEPTIDE2,1:R2-1:R1|PEPTIDE2,CHEM2,4:R2-1:R1$$$V2.0",
"A-A-A-A-A-A-[PEG-2]-C-C-C-C-[PEG-2]",
),
"helm_chem_with_biln_code": (
"CHEM1{[PEG-2]}$$$$V2.0",
"[PEG-2]",
),
"helm_alias_to_biln_alias": (
"PEPTIDE1{[Cys_SEt]}$$$$V2.0",
"Edc",
),
}

Expand All @@ -82,10 +205,79 @@
except IndigoException as e:
print(name + ":FAILED - " + getIndigoExceptionText(e))

helm_errors = {
"CHEM1{[qweqwe]}$$$$V2.0": "Only amino acids and CHEMs with BILN codes can get exported to BILN.",
# Unresolved HELM aliases that map to real BILN terminal caps must still be
# validated against the resolved library template attachment points.
"PEPTIDE1{[Ac]}|PEPTIDE2{K}$PEPTIDE1,PEPTIDE2,1:R1-1:R3$$$V2.0": "Cannot save in BILN format - unsupported attachment point 'R1'.",
"PEPTIDE1{A}|RNA1{R(A)P}$$$$V2.0": "Only amino acids and CHEMs with BILN codes can get exported to BILN.",
# Legacy integration input retained as an error expectation. #3541 export
# requirement 1 forbids exporting PEPTIDE monomers without BILN codes.
"PEPTIDE1{[Abu].[Sar].[NMeL].V.[NMeL].A.[DAla].[NMeL].[NMeL].[NMeV].[NMeThr4RBut2enyl]}$PEPTIDE1,PEPTIDE1,1:R1-11:R2$$$V2.0": "Only amino acids and CHEMs with BILN codes can get exported to BILN.",
}

for helm in sorted(helm_errors.keys()):
error = helm_errors[helm]
try:
doc = indigo.loadHelm(helm, lib)
doc.biln(lib)
print("Test %s failed: exception expected." % helm)
except IndigoException as e:
text = getIndigoExceptionText(e)
if error in text:
print("Test '%s': got expected error '%s'" % (helm, error))
else:
print(
"Test '%s': expected error '%s' but got '%s'"
% (helm, error, text)
)

ket_errors = {
"custom_chem_without_biln_code": (
"CHEM1{[qweqwe]}$$$$V2.0",
"Only amino acids and CHEMs with BILN codes can get exported to BILN.",
),
"unresolved_cap_invalid_attachment": (
"PEPTIDE1{[Ac]}|PEPTIDE2{K}$PEPTIDE1,PEPTIDE2,1:R1-1:R3$$$V2.0",
"Cannot save in BILN format - unsupported attachment point 'R1'.",
),
}

for name in sorted(ket_errors.keys()):
helm, error = ket_errors[name]
try:
doc = indigo.loadHelm(helm, lib)
doc = indigo.loadKetDocument(doc.json())
doc.biln(lib)
print("Test KET %s failed: exception expected." % name)
except IndigoException as e:
text = getIndigoExceptionText(e)
if error in text:
print("Test KET '%s': got expected error '%s'" % (name, error))
else:
print(
"Test KET '%s': expected error '%s' but got '%s'"
% (name, error, text)
)

biln_errors = {
"A(1,3)-C": "Invalid BILN bond 1: expected two endpoints but found 1.",
"A--C": "Invalid BILN string: empty monomer.",
"A-C(1,4)": "Invalid BILN bond 1: expected two endpoints but found 1.",
# #3541 import requirement 1: any invalid BILN string must return the
# generic error text below. This intentionally replaces older detailed
# error expectations for the pre-existing invalid integration cases.
"A(1,3)-C": "The string cannot be interpreted as a valid BILN string.",
"A--C": "The string cannot be interpreted as a valid BILN string.",
"A-C(1,4)": "The string cannot be interpreted as a valid BILN string.",
"[D-Cit](1,2)-aThr(1,1)(2,2)-meS(2,1)": "The string cannot be interpreted as a valid BILN string.",
"D-2Thi-D-D-gGlu-meF-G-Lys-al": "The string cannot be interpreted as a valid BILN string.",
"A-C(-1,3)-D(2,3)-E.F-G-H(-1,3)-I-K(2,3)": "The string cannot be interpreted as a valid BILN string.",
"A-C(1.25,3)-D(2,3)-E.F-G-H(1.25,3)-I-K(2,3)": "The string cannot be interpreted as a valid BILN string.",
"A-C(1,3)-D(1,3)-E.F-G-H(1,3)-I-K(2,3)": "The string cannot be interpreted as a valid BILN string.",
"A-C(1,4)-D(2,3)-E.F-G-H(1,3)-I-K(2,3)": "The string cannot be interpreted as a valid BILN string.",
# Terminal caps must be resolved against their real templates, not imported
# as unresolved monomers with synthetic R1..R4 attachment points.
"Ac(1,1).K(1,3)": "The string cannot be interpreted as a valid BILN string.",
"Ac(1,4).K(1,3)": "The string cannot be interpreted as a valid BILN string.",
"Cys_SEt": "The string cannot be interpreted as a valid BILN string.",
}

for biln in sorted(biln_errors.keys()):
Expand Down
Loading
Loading