tripal_feature.drush.inc 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  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. 'object_rel' => dt('Retreives the sequence of any features in relationship with the matched features from other criteria where the feature is the subject of the relationship'),
  42. 'subject_rel' => dt('Retreives the sequence of any features in relationship with the matched features from other criteria where the feature is the object of the relationship. '),
  43. ),
  44. 'examples' => array(
  45. 'Standard example' => 'drush tripal-current-job',
  46. ),
  47. 'aliases' => array('trp-get-seq'),
  48. );
  49. $items['tripal-feature-sync'] = array(
  50. 'description' => dt('Syncs an individual feature.'),
  51. 'options' => array(
  52. 'id' => dt('The feature ID of the feature to sync'),
  53. ),
  54. 'examples' => array(
  55. 'Standard example' => 'drush tripal-feature-sync --id=48273',
  56. ),
  57. 'aliases' => array('trp-fsync'),
  58. );
  59. return $items;
  60. }
  61. /**
  62. * Executes jobs in the Tripal Jobs Queue
  63. *
  64. * NOTE: The following code is executed when drush 'trpjob-run' or 'drush tripal-launch-jobs' is called
  65. */
  66. function drush_tripal_feature_tripal_get_sequence() {
  67. $org_commonname = drush_get_option('org');
  68. $genus = drush_get_option('genus');
  69. $species = drush_get_option('species');
  70. $analysis_name = drush_get_option('analysis');
  71. $type = drush_get_option('type');
  72. $feature_name = drush_get_option('name');
  73. $upstream = drush_get_option('up');
  74. $downstream = drush_get_option('down');
  75. $output_format = drush_get_option('out');
  76. $derive_from_parent = drush_get_option('parent');
  77. $aggregate = drush_get_option('agg');
  78. $child = drush_get_option('child');
  79. $object_rel = drush_get_option('object_rel');
  80. $subject_rel = drush_get_option('subject_rel');
  81. tripal_feature_seq_extract_get_features($org_commonname, $genus, $species, $analysis_name,
  82. $type, $feature_name, $upstream, $downstream, $output_format, $derive_from_parent,
  83. $aggregate, $child, $subject_rel, $object_rel);
  84. }
  85. /*
  86. *
  87. */
  88. function drush_tripal_feature_sync() {
  89. $feature_id = drush_get_option('id');
  90. tripal_feature_sync_feature($feature_id);
  91. }