Repository navigation
Conversation
Coverage Report for CI Build 34480272501Warning No base build found for commit Coverage: 72.556%Details
Uncovered Changes
Coverage RegressionsRequires a base build to compare against. How to fix this → Coverage Stats
💛 - Coveralls |
There was a problem hiding this comment.
Sorry, but I am not super fond of this solution. As I wrote in a code comment, it's adding complexity to the general case loader used when the case is first loaded.
I'm sure it works fine and does the loading of the variants, but if I got the code right, it doesn't modify the original case document, which will still contain the vcf file with only the autosomes. Something like this:
So if you want to remove and re-upload the variants for the case in the future the MT ones won't be loaded.
Solutions I like
- Merging the files - autosomes + MT under the automsomes file and reupload all cases
- Updating the case document with a new type of VCF file, like
mt_vcf_path? via the loqusdb update command. And then re-upload all variants, including 3 categories this time (sns, mt_snvs, svs). I think this would be the cleanest way to go, after solution 1..
What do you think @dnil?
I changed it so the command is now under loqusdb update, I agree that makes more sense. I had to add some of the options that were only in loqusdb load, and I will now test it in the morning, and update the output in the test. I also added that it updates the nr_variants, I'll test it now. I like the second option you mention, maybe something like additional_vcf_path? That can be null for files that do not have anything extra uploaded (just like when no SVs are uploaded). That way we would not have to reupload anything, and could just trigger the update command for those cases. |
Nice, let's try like this. We also have to keep in mind that invasive changes might break loqusdbapi, which uses several loqusdb functions in background. Let's check before merging |
|
northwestwitch
left a comment
There was a problem hiding this comment.
I think it's definitely getting there but there are some things I would change. Mainly:
- If you allow extra VCF files to be both SNVs and SVs, I think you should allow both to be loaded, and not hard code that the additional file should be SNVs
- I'm not sure about the variants existence check before the insert: it could slow down the whole thing, which we don't want
Nice with the check of build and chromosome profix. It was completely missing and potentially a bug! 💯
This could use a review/suggestion also from @dnil that perhaps has a better insight than me on the loqus database?
| help="Specify the maximum window size for svs", | ||
| ) | ||
| @click.option( | ||
| "--add-to-existing-snv", |
There was a problem hiding this comment.
Why is it named like this if the additional file can be a SV VCF?
| help="Specify the maximum window size for svs", | ||
| ) | ||
| @click.option( | ||
| "--add-to-existing-snv", |
| is_flag=True, | ||
| default=False, | ||
| show_default=True, | ||
| help="Add SNVs to an existing case without replacing its stored SNV VCF", |
There was a problem hiding this comment.
| help="Add SNVs to an existing case without replacing its stored SNV VCF", | |
| help="Associate an additional VCF with a case without replacing existing VCFs or variants", |
| ctx.abort() | ||
|
|
||
| if add_to_existing_snv and (not variant_file or sv_variants): | ||
| LOG.warning("--add-to-existing-snv requires --variant-file and no --sv-variants") |
There was a problem hiding this comment.
I would not make this check. Instead I would check that you provide either a SNV or a SV file.
| variant_sv_path = os.path.abspath(sv_variants) | ||
|
|
||
| adapter = ctx.obj["adapter"] | ||
| genome_build = ctx.obj["genome_build"] |
| raise CaseError("Case {} does not exist in database".format(case_obj["case_id"])) | ||
|
|
||
| if add_to_existing_snv: | ||
| if not existing_case.get("vcf_path"): |
There was a problem hiding this comment.
Why? I don't think it matters for the sake of adding extra VCFs and variants, or perhaps I'm not considering something?
| for variant in variants | ||
| if variant | ||
| and case_obj["case_id"] | ||
| not in (adapter.get_variant(variant) or {}).get("families", []) |
There was a problem hiding this comment.
I see where this comes from. I don't know, this lookup for each variant has the potential of slowing down the whole process, as the loqus database is huge.. I guess we could entirely skip this code if we assume that we are not going to insert variants that already exist for the case, but mmm
|
I don't know, The more I think about this and the more complicated it seems.. |
Thank you for the review. I can see your point, this is getting more messy the further we get. The sample order is also not something I can promise is the same every time. This PR came from a need to have the MT variants added for each case. I will check how involved it would be to manually create the concatenated files for these cases, and re-upload each case. Edit, assuming only 15 minutes to delete and load each case, we are looking at 21 days' worth of uploading, that does not include concatenating and storing the files. |
203df44 to
75b19cb
Compare
|
Currently uploaded mt variants for 1589 singleton cases (all eligible WGS hg38 cases since the start of RD hg38 until this week). This leaves out 253 duo and trio cases (mix of WGS and WES; WES don't have the MT file) that we can add in the future or ignore, depending on whether we trust the sample matching for multi-sample cases. Using the .sh script below: |
|
Closed, as the needed files are now part of the database. |
|
Great job @peterpru! 👏🏻 👏🏻 🥳 🥇 |






Description
This PR adds the option to update an existing set of SNVs with additional SNVs, without modifying the already uploaded variants. This is a solution for uploading MT variants of cases that have already been run, but did not have their MT variants uploaded (https://github.com/Clinical-Genomics/MTP-RAREDISEASE/issues/172). We do not want to reupload all these cases, only to add to them.
This should run as:
Added
loqusdb update --add-to-existing-snvto append SNVs to an existing case without replacing its original SNV upload.--ignore-gq-if-unsetsupport toloqusdb update.Changed
loqusdb updatenow accepts the global--genome-buildand--keep-chr-prefixoptions.How to prepare for test
uspaxabash /home/proj/production/servers/resources/hasta.scilifelab.se/update-tool-stage.sh -e S_loqusdb -t loqusdb -b update-existing-snv-variantsHow to test
Do regular upload of NIST sample:
/home/proj/stage/bin/miniconda3/envs/S_loqusdb/bin/loqusdb --config /home/proj/stage/servers/config/hasta.scilifelab.se/loqusdb-wgs-stage.yaml --keep-chr-prefix --genome-build GRCh38 load --case-id evolvedsalmon --variant-file /home/proj/production/housekeeper-bundles/evolvedsalmon/2026-05-13/evolvedsalmon_snv_ranked_clinical.vcf.gz --check-profile /home/proj/production/housekeeper-bundles/evolvedsalmon/2026-05-13/evolvedsalmon_snv_ranked_clinical.vcf.gz --family-file /home/proj/production/housekeeper-bundles/evolvedsalmon/2026-05-13/evolvedsalmon.ped --gq-threshold 10 --hard-threshold 0.95 --soft-threshold 0.9Do the addition with the new flag --add-to-existing-snv:
/home/proj/stage/bin/miniconda3/envs/S_loqusdb/bin/loqusdb --config /home/proj/stage/servers/config/hasta.scilifelab.se/loqusdb-wgs-stage.yaml --keep-chr-prefix --genome-build GRCh38 update --case-id evolvedsalmon --variant-file /home/proj/production/housekeeper-bundles/evolvedsalmon/2026-05-13/evolvedsalmon_mt_ranked_clinical.vcf.gz --family-file /home/proj/production/housekeeper-bundles/evolvedsalmon/2026-05-13/evolvedsalmon.ped --ignore-gq-if-unset --add-to-existing-snvExpected test outcome
Checking in MongoDB compass shows the number of variants in the DB to be 608989, which is the 608974 of the SNV upload + the 15 of the MT upload.

Query mongoDB to show MT variants added:
Bonus test, the case variants should have been updated to the new number:

After loqusDB load it shows the nr of variants in the VCF:
After loqusdb update it shows the number of variants in the VCF + MT VCF:

Review
Thanks for filling in who performed the code review and the test!
This version is a
Implementation Plan