Coverage for SynRBL/preprocess.py: 27%

11 statements  

« prev     ^ index     » next       coverage.py v7.4.3, created at 2024-04-11 11:17 +0200

1import pandas as pd 

2 

3from SynRBL.SynProcessor import RSMIProcessing 

4 

5 

6def preprocess(reactions, reaction_col, index_col, solved_col, n_jobs=1): 

7 df = pd.DataFrame(reactions) 

8 df[solved_col] = False 

9 

10 if "Unnamed: 0" in df.columns: 

11 df = df.drop("Unnamed: 0", axis=1) 

12 

13 process = RSMIProcessing( 

14 data=df, 

15 rsmi_col=reaction_col, 

16 parallel=True, 

17 n_jobs=n_jobs, 

18 data_name=None, # type: ignore 

19 index_col=index_col, 

20 drop_duplicates=False, 

21 save_json=False, 

22 save_path_name=None, # type: ignore 

23 verbose=0, 

24 ) 

25 reactions = process.data_splitter() 

26 reactions["input_reaction"] = reactions[reaction_col] 

27 

28 return reactions.to_dict("records")