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

contacts are created but are not linked to projects #245

Open
dsenalik opened this issue Oct 28, 2022 · 2 comments
Open

contacts are created but are not linked to projects #245

dsenalik opened this issue Oct 28, 2022 · 2 comments

Comments

@dsenalik
Copy link
Collaborator

dsenalik commented Oct 28, 2022

Contacts are created from BioSamples and BioProjects, but are not linked to the source BioProject which should be done using the chado.project_contact table.
BioSamples are linked to contacts currently, using the biosourceprovider_id column of the chado.biomaterial table.

@dsenalik
Copy link
Collaborator Author

After loading, you can list links that could be made with this SQL

SELECT DISTINCT BP.project_id, C.contact_id FROM biomaterial B
    LEFT JOIN chado.contact C ON B.biosourceprovider_id = C.contact_id
    LEFT JOIN biomaterial_project BP ON B.biomaterial_id=BP.biomaterial_id
    LEFT JOIN project_contact PC ON BP.project_id=PC.project_id
WHERE BP.project_id IS NOT NULL AND C.contact_ID IS NOT NULL AND PC.project_id IS NULL;

and you can make the links by adding the INSERT with

INSERT INTO project_contact (project_id, contact_id)
    SELECT DISTINCT BP.project_id, C.contact_id FROM biomaterial B
    LEFT JOIN chado.contact C ON B.biosourceprovider_id = C.contact_id
    LEFT JOIN biomaterial_project BP ON B.biomaterial_id=BP.biomaterial_id
    LEFT JOIN project_contact PC ON BP.project_id=PC.project_id
WHERE BP.project_id IS NOT NULL AND C.contact_ID IS NOT NULL AND PC.project_id IS NULL;

@dsenalik
Copy link
Collaborator Author

dsenalik commented Nov 1, 2022

See also Issue #174 for discussion about improved contact import.

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