33import sys
44import glob
55from pathlib import Path
6+
67if False :
78 import IsoSpecCppPy
89
10+
911class IsoFFI :
1012 def __init__ (self ):
1113 self .ffi = cffi .FFI ()
12- self .ffi .cdef ('''
14+ self .ffi .cdef (
15+ """
1316 void * setupIso(int dimNumber,
1417 const int* isotopeNumbers,
1518 const int* atomCounts,
@@ -19,8 +22,11 @@ def __init__(self):
1922 void * isoFromFasta(const char* fasta, bool use_nominal_masses, bool add_water);
2023
2124 double getLightestPeakMassIso(void* iso);
25+ double getLightestPeakLProbIso(void* iso);
2226 double getHeaviestPeakMassIso(void* iso);
27+ double getHeaviestPeakLProbIso(void* iso);
2328 double getMonoisotopicPeakMassIso(void* iso);
29+ double getMonoisotopicPeakLProbIso(void* iso);
2430 double getModeLProbIso(void* iso);
2531 double getModeMassIso(void* iso);
2632 double getTheoreticalAverageMassIso(void* iso);
@@ -157,39 +163,47 @@ def __init__(self):
157163 extern const char* elem_table_element[NUMBER_OF_ISOTOPIC_ENTRIES];
158164 extern const char* elem_table_symbol[NUMBER_OF_ISOTOPIC_ENTRIES];
159165 extern const bool elem_table_Radioactive[NUMBER_OF_ISOTOPIC_ENTRIES];
160- ''' );
166+ """
167+ )
161168
162169 mod_dir = Path (__file__ ).resolve ().parent
163170
164- if (mod_dir .parent / 'setup.py' ).exists ():
165- raise ImportError ('''Attempted to load IsoSpecPy module from its build directory. This usually
171+ if (mod_dir .parent / "setup.py" ).exists ():
172+ raise ImportError (
173+ """Attempted to load IsoSpecPy module from its build directory. This usually
166174won't work and is generally a Bad Idea. Please cd somewhere else, or, if you're really
167- sure you want to do that, edit the source and disable this check.''' )
175+ sure you want to do that, edit the source and disable this check."""
176+ )
168177
169- libnames = [' IsoSpecCppPy*' , ' IsoSpec++*' ]
170- libprefix = ['' , ' lib' , ' Lib' ]
171- extension = [' .so' , ' .dylib' , ' .dll' ]
178+ libnames = [" IsoSpecCppPy*" , " IsoSpec++*" ]
179+ libprefix = ["" , " lib" , " Lib" ]
180+ extension = [" .so" , " .dylib" , " .dll" ]
172181 try :
173- if platform .system () == ' Linux' :
174- extension = [' .so' , ' pyd' ]
175- elif platform .system () == ' Windows' :
176- extension = [' .dll' , ' .pyd' ]
182+ if platform .system () == " Linux" :
183+ extension = [" .so" , " pyd" ]
184+ elif platform .system () == " Windows" :
185+ extension = [" .dll" , " .pyd" ]
177186 except :
178187 pass
179188
180- prebuilt = [ '' , ' prebuilt-' ]
189+ prebuilt = [ "" , " prebuilt-" ]
181190
182191 def cprod (ll1 , ll2 ):
183192 res = []
184193 for l1 in ll1 :
185194 for l2 in ll2 :
186- res .append (l1 + l2 )
195+ res .append (l1 + l2 )
187196 return res
188197
189198 paths_to_check = cprod (prebuilt , cprod (libprefix , cprod (libnames , extension )))
190199 dpc = []
191200
192- for dirpath in [mod_dir , mod_dir .parent , mod_dir .parent / 'bin' , mod_dir .parent / 'lib' ]:
201+ for dirpath in [
202+ mod_dir ,
203+ mod_dir .parent ,
204+ mod_dir .parent / "bin" ,
205+ mod_dir .parent / "lib" ,
206+ ]:
193207 dpc .extend ([dirpath / p for p in paths_to_check ])
194208
195209 paths_to_check = dpc
@@ -200,7 +214,10 @@ def cprod(ll1, ll2):
200214 paths_to_check = expanded
201215 try :
202216 import importlib
203- paths_to_check .insert (0 , Path (importlib .util .find_spec ("IsoSpecCppPy" ).origin ))
217+
218+ paths_to_check .insert (
219+ 0 , Path (importlib .util .find_spec ("IsoSpecCppPy" ).origin )
220+ )
204221 except (ImportError , AttributeError ):
205222 pass
206223
@@ -213,11 +230,21 @@ def cprod(ll1, ll2):
213230 self .libpath = libpath
214231 break
215232 except (IndexError , OSError ) as e :
216- errmsg = "Load libIsoSpec++.so, tried: " + libpath + '\n ' + "Got error: " + str (type (e )) + ": " + str (e )
233+ errmsg = (
234+ "Load libIsoSpec++.so, tried: "
235+ + libpath
236+ + "\n "
237+ + "Got error: "
238+ + str (type (e ))
239+ + ": "
240+ + str (e )
241+ )
217242 errors .append (errmsg )
218243
219244 if self .clib == None :
220- raise ImportError ("Cannot find or load the C++ part of the library\n " + '\n ' .join (errors ))
245+ raise ImportError (
246+ "Cannot find or load the C++ part of the library\n " + "\n " .join (errors )
247+ )
221248
222249
223250isoFFI = IsoFFI () # This is done while including the module
0 commit comments