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

Improve variant comparison #10

Open
smlmbrt opened this issue Aug 4, 2023 · 0 comments
Open

Improve variant comparison #10

smlmbrt opened this issue Aug 4, 2023 · 0 comments

Comments

@smlmbrt
Copy link
Member

smlmbrt commented Aug 4, 2023

Find a better way to handle this, the try/except patter seems to throw an error:

try:
variants: Variants = compare_variants(ref_variants=X_bim, study_variants=W_bim)
except NameError:
with open(ref_filepref + '_vars.dat', 'r') as infile:
ref_vars = infile.read().strip().split('\n')
stu_vars = bim_varlist(W_bim)
variants: Variants = compare_variants(ref_variants=ref_vars, study_variants=stu_vars)

Error:

Traceback (most recent call last):
  File "/venv/lib/python3.10/site-packages/fraposa_pgsc/fraposa.py", line 524, in pca
    variants: Variants = compare_variants(ref_variants=X_bim, study_variants=W_bim)
UnboundLocalError: local variable 'X_bim' referenced before assignment

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/venv/bin/fraposa", line 8, in <module>
    sys.exit(main())
  File "/venv/lib/python3.10/site-packages/fraposa_pgsc/fraposa_runner.py", line 56, in main
    fp.pca(ref_filepref=ref_filepref, stu_filepref=stu_filepref, stu_filt_iid=stu_filt_iid, out_filepref=out_filepref,
  File "/venv/lib/python3.10/site-packages/fraposa_pgsc/fraposa.py", line 529, in pca
    variants: Variants = compare_variants(ref_variants=ref_vars, study_variants=stu_vars)
  File "/venv/lib/python3.10/site-packages/fraposa_pgsc/fraposa.py", line 191, in compare_variants
    stu_indexed: list[int] = [ref_indexed[variant] for variant in stu_vars]
  File "/venv/lib/python3.10/site-packages/fraposa_pgsc/fraposa.py", line 191, in <listcomp>
    stu_indexed: list[int] = [ref_indexed[variant] for variant in stu_vars]
KeyError: '1:255633:A:G'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant