Overview

Namespaces

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

Classes

  • AbstractTable
  • Acquisition
  • Analysis
  • Assay
  • Biomaterial
  • Contact
  • Feature
  • Organism
  • Protocol
  • Publication
  • Quantification

Interfaces

  • Table
  • Overview
  • Namespace
  • Class
  • Tree
  1: <?php
  2: 
  3: namespace cli_db;
  4: 
  5: require_once ROOT . 'classes/AbstractTable.php';
  6: 
  7: class Assay extends AbstractTable {
  8: 
  9:     /**
 10:      * @inheritdoc
 11:      */
 12:     public static function getKeys() {
 13:         return array(
 14:             'id' => array(
 15:                 'colname' => 'AssayId',
 16:                 'actions' => array(
 17:                     'details' => 'required',
 18:                     'update' => 'required',
 19:                     'delete' => 'required',
 20:                     'link_biomaterial_sample' => 'required',
 21:                     'unlink_biomaterial_sample' => 'required',
 22:                 ),
 23:                 'description' => 'assay id'
 24:             ),
 25:             'name' => array(
 26:                 'colname' => 'Name',
 27:                 'actions' => array(
 28:                     'insert' => 'required',
 29:                     'update' => 'optional',
 30:                 ),
 31:                 'description' => 'name (unique)'
 32:             ),
 33:             'description' => array(
 34:                 'colname' => 'Description',
 35:                 'actions' => array(
 36:                     'insert' => 'optional',
 37:                     'update' => 'optional',
 38:                 ),
 39:                 'description' => 'description'
 40:             ),
 41:             'protocol_id' => array(
 42:                 'colname' => 'ProtocolId',
 43:                 'actions' => array(
 44:                     'insert' => 'optional',
 45:                     'update' => 'optional',
 46:                 ),
 47:                 'description' => 'protocol id'
 48:             ),
 49:             'assaydate' => array(
 50:                 'colname' => 'Assaydate',
 51:                 'actions' => array(
 52:                     'insert' => 'optional',
 53:                     'update' => 'optional',
 54:                 ),
 55:                 'description' => 'date of assay gathering'
 56:             ),
 57:             'operator_id' => array(
 58:                 'colname' => 'OperatorId',
 59:                 'actions' => array(
 60:                     'insert' => 'required',
 61:                     'update' => 'optional',
 62:                 ),
 63:                 'description' => 'contact id'
 64:             ),
 65:             'biomaterial_id' => array(
 66:                 'actions' => array(
 67:                     'link_biomaterial_sample' => 'required',
 68:                     'unlink_biomaterial_sample' => 'required',
 69:                 ),
 70:                 'description' => 'biomaterial id'
 71:             ),
 72:         );
 73:     }
 74: 
 75:     /**
 76:      * @inheritdoc
 77:      */
 78:     public static function CLI_commandDescription() {
 79:         return 'Manipulate assays.';
 80:     }
 81: 
 82:     /**
 83:      * @inheritdoc
 84:      */
 85:     public static function CLI_commandName() {
 86:         return 'assay';
 87:     }
 88: 
 89:     /**
 90:      * @inheritdoc
 91:      */
 92:     public static function CLI_longHelp() {
 93:         
 94:     }
 95: 
 96:     /**
 97:      * @inheritdoc
 98:      */
 99:     public static function getSubCommands() {
100:         return array('insert', 'update', 'delete', 'details', 'list', 'link_biomaterial_sample', 'unlink_biomaterial_sample');
101:     }
102: 
103:     /**
104:      * @inheritdoc
105:      */
106:     public static function getPropelClass() {
107:         return '\\cli_db\\propel\\Assay';
108:     }
109: 
110:     /**
111:      * @inheritdoc
112:      */
113:     protected static function command_insert_set_defaults(\BaseObject $item) {
114:         // satisfy NOT NULL constraint
115:         $item->setArraydesignId(1);
116:     }
117: 
118:     /**
119:      * @inheritdoc
120:      * overwritten to show linked samples
121:      */
122:     protected static function command_details($options, $keys) {
123:         parent::command_details($options, $keys);
124: 
125:         $q = new propel\AssayQuery();
126:         $assay = $q->findOneByAssayId($options['id']);
127: 
128:         $references = array();
129:         foreach ($assay->getAssayBiomaterialsJoinBiomaterial() as $ass_b) {
130:             $biomat = $ass_b->getBiomaterial();
131:             $references[] = array('Sample', sprintf("Id: %s\nName: %s", $biomat->getBiomaterialId(), $biomat->getName()));
132:         }
133:         if (count($references) > 0) {
134:             print "linked Samples:\n";
135:             self::printTable(array('Table', 'Row'), $references);
136:         }
137:     }
138: 
139:     /**
140:      * links given biomaterial sample against this assay
141:      * @param Array $options user-specified command line parameters
142:      * @param Array $keys result from self::getKeys()
143:      * @return type
144:      */
145:     protected static function command_link_biomaterial_sample($options, $keys) {
146:         $ass_b = new propel\AssayBiomaterial();
147:         $ass_b->setAssayId($options['id']);
148:         $ass_b->setBiomaterialId($options['biomaterial_id']);
149:         $lines = $ass_b->save();
150:         printf("%d line(s) inserted.\n", $lines);
151: 
152:         return array($ass_b, $lines);
153:     }
154: 
155:     /**
156:      * unlinks given biomaterial sample from this assay
157:      * @param Array $options user-specified command line parameters
158:      * @param Array $keys result from self::getKeys()
159:      * @return type
160:      */
161:     protected static function command_unlink_biomaterial_sample($options, $keys) {
162:         $ass_b_q = new propel\AssayBiomaterialQuery();
163:         $ass_b_q->filterByAssayId($options['id']);
164:         $ass_b_q->filterByBiomaterialId($options['biomaterial_id']);
165:         $ass_b = $ass_b_q->findOne();
166:         if ($ass_b == null) {
167:             trigger_error(sprintf("No relationship between assay %d and biomaterial %d found.\n", $options['id'], $options['biomaterial_id']), E_USER_ERROR);
168:         }
169:         $ass_b->delete();
170:         printf("Relationship between assay %d and biomaterial %d deleted successfully.\n", $ass_b->getAssayId(), $ass_b->getBiomaterialId());
171: 
172:         return $ass_b;
173:     }
174: 
175: }
176: 
177: ?>
178: 
tbro API documentation generated by ApiGen 2.8.0