1: <?php
2:
3: namespace webservices\combisearch;
4:
5: use \PDO as PDO;
6:
7: 8: 9: 10:
11: class Hasgo_or_children extends \WebService {
12:
13: 14: 15: 16: 17: 18:
19: public function execute($querydata) {
20: global $db;
21: $constant = 'constant';
22:
23: $species = $querydata['species'];
24: $release = $querydata['release'];
25:
26: $term = trim($querydata['term']);
27:
28: $query_get_parent_cvterm = <<<EOF
29: SELECT cvterm.cvterm_id
30: FROM dbxref, cvterm, cvterm_relationship
31: WHERE db_id=(SELECT db_id FROM db WHERE name='GO')
32: AND trim(LEADING '0' FROM accession)=trim(LEADING '0' FROM :accession)
33: AND dbxref.dbxref_id = cvterm.dbxref_id
34: LIMIT 1
35: EOF;
36: $stm_get_parent = $db->prepare($query_get_parent_cvterm);
37:
38:
39:
40: $query_get_features = <<<EOF
41: SELECT fd.feature_id
42: FROM
43: feature_dbxref fd,
44: (SELECT dbxref_id FROM get_cvterm_children(:parent) GROUP BY cvterm_id, dbxref_id
45: ) AS dbxref,
46: (SELECT feature_id FROM feature WHERE feature.type_id={$constant('CV_ISOFORM')} AND feature.organism_id = :species AND feature.dbxref_id = (SELECT dbxref_id FROM dbxref WHERE db_id={$constant('DB_ID_IMPORTS')} AND accession=:release LIMIT 1)) as feature
47: WHERE
48: feature.feature_id = fd.feature_id
49: AND fd.dbxref_id = dbxref.dbxref_id
50:
51:
52: EOF;
53:
54: $stm_get_features = $db->prepare($query_get_features);
55:
56:
57: $data = array('results' => array());
58:
59: $stm_get_parent->execute(array(
60: 'accession' => $term
61: ));
62: $parent = $stm_get_parent->fetchColumn();
63: if ($parent == null)
64: return $data;
65:
66: $stm_get_features->execute(array(
67: 'parent' => $parent,
68: 'species' => $species,
69: 'release' => $release
70: ));
71: while ($feature = $stm_get_features->fetch(PDO::FETCH_ASSOC)) {
72: $data['results'][] = $feature['feature_id'];
73: }
74:
75: return $data;
76: }
77:
78: }
79:
80: ?>
81: