1
SELECT stock.stock_id AS accession_id,
2
nd_experiment_protocol.nd_protocol_id AS genotyping_protocol_id,
3
nd_experiment_project.project_id AS genotyping_project_id,
4
genotype.genotype_id,
5
stock_type.name AS stock_type
6
FROM (((((((stock
7
JOIN cvterm stock_type ON (((stock_type.cvterm_id = stock.type_id) AND ((stock_type.name)::text = 'accession'::text))))
8
JOIN nd_experiment_stock ON ((stock.stock_id = nd_experiment_stock.stock_id)))
9
JOIN nd_experiment_protocol ON ((nd_experiment_stock.nd_experiment_id = nd_experiment_protocol.nd_experiment_id)))
10
LEFT JOIN nd_experiment_project ON ((nd_experiment_stock.nd_experiment_id = nd_experiment_project.nd_experiment_id)))
11
JOIN nd_protocol ON ((nd_experiment_protocol.nd_protocol_id = nd_protocol.nd_protocol_id)))
12
JOIN nd_experiment_genotype ON ((nd_experiment_stock.nd_experiment_id = nd_experiment_genotype.nd_experiment_id)))
13
JOIN genotype ON ((genotype.genotype_id = nd_experiment_genotype.genotype_id)))
14
GROUP BY stock.stock_id, nd_experiment_protocol.nd_protocol_id, nd_experiment_project.project_id, genotype.genotype_id, stock_type.name
15
UNION
16
SELECT accession.stock_id AS accession_id,
17
nd_experiment_protocol.nd_protocol_id AS genotyping_protocol_id,
18
nd_experiment_project.project_id AS genotyping_project_id,
19
nd_experiment_genotype.genotype_id,
20
stock_type.name AS stock_type
21
FROM ((((((((stock accession
22
JOIN stock_relationship ON (((accession.stock_id = stock_relationship.object_id) AND (stock_relationship.type_id IN ( SELECT cvterm.cvterm_id
23
FROM cvterm
24
WHERE ((cvterm.name)::text = ANY (ARRAY[('tissue_sample_of'::character varying)::text, ('plant_of'::character varying)::text, ('plot_of'::character varying)::text])))))))
25
JOIN stock ON (((stock_relationship.subject_id = stock.stock_id) AND (stock.type_id IN ( SELECT cvterm.cvterm_id
26
FROM cvterm
27
WHERE ((cvterm.name)::text = ANY (ARRAY[('tissue_sample'::character varying)::text, ('plant'::character varying)::text, ('plot'::character varying)::text])))))))
28
JOIN cvterm stock_type ON ((stock_type.cvterm_id = stock.type_id)))
29
JOIN nd_experiment_stock ON ((stock.stock_id = nd_experiment_stock.stock_id)))
30
JOIN nd_experiment_protocol ON ((nd_experiment_stock.nd_experiment_id = nd_experiment_protocol.nd_experiment_id)))
31
LEFT JOIN nd_experiment_project ON ((nd_experiment_stock.nd_experiment_id = nd_experiment_project.nd_experiment_id)))
32
JOIN nd_protocol ON ((nd_experiment_protocol.nd_protocol_id = nd_protocol.nd_protocol_id)))
33
JOIN nd_experiment_genotype ON ((nd_experiment_stock.nd_experiment_id = nd_experiment_genotype.nd_experiment_id)))
34
GROUP BY accession.stock_id, nd_experiment_protocol.nd_protocol_id, nd_experiment_project.project_id, nd_experiment_genotype.genotype_id, stock_type.name
35
ORDER BY 1, 2, 3, 4;