Clinical-Genomics / genotype

Simple genotype comparison of VCF files
http://taboo.readthedocs.org/en/latest/
MIT License
8 stars 2 forks source link

Improved error message for multiple SNP variants found in fetch_snp #62

Closed ChrOertlin closed 1 year ago

ChrOertlin commented 1 year ago

This PR adds/fixes ...

This PR aims to improve an error message log in _fetchsnp() of the VCF.py file.

How to prepare for test:

How to test:

Expected test outcome:

Review:

This version is a:

Implementation plan:

ChrOertlin commented 1 year ago

@henrikstranneheim , could you have a second look at the code. To improve the formatting in the error message we had to write up a function that parses the Variant.

Karl-Svard commented 1 year ago

Output when testing on stage:

θ72° 11d [hiseq.clinical@hasta:/home/proj/stage/housekeeper-bundles/safemoose/2023-01-02] [S_base] 1m58s $ cg upload genotypes safemoose
/home/proj/stage/bin/miniconda3/envs/S_main/lib/python3.7/site-packages/sqlalchemy/orm/relationships.py:2231: SAWarning: Cascade settings "delete, merge, save-update" should not be combined with a viewonly=True relationship.   This configuration will raise an error in version 1.4.  Note that in versions prior to 1.4, these cascade settings may still produce a mutating effect even though this relationship is marked as viewonly=True.
  "viewonly=True." % (", ".join(sorted(non_viewonly)))
Called undefined __fields__ on HousekeeperAPI, please wrap
Called undefined __fields__ on HousekeeperAPI, please wrap
Called undefined __fields__ on HousekeeperAPI, please wrap
Called undefined __fields__ on HousekeeperAPI, please wrap
Called undefined __fields__ on HousekeeperAPI, please wrap
Called undefined __fields__ on HousekeeperAPI, please wrap
Called undefined __fields__ on HousekeeperAPI, please wrap
Called undefined __fields__ on HousekeeperAPI, please wrap
Called undefined __fields__ on HousekeeperAPI, please wrap
Called undefined __fields__ on HousekeeperAPI, please wrap
----------------- UPLOAD -----------------
----------------- GENOTYPES -------------------
/home/proj/stage/bin/miniconda3/envs/S_main/lib/python3.7/site-packages/sqlalchemy/orm/relationships.py:1998: SAWarning: Setting backref / back_populates on relationship Demux.samples to refer to viewonly relationship Sample.demuxes should include sync_backref=False set on the Demux.samples relationship.  (this warning may be suppressed after 10 occurrences)
  (rel_b, rel_a, rel_b),
/home/proj/stage/bin/miniconda3/envs/S_main/lib/python3.7/site-packages/sqlalchemy/orm/relationships.py:1998: SAWarning: Setting backref / back_populates on relationship Sample.demuxes to refer to viewonly relationship Demux.samples should include sync_backref=False set on the Sample.demuxes relationship.  (this warning may be suppressed after 10 occurrences)
  (rel_b, rel_a, rel_b),
Initializing UploadGenotypesAPI
Fetching upload genotype data for safemoose
Fetch latest version from bundle safemoose
Fetching files with tags in [genotype]
Fetching files from version 125691
Fetching files with tags in [qc-metrics,deliverable]
Fetching files from version 125691
loading VCF genotypes for sample(s): ACC10948A15
Running command /home/proj/stage/bin/miniconda3/envs/S_genotype/bin/genotype --config /home/proj/stage/servers/config/hasta.scilifelab.se/genotype-stage.yaml load /home/proj/stage/housekeeper-bundles/safemoose/2023-01-02/safemoose_gatkcomb.bcf
Call ['/home/proj/stage/bin/miniconda3/envs/S_genotype/bin/genotype', '--config', '/home/proj/stage/servers/config/hasta.scilifelab.se/genotype-stage.yaml', 'load', '/home/proj/stage/housekeeper-bundles/safemoose/2023-01-02/safemoose_gatkcomb.bcf'] exit with a non zero exit code
2023-01-11 13:56:36 hasta.scilifelab.se genotype.cli.load_cmd[9924] INFO loading analyses from VCF file: safemoose_gatkcomb.bcf
Traceback (most recent call last):
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/bin/genotype", line 8, in <module>
    sys.exit(root())
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/lib/python3.7/site-packages/click/core.py", line 1130, in __call__
    return self.main(*args, **kwargs)
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/lib/python3.7/site-packages/click/core.py", line 1055, in main
    rv = self.invoke(ctx)
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/lib/python3.7/site-packages/click/core.py", line 1657, in invoke
    return _process_result(sub_ctx.command.invoke(sub_ctx))
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/lib/python3.7/site-packages/click/core.py", line 1404, in invoke
    return ctx.invoke(self.callback, **ctx.params)
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/lib/python3.7/site-packages/click/core.py", line 760, in invoke
    return __callback(*args, **kwargs)
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/lib/python3.7/site-packages/click/decorators.py", line 26, in new_func
    return f(get_current_context(), *args, **kwargs)
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/lib/python3.7/site-packages/genotype/cli/load_cmd.py", line 33, in load_cmd
    analyses = load_vcf(vcf_file=input_file, snps=snps)
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/lib/python3.7/site-packages/genotype/load/vcf.py", line 29, in load_vcf
    variant = fetch_snp(vcf, snp)
  File "/home/proj/stage/bin/miniconda3/envs/S_genotype/lib/python3.7/site-packages/genotype/load/vcf.py", line 68, in fetch_snp
    f"Multiple variants ({len(variants)}) found for SNP at position {pos_str}: {return_alternatives(variants)}."
ValueError: Multiple variants (2) found for SNP at position 17:71197748-71197748: G/A, G/T.
sonarcloud[bot] commented 1 year ago

Kudos, SonarCloud Quality Gate passed!    Quality Gate passed

Bug A 0 Bugs
Vulnerability A 0 Vulnerabilities
Security Hotspot A 0 Security Hotspots
Code Smell A 0 Code Smells

No Coverage information No Coverage information
0.0% 0.0% Duplication

Karl-Svard commented 1 year ago

Deployed in prod

11d [hiseq.clinical@hasta:~] [P_base] $ bash /home/proj/production/servers/resources/hasta.scilifelab.se/update-tool-prod.sh -e P_genotype -t genotype -b master
Collecting git+https://github.com/Clinical-Genomics/genotype@master
  Running command git clone --quiet https://github.com/Clinical-Genomics/genotype /home/hiseq.clinical/tmp/pip-req-build-0nuksv2r
  Cloning https://github.com/Clinical-Genomics/genotype (to revision master) to ./tmp/pip-req-build-0nuksv2r
  Resolved https://github.com/Clinical-Genomics/genotype to commit b1df4c5468dacf051f66f57606bbeff867d91d8d
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Building wheels for collected packages: genotype
  Building wheel for genotype (pyproject.toml): started
  Building wheel for genotype (pyproject.toml): finished with status 'done'
  Created wheel for genotype: filename=genotype-4.1.4-py3-none-any.whl size=31431 sha256=4792d83d38455a0919fa3ab0ccde59708dac498f37571558b0191870e32886f1
  Stored in directory: /home/hiseq.clinical/tmp/pip-ephem-wheel-cache-ijsvo1nt/wheels/01/16/ea/57ccaf0014013064dba677747cfca144721c057caa9bbc6734
Successfully built genotype
Installing collected packages: genotype
  Attempting uninstall: genotype
    Found existing installation: genotype 4.1.2
    Uninstalling genotype-4.1.2:
      Successfully uninstalled genotype-4.1.2
Successfully installed genotype-4.1.4
Collecting git+https://github.com/Clinical-Genomics/genotype@master
  Running command git clone --quiet https://github.com/Clinical-Genomics/genotype /home/hiseq.clinical/tmp/pip-req-build-fh2xame0
  Cloning https://github.com/Clinical-Genomics/genotype (to revision master) to ./tmp/pip-req-build-fh2xame0
  Resolved https://github.com/Clinical-Genomics/genotype to commit b1df4c5468dacf051f66f57606bbeff867d91d8d
  Installing build dependencies: started
  Installing build dependencies: finished with status 'done'
  Getting requirements to build wheel: started
  Getting requirements to build wheel: finished with status 'done'
  Preparing metadata (pyproject.toml): started
  Preparing metadata (pyproject.toml): finished with status 'done'
Requirement already satisfied: pymysql in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (1.0.2)
Requirement already satisfied: Flask==1.1.1 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (1.1.1)
Requirement already satisfied: gunicorn in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (20.1.0)
Requirement already satisfied: markupsafe==1.1.1 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (1.1.1)
Requirement already satisfied: Flask-Bootstrap in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (3.3.7.1)
Requirement already satisfied: cyvcf2 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (0.30.18)
Requirement already satisfied: Alchy in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (2.2.2)
Requirement already satisfied: wheel in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (0.37.1)
Requirement already satisfied: pysam in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (0.19.1)
Requirement already satisfied: itsdangerous==1.1.0 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (1.1.0)
Requirement already satisfied: Flask-Login==0.5.0 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (0.5.0)
Requirement already satisfied: Flask-Reverse-Proxy in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (0.2.0.2)
Requirement already satisfied: numpy==1.19.2 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (1.19.2)
Requirement already satisfied: ruamel.yaml in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (0.17.21)
Requirement already satisfied: Flask-Security in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (3.0.0)
Requirement already satisfied: Flask-Dance==3.0.0 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (3.0.0)
Requirement already satisfied: xlrd==1.2.0 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (1.2.0)
Requirement already satisfied: Flask-SQLAlchemy==2.1 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (2.1)
Requirement already satisfied: pyyaml in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (6.0)
Requirement already satisfied: jinja2==2.11.2 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (2.11.2)
Requirement already satisfied: click in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (8.1.3)
Requirement already satisfied: coloredlogs in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (15.0.1)
Requirement already satisfied: Flask-Alchy in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (0.5.0)
Requirement already satisfied: cython in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (0.29.32)
Requirement already satisfied: werkzeug<1.0.0 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (0.16.1)
Requirement already satisfied: SQLAlchemy<1.4 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from genotype==4.1.4) (1.3.24)
Requirement already satisfied: oauthlib in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Dance==3.0.0->genotype==4.1.4) (3.2.2)
Requirement already satisfied: six in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Dance==3.0.0->genotype==4.1.4) (1.16.0)
Requirement already satisfied: urlobject in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Dance==3.0.0->genotype==4.1.4) (2.4.3)
Requirement already satisfied: requests-oauthlib>=1.0.0 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Dance==3.0.0->genotype==4.1.4) (1.3.1)
Requirement already satisfied: requests>=2.0 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Dance==3.0.0->genotype==4.1.4) (2.28.1)
Requirement already satisfied: importlib-metadata in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from click->genotype==4.1.4) (5.0.0)
Requirement already satisfied: pydash>=3.4.7 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Alchy->genotype==4.1.4) (5.1.1)
Requirement already satisfied: humanfriendly>=9.1 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from coloredlogs->genotype==4.1.4) (10.0)
Requirement already satisfied: visitor in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Bootstrap->genotype==4.1.4) (0.1.3)
Requirement already satisfied: dominate in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Bootstrap->genotype==4.1.4) (2.7.0)
Requirement already satisfied: Flask-BabelEx>=0.9.3 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Security->genotype==4.1.4) (0.9.4)
Requirement already satisfied: Flask-WTF>=0.13.1 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Security->genotype==4.1.4) (1.0.1)
Requirement already satisfied: Flask-Principal>=0.3.3 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Security->genotype==4.1.4) (0.4.0)
Requirement already satisfied: Flask-Mail>=0.7.3 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Security->genotype==4.1.4) (0.9.1)
Requirement already satisfied: passlib>=1.7 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Security->genotype==4.1.4) (1.7.4)
Requirement already satisfied: setuptools>=3.0 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from gunicorn->genotype==4.1.4) (65.5.0)
Requirement already satisfied: ruamel.yaml.clib>=0.2.6 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from ruamel.yaml->genotype==4.1.4) (0.2.7)
Requirement already satisfied: Babel>=1.0 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-BabelEx>=0.9.3->Flask-Security->genotype==4.1.4) (2.10.3)
Requirement already satisfied: speaklater>=1.2 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-BabelEx>=0.9.3->Flask-Security->genotype==4.1.4) (1.3)
Requirement already satisfied: blinker in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-Mail>=0.7.3->Flask-Security->genotype==4.1.4) (1.5)
Requirement already satisfied: WTForms in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Flask-WTF>=0.13.1->Flask-Security->genotype==4.1.4) (3.0.1)
Requirement already satisfied: certifi>=2017.4.17 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from requests>=2.0->Flask-Dance==3.0.0->genotype==4.1.4) (2022.9.24)
Requirement already satisfied: idna<4,>=2.5 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from requests>=2.0->Flask-Dance==3.0.0->genotype==4.1.4) (3.4)
Requirement already satisfied: charset-normalizer<3,>=2 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from requests>=2.0->Flask-Dance==3.0.0->genotype==4.1.4) (2.1.1)
Requirement already satisfied: urllib3<1.27,>=1.21.1 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from requests>=2.0->Flask-Dance==3.0.0->genotype==4.1.4) (1.26.12)
Requirement already satisfied: zipp>=0.5 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from importlib-metadata->click->genotype==4.1.4) (3.10.0)
Requirement already satisfied: typing-extensions>=3.6.4 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from importlib-metadata->click->genotype==4.1.4) (4.4.0)
Requirement already satisfied: pytz>=2015.7 in /home/proj/production/bin/miniconda3/envs/P_genotype/lib/python3.7/site-packages (from Babel>=1.0->Flask-BabelEx>=0.9.3->Flask-Security->genotype==4.1.4) (2022.5)
fatal: Not a git repository (or any parent up to mount point /home)
Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).
repository is clean
Logging deploy ...
Getting deployer... done.
Getting last commit message and SHA... done.
Getting version of deploy scripts... /home/hiseq.clinical
done.
Log deploy... done.
genotype, version 4.1.4