123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136 |
- <?php
- class so__transcript extends TripalField {
-
-
-
-
-
-
-
-
-
-
-
-
- public static $term = 'SO:0000673';
-
- public static $label = 'Transcripts';
-
- public static $description = 'An RNA synthesized on a DNA or RNA template by an RNA polymerase.';
-
-
-
- public static $settings = array(
- 'chado_table' => '',
- 'chado_column' => '',
- 'base_table' => '',
- );
-
-
-
-
- public static $instance_settings = array();
-
-
- public static $storage = 'tripal_no_storage';
-
- public static $default_widget = 'so__transcript_widget';
-
- public static $default_formatter = 'so__transcript_formatter';
-
-
-
-
-
- protected $field;
-
-
-
- protected $instance;
-
- public function validate($entity_type, $entity, $field, $items, &$errors) {
- }
-
- public function load($entity, $details = array()) {
- $record = $details['record'];
- $field_name = $this->field['field_name'];
- $field_type = $this->field['type'];
- $field_table = $this->field['settings']['chado_table'];
- $field_column = $this->field['settings']['chado_column'];
-
- $entity->{$field_name}['und'][0] = array(
- 'value' => array(
- 'type' => '',
- 'name' => '',
- 'identifier' => '',
- 'location' => '',
- ),
- );
-
- $sql = "
- SELECT FS.name, FS.uniquename, FS.feature_id, FCVT.name as type
- FROM {feature_relationship} FR
- INNER JOIN {feature} FS on FS.feature_id = FR.subject_id
- INNER JOIN {cvterm} FCVT on FCVT.cvterm_id = FS.type_id
- INNER JOIN {cv} CV on CV.cv_id = FCVT.cv_id
- WHERE
- FR.object_id = :feature_id and
- FCVT.name = 'mRNA' and
- CV.name = 'sequence'
- ";
- $results = chado_query($sql, array(':feature_id' => $record->feature_id));
- $i = 0;
- while ($transcript = $results->fetchObject()) {
-
- $sql = "
- SELECT FL.*, F.name as srcfeature_name
- FROM {featureloc} FL
- INNER JOIN {feature} F on F.feature_id = FL.srcfeature_id
- WHERE FL.feature_id = :object_id
- ";
- $floc_results = chado_query($sql, array(':object_id' => $transcript->feature_id));
- $loc = "";
- while ($location = $floc_results->fetchObject()) {
- $loc .= $location->srcfeature_name . ":" . $location->fmin . ".." . $location->fmax;
- }
- $entity->{$field_name}['und'][$i]['value'] = array(
- 'type' => $transcript->type,
- 'name' => $transcript->name,
- 'identifier' => $transcript->uniquename,
- 'location' => $loc,
- );
- $entity_id = tripal_get_chado_entity_id($field_table, $record->feature_id);
- if ($entity_id) {
- $entity->{$field_name}['und'][$i]['value']['entity'] = 'TripalEntity:' . $entity_id;
- }
- $i++;
- }
- }
- }
|