406
|
1 import argparse
|
|
2 import utils.general_utils as utils
|
407
|
3 from typing import Optional, Dict, Set, List, Tuple
|
406
|
4 import os
|
|
5 import numpy as np
|
|
6 import pandas as pd
|
|
7 import cobra
|
407
|
8 from cobra import Model, Reaction, Metabolite
|
|
9 import re
|
406
|
10 import sys
|
|
11 import csv
|
|
12 from joblib import Parallel, delayed, cpu_count
|
|
13
|
407
|
14 # , medium
|
|
15
|
406
|
16 ################################# process args ###############################
|
|
17 def process_args(args :List[str] = None) -> argparse.Namespace:
|
|
18 """
|
|
19 Processes command-line arguments.
|
|
20
|
|
21 Args:
|
|
22 args (list): List of command-line arguments.
|
|
23
|
|
24 Returns:
|
|
25 Namespace: An object containing parsed arguments.
|
|
26 """
|
|
27 parser = argparse.ArgumentParser(usage = '%(prog)s [options]',
|
|
28 description = 'process some value\'s')
|
|
29
|
|
30
|
407
|
31 parser.add_argument("-mo", "--model_upload", type = str,
|
406
|
32 help = "path to input file with custom rules, if provided")
|
|
33
|
|
34 parser.add_argument("-meo", "--medium", type = str,
|
|
35 help = "path to input file with custom medium, if provided")
|
|
36
|
|
37 parser.add_argument('-ol', '--out_log',
|
|
38 help = "Output log")
|
|
39
|
|
40 parser.add_argument('-td', '--tool_dir',
|
|
41 type = str,
|
|
42 required = True,
|
|
43 help = 'your tool directory')
|
|
44
|
|
45 parser.add_argument('-ir', '--input_ras',
|
|
46 type=str,
|
|
47 required = False,
|
|
48 help = 'input ras')
|
|
49
|
|
50 parser.add_argument('-rn', '--name',
|
|
51 type=str,
|
|
52 help = 'ras class names')
|
|
53
|
|
54 parser.add_argument('-rs', '--ras_selector',
|
|
55 required = True,
|
|
56 type=utils.Bool("using_RAS"),
|
|
57 help = 'ras selector')
|
|
58
|
|
59 parser.add_argument('-cc', '--cell_class',
|
|
60 type = str,
|
|
61 help = 'output of cell class')
|
|
62 parser.add_argument(
|
|
63 '-idop', '--output_path',
|
|
64 type = str,
|
|
65 default='ras_to_bounds/',
|
|
66 help = 'output path for maps')
|
|
67
|
|
68
|
|
69 ARGS = parser.parse_args(args)
|
|
70 return ARGS
|
|
71
|
|
72 ########################### warning ###########################################
|
|
73 def warning(s :str) -> None:
|
|
74 """
|
|
75 Log a warning message to an output log file and print it to the console.
|
|
76
|
|
77 Args:
|
|
78 s (str): The warning message to be logged and printed.
|
|
79
|
|
80 Returns:
|
|
81 None
|
|
82 """
|
|
83 with open(ARGS.out_log, 'a') as log:
|
|
84 log.write(s + "\n\n")
|
|
85 print(s)
|
|
86
|
|
87 ############################ dataset input ####################################
|
|
88 def read_dataset(data :str, name :str) -> pd.DataFrame:
|
|
89 """
|
|
90 Read a dataset from a CSV file and return it as a pandas DataFrame.
|
|
91
|
|
92 Args:
|
|
93 data (str): Path to the CSV file containing the dataset.
|
|
94 name (str): Name of the dataset, used in error messages.
|
|
95
|
|
96 Returns:
|
|
97 pandas.DataFrame: DataFrame containing the dataset.
|
|
98
|
|
99 Raises:
|
|
100 pd.errors.EmptyDataError: If the CSV file is empty.
|
|
101 sys.exit: If the CSV file has the wrong format, the execution is aborted.
|
|
102 """
|
|
103 try:
|
|
104 dataset = pd.read_csv(data, sep = '\t', header = 0, engine='python')
|
|
105 except pd.errors.EmptyDataError:
|
|
106 sys.exit('Execution aborted: wrong format of ' + name + '\n')
|
|
107 if len(dataset.columns) < 2:
|
|
108 sys.exit('Execution aborted: wrong format of ' + name + '\n')
|
|
109 return dataset
|
|
110
|
|
111
|
|
112 def apply_ras_bounds(bounds, ras_row):
|
|
113 """
|
|
114 Adjust the bounds of reactions in the model based on RAS values.
|
|
115
|
|
116 Args:
|
|
117 bounds (pd.DataFrame): Model bounds.
|
|
118 ras_row (pd.Series): A row from a RAS DataFrame containing scaling factors for reaction bounds.
|
|
119 Returns:
|
|
120 new_bounds (pd.DataFrame): integrated bounds.
|
|
121 """
|
|
122 new_bounds = bounds.copy()
|
|
123 for reaction in ras_row.index:
|
|
124 scaling_factor = ras_row[reaction]
|
|
125 if not np.isnan(scaling_factor):
|
|
126 lower_bound=bounds.loc[reaction, "lower_bound"]
|
|
127 upper_bound=bounds.loc[reaction, "upper_bound"]
|
|
128 valMax=float((upper_bound)*scaling_factor)
|
|
129 valMin=float((lower_bound)*scaling_factor)
|
|
130 if upper_bound!=0 and lower_bound==0:
|
|
131 new_bounds.loc[reaction, "upper_bound"] = valMax
|
|
132 if upper_bound==0 and lower_bound!=0:
|
|
133 new_bounds.loc[reaction, "lower_bound"] = valMin
|
|
134 if upper_bound!=0 and lower_bound!=0:
|
|
135 new_bounds.loc[reaction, "lower_bound"] = valMin
|
|
136 new_bounds.loc[reaction, "upper_bound"] = valMax
|
|
137 return new_bounds
|
|
138
|
|
139 def process_ras_cell(cellName, ras_row, model, rxns_ids, output_folder):
|
|
140 """
|
|
141 Process a single RAS cell, apply bounds, and save the bounds to a CSV file.
|
|
142
|
|
143 Args:
|
|
144 cellName (str): The name of the RAS cell (used for naming the output file).
|
|
145 ras_row (pd.Series): A row from a RAS DataFrame containing scaling factors for reaction bounds.
|
|
146 model (cobra.Model): The metabolic model to be modified.
|
|
147 rxns_ids (list of str): List of reaction IDs to which the scaling factors will be applied.
|
|
148 output_folder (str): Folder path where the output CSV file will be saved.
|
|
149
|
|
150 Returns:
|
|
151 None
|
|
152 """
|
|
153 bounds = pd.DataFrame([(rxn.lower_bound, rxn.upper_bound) for rxn in model.reactions], index=rxns_ids, columns=["lower_bound", "upper_bound"])
|
|
154 new_bounds = apply_ras_bounds(bounds, ras_row)
|
|
155 new_bounds.to_csv(output_folder + cellName + ".csv", sep='\t', index=True)
|
|
156 pass
|
|
157
|
407
|
158 def generate_bounds(model: cobra.Model, ras=None, output_folder='output/') -> pd.DataFrame:
|
406
|
159 """
|
|
160 Generate reaction bounds for a metabolic model based on medium conditions and optional RAS adjustments.
|
|
161
|
|
162 Args:
|
|
163 model (cobra.Model): The metabolic model for which bounds will be generated.
|
|
164 medium (dict): A dictionary where keys are reaction IDs and values are the medium conditions.
|
|
165 ras (pd.DataFrame, optional): RAS pandas dataframe. Defaults to None.
|
|
166 output_folder (str, optional): Folder path where output CSV files will be saved. Defaults to 'output/'.
|
|
167
|
|
168 Returns:
|
|
169 pd.DataFrame: DataFrame containing the bounds of reactions in the model.
|
|
170 """
|
407
|
171 rxns_ids = [rxn.id for rxn in model.reactions]
|
406
|
172
|
|
173 # Perform Flux Variability Analysis (FVA) on this medium
|
|
174 df_FVA = cobra.flux_analysis.flux_variability_analysis(model, fraction_of_optimum=0, processes=1).round(8)
|
|
175
|
|
176 # Set FVA bounds
|
|
177 for reaction in rxns_ids:
|
|
178 model.reactions.get_by_id(reaction).lower_bound = float(df_FVA.loc[reaction, "minimum"])
|
|
179 model.reactions.get_by_id(reaction).upper_bound = float(df_FVA.loc[reaction, "maximum"])
|
|
180
|
|
181 if ras is not None:
|
|
182 Parallel(n_jobs=cpu_count())(delayed(process_ras_cell)(cellName, ras_row, model, rxns_ids, output_folder) for cellName, ras_row in ras.iterrows())
|
|
183 else:
|
|
184 bounds = pd.DataFrame([(rxn.lower_bound, rxn.upper_bound) for rxn in model.reactions], index=rxns_ids, columns=["lower_bound", "upper_bound"])
|
|
185 newBounds = apply_ras_bounds(bounds, pd.Series([1]*len(rxns_ids), index=rxns_ids))
|
|
186 newBounds.to_csv(output_folder + "bounds.csv", sep='\t', index=True)
|
|
187 pass
|
|
188
|
407
|
189 # TODO: VALUTARE QUALI DI QUESTE FUNZIONI METTERE IN UTILS.PY
|
|
190 def build_cobra_model_from_csv(csv_path: str, model_id: str = "ENGRO2_custom") -> cobra.Model:
|
|
191 """
|
|
192 Costruisce un modello COBRApy a partire da un file CSV con i dati delle reazioni.
|
|
193
|
|
194 Args:
|
|
195 csv_path: Path al file CSV (separato da tab)
|
|
196 model_id: ID del modello da creare
|
|
197
|
|
198 Returns:
|
|
199 cobra.Model: Il modello COBRApy costruito
|
|
200 """
|
|
201
|
|
202 # Leggi i dati dal CSV
|
|
203 df = pd.read_csv(csv_path, sep='\t')
|
|
204
|
|
205 # Crea il modello vuoto
|
|
206 model = Model(model_id)
|
|
207
|
|
208 # Dict per tenere traccia di metaboliti e compartimenti
|
|
209 metabolites_dict = {}
|
|
210 compartments_dict = {}
|
|
211
|
|
212 print(f"Costruendo modello da {len(df)} reazioni...")
|
|
213
|
|
214 # Prima passata: estrai metaboliti e compartimenti dalle formule delle reazioni
|
|
215 for idx, row in df.iterrows():
|
|
216 reaction_formula = str(row['Reaction']).strip()
|
|
217 if not reaction_formula or reaction_formula == 'nan':
|
|
218 continue
|
|
219
|
|
220 # Estrai metaboliti dalla formula della reazione
|
|
221 metabolites = extract_metabolites_from_reaction(reaction_formula)
|
|
222
|
|
223 for met_id in metabolites:
|
|
224 compartment = extract_compartment_from_metabolite(met_id)
|
|
225
|
|
226 # Aggiungi compartimento se non esiste
|
|
227 if compartment not in compartments_dict:
|
|
228 compartments_dict[compartment] = compartment
|
|
229
|
|
230 # Aggiungi metabolita se non esiste
|
|
231 if met_id not in metabolites_dict:
|
|
232 metabolites_dict[met_id] = Metabolite(
|
|
233 id=met_id,
|
|
234 compartment=compartment,
|
|
235 name=met_id.replace(f"_{compartment}", "").replace("__", "_")
|
|
236 )
|
|
237
|
|
238 # Aggiungi compartimenti al modello
|
|
239 model.compartments = compartments_dict
|
|
240
|
|
241 # Aggiungi metaboliti al modello
|
|
242 model.add_metabolites(list(metabolites_dict.values()))
|
|
243
|
|
244 print(f"Aggiunti {len(metabolites_dict)} metaboliti e {len(compartments_dict)} compartimenti")
|
|
245
|
|
246 # Seconda passata: aggiungi le reazioni
|
|
247 reactions_added = 0
|
|
248 reactions_skipped = 0
|
|
249
|
|
250 for idx, row in df.iterrows():
|
|
251 try:
|
|
252 reaction_id = str(row['ReactionID']).strip()
|
|
253 if reaction_id == 'EX_thbpt_e':
|
|
254 print('qui')
|
|
255 print(reaction_id)
|
|
256 print(str(row['Reaction']).strip())
|
|
257 print('qui')
|
|
258 reaction_formula = str(row['Reaction']).strip()
|
|
259
|
|
260 # Salta reazioni senza formula
|
|
261 if not reaction_formula or reaction_formula == 'nan':
|
|
262 reactions_skipped += 1
|
|
263 continue
|
|
264
|
|
265 # Crea la reazione
|
|
266 reaction = Reaction(reaction_id)
|
|
267 reaction.name = reaction_id
|
|
268
|
|
269 # Imposta bounds
|
|
270 reaction.lower_bound = float(row['lower_bound']) if pd.notna(row['lower_bound']) else -1000.0
|
|
271 reaction.upper_bound = float(row['upper_bound']) if pd.notna(row['upper_bound']) else 1000.0
|
|
272
|
|
273 # Aggiungi gene rule se presente
|
|
274 if pd.notna(row['Rule']) and str(row['Rule']).strip():
|
|
275 reaction.gene_reaction_rule = str(row['Rule']).strip()
|
|
276
|
|
277 # Parse della formula della reazione
|
|
278 try:
|
|
279 parse_reaction_formula(reaction, reaction_formula, metabolites_dict)
|
|
280 except Exception as e:
|
|
281 print(f"Errore nel parsing della reazione {reaction_id}: {e}")
|
|
282 reactions_skipped += 1
|
|
283 continue
|
|
284
|
|
285 # Aggiungi la reazione al modello
|
|
286 model.add_reactions([reaction])
|
|
287 reactions_added += 1
|
|
288
|
|
289 except Exception as e:
|
|
290 print(f"Errore nell'aggiungere la reazione {reaction_id}: {e}")
|
|
291 reactions_skipped += 1
|
|
292 continue
|
|
293
|
|
294 print(f"Aggiunte {reactions_added} reazioni, saltate {reactions_skipped} reazioni")
|
|
295
|
|
296 # Imposta l'obiettivo di biomassa
|
|
297 set_biomass_objective(model)
|
|
298
|
|
299 # Imposta il medium
|
|
300 set_medium_from_data(model, df)
|
|
301
|
|
302 print(f"Modello completato: {len(model.reactions)} reazioni, {len(model.metabolites)} metaboliti")
|
|
303
|
|
304 return model
|
|
305
|
|
306
|
|
307 # Estrae tutti gli ID metaboliti nella formula (gestisce prefissi numerici + underscore)
|
|
308 def extract_metabolites_from_reaction(reaction_formula: str) -> Set[str]:
|
|
309 """
|
|
310 Estrae gli ID dei metaboliti da una formula di reazione.
|
|
311 Pattern robusto: cattura token che terminano con _<compartimento> (es. _c, _m, _e)
|
|
312 e permette che comincino con cifre o underscore.
|
|
313 """
|
|
314 metabolites = set()
|
|
315 # coefficiente opzionale seguito da un token che termina con _<letters>
|
|
316 pattern = r'(?:\d+(?:\.\d+)?\s+)?([A-Za-z0-9_]+_[a-z]+)'
|
|
317 matches = re.findall(pattern, reaction_formula)
|
|
318 metabolites.update(matches)
|
|
319 return metabolites
|
|
320
|
|
321
|
|
322 def extract_compartment_from_metabolite(metabolite_id: str) -> str:
|
|
323 """
|
|
324 Estrae il compartimento dall'ID del metabolita.
|
|
325 """
|
|
326 # Il compartimento è solitamente l'ultima lettera dopo l'underscore
|
|
327 if '_' in metabolite_id:
|
|
328 return metabolite_id.split('_')[-1]
|
|
329 return 'c' # default cytoplasm
|
|
330
|
|
331
|
|
332 def parse_reaction_formula(reaction: Reaction, formula: str, metabolites_dict: Dict[str, Metabolite]):
|
|
333 """
|
|
334 Parsa una formula di reazione e imposta i metaboliti con i loro coefficienti.
|
|
335 """
|
|
336
|
|
337 if reaction.id == 'EX_thbpt_e':
|
|
338 print(reaction.id)
|
|
339 print(formula)
|
|
340 # Dividi in parte sinistra e destra
|
|
341 if '<=>' in formula:
|
|
342 left, right = formula.split('<=>')
|
|
343 reversible = True
|
|
344 elif '<--' in formula:
|
|
345 left, right = formula.split('<--')
|
|
346 reversible = False
|
|
347 left, right = left, right
|
|
348 elif '-->' in formula:
|
|
349 left, right = formula.split('-->')
|
|
350 reversible = False
|
|
351 elif '<-' in formula:
|
|
352 left, right = formula.split('<-')
|
|
353 reversible = False
|
|
354 left, right = left, right
|
|
355 else:
|
|
356 raise ValueError(f"Formato reazione non riconosciuto: {formula}")
|
|
357
|
|
358 # Parse dei metaboliti e coefficienti
|
|
359 reactants = parse_metabolites_side(left.strip())
|
|
360 products = parse_metabolites_side(right.strip())
|
|
361
|
|
362 # Aggiungi metaboliti alla reazione
|
|
363 metabolites_to_add = {}
|
|
364
|
|
365 # Reagenti (coefficienti negativi)
|
|
366 for met_id, coeff in reactants.items():
|
|
367 if met_id in metabolites_dict:
|
|
368 metabolites_to_add[metabolites_dict[met_id]] = -coeff
|
|
369
|
|
370 # Prodotti (coefficienti positivi)
|
|
371 for met_id, coeff in products.items():
|
|
372 if met_id in metabolites_dict:
|
|
373 metabolites_to_add[metabolites_dict[met_id]] = coeff
|
|
374
|
|
375 reaction.add_metabolites(metabolites_to_add)
|
|
376
|
|
377
|
|
378 def parse_metabolites_side(side_str: str) -> Dict[str, float]:
|
|
379 """
|
|
380 Parsa un lato della reazione per estrarre metaboliti e coefficienti.
|
|
381 """
|
|
382 metabolites = {}
|
|
383 if not side_str or side_str.strip() == '':
|
|
384 return metabolites
|
|
385
|
|
386 terms = side_str.split('+')
|
|
387 for term in terms:
|
|
388 term = term.strip()
|
|
389 if not term:
|
|
390 continue
|
|
391
|
|
392 # pattern allineato: coefficiente opzionale + id che termina con _<compartimento>
|
|
393 match = re.match(r'(?:(\d+\.?\d*)\s+)?([A-Za-z0-9_]+_[a-z]+)', term)
|
|
394 if match:
|
|
395 coeff_str, met_id = match.groups()
|
|
396 coeff = float(coeff_str) if coeff_str else 1.0
|
|
397 metabolites[met_id] = coeff
|
|
398
|
|
399 return metabolites
|
|
400
|
|
401
|
|
402
|
|
403 def set_biomass_objective(model: Model):
|
|
404 """
|
|
405 Imposta la reazione di biomassa come obiettivo.
|
|
406 """
|
|
407 biomass_reactions = [r for r in model.reactions if 'biomass' in r.id.lower()]
|
|
408
|
|
409 if biomass_reactions:
|
|
410 model.objective = biomass_reactions[0].id
|
|
411 print(f"Obiettivo impostato su: {biomass_reactions[0].id}")
|
|
412 else:
|
|
413 print("Nessuna reazione di biomassa trovata")
|
|
414
|
|
415
|
|
416 def set_medium_from_data(model: Model, df: pd.DataFrame):
|
|
417 """
|
|
418 Imposta il medium basato sulla colonna InMedium.
|
|
419 """
|
|
420 medium_reactions = df[df['InMedium'] == True]['ReactionID'].tolist()
|
|
421
|
|
422 medium_dict = {}
|
|
423 for rxn_id in medium_reactions:
|
|
424 if rxn_id in [r.id for r in model.reactions]:
|
|
425 reaction = model.reactions.get_by_id(rxn_id)
|
|
426 if reaction.lower_bound < 0: # Solo reazioni di uptake
|
|
427 medium_dict[rxn_id] = abs(reaction.lower_bound)
|
|
428
|
|
429 if medium_dict:
|
|
430 model.medium = medium_dict
|
|
431 print(f"Medium impostato con {len(medium_dict)} componenti")
|
|
432
|
|
433
|
|
434 def validate_model(model: Model) -> Dict[str, any]:
|
|
435 """
|
|
436 Valida il modello e fornisce statistiche di base.
|
|
437 """
|
|
438 validation = {
|
|
439 'num_reactions': len(model.reactions),
|
|
440 'num_metabolites': len(model.metabolites),
|
|
441 'num_genes': len(model.genes),
|
|
442 'num_compartments': len(model.compartments),
|
|
443 'objective': str(model.objective),
|
|
444 'medium_size': len(model.medium),
|
|
445 'reversible_reactions': len([r for r in model.reactions if r.reversibility]),
|
|
446 'exchange_reactions': len([r for r in model.reactions if r.id.startswith('EX_')]),
|
|
447 }
|
|
448
|
|
449 try:
|
|
450 # Test di crescita
|
|
451 solution = model.optimize()
|
|
452 validation['growth_rate'] = solution.objective_value
|
|
453 validation['status'] = solution.status
|
|
454 except Exception as e:
|
|
455 validation['growth_rate'] = None
|
|
456 validation['status'] = f"Error: {e}"
|
|
457
|
|
458 return validation
|
406
|
459
|
|
460
|
|
461 ############################# main ###########################################
|
|
462 def main(args:List[str] = None) -> None:
|
|
463 """
|
|
464 Initializes everything and sets the program in motion based on the fronted input arguments.
|
|
465
|
|
466 Returns:
|
|
467 None
|
|
468 """
|
|
469 if not os.path.exists('ras_to_bounds'):
|
|
470 os.makedirs('ras_to_bounds')
|
|
471
|
|
472
|
|
473 global ARGS
|
|
474 ARGS = process_args(args)
|
|
475
|
|
476 if(ARGS.ras_selector == True):
|
|
477 ras_file_list = ARGS.input_ras.split(",")
|
|
478 ras_file_names = ARGS.name.split(",")
|
|
479 if len(ras_file_names) != len(set(ras_file_names)):
|
|
480 error_message = "Duplicated file names in the uploaded RAS matrices."
|
|
481 warning(error_message)
|
|
482 raise ValueError(error_message)
|
|
483 pass
|
|
484 ras_class_names = []
|
|
485 for file in ras_file_names:
|
|
486 ras_class_names.append(file.rsplit(".", 1)[0])
|
|
487 ras_list = []
|
|
488 class_assignments = pd.DataFrame(columns=["Patient_ID", "Class"])
|
|
489 for ras_matrix, ras_class_name in zip(ras_file_list, ras_class_names):
|
|
490 ras = read_dataset(ras_matrix, "ras dataset")
|
|
491 ras.replace("None", None, inplace=True)
|
|
492 ras.set_index("Reactions", drop=True, inplace=True)
|
|
493 ras = ras.T
|
|
494 ras = ras.astype(float)
|
|
495 if(len(ras_file_list)>1):
|
|
496 #append class name to patient id (dataframe index)
|
|
497 ras.index = [f"{idx}_{ras_class_name}" for idx in ras.index]
|
|
498 else:
|
|
499 ras.index = [f"{idx}" for idx in ras.index]
|
|
500 ras_list.append(ras)
|
|
501 for patient_id in ras.index:
|
|
502 class_assignments.loc[class_assignments.shape[0]] = [patient_id, ras_class_name]
|
|
503
|
|
504
|
|
505 # Concatenate all ras DataFrames into a single DataFrame
|
|
506 ras_combined = pd.concat(ras_list, axis=0)
|
|
507 # Normalize the RAS values by max RAS
|
|
508 ras_combined = ras_combined.div(ras_combined.max(axis=0))
|
|
509 ras_combined.dropna(axis=1, how='all', inplace=True)
|
|
510
|
|
511
|
|
512
|
407
|
513 #model_type :utils.Model = ARGS.model_selector
|
|
514 #if model_type is utils.Model.Custom:
|
|
515 # model = model_type.getCOBRAmodel(customPath = utils.FilePath.fromStrPath(ARGS.model), customExtension = utils.FilePath.fromStrPath(ARGS.model_name).ext)
|
|
516 #else:
|
|
517 # model = model_type.getCOBRAmodel(toolDir=ARGS.tool_dir)
|
|
518
|
|
519 # TODO LOAD MODEL FROM UPLOAD
|
|
520
|
|
521 model = build_cobra_model_from_csv(ARGS.model_upload)
|
|
522
|
|
523 validation = validate_model(model)
|
406
|
524
|
407
|
525 print("\n=== VALIDAZIONE MODELLO ===")
|
|
526 for key, value in validation.items():
|
|
527 print(f"{key}: {value}")
|
|
528
|
|
529 #if(ARGS.medium_selector == "Custom"):
|
|
530 # medium = read_dataset(ARGS.medium, "medium dataset")
|
|
531 # medium.set_index(medium.columns[0], inplace=True)
|
|
532 # medium = medium.astype(float)
|
|
533 # medium = medium[medium.columns[0]].to_dict()
|
|
534 #else:
|
|
535 # df_mediums = pd.read_csv(ARGS.tool_dir + "/local/medium/medium.csv", index_col = 0)
|
|
536 # ARGS.medium_selector = ARGS.medium_selector.replace("_", " ")
|
|
537 # medium = df_mediums[[ARGS.medium_selector]]
|
|
538 # medium = medium[ARGS.medium_selector].to_dict()
|
406
|
539
|
|
540 if(ARGS.ras_selector == True):
|
407
|
541 generate_bounds(model, ras = ras_combined, output_folder=ARGS.output_path)
|
406
|
542 class_assignments.to_csv(ARGS.cell_class, sep = '\t', index = False)
|
|
543 else:
|
407
|
544 generate_bounds(model, output_folder=ARGS.output_path)
|
406
|
545
|
|
546 pass
|
|
547
|
|
548 ##############################################################################
|
|
549 if __name__ == "__main__":
|
|
550 main() |