|
21 | 21 | from corems.molecular_id.search.priorityAssignment import OxygenPriorityAssignment |
22 | 22 | from corems.transient.input.brukerSolarix import ReadBrukerSolarix |
23 | 23 | from corems.encapsulation.output import parameter_to_dict |
| 24 | +import matplotlib as mpl |
24 | 25 | from matplotlib import pyplot as plt |
25 | 26 | from matplotlib import gridspec as gridspec |
26 | 27 | from tqdm import tqdm |
@@ -195,6 +196,9 @@ def read_workflow_parameter(di_workflow_parameters_toml_file): |
195 | 196 |
|
196 | 197 | def create_plots(mass_spectrum, workflow_params, dirloc): |
197 | 198 | print("create plots") |
| 199 | + # Prevent overflow error when plotting |
| 200 | + mpl.rcParams['agg.path.chunksize'] = 10000 |
| 201 | + |
198 | 202 | ms_by_classes = HeteroatomsClassification( |
199 | 203 | mass_spectrum, choose_molecular_formula=False |
200 | 204 | ) |
@@ -517,8 +521,7 @@ def find_calibration_for_batch(workflow_params): |
517 | 521 |
|
518 | 522 | def run_wdl_direct_infusion_workflow(*args, **kwargs): |
519 | 523 | print("run wdl direct infusion workflow") |
520 | | - cores = kwargs.get("jobs") |
521 | | - del kwargs["jobs"] |
| 524 | + |
522 | 525 | kwargs["polarity"] = -1 if kwargs.get("polarity") == "negative" else 1 |
523 | 526 |
|
524 | 527 | workflow_params = DiWorkflowParameters(**kwargs) |
@@ -553,26 +556,45 @@ def run_direct_infusion_workflow(workflow_params_file, jobs, replicas): |
553 | 556 | click.echo("Loading Searching Settings from %s" % workflow_params_file) |
554 | 557 | workflow_params = read_workflow_parameter(workflow_params_file) |
555 | 558 |
|
556 | | - # Set up paths |
| 559 | + # File paths need to be a list of strings. If you gave it one string... |
| 560 | + if isinstance(workflow_params.file_paths, str): |
| 561 | + # If it has a wildcard, get a list of files in the directory |
| 562 | + if "*" in workflow_params.file_paths: |
| 563 | + p = Path(workflow_params.file_paths) |
| 564 | + workflow_params.file_paths = list(Path(p.parent).glob(p.name)) |
| 565 | + workflow_params.file_paths = list(map(str, workflow_params.file_paths)) |
| 566 | + # If no wildcard (single filepath), cast to list to match types later |
| 567 | + else: |
| 568 | + workflow_params.file_paths = list(workflow_params.file_paths) |
| 569 | + |
| 570 | + # Set up output paths |
557 | 571 | dirloc = Path(workflow_params.output_directory) |
558 | 572 | dirloc.mkdir(exist_ok=True) |
559 | 573 |
|
| 574 | + if workflow_params.batch_calibrate: |
| 575 | + # Before processing the samples, set calibration based on SRFA |
| 576 | + error_boundaries, workflow_params.file_paths = find_calibration_for_batch(workflow_params) |
| 577 | + else: |
| 578 | + # Not used if not batch_calibrate, placeholder for run_assignment input |
| 579 | + error_boundaries = () |
| 580 | + |
560 | 581 | worker_args = replicas * [ |
561 | | - (file_path, workflow_params.to_toml()) |
| 582 | + (file_path, workflow_params.to_toml(), error_boundaries) |
562 | 583 | for file_path in workflow_params.file_paths |
563 | 584 | ] |
564 | 585 |
|
565 | | - cores = jobs |
566 | | - pool = Pool(cores) |
| 586 | + # cores = jobs |
| 587 | + # pool = Pool(cores) |
567 | 588 |
|
568 | 589 | for worker_arg in worker_args: |
| 590 | + print(worker_arg[0]) |
569 | 591 | workflow_worker(worker_arg) |
570 | | - # for i, results in enumerate(pool.imap_unordered(workflow_worker, worker_args), 1): |
571 | 592 |
|
| 593 | + # for i, results in enumerate(pool.imap_unordered(workflow_worker, worker_args), 1): |
572 | 594 | # pass |
573 | 595 |
|
574 | | - pool.close() |
575 | | - pool.join() |
| 596 | + # pool.close() |
| 597 | + # pool.join() |
576 | 598 |
|
577 | 599 |
|
578 | 600 | def run_di_mpi(workflow_params_file, tasks, replicas): |
|
0 commit comments