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

Truvari refine fails when no regions to refine #185

Closed
nate-d-olson opened this issue Jan 4, 2024 · 4 comments
Closed

Truvari refine fails when no regions to refine #185

nate-d-olson opened this issue Jan 4, 2024 · 4 comments

Comments

@nate-d-olson
Copy link

Version :
v4.1.0

Describe the bug :
Truvari returns an error when there are no regions to refine. Truvari fails during the haplotype extraction step.

To Reproduce :
Running truvari refine on truvari bench output.

2024-01-04 15:17:38,895 [INFO] Truvari v4.1.0
2024-01-04 15:17:38,896 [INFO] Command /defrabb_runs/runs_in_progress/test/.snakemake/conda/f189be9ffe3697323294d64c0da0f554_/bin/truvari refine --threads 1 --align mafft --use-original --reference resources/references/GRCh38_chr21.fa --regions results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default/candidate.refine.bed results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default
2024-01-04 15:17:38,896 [INFO] Params:
{
    "benchdir": "results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default",
    "reference": "resources/references/GRCh38_chr21.fa",
    "regions": "results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default/candidate.refine.bed",
    "use_original_vcfs": true,
    "use_region_coords": false,
    "recount": false,
    "threads": 1,
    "align": "mafft",
    "debug": false
}
2024-01-04 15:17:38,896 [INFO] Setting up regions
2024-01-04 15:17:38,897 [INFO] 26 --includebed reduced to 7 after intersecting with 10 from --regions
2024-01-04 15:17:38,960 [INFO] 0 regions to be refined
2024-01-04 15:17:38,967 [INFO] Preparing regions
2024-01-04 15:17:38,968 [INFO] Extracting haplotypes
Traceback (most recent call last):
  File "/defrabb_runs/runs_in_progress/test/.snakemake/conda/f189be9ffe3697323294d64c0da0f554_/bin/truvari", line 10, in <module>
    sys.exit(main())
  File "/defrabb_runs/runs_in_progress/test/.snakemake/conda/f189be9ffe3697323294d64c0da0f554_/lib/python3.9/site-packages/truvari/__main__.py", line 102, in main
    TOOLS[args.cmd](args.options)
  File "/defrabb_runs/runs_in_progress/test/.snakemake/conda/f189be9ffe3697323294d64c0da0f554_/lib/python3.9/site-packages/truvari/refine.py", line 389, in refine_main
    truvari.phab(to_eval_coords, base_vcf, args.reference, phab_vcf, buffer=PHAB_BUFFER, comp_vcf=comp_vcf,
  File "/defrabb_runs/runs_in_progress/test/.snakemake/conda/f189be9ffe3697323294d64c0da0f554_/lib/python3.9/site-packages/truvari/phab.py", line 307, in phab
    ref_haps_fn = extract_reference(region_fn, ref_fn)
  File "/defrabb_runs/runs_in_progress/test/.snakemake/conda/f189be9ffe3697323294d64c0da0f554_/lib/python3.9/site-packages/truvari/phab.py", line 80, in extract_reference
    fout.write(samtools.faidx(ref_fn, "-r", reg_fn))
  File "/defrabb_runs/runs_in_progress/test/.snakemake/conda/f189be9ffe3697323294d64c0da0f554_/lib/python3.9/site-packages/pysam/utils.py", line 83, in __call__
    raise SamtoolsError(
pysam.utils.SamtoolsError: 'samtools returned with error 1: stdout=, stderr='

Expected behavior :
Truvari completes with message stating to regions were refined, potentially returning an error. Not sure what the optimal behavior is here for most users.

Example Data :
Tarballs with truvari bench output and ref file used.

Additional context :
Encountered this error running a small test dataset during pipeline development. I can provide input files and commands used to generate the truvari bench output if needed.

@ACEnglish
Copy link
Owner

Funny story, this is the third ticket in a row related to pysam.bcftools.consensus. Luckily, the first ticket required me to replace the haplotype consensus creation step with something more stable. Therefore, you may not see the error if you install directly from develop and try again. Please install from develop and let me know if you still see an error.

git clone https://github.com/spiralgenetics/truvari.git
python3 -m pip install truvari

@nate-d-olson
Copy link
Author

Unfortunately, the replacement didn't address this error. Looks like it is an issue with extract_references, specifically the call to pysam.faidx(). Here is the log file.

2024-01-04 17:33:39,857 [INFO] Truvari v4.2.0rc1
2024-01-04 17:33:39,858 [INFO] Command /home/nolson/mambaforge/envs/truvari_eval/bin/truvari refine --threads 1 --align mafft --use-original --reference resources/references/GRCh38_chr21.fa --regions results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default/candidate.refine.bed results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default
2024-01-04 17:33:39,858 [INFO] Params:
{
    "benchdir": "results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default",
    "reference": "resources/references/GRCh38_chr21.fa",
    "regions": "results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default/candidate.refine.bed",
    "use_original_vcfs": true,
    "use_region_coords": false,
    "recount": false,
    "threads": 1,
    "align": "mafft",
    "mafft_params": "--auto --thread 1",
    "debug": false
}
2024-01-04 17:33:39,858 [INFO] Setting up regions
2024-01-04 17:33:39,859 [INFO] 26 --includebed reduced to 7 after intersecting with 10 from --regions
2024-01-04 17:33:39,934 [INFO] 0 regions to be refined
2024-01-04 17:33:39,950 [INFO] Preparing regions
2024-01-04 17:33:39,951 [INFO] Extracting haplotypes
Traceback (most recent call last):
  File "/home/nolson/mambaforge/envs/truvari_eval/bin/truvari", line 8, in <module>
    sys.exit(main())
  File "/home/nolson/mambaforge/envs/truvari_eval/lib/python3.9/site-packages/truvari/__main__.py", line 102, in main
    TOOLS[args.cmd](args.options)
  File "/home/nolson/mambaforge/envs/truvari_eval/lib/python3.9/site-packages/truvari/refine.py", line 413, in refine_main
    truvari.phab(to_eval_coords, base_vcf, args.reference, phab_vcf, buffer=PHAB_BUFFER,
  File "/home/nolson/mambaforge/envs/truvari_eval/lib/python3.9/site-packages/truvari/phab.py", line 338, in phab
    ref_haps_fn = extract_reference(region_fn, ref_fn)
  File "/home/nolson/mambaforge/envs/truvari_eval/lib/python3.9/site-packages/truvari/phab.py", line 80, in extract_reference
    fout.write(samtools.faidx(ref_fn, "-r", reg_fn))
  File "/home/nolson/mambaforge/envs/truvari_eval/lib/python3.9/site-packages/pysam/utils.py", line 83, in __call__
    raise SamtoolsError(
pysam.utils.SamtoolsError: 'samtools returned with error 1: stdout=, stderr='```

ACEnglish added a commit that referenced this issue Jan 4, 2024
no region guard for refine
@ACEnglish
Copy link
Owner

My mistake. I saw pysam and guess I stopped reading the error. I just pushed a guard into develop that should work.

@nate-d-olson
Copy link
Author

Thanks! That works. I'll close the issue. Here the log from my run 2024-01-04 17:50:07,230 [INFO] Truvari v4.2.0rc1 2024-01-04 17:50:07,230 [INFO] Command /home/nolson/mambaforge/envs/truvari_eval/bin/truvari refine --threads 1 --align mafft --use-original --reference resources/references/GRCh38_chr21.fa --regions results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default/candidate.refine.bed results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default 2024-01-04 17:50:07,230 [INFO] Params: { "benchdir": "results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default", "reference": "resources/references/GRCh38_chr21.fa", "regions": "results/evaluations/truvari/eval14_testC/GRCh38_chr21_CMRGv1.00-stvar_asm17aChr21_stvar_dipcall-default/candidate.refine.bed", "use_original_vcfs": true, "use_region_coords": false, "recount": false, "threads": 1, "align": "mafft", "mafft_params": "--auto --thread 1", "debug": false } 2024-01-04 17:50:07,230 [INFO] Setting up regions 2024-01-04 17:50:07,231 [INFO] 26 --includebed reduced to 7 after intersecting with 10 from --regions 2024-01-04 17:50:07,280 [INFO] 0 regions to be refined 2024-01-04 17:50:07,293 [INFO] Preparing regions 2024-01-04 17:50:07,294 [CRITICAL] No regions to be refined. Exiting

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

2 participants