public function so__cds::load
3.x so__cds.inc | public so__cds::load($entity) |
Overrides TripalField::load
See also
File
- tripal_chado/
includes/ TripalFields/ so__cds/ so__cds.inc, line 65
Class
Code
public function load($entity) {
$field_name = $this->field['field_name'];
$feature = $entity->chado_record;
$num_seqs = 0;
// Set some defauls for the empty record
$entity->{$field_name}['und'][0] = array(
'value' => '',
);
$options = array(
'return_array' => TRUE,
'order_by' => array('rank' => 'ASC'),
);
$feature = chado_expand_var($feature, 'table', 'featureloc', $options);
$featurelocs = $feature->featureloc->feature_id;
foreach ($featurelocs as $featureloc) {
// Generate a CDS sequence if one exsits for this feature alignment.
$cds_sequence = chado_get_feature_sequences(
array(
'feature_id' => $feature->feature_id,
'parent_id' => $featureloc->srcfeature_id->feature_id,
'name' => $feature->name,
'featureloc_id' => $featureloc->featureloc_id,
),
array(
// CDS are in parent-child relationships so we want to use the
// sequence from the parent
'derive_from_parent' => 1,
// we want to combine all CDS for this feature into a single sequence
'aggregate' => 1,
// we're looking for CDS features
'sub_feature_types' => array('CDS'),
'is_html' => 0
)
);
if (count($cds_sequence) > 0) {
// the chado_get_feature_sequences() function can return multiple sequences
// if a feature is aligned to multiple places. In the case of CDSs we expect
// that one mRNA is only aligned to a single location on the assembly so we
// can access the CDS sequence with index 0.
if ($cds_sequence[0]['residues']) {
$entity->{$field_name}['und'][$num_seqs++]['value'] = $cds_sequence[0]['residues'];
}
}
}
}