Parses source tables
Validates tables and samples against checks and schemas, reads
in the source table itself and returns a dict with a list of
validated reports, the report type detected and the source table
itself, in a pandas DataFrame.
| Parameters: |
-
source_table
(Path)
–
Path to the csv source table
-
console
(Console)
–
Console to print messages to, utilized by subfunctions.
|
| Returns: |
-
dict( Dict
) –
Dict with 'samples', containing the samples and report types;
and 'dataframe' with the source table itself.
|
Source code in microview/file_finder.py
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221 | def parse_source_table(source_table: Path, console) -> Dict:
"""
Parses source tables
Validates tables and samples against checks and schemas, reads
in the source table itself and returns a dict with a list of
validated reports, the report type detected and the source table
itself, in a pandas DataFrame.
Args:
source_table (Path): Path to the csv source table
console (rich.Console): Console to print messages to, utilized by subfunctions.
Returns:
dict: Dict with 'samples', containing the samples and report types;
and 'dataframe' with the source table itself.
"""
report = get_validation_dict(source_table, schema=contrast_table_schema)
check_source_table_validation(report, console)
df = read_csv(source_table)
sample_paths: List[Path] = [Path(sample) for sample in df["sample"].to_list()]
validated_paths = validate_paths(sample_paths, source_table)
samples = detect_report_type(validated_paths, console)
return {
"samples": samples,
"dataframe": df,
}
|