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

Reload VCF - sample order switched #1191

Open
davmlaw opened this issue Nov 7, 2024 · 0 comments
Open

Reload VCF - sample order switched #1191

davmlaw opened this issue Nov 7, 2024 · 0 comments

Comments

@davmlaw
Copy link
Contributor

davmlaw commented Nov 7, 2024

In current SA Path code - we reloaded a VCF in place where an extra sample had been added

This caused a different packed field index for sample sample name:

    for i, sample_name in enumerate(sample_names):
        sample = vcf.samples_by_vcf_name[sample_name]
        logging.info("Creating cohort sample for: %s", sample)
        CohortSample.objects.get_or_create(cohort=cohort,
                                           sample=sample,
                                           defaults={
                                                "cohort_genotype_packed_field_index": i,
                                                "sort_order": i,
                                           })

Then died with:

 Error: duplicate key value violates unique constraint "snpdb_cohortsample_cohort_id_cohort_genotyp_b2c4ac43_uniq" DETAIL: Key (cohort_id, cohort_genotype_packed_field_index)=(6057, 0) already exists. ."

Maybe a hack would be to set the index super high with:

qs.update(cohort_genotype_packed_field_index=F"(cohort_genotype_packed_field_index")+1000)
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