tripal_feature_sequence.tpl.php 2.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. <?php
  2. /*
  3. * There are two ways that sequences can be displayed. They can come from the
  4. * feature.residues column or they can come from an alignment with another feature.
  5. * This template will show both or one or the other depending on the data available.
  6. *
  7. * For retreiving the sequence from an alignment we would typically make a call to
  8. * tripal_core_expand_chado_vars function. For example, to retrieve all
  9. * of the featurelocs in order to get the sequences needed for this template, the
  10. * following function call would be made:
  11. *
  12. * $feature = tripal_core_expand_chado_vars($feature,'table','featureloc');
  13. *
  14. * Then all of the sequences would need to be retreived from the alignments and
  15. * formatted for display below. However, to simplify this template, this has already
  16. * been done by the tripal_feature module and the sequences are made available in
  17. * the variable:
  18. *
  19. * $feature->featureloc_sequences
  20. *
  21. */
  22. $feature = $variables['node']->feature;
  23. // we don't want to get the sequence for traditionally large types. They are
  24. // too big, bog down the web browser, take longer to load and it's not
  25. // reasonable to print them on a page.
  26. $residues ='';
  27. if(strcmp($feature->type_id->name,'scaffold') !=0 and
  28. strcmp($feature->type_id->name,'chromosome') !=0 and
  29. strcmp($feature->type_id->name,'supercontig') !=0 and
  30. strcmp($feature->type_id->name,'pseudomolecule') !=0) {
  31. $feature = tripal_core_expand_chado_vars($feature,'field','feature.residues');
  32. $residues = $feature->residues;
  33. }
  34. // get the sequence derived from alignments
  35. $feature = $variables['node']->feature;
  36. $featureloc_sequences = $feature->featureloc_sequences;
  37. if ($residues or count($featureloc_sequences) > 0) { ?>
  38. <div class="tripal_feature-data-block-desc tripal-data-block-desc"></div> <?php
  39. // show the alignment sequences first as they are colored with child features
  40. if(count($featureloc_sequences) > 0){
  41. foreach($featureloc_sequences as $src => $attrs){
  42. print $attrs['formatted_seq'];
  43. }
  44. }
  45. // add in the residues if they are present
  46. if ($residues) { ?>
  47. <pre id="tripal_feature-sequence-residues"><?php
  48. // format the sequence to break every 100 residues
  49. print preg_replace("/(.{50})/","\\1<br>",$feature->residues); ?>
  50. </pre> <?php
  51. }
  52. }