1: <?php
2:
3: namespace webservices\details\annotations\feature;
4:
5: use \PDO as PDO;
6: 7: 8:
9: class Mapman extends \WebService {
10:
11: public function getById($param_isoform_id) {
12:
13:
14: global $db;
15:
16: if (false)
17: $db = new PDO();
18:
19: $const = 'constant';
20:
21: 22: 23: 24:
25: $query_get_mapman = <<<EOF
26: SELECT
27: f.feature_id AS annotation_feature_id,
28: fp.value AS feature_annotation,
29: 'MapMan' AS db_name,
30: fdb.dbxref_id AS dbxref_id
31: FROM
32: feature f
33: JOIN featureprop fp ON (f.feature_id = fp.feature_id)
34: JOIN feature_dbxref fdb ON (f.feature_id = fdb.feature_id)
35: WHERE
36: f.feature_id IN (SELECT subject_id FROM feature_relationship WHERE object_id = :isoform_id)
37: AND f.type_id={$const('CV_ANNOTATION_MAPMAN_FEATURE')}
38:
39: EOF;
40:
41:
42: $query_get_dbxrefs = <<<EOF
43: SELECT
44: c.dbxref_id,
45: c.name AS bin_accession,
46: c.definition AS bin_definition,
47: split_part(cp.value, '\t', 1) AS bin_annot_chem,
48: split_part(cp.value, '\t', 2) AS bin_annot_definition
49: FROM
50: cvterm c
51: LEFT JOIN cvtermprop cp ON (c.cvterm_id = cp.cvterm_id AND cp.type_id={$const('CV_ANNOTATION_MAPMAN_PROP')})
52: WHERE
53: c.dbxref_id = any(ARRAY[%s])
54: EOF;
55:
56: $stm_get_mapman_hits = $db->prepare($query_get_mapman);
57: $stm_get_mapman_hits->bindParam('isoform_id', $param_isoform_id);
58:
59:
60: $ret = array();
61:
62: $bins = array();
63:
64: $stm_get_mapman_hits->execute();
65: while ($row = $stm_get_mapman_hits->fetch(PDO::FETCH_ASSOC)) {
66:
67: $bins[$row['dbxref_id']] = array();
68:
69: $ret[$row['annotation_feature_id']]= array(
70: 'annotation' => $row['feature_annotation'],
71: 'dbxref' => $row['dbxref_id']
72: );
73: }
74:
75:
76: if (count($bins) > 0) {
77:
78: $lookfor = array_keys($bins);
79:
80: $place_holders = implode(',', array_fill(0, count($lookfor), '? ::int'));
81:
82: $stm_get_dbxrefs = $db->prepare(sprintf($query_get_dbxrefs, $place_holders));
83:
84: $stm_get_dbxrefs->execute($lookfor);
85: while ($row = $stm_get_dbxrefs->fetch(PDO::FETCH_ASSOC)) {
86:
87: $ref = &$bins[$row['dbxref_id']];
88:
89: $ref['bin_accession'] = $row['bin_accession'];
90: $ref['bin_definition'] = $row['bin_definition'];
91: if ($row['bin_annot_chem'] != null) {
92: $ref['bin_annotations'][] = array(
93: 'bin_annot_chem' => $row['bin_annot_chem'],
94: 'bin_annot_definition' => $row['bin_annot_definition']
95: );
96: }
97: }
98:
99: foreach ($ret as &$val){
100: $val = array_merge($val, $bins[$val['dbxref']]);
101: }
102: }
103: return $ret;
104: }
105:
106: 107: 108:
109: public function execute($querydata) {
110:
111: return $this->getById($querydata['query1']);
112: }
113:
114: }
115:
116: ?>
117: