Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: issue warnings instead of errors when trying to check the header of hap files and issue error when output of transform is not provided to simphenotype #254

Merged
merged 3 commits into from
Aug 7, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions haptools/data/haplotypes.py
Original file line number Diff line number Diff line change
Expand Up @@ -861,7 +861,7 @@ def check_header(
Whether to also check the version of the file
softly: bool, optional
If True, then this function will not raise any ValueErrors. Instead, it
will only issue errors via the logging module, which may be ignored.
will only issue warnings via the logging module, which may be ignored.

Raises
------
Expand All @@ -881,7 +881,7 @@ def check_header(
if softly:

def err_msgr(msg):
self.log.error(msg)
self.log.warning(msg)

else:

Expand Down Expand Up @@ -932,7 +932,12 @@ def err_msgr(msg):
)
# if there are any fields left...
if any(exp_extras.values()):
names = [n for name in exp_extras.values() for n in name]
names = tuple(
f"#{t} {tval}"
for t in exp_extras
for tval in exp_extras[t]
if exp_extras[t]
)
err_msgr(
"Expected the input .hap file to have these extra fields, but they "
f"don't seem to be declared in the header: {*names,}"
Expand Down
4 changes: 2 additions & 2 deletions haptools/sim_phenotype.py
mlamkin7 marked this conversation as resolved.
Show resolved Hide resolved
Original file line number Diff line number Diff line change
Expand Up @@ -444,10 +444,10 @@ def simulate_pt(
gt = Genotypes.merge_variants((gt, tr_gt), fname=None)

# check that all of the genotypes were loaded successfully and warn otherwise
if len(haplotype_ids) < len(gt.variants):
if len(haplotype_ids) > len(gt.variants):
diff = list(haplotype_ids.difference(gt.variants["id"]))
first_few = 5 if len(diff) > 5 else len(diff)
log.warning(
log.error(
f"{len(diff)} effects could not be found in the genotypes file. Check "
"that the IDs in your .snplist or .hap file correspond with those in the "
"genotypes file. Here are the first few missing variants: "
Expand Down
Loading