diff options
| author | Frederick Muriuki Muriithi <fredmanglis@gmail.com> | 2026-11-11 15:14:48 +0000 |
|---|---|---|
| committer | Frederick Muriuki Muriithi <fredmanglis@gmail.com> | 2026-11-11 09:41:53 -0600 |
| commit | e0216d86e45bc72eb86ba91585b1288ab1a49993 (patch) | |
| tree | 0e4b40f8eaf1ab2b88a5290af64037644a639391 /uploader/scripts | |
| parent | 6867a167506e59b6303cdf2ad62d227a1b2345de (diff) | |
| download | gn-uploader-e0216d86e45bc72eb86ba91585b1288ab1a49993.tar.gz | |
Scope the genotype description to pre-matrix comments
Only comments before the data matrix start feed `FileStats.description`: before the header row for untransposed files, and before the first data (markers) row for transposed files. Later comments are still counted but not used, since they relate to adjacent rows and would be taken out of context by untransposing. Track `matrix_started` per chunk and drop later chunks' comments once the matrix has started, so the multi-processed path matches the single-threaded one. Co-authored-by: pi coding agent <pi@pi.dev>
Diffstat (limited to 'uploader/scripts')
| -rw-r--r-- | uploader/scripts/genotypes/preprocess_csv_collect_info.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/uploader/scripts/genotypes/preprocess_csv_collect_info.py b/uploader/scripts/genotypes/preprocess_csv_collect_info.py index c32e5cd..e6a5266 100644 --- a/uploader/scripts/genotypes/preprocess_csv_collect_info.py +++ b/uploader/scripts/genotypes/preprocess_csv_collect_info.py @@ -204,6 +204,7 @@ class _ChunkStats:# pylint: disable=[too-many-instance-attributes] markers_seen: bool = False errors: tuple = field(default_factory=tuple) comments: tuple = field(default_factory=tuple) + matrix_started: bool = False # has data matrix started? def _accumulate( @@ -218,7 +219,10 @@ def _accumulate( stats = _ChunkStats() for line in (ln.strip() for ln in lines): stats.total_lines += 1 + if not stats.matrix_started and line_splitter(line) == headers: + stats.matrix_started = True if not is_skippable_line(line): + stats.matrix_started = True stats.data_lines += 1 fields_values = line_splitter(line) if fileconfigs["transposed"]: @@ -246,8 +250,9 @@ def _accumulate( **parse_dot_geno_line(line)} if is_comment_line(line): #handle special geno formats stats.comment_lines += 1 - stats.comments = stats.comments + ( - line[len(fileconfigs["comment.char"]):].strip(),) + if not stats.matrix_started: + stats.comments = stats.comments + ( + line[len(fileconfigs["comment.char"]):].strip(),) if line == "": # Blank line stats.blank_lines += 1 return stats @@ -281,7 +286,9 @@ def _merge_chunk_stats( markers=markers, markers_seen=left.markers_seen or right.markers_seen, errors=left.errors + right.errors, - comments=left.comments + right.comments) + comments=left.comments + ( + tuple() if left.matrix_started else right.comments), + matrix_started=left.matrix_started or right.matrix_started) def _merge_all_chunk_stats( |
