Mercurial > repos > bimib > cobraxy
comparison COBRAxy/ras_to_bounds.py @ 147:3fca9b568faf draft
Uploaded
author | bimib |
---|---|
date | Wed, 06 Nov 2024 13:57:24 +0000 |
parents | 726e1dc71f03 |
children | 00a66b9bc29e |
comparison
equal
deleted
inserted
replaced
146:88cf4543e210 | 147:3fca9b568faf |
---|---|
8 import sys | 8 import sys |
9 import csv | 9 import csv |
10 from joblib import Parallel, delayed, cpu_count | 10 from joblib import Parallel, delayed, cpu_count |
11 | 11 |
12 ################################# process args ############################### | 12 ################################# process args ############################### |
13 def process_args(args :List[str]) -> argparse.Namespace: | 13 def process_args(args :List[str] = None) -> argparse.Namespace: |
14 """ | 14 """ |
15 Processes command-line arguments. | 15 Processes command-line arguments. |
16 | 16 |
17 Args: | 17 Args: |
18 args (list): List of command-line arguments. | 18 args (list): List of command-line arguments. |
64 help = 'ras selector') | 64 help = 'ras selector') |
65 | 65 |
66 parser.add_argument('-cc', '--cell_class', | 66 parser.add_argument('-cc', '--cell_class', |
67 type = str, | 67 type = str, |
68 help = 'output of cell class') | 68 help = 'output of cell class') |
69 | 69 parser.add_argument( |
70 | 70 '-idop', '--output_path', |
71 ARGS = parser.parse_args() | 71 type = str, |
72 default='ras_to_bounds/', | |
73 help = 'output path for maps') | |
74 | |
75 | |
76 ARGS = parser.parse_args(args) | |
72 return ARGS | 77 return ARGS |
73 | 78 |
74 ########################### warning ########################################### | 79 ########################### warning ########################################### |
75 def warning(s :str) -> None: | 80 def warning(s :str) -> None: |
76 """ | 81 """ |
199 pass | 204 pass |
200 | 205 |
201 | 206 |
202 | 207 |
203 ############################# main ########################################### | 208 ############################# main ########################################### |
204 def main() -> None: | 209 def main(args:List[str] = None) -> None: |
205 """ | 210 """ |
206 Initializes everything and sets the program in motion based on the fronted input arguments. | 211 Initializes everything and sets the program in motion based on the fronted input arguments. |
207 | 212 |
208 Returns: | 213 Returns: |
209 None | 214 None |
211 if not os.path.exists('ras_to_bounds'): | 216 if not os.path.exists('ras_to_bounds'): |
212 os.makedirs('ras_to_bounds') | 217 os.makedirs('ras_to_bounds') |
213 | 218 |
214 | 219 |
215 global ARGS | 220 global ARGS |
216 ARGS = process_args(sys.argv) | 221 ARGS = process_args(args) |
217 | |
218 ARGS.output_folder = 'ras_to_bounds/' | |
219 | 222 |
220 if(ARGS.ras_selector == True): | 223 if(ARGS.ras_selector == True): |
221 ras_file_list = ARGS.input_ras.split(",") | 224 ras_file_list = ARGS.input_ras.split(",") |
222 ras_file_names = ARGS.name.split(",") | 225 ras_file_names = ARGS.name.split(",") |
223 if len(ras_file_names) != len(set(ras_file_names)): | 226 if len(ras_file_names) != len(set(ras_file_names)): |
267 ARGS.medium_selector = ARGS.medium_selector.replace("_", " ") | 270 ARGS.medium_selector = ARGS.medium_selector.replace("_", " ") |
268 medium = df_mediums[[ARGS.medium_selector]] | 271 medium = df_mediums[[ARGS.medium_selector]] |
269 medium = medium[ARGS.medium_selector].to_dict() | 272 medium = medium[ARGS.medium_selector].to_dict() |
270 | 273 |
271 if(ARGS.ras_selector == True): | 274 if(ARGS.ras_selector == True): |
272 generate_bounds(model, medium, ras = ras_combined, output_folder=ARGS.output_folder) | 275 generate_bounds(model, medium, ras = ras_combined, output_folder=ARGS.output_path) |
273 class_assignments.to_csv(ARGS.cell_class, sep = '\t', index = False) | 276 class_assignments.to_csv(ARGS.cell_class, sep = '\t', index = False) |
274 else: | 277 else: |
275 generate_bounds(model, medium, output_folder=ARGS.output_folder) | 278 generate_bounds(model, medium, output_folder=ARGS.output_path) |
276 | 279 |
277 pass | 280 pass |
278 | 281 |
279 ############################################################################## | 282 ############################################################################## |
280 if __name__ == "__main__": | 283 if __name__ == "__main__": |