1: <?php
2:
3: namespace webservices\details;
4:
5: require_once 'TranscriptDB//db.php';
6: 7: 8: 9:
10: class Features extends \WebService {
11:
12: 13: 14: 15: 16:
17: public function execute($querydata) {
18: $feature_ids = array();
19:
20: if (isset($querydata['query1']))
21: $feature_ids[] = $querydata['query1'];
22:
23: if (isset($querydata['terms']))
24: $feature_ids = array_merge($feature_ids, $querydata['terms']);
25:
26:
27: $ret = array('results' => array());
28: if (count($feature_ids) == 0) {
29: return $ret;
30: }
31:
32: $place_holders = implode(',', array_fill(0, count($feature_ids), '?'));
33:
34: global $db;
35: $constant = 'constant';
36:
37: $query = <<<EOF
38: SELECT
39: feature.feature_id, feature.name, dbxref.accession AS dataset, organism.common_name AS organism, type_id, COALESCE((
40: SELECT s.name
41: FROM feature_synonym fs, synonym s
42: WHERE fs.feature_id=feature.feature_id
43: AND s.synonym_id=fs.synonym_id
44: AND s.type_id=(SELECT type_id FROM cvterm WHERE name='symbol' LIMIT 1)
45: LIMIT 1
46: ),'') AS alias
47: FROM feature
48: JOIN dbxref ON (feature.dbxref_id = dbxref.dbxref_id AND dbxref.db_id = {$constant('DB_ID_IMPORTS')})
49: JOIN organism ON (feature.organism_id = organism.organism_id)
50: WHERE feature.feature_id IN ($place_holders)
51: EOF;
52:
53:
54: $stm = $db->prepare($query);
55: $stm->execute($feature_ids);
56: while ($row = $stm->fetch(\PDO::FETCH_ASSOC)) {
57: switch ($row['type_id']) {
58: case CV_ISOFORM:
59: $row['type'] = 'isoform';
60: break;
61: case CV_UNIGENE:
62: $row['type'] = 'unigene';
63: break;
64: default:
65: $row['type'] = 'unknown';
66: break;
67: }
68: unset($row['type_id']);
69: $ret['results'][] = $row;
70: }
71: return $ret;
72: }
73:
74: }
75:
76: ?>
77: