Skip to content

Commit d87c650

Browse files
committed
merge: branch 'master' into stable
2 parents e466616 + ddfcada commit d87c650

File tree

4 files changed

+74
-3
lines changed

4 files changed

+74
-3
lines changed

environment.yaml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,3 +5,4 @@ dependencies:
55
- brs_utils
66
- filetype
77
- colored
8+
- pytest

retropath2_wrapper/RetroPath2.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -333,8 +333,7 @@ def check_inchi_from_file(
333333
# Other (sub-)layers
334334
# matches:
335335
# (/.+)? --> if '/' is present, then at least one character/symbol is mandatory
336-
# if match('InChI=1(S)?/(([a-z|[A-Z])\d+)+(/.+)?$', inchi) is None:
337-
if match('InChI=1(S)?/(([a-z|[A-Z])+\d+)+(/.+)?$', inchi) is None:
336+
if match('InChI=1(S)?/(([a-z|[A-Z])+\d*)+(/.+)?$', inchi) is None:
338337
logger.error(' {inchi} is not a valid InChI notation'.format(inchi=inchi))
339338
return ''
340339

tests/data/inchi_test_cases.csv

Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
InChI=1S/C3H9NO2/c4-3(1-5)2-6/h3,5-6H,1-2,4H2
2+
InChI=1S/C3H8O2/c4-2-1-3-5/h4-5H,1-3H2
3+
InChI=1S/C10H16/c1-8(2)10-6-4-9(3)5-7-10/h4,10H,1,5-7H2,2-3H3/t10-/m0/s1
4+
InChI=1S/C5H10N/c1-6-4-2-3-5-6/h4H,2-3,5H2,1H3/q+1
5+
InChI=1S/C5H12O/c1-5(2)3-4-6/h5-6H,3-4H2,1-2H3
6+
InChI=1S/C4H8O3/c1-3(5)2-4(6)7/h3,5H,2H2,1H3,(H,6,7)
7+
InChI=1S/C6H6O4/c7-5(8)3-1-2-4-6(9)10/h1-4H,(H,7,8)(H,9,10)/p-2/b3-1-,4-2-
8+
InChI=1S/C3H8O/c1-2-3-4/h4H,2-3H2,1H3
9+
InChI=1S/C7H6O4/c8-4-1-2-6(9)5(3-4)7(10)11/h1-3,8-9H,(H,10,11)
10+
InChI=1S/C6H11NO4/c1-4(8)11-3-2-5(7)6(9)10/h5H,2-3,7H2,1H3,(H,9,10)/t5-/m0/s1
11+
InChI=1S/C8H8O3/c1-11-8-4-6(5-9)2-3-7(8)10/h2-5,10H,1H3
12+
InChI=1S/C7H8O/c8-6-7-4-2-1-3-5-7/h1-5,8H,6H2
13+
InChI=1S/C5H6O4/c1-3(5(8)9)2-4(6)7/h2H,1H3,(H,6,7)(H,8,9)/b3-2+
14+
InChI=1S/C8H8O/c1-2-7-3-5-8(9)6-4-7/h2-6,9H,1H2
15+
InChI=1S/C40H56/c1-33(2)19-13-23-37(7)27-17-31-39(9)29-15-25-35(5)21-11-12-22-36(6)26-16-30-40(10)32-18-28-38(8)24-14-20-34(3)4/h11-12,15-22,25-32H,13-14,23-24H2,1-10H3/b12-11+,25-15+,26-16+,31-17+,32-18+,35-21+,36-22+,37-27+,38-28+,39-29+,40-30+
16+
InChI=1S/C7H8N4O2/c1-10-5-4(8-3-9-5)6(12)11(2)7(10)13/h3H,1-2H3,(H,8,9)
17+
InChI=1S/C8H10N4O2/c1-10-4-9-6-5(10)7(13)12(3)8(14)11(6)2/h4H,1-3H3
18+
InChI=1S/C8H8O4/c9-6-3-1-5(2-4-6)7(10)8(11)12/h1-4,7,9-10H,(H,11,12)
19+
InChI=1S/C6H6O3/c7-4-2-1-3-5(8)6(4)9/h1-3,7-9H
20+
InChI=1S/C15H32/c1-3-5-7-9-11-13-15-14-12-10-8-6-4-2/h3-15H2,1-2H3
21+
InChI=1S/C7H6O3/c8-6-4-2-1-3-5(6)7(9)10/h1-4,8H,(H,9,10)/p-1
22+
InChI=1S/C6H6O/c7-6-4-2-1-3-5-6/h1-5,7H
23+
InChI=1S/C3H6O3/c4-2-1-3(5)6/h4H,1-2H2,(H,5,6)/p-1
24+
InChI=1S/C12H16O7/c13-5-8-9(15)10(16)11(17)12(19-8)18-7-3-1-6(14)2-4-7/h1-4,8-17H,5H2/t8-,9-,10+,11-,12+/m1/s1
25+
InChI=1S/C19H16O4/c20-16-7-1-14(2-8-16)5-11-18(22)13-19(23)12-6-15-3-9-17(21)10-4-15/h1-12,20-21H,13H2/b11-5+,12-6+
26+
InChI=1S/C4H10O2/c1-3(5)4(2)6/h3-6H,1-2H3/t3-,4-/m1/s1
27+
InChI=1S/C14H12O3/c15-12-5-3-10(4-6-12)1-2-11-7-13(16)9-14(17)8-11/h1-9,15-17H/b2-1+
28+
InChI=1S/C40H56/c1-31(19-13-21-33(3)25-27-37-35(5)23-15-29-39(37,7)8)17-11-12-18-32(2)20-14-22-34(4)26-28-38-36(6)24-16-30-40(38,9)10/h11-14,17-22,25-28H,15-16,23-24,29-30H2,1-10H3/b12-11+,19-13+,20-14+,27-25+,28-26+,31-17+,32-18+,33-21+,34-22+
29+
InChI=1S/C5H6O4/c1-3(5(8)9)2-4(6)7/h2H,1H3,(H,6,7)(H,8,9)/p-2/b3-2+
30+
InChI=1S/C6H10N2O2/c1-4-7-3-2-5(8-4)6(9)10/h5H,2-3H2,1H3,(H,7,8)(H,9,10)/t5-/m0/s1
31+
InChI=1S/C15H12O5/c16-9-3-1-8(2-4-9)15-14(19)13(18)11-6-5-10(17)7-12(11)20-15/h1-7,14-17,19H/t14-,15+/m0/s1
32+
InChI=1S/C4H10O/c1-2-3-4-5/h5H,2-4H2,1H3
33+
InChI=1S/C3H10N2/c4-2-1-3-5/h1-5H2
34+
InChI=1S/C15H12O6/c16-8-4-11(19)15-12(20)6-13(21-14(15)5-8)7-1-2-9(17)10(18)3-7/h1-5,13,16-19H,6H2/p-1/t13-/m0/s1
35+
InChI=1S/C4H8O3/c5-3-1-2-4(6)7/h5H,1-3H2,(H,6,7)
36+
InChI=1S/C9H8O3/c10-8-4-1-7(2-5-8)3-6-9(11)12/h1-6,10H,(H,11,12)/p-1/b6-3+
37+
InChI=1S/C9H6O3/c10-7-5-9(11)12-8-4-2-1-3-6(7)8/h1-5,10H
38+
InChI=1S/C3H6O/c1-3(2)4/h1-2H3
39+
InChI=1S/C10H16/c1-7(2)10-5-4-8(3)9(10)6-10/h7,9H,3-6H2,1-2H3/t9-,10-/m0/s1
40+
InChI=1S/C9H8O4/c10-7-3-1-6(5-8(7)11)2-4-9(12)13/h1-5,10-11H,(H,12,13)/p-1/b4-2+
41+
InChI=1S/C2H4/c1-2/h1-2H2
42+
InChI=1S/C10H10O4/c1-14-9-6-7(2-4-8(9)11)3-5-10(12)13/h2-6,11H,1H3,(H,12,13)/p-1/b5-3+
43+
InChI=1S/C4H10O/c1-4(2)3-5/h4-5H,3H2,1-2H3
44+
InChI=1S/C3H4O4/c4-2(5)1-3(6)7/h1H2,(H,4,5)(H,6,7)
45+
InChI=1S/C20H34O/c1-7-19(5,21)14-11-16-15(2)9-10-17-18(3,4)12-8-13-20(16,17)6/h7,16-17,21H,1-2,8-14H2,3-6H3/t16-,17-,19-,20+/m0/s1
46+
InChI=1S/C20H34O/c1-7-18(4)13-9-16-19(5)12-8-11-17(2,3)15(19)10-14-20(16,6)21-18/h7,15-16H,1,8-14H2,2-6H3/t15?,16?,18-,19-,20+/m0/s1
47+
InChI=1S/C20H32/c1-14(2)15-7-9-17-16(13-15)8-10-18-19(3,4)11-6-12-20(17,18)5/h7,14,18H,6,8-13H2,1-5H3/t18-,20+/m0/s1
48+
InChI=1S/C14H12O2/c15-13-8-12(9-14(16)10-13)7-6-11-4-2-1-3-5-11/h1-10,15-16H/b7-6+
49+
InChI=1S/C18H16O8/c19-12-4-1-10(7-14(12)21)3-6-17(23)26-16(18(24)25)9-11-2-5-13(20)15(22)8-11/h1-8,16,19-22H,9H2,(H,24,25)/p-1/b6-3+/t16-/m1/s1
50+
InChI=1S/C20H36O2/c1-7-18(4,21)13-9-16-19(5)12-8-11-17(2,3)15(19)10-14-20(16,6)22/h7,15-16,21-22H,1,8-14H2,2-6H3/t15-,16+,18-,19-,20+/m0/s1
51+
InChI=1S/C15H24/c1-11(2)13-8-9-14-7-5-6-12(3)15(14,4)10-13/h7,12-13H,1,5-6,8-10H2,2-4H3/t12-,13-,15+/m1/s1
52+
InChI=1S/C5H12O5/c6-1-3(8)5(10)4(9)2-7/h3-10H,1-2H2/t3-,4+,5+

tests/test_RP2.py

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
__KNIME_VER__,
1818
__RETROPATH2_KWF__,
1919
set_vars,
20-
gunzip_to_csv
20+
gunzip_to_csv,
21+
check_inchi_from_file
2122
)
2223
from retropath2_wrapper.__main__ import create_logger
2324

@@ -126,3 +127,21 @@ def test_set_vars_None(self):
126127
# self.outdir,
127128
# dmin=16)
128129
# self.assertTrue(cmp(result, self.ref_file))
130+
131+
132+
class TestMethods:
133+
134+
inchi_test_file = Path(__file__).parent / 'data' / 'inchi_test_cases.csv'
135+
136+
def test_check_inchi_from_file(self, tmpdir):
137+
with open(self.inchi_test_file) as ifh:
138+
inchis = ifh.read().splitlines()
139+
for inchi in inchis:
140+
tmp_file = Path(tmpdir) / 'source.csv'
141+
with open(tmp_file, 'w') as ofh:
142+
ofh.write('"Name","InChI"\n')
143+
ofh.write(f'"target","{inchi}"')
144+
try:
145+
assert check_inchi_from_file(tmp_file) != ''
146+
except AssertionError as e:
147+
raise e

0 commit comments

Comments
 (0)