function tripal_feature_load_featurelocs
2.x tripal_feature.theme.inc | tripal_feature_load_featurelocs($feature_id, $side = 'as_parent', $aggregate = 1) |
3.x tripal_feature.theme.inc | tripal_feature_load_featurelocs($feature_id, $side = 'as_parent', $aggregate = 1) |
1.x tripal_feature.module | tripal_feature_load_featurelocs($feature_id, $side = 'as_parent', $aggregate = 1) |
Load the locations for a given feature
Parameters
$feature_id: The feature to look up locations for
$side: Whether the feature is the scrfeature, 'as_parent', or feature, 'as_child'
$aggregate: Whether or not to get the locations for related features
1 call to tripal_feature_load_featurelocs()
- tripal_feature_load_featureloc_sequences in legacy/
tripal_feature/ theme/ tripal_feature.theme.inc - Get the sequence this feature is located on
File
- legacy/
tripal_feature/ theme/ tripal_feature.theme.inc, line 206
Code
function tripal_feature_load_featurelocs($feature_id, $side = 'as_parent', $aggregate = 1) {
$sql = "
SELECT
F.name, F.feature_id, F.uniquename,
FS.name as src_name, FS.feature_id as src_feature_id, FS.uniquename as src_uniquename,
CVT.name as cvname, CVT.cvterm_id,
CVTS.name as src_cvname, CVTS.cvterm_id as src_cvterm_id,
FL.fmin, FL.fmax, FL.is_fmin_partial, FL.is_fmax_partial,FL.strand, FL.phase
FROM {featureloc} FL
INNER JOIN {feature} F ON FL.feature_id = F.feature_id
INNER JOIN {feature} FS ON FS.feature_id = FL.srcfeature_id
INNER JOIN {cvterm} CVT ON F.type_id = CVT.cvterm_id
INNER JOIN {cvterm} CVTS ON FS.type_id = CVTS.cvterm_id
";
if (strcmp($side, 'as_parent') == 0) {
$sql .= "WHERE FL.srcfeature_id = :feature_id ";
}
if (strcmp($side, 'as_child') == 0) {
$sql .= "WHERE FL.feature_id = :feature_id ";
}
$flresults = chado_query($sql, array(':feature_id' => $feature_id));
// copy the results into an array
$i = 0;
$featurelocs = array();
while ($loc = $flresults->fetchObject()) {
// if a drupal node exists for this feature then add the nid to the
// results object
$loc->fnid = chado_get_nid_from_id('feature', $loc->feature_id);
$loc->snid = chado_get_nid_from_id('feature', $loc->src_feature_id);
// add the result to the array
$featurelocs[$i++] = $loc;
}
// Add the relationship feature locs if aggregate is turned on
if ($aggregate and strcmp($side, 'as_parent') == 0) {
// get the relationships for this feature without substituting any children
// for the parent. We want all relationships
$relationships = tripal_feature_get_aggregate_relationships($feature_id, 0);
foreach ($relationships as $rindex => $rel) {
// get the featurelocs for each of the relationship features
$rel_featurelocs = tripal_feature_load_featurelocs($rel->subject_id, 'as_child', 0);
foreach ($rel_featurelocs as $findex => $rfloc) {
$featurelocs[$i++] = $rfloc;
}
}
}
usort($featurelocs, 'tripal_feature_sort_locations');
return $featurelocs;
}