File tree Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Expand file tree Collapse file tree 3 files changed +24
-3
lines changed Original file line number Diff line number Diff line change @@ -5,3 +5,4 @@ dependencies:
55 - brs_utils
66 - filetype
77 - colored
8+ - pytest
Original file line number Diff line number Diff 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
Original file line number Diff line number Diff line change 1717 __KNIME_VER__ ,
1818 __RETROPATH2_KWF__ ,
1919 set_vars ,
20- gunzip_to_csv
20+ gunzip_to_csv ,
21+ check_inchi_from_file
2122)
2223from retropath2_wrapper .__main__ import create_logger
2324
@@ -126,3 +127,23 @@ 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+ def test_check_inchi_from_file (self , tmpdir ):
135+ inchis = [
136+ 'InChI=1S/C3H6O/c1-3(2)4/h1-2H3' ,
137+ '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+' ,
138+ 'InChI=1S/H2O2/c1-2/h1-2H' ,
139+ 'InChI=1S/C4H10O/c1-4(2)3-5/h4-5H,3H2,1-2H3'
140+ ]
141+ for inchi in inchis :
142+ tmp_file = Path (tmpdir ) / 'source.csv'
143+ with open (tmp_file , 'w' ) as fh :
144+ fh .write ('"Name","InChI"\n ' )
145+ fh .write (f'"target","{ inchi } "' )
146+ try :
147+ assert check_inchi_from_file (tmp_file ) != ''
148+ except AssertionError as e :
149+ raise e
You can’t perform that action at this time.
0 commit comments