Overview

Namespaces

  • cli_db
    • propel
      • map
      • om
  • cli_import
  • LoggedPDO
  • None
  • PHP
  • webservices
    • cart
    • combisearch
    • details
      • annotations
        • feature
    • graphs
      • barplot
      • genome
    • listing
    • queue

Classes

  • Dbxref
  • Interpro_predpeps
  • Mapman
  • Pub
  • Repeatmasker
  • Synonym
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: namespace webservices\details\annotations\feature;
  4: 
  5: use \PDO as PDO;
  6: 
  7: /**
  8:  * Web Service.
  9:  * Returns Predpep details and all Interpro Annotations for requested isoform feature.
 10:  */
 11: class Interpro_predpeps extends \WebService {
 12: 
 13:     /**
 14:      * return array by feature id
 15:      * @global \PDO $db
 16:      * @param int $param_feature_id
 17:      * @return Array
 18:      */
 19:     public function getById($param_feature_id) {
 20:         global $db;
 21: #UI hint
 22:         if (false)
 23:             $db = new PDO();
 24: 
 25:         $constant = 'constant';
 26:         $param_predpep_id = null;
 27: 
 28:         //predpep details
 29:         $query_get_predpeps = <<<EOF
 30: SELECT predpep.*, featureloc.* 
 31:     FROM feature AS predpep, featureloc 
 32:     WHERE featureloc.feature_id=predpep.feature_id 
 33:         AND featureloc.srcfeature_id=:isoform_id
 34:         AND predpep.type_id = {$constant('CV_PREDPEP')}
 35: EOF;
 36: 
 37:         $stm_get_predpeps = $db->prepare($query_get_predpeps);
 38:         $stm_get_predpeps->bindParam('isoform_id', $param_feature_id);
 39:         /**
 40:          * get_predpep_annotations_interpro RETURNS
 41:          *   TABLE (predpep_id int, feature_id int, uniquename text, fmin int, fmax int, strand smallint, interpro_ID text, evalue double precision, analysis_name character varying(255), program  character varying(255), programversion  character varying(255), sourcename  character varying(255), analysis_match_id text, analysis_match_description text)
 42:          */
 43:         $stm_get_interpro = $db->prepare('SELECT * FROM get_predpep_annotations_interpro(ARRAY[:predpep_id::int])');
 44:         $stm_get_interpro->bindParam('predpep_id', $param_predpep_id);
 45: 
 46:         //all interpro dbxrefs, including description and cv
 47:         $query_get_interpro_dbxrefs = <<<EOF
 48: SELECT 
 49:   DISTINCT ON (cvterm.dbxref_id, cv.cv_id)
 50:   db.name AS dbname, dbxref.accession, dbxref.version AS dbversion, cvterm.name AS name, cvterm.definition AS definition, cv.name AS go_namespace 
 51: FROM 
 52:   feature_dbxref
 53:   JOIN dbxref ON (dbxref.dbxref_id = feature_dbxref.dbxref_id)
 54:   JOIN db ON (db.db_id = dbxref.db_id)
 55:   LEFT JOIN cvterm ON (cvterm.dbxref_id = dbxref.dbxref_id)
 56:   LEFT JOIN cv ON (cv.cv_id = cvterm.cv_id)
 57: WHERE 
 58:   feature_dbxref.feature_id = :interpro_feature_id                
 59: EOF;
 60: 
 61:         $stm_get_interpro_dbxref = $db->prepare($query_get_interpro_dbxrefs);
 62:         $stm_get_interpro_dbxref->bindParam('interpro_feature_id', $param_interpro_feature_id);
 63: 
 64:         $ret = array();
 65: 
 66:         // build return array structure
 67:         $stm_get_predpeps->execute();
 68:         //for each predpep
 69:         while ($predpep = $stm_get_predpeps->fetch(PDO::FETCH_ASSOC)) {
 70:             $ret[] = $predpep;
 71:             //$current points to the last entry in the $ret array
 72:             $current = &$ret[count($ret) - 1];
 73: 
 74:             $param_predpep_id = $predpep['feature_id'];
 75:             //get interpro annotations
 76:             $stm_get_interpro->execute();
 77:             while ($interpro = $stm_get_interpro->fetch(PDO::FETCH_ASSOC)) {
 78:                 //accumulate these in the array $ret[last]['interpro']
 79:                 $current['interpro'][] = $interpro;
 80:                 //curr_interpro points to the currently added interpro entry
 81:                 $curr_interpro = &$current['interpro'][count($current['interpro']) - 1];
 82:                 $param_interpro_feature_id = $interpro['feature_id'];
 83:                 // for each interpro annotation get all dbxrefs
 84:                 $stm_get_interpro_dbxref->execute();
 85:                 while ($interpro_dbxref = $stm_get_interpro_dbxref->fetch(PDO::FETCH_ASSOC)) {
 86:                     // and accumulate them in $ret[last]['interpro'][last]['dbxref'][]
 87:                     $curr_interpro['dbxref'][] = $interpro_dbxref;
 88:                 }
 89:             }
 90:         }
 91: //$ret may look like
 92: //[
 93: //    {
 94: //        "feature_id": 921323,
 95: //        "dbxref_id": 97321,
 96: //        "organism_id": 13,
 97: //        "name": "m.3284207",
 98: //        "uniquename": "test_comp231081_c0_seq1:1544-510",
 99: //        "residues": "MAAMNKYSTQLVLLALIIFAMGLFAAKVSSSRLLNSDVSMKERHEQWMKEYGRVYEDTAEKERRFNIFKINVERIESMNKLNRSFTLGVNAFTDLTLEEFRASHNGYKQRPVGSLKATSFKYENFTSVPNLINWVTNGAVTPVKDQGQCGCCWAFSAVASTEGIHSINTKKLVSLSEQQVLDCDTNGQDQGCNGGMPQGAFEYMISNGGLTTEDAYPYTGSQGWWCNLWFDAIAAKISNYENVPSDEGSLQKAVANQPCSVAIDASCDDFMQYSGGVFSESCGDNLDHAVTAVGYGTTDDGTDYWLVKNSWGTSWGENGYIRMQRNVGGNGMCGIATDASYPTM*",
100: //        "seqlen": 345,
101: //        "md5checksum": null,
102: //        "type_id": 219,
103: //        "is_analysis": false,
104: //        "is_obsolete": false,
105: //        "timeaccessioned": "2013-06-10 20:29:09.73871",
106: //        "timelastmodified": "2013-06-10 20:29:09.73871",
107: //        "featureloc_id": 295019,
108: //        "srcfeature_id": 456227,
109: //        "fmin": 510,
110: //        "is_fmin_partial": false,
111: //        "fmax": 1544,
112: //        "is_fmax_partial": false,
113: //        "strand": -1,
114: //        "phase": null,
115: //        "residue_info": null,
116: //        "locgroup": 0,
117: //        "rank": 0,
118: //        "interpro": [
119: //            {
120: //                "predpep_id": 921323,
121: //                "feature_id": 1815524,
122: //                "uniquename": "test_comp231081_c0_seq1:1544-510_SSF54001_33_344",
123: //                "fmin": 33,
124: //                "fmax": 344,
125: //                "strand": 1,
126: //                "interpro_id": null,
127: //                "evalue": "2.2e-106",
128: //                "analysis_name": "Interpro Analysis",
129: //                "program": "Interpro",
130: //                "programversion": "unknown",
131: //                "sourcename": "superfamily",
132: //                "analysis_match_id": "SSF54001",
133: //                "analysis_match_description": "Cysteine proteinases"
134: //            },
135: //            {
136: //                "predpep_id": 921323,
137: //                "feature_id": 1815640,
138: //                "uniquename": "test_comp231081_c0_seq1:1544-510_PF00112_128_343",
139: //                "fmin": 128,
140: //                "fmax": 343,
141: //                "strand": 1,
142: //                "interpro_id": "IPR000668",
143: //                "evalue": "3.1e-075",
144: //                "analysis_name": "Interpro Analysis",
145: //                "program": "Interpro",
146: //                "programversion": "unknown",
147: //                "sourcename": "HMMPfam",
148: //                "analysis_match_id": "PF00112",
149: //                "analysis_match_description": "Peptidase_C1",
150: //                "dbxref": [
151: //                    {
152: //                        "dbname": "GO",
153: //                        "accession": "0006508",
154: //                        "dbversion": "",
155: //                        "name": "proteolysis",
156: //                        "definition": "The hydrolysis of proteins into smaller polypeptides and\/or amino acids by cleavage of their peptide bonds.",
157: //                        "go_namespace": "biological_process"
158: //                    },
159: //                    {
160: //                        "dbname": "GO",
161: //                        "accession": "0008234",
162: //                        "dbversion": "",
163: //                        "name": "cysteine-type peptidase activity",
164: //                        "definition": "Catalysis of the hydrolysis of peptide bonds in a polypeptide chain by a mechanism in which the sulfhydryl group of a cysteine residue at the active center acts as a nucleophile.",
165: //                        "go_namespace": "molecular_function"
166: //                    }
167: //                ]
168: //            },
169: //        ]
170: //    }
171: //]
172:         return $ret;
173:     }
174: 
175:     /**
176:      * @inheritDoc
177:      */
178:     public function execute($querydata) {
179:         return $this->getById($querydata['query1']);
180:     }
181: 
182: }
183: 
184: ?>
185: 
tbro API documentation generated by ApiGen 2.8.0