|
10 | 10 | from typing import Dict, List, Optional, Tuple, Union
|
11 | 11 |
|
12 | 12 | import multiqc as mqc
|
13 |
| -import numpy as np |
14 | 13 | import pandas as pd
|
15 |
| -from multiqc.plots import bargraph, table |
| 14 | +from multiqc.plots import bargraph |
16 | 15 | from multiqc.types import Anchor
|
17 | 16 | from utils.constant_variables import CLUSTER_PCONFIG
|
18 | 17 | from utils.file_tools import filelist_to_df, get_module_selection, read_in_quast, write_df
|
@@ -178,6 +177,21 @@ def file_choices(choices, fname):
|
178 | 177 | )
|
179 | 178 | return parser.parse_args(argv)
|
180 | 179 |
|
| 180 | +def get_failed_samples(samples: List[str]) -> List[str]: |
| 181 | + """ |
| 182 | + Get failed samples from the modules |
| 183 | + - sample_low_reads |
| 184 | + - samples_without_contigs |
| 185 | + """ |
| 186 | + if (samples_low_reads := get_module_data(mqc, 'samples_low_reads')): |
| 187 | + logger.info("samples_low_reads %s", samples_low_reads) |
| 188 | + samples.extend([k for k in samples_low_reads.keys()]) |
| 189 | + |
| 190 | + if (samples_without_contigs := get_module_data(mqc, 'samples_without_contigs')): |
| 191 | + logger.info("samples_without_contigs %s", samples_without_contigs) |
| 192 | + samples.extend([k for k in samples_without_contigs.keys() ]) |
| 193 | + |
| 194 | + return samples |
181 | 195 |
|
182 | 196 | def load_custom_data(args) -> List[pd.DataFrame]:
|
183 | 197 | """
|
@@ -409,11 +423,12 @@ def extract_mqc_data(table_headers: Union[str, Path]) -> Optional[pd.DataFrame]:
|
409 | 423 | return join_df(result, data) if data else result, columns_result
|
410 | 424 |
|
411 | 425 |
|
412 |
| -def write_results(contigs_mqc, constrains_mqc, constrains_genstats, args) -> int: |
| 426 | +def write_results(contigs_mqc: pd.DataFrame, constrains_mqc: pd.DataFrame, constrains_genstats: pd.DataFrame) -> int: |
413 | 427 | """
|
414 | 428 | Write the results to files.
|
415 | 429 | """
|
416 |
| - samples = [] |
| 430 | + samples = get_failed_samples([]) |
| 431 | + logger.info("samples %s", samples) |
417 | 432 | if not contigs_mqc.empty:
|
418 | 433 | logger.info("Writing Unfiltered Denovo constructs table file: contigs_overview.tsv")
|
419 | 434 | samples.extend(contigs_mqc["sample"])
|
@@ -511,7 +526,7 @@ def main(argv=None):
|
511 | 526 |
|
512 | 527 | coalesced_constrains, constrains_genstats = reformat_constrain_df(constrains_mqc, renamed_columns, args)
|
513 | 528 |
|
514 |
| - write_results(contigs_mqc, coalesced_constrains, constrains_genstats, args) |
| 529 | + write_results(contigs_mqc, coalesced_constrains, constrains_genstats) |
515 | 530 | return 0
|
516 | 531 |
|
517 | 532 |
|
|
0 commit comments