123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123 |
- <?php
- class so__transcript extends ChadoField {
-
-
-
-
-
-
-
-
- public static $default_label = 'Transcripts';
-
- public static $description = 'An RNA synthesized on a DNA or RNA template by an RNA polymerase.';
-
-
-
-
-
-
-
- public static $default_instance_settings = array(
-
- 'term_vocabulary' => 'SO',
-
- 'term_name' => 'transcript',
-
- 'term_accession' => '0000673',
-
-
-
- 'term_fixed' => FALSE,
- );
-
- public static $default_widget = 'so__transcript_widget';
-
- public static $default_formatter = 'so__transcript_formatter';
-
-
-
-
-
- protected $field;
-
-
-
- protected $instance;
-
- public function load($entity) {
- $record = $entity->chado_record;
- $field_name = $this->field['field_name'];
- $field_type = $this->field['type'];
- $field_table = $this->instance['settings']['chado_table'];
- $field_column = $this->instance['settings']['chado_column'];
-
- $entity->{$field_name}['und'][0] = array(
- 'value' => array(
- 'rdfs:type' => '',
- 'schema:name' => '',
-
- 'data:0842' => '',
-
- 'SO:0000735' => '',
- ),
- );
-
- $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(
- 'rdfs:type' => $transcript->type,
- 'schema:name' => $transcript->name,
- 'data:0842' => $transcript->uniquename,
- 'SO:0000735' => $loc,
- );
- $entity_id = chado_get_record_entity_by_bundle($entity->bundle, $record_id);
- if ($entity_id) {
- $entity->{$field_name}['und'][$i]['value']['entity'] = 'TripalEntity:' . $entity_id;
- }
- $i++;
- }
- }
- }
|