Skip to content

Improve variant comparison #10

@smlmbrt

Description

@smlmbrt

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'

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions