tripal_feature.drush.inc 3.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293
  1. <?php
  2. /**
  3. * @file
  4. * Contains function relating to drush-integration of this module.
  5. */
  6. /**
  7. * Describes each drush command implemented by the module
  8. *
  9. * @return
  10. * The first line of description when executing the help for a given command
  11. */
  12. function tripal_feature_drush_help($command) {
  13. switch ($command) {
  14. case 'drush:tripal-get_sequence':
  15. return dt('Prints sequences that match specified categories.');
  16. }
  17. }
  18. /**
  19. * Registers a drush command and constructs the full help for that command
  20. *
  21. * @return
  22. * And array of command descriptions
  23. */
  24. function tripal_feature_drush_command() {
  25. $items = array();
  26. $items['tripal-get-sequence'] = array(
  27. 'description' => dt('Prints sequences that match specified categories.'),
  28. 'options' => array(
  29. 'org' => dt('The organism\'s common name. If specified, features for this organism will be retrieved.'),
  30. 'genus' => dt('The organism\'s genus. If specified, features for all organism with this genus will be retrieved.'),
  31. 'species' => dt('The organism\'s species name. If specified, features for this all organism with this species will be retrieved.'),
  32. 'analysis' => dt('The analysis name. If specified, features for this analysis will be retrieved.'),
  33. 'type' => dt('The type of feature to retrieve (e.g. mRNA). All features that match this type will be retrieved.'),
  34. 'name' => dt('The name of the feature to retrieve.'),
  35. 'up' => dt('An integer value specifying the number of upstream bases to include.'),
  36. 'down' => dt('An integer value specifying the number of downstream bases to incldue.'),
  37. 'out' => dt('The output format. Valid options are "fasta_html", "fasta_txt" and raw.'),
  38. 'parent' => dt('Set this argument to 1 to retrieve the sequence from the parent in an alignment rather than the residues column of the feature itself.'),
  39. 'agg' => dt('Set this argument to 1 to aggregate sub features into a single sequence. This is useful, for example, for obtaining CDS sequence from an mRNA'),
  40. 'child' => dt('Set this argument to the sequence ontology term for the children to aggregate. This is useful in the case where a gene has exons as well as CDSs and UTRs. You may sepcify as many feature types as desired by separating each with a single comma (no spaces).'),
  41. ),
  42. 'examples' => array(
  43. 'Standard example' => 'drush tripal-current-job',
  44. ),
  45. 'aliases' => array('trp-get-seq'),
  46. );
  47. $items['tripal-feature-sync'] = array(
  48. 'description' => dt('Syncs an individual feature.'),
  49. 'options' => array(
  50. 'id' => dt('The feature ID of the feature to sync'),
  51. ),
  52. 'examples' => array(
  53. 'Standard example' => 'drush tripal-feature-sync --id=48273',
  54. ),
  55. 'aliases' => array('trp-fsync'),
  56. );
  57. return $items;
  58. }
  59. /**
  60. * Executes jobs in the Tripal Jobs Queue
  61. *
  62. * NOTE: The following code is executed when drush 'trpjob-run' or 'drush tripal-launch-jobs' is called
  63. */
  64. function drush_tripal_feature_tripal_get_sequence() {
  65. $org_commonname = drush_get_option('org');
  66. $genus = drush_get_option('genus');
  67. $species = drush_get_option('species');
  68. $analysis_name = drush_get_option('analysis');
  69. $type = drush_get_option('type');
  70. $feature_name = drush_get_option('name');
  71. $upstream = drush_get_option('up');
  72. $downstream = drush_get_option('down');
  73. $output_format = drush_get_option('out');
  74. $derive_from_parent = drush_get_option('parent');
  75. $aggregate = drush_get_option('agg');
  76. $child = drush_get_option('child');
  77. tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name,
  78. $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent,
  79. $aggregate, $child);
  80. }
  81. /*
  82. *
  83. */
  84. function drush_tripal_feature_sync() {
  85. $feature_id = drush_get_option('id');
  86. tripal_feature_sync_feature($feature_id);
  87. }