Browse Source

Added API which currently only includes pulling out options...

Lacey Sanderson 10 years ago
parent
commit
7009cadc5e
5 changed files with 41 additions and 56 deletions
  1. BIN
      api/._blast_ui.api.inc
  2. 36 0
      api/blast_ui.api.inc
  3. 3 0
      blast_ui.module
  4. 1 27
      includes/blast_ui.blastn.inc
  5. 1 29
      includes/blast_ui.blastp.inc

BIN
api/._blast_ui.api.inc


+ 36 - 0
api/blast_ui.api.inc

@@ -0,0 +1,36 @@
+<?php
+
+/**
+ * @file
+ * Contains more generally applicable functions as well as some meant to help developers
+ * Plug-in to the BLAST UI functionality
+ */
+
+/**
+ * Returns a list BLAST DATABASE options
+ *
+ * @param $type
+ *   The type of BLAST dabases to restrict the list to (ie: n: nucleotide or p: protein)
+ *
+ * @return
+ *   An array where the nid is the key and the value is the human-readable name of the option
+ */
+function get_blast_database_options($type) {
+
+  // Get all BlastDB nodes
+  $nodes  = node_load_multiple(array(), array('type'=> 'blastdb'));
+
+  $options = array();
+  foreach ($nodes as $node) {
+    if ( isset($node) && isset($node->db_dbtype) ) {
+	    if ( ($node->db_dbtype == $type) ) {
+        $options[$node->nid] = $node->db_name;
+	    }
+    }
+  }
+
+  asort($options);
+  $options[0] = 'Select a Dataset';
+
+  return $options;
+}

+ 3 - 0
blast_ui.module

@@ -15,6 +15,9 @@ require_once 'includes/blast_ui.node.inc';
 // Functions specific to themeing (ie: preprocess)
 require_once 'theme/blast_ui.theme.inc';
 
+// Application Programmers Interface
+require_once 'api/blast_ui.api.inc';
+
 /**
  * Implements hook_menu().
  */

+ 1 - 27
includes/blast_ui.blastn.inc

@@ -53,7 +53,7 @@ function blast_nucleotide_form($form, &$form_state) {
     '#collapsed' => FALSE,
   );
 
-  $options = _DB_options();
+  $options = get_blast_database_options('n');
   $form['DB']['SELECT_DB'] = array(
     '#type' => 'select',
     '#title' => t('Nucleotide BLAST Databases:'),
@@ -395,29 +395,3 @@ function _validateFasta($sequence) {
 
   return $flag;
 }
-
-
-/**
- * Generate an array of BLAST database options based on existing nodes of type BlastDB
- *
- * @return
- *  Return human readble names of the pre-existing blast databases
- */
-function _DB_options() {
-  $type = 'blastdb';
-  $nodes  = node_load_multiple(array(), array('type'=> $type));
-  $options = array();
-
-  foreach ($nodes as $node) {
-    if ( isset($node) && isset($node->db_dbtype) ) {
-	    if ( ($node->db_dbtype=='n') ) {
-        $options[$node->nid] = $node->db_name;
-	    }
-    }
-  }
-
-  asort($options);
-  $options[0] = 'Select a Dataset';
-
-  return $options;
-}

+ 1 - 29
includes/blast_ui.blastp.inc

@@ -51,7 +51,7 @@ function blast_protein_form($form, &$form_state) {
     '#collapsed' => FALSE,
   );
 
-  $options = DB_options();
+  $options = get_blast_database_options('p');
   $form['DB']['SELECT_DB'] = array(
   '#type' => 'select',
    '#title' => t('Protein BLAST Databases:'),
@@ -692,34 +692,6 @@ function validateFasta($sequence) {
   return $flag;
 }
 
-
-/**
- * Generate an array of BLAST database options based on existing nodes of type BlastDB
- *
- * @return
- *  Return human readble names of the pre-existing blast databases
- *
- */
-function DB_options() {
-   $type = 'blastdb';
-   $nodes  = node_load_multiple(array(), array('type'=> $type));
-
-   $options = array();
-
-   foreach ($nodes as $node) {
-      if ( isset($node) && isset($node->db_dbtype) ) {
-        if ( ($node->db_dbtype=='p') ) {
-         $options[$node->nid] = $node->db_name;
-        }
-      }
-   }
-
-   asort($options);
-   $options[0] = 'Select a Dataset';
-
-   return $options;
-}
-
 /**
  * Fill the first dropdown list with appropriate options
  *