Skip to content

Commit eb8fbaa

Browse files
committed
add log warning re: missing variants
1 parent 84a68c4 commit eb8fbaa

File tree

2 files changed

+19
-10
lines changed

2 files changed

+19
-10
lines changed

pgscatalog.core/src/pgscatalog/core/cli/combine_cli.py

+9-6
Original file line numberDiff line numberDiff line change
@@ -99,13 +99,16 @@ def run():
9999
writer.write(dumped_variants)
100100
n_finished += 1
101101
finally:
102-
variant_log.append(
103-
ScoreLog(
104-
header=scorefile.header,
105-
variants=normalised_score,
106-
compatible_effect_type=is_compatible,
107-
)
102+
log = ScoreLog(
103+
header=scorefile.header,
104+
variants=normalised_score,
105+
compatible_effect_type=is_compatible,
108106
)
107+
if log.variants_are_missing:
108+
logger.warning(
109+
f"{log.variant_count_difference} fewer variants in output compared to original file"
110+
)
111+
variant_log.append(log)
109112

110113
if n_finished == 0:
111114
raise ValueError(

pgscatalog.core/src/pgscatalog/core/lib/models.py

+10-4
Original file line numberDiff line numberDiff line change
@@ -725,12 +725,15 @@ def sources(self) -> Optional[list[str]]:
725725
return None
726726

727727
@property
728-
def n_actual_variants(self) -> int:
728+
def n_actual_variants(self) -> Optional[int]:
729729
# this distinction is useful if variants have been filtered out
730-
return len(self.variants)
730+
if self.variants is not None:
731+
return len(self.variants)
732+
else:
733+
return None
731734

732735
@cached_property
733-
def variant_count_difference(self) -> int:
736+
def variant_count_difference(self) -> Optional[int]:
734737
# grab directly from header
735738
header_variants = getattr(self.header, "variants_number", None)
736739
if header_variants is None:
@@ -741,7 +744,10 @@ def variant_count_difference(self) -> int:
741744
else:
742745
header_variants = self.header.row_count
743746

744-
return abs(header_variants - self.n_actual_variants)
747+
try:
748+
return abs(header_variants - self.n_actual_variants)
749+
except TypeError:
750+
return None
745751

746752
@property
747753
def variants_are_missing(self) -> bool:

0 commit comments

Comments
 (0)