views-data-export-fasta-body.tpl.php 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849
  1. <?php
  2. /**
  3. * @file
  4. * Renders the body portion of a FASTA views data export
  5. */
  6. $defline_tpl = $variables['options']['display']['defline_fields'];
  7. $num_bases_per_line = $variables['options']['display']['num_bases_per_line'];
  8. $use_residues = $variables['options']['display']['use_residues'];
  9. $residues_colname = $variables['options']['display']['residues_colname'];
  10. if(!$num_bases_per_line){
  11. $num_bases_per_line = 50;
  12. }
  13. // foreach row in the views table
  14. foreach ($themed_rows as $index => $fields) {
  15. $defline = array();
  16. $residues = '';
  17. // if we're using the residues as is then we assume the residues are already
  18. // formatted in FASTA format. We just need to print
  19. if ($use_residues) {
  20. print "$fields[$residues_colname]\r\n";
  21. }
  22. // if we're not using the residues as is then wrap the residues
  23. // and generate a proper FASTA format
  24. else {
  25. foreach ($fields as $key => $value) {
  26. // if the setup indicates, wrap the sequence
  27. if (strcmp($key, $residues_colname) == 0) {
  28. $residues = wordwrap($value, $num_bases_per_line, "\r\n", TRUE);
  29. }
  30. // set the FASTA header
  31. if (strcmp($key, 'defline') == 0) {
  32. $defline = $value;
  33. }
  34. }
  35. // print the FASTA record
  36. print ">$defline\r\n";
  37. print "$residues\r\n";
  38. }
  39. }