array( 'name' => t('Blast Database'), 'base' => 'blastdb', 'description' => t('Registers a BLAST Database for use with the BLAST UI.'), ), ); } /** * Implements hook_node_access(). */ function blastdb_node_access($node, $op, $account) { $node_type = $node; if (is_object($node)) { $node_type = $node->type; } if($node_type == 'blastdb') { if ($op == 'create') { if (!user_access('create Blast Database', $account)) { return NODE_ACCESS_DENY; } return NODE_ACCESS_ALLOW; } if ($op == 'update') { if (!user_access('edit Blast Database', $account)) { return NODE_ACCESS_DENY; } } if ($op == 'delete') { if (!user_access('delete Blast Database', $account)) { return NODE_ACCESS_DENY; } } if ($op == 'view') { if (!user_access('access Blast Database', $account)) { return NODE_ACCESS_DENY; } } return NODE_ACCESS_IGNORE; } } /** * Form constructor for the blastdb node * * @see blastdb_insert() * @see blastdb_update() * @see blastdb_delete() * @see blastdb_load() */ function blastdb_form($node, &$form_state) { $form = array(); $form['#validate'] = array('blastdb_form_validate'); $form['core'] = array( '#type' => 'fieldset', '#title' => 'General' ); $form['core']['db_name']= array( '#type' => 'textfield', '#title' => t('Human-readable Name for Blast database'), '#required' => TRUE, '#default_value' => isset($node->db_name) ? $node->db_name : '', ); $form['core']['db_path']= array( '#type' => 'textfield', '#title' => t('File Prefix including Full Path'), '#description' => t('The full path to your blast database including the file name but not the file type suffix. For example, /var/www/website/sites/default/files/myblastdb'), '#required' => TRUE, '#default_value' => isset($node->db_path) ? $node->db_path : '', ); $form['core']['db_dbtype'] = array( '#type' => 'radios', '#title' => t('Type of the blast database'), '#options' => array( 'nucleotide' => t('Nucleotide'), 'protein' => t('Protein'), ), '#required' => TRUE, '#default_value' => isset($node->db_dbtype) ? $node->db_dbtype : 'n', ); $form['dbxref'] = array( '#type' => 'fieldset', '#title' => 'Database References', '#description' => 'These settings can be used to tell the BLAST UI that ' . 'information about the records in this BLAST database can be found ' . 'either in the current website or an external website.' ); $description = array( 'default' => 'A single word followed by a free-text definition. ' . 'The first word contains only alphanumeric characters and optionally ' . 'underscores and will be used as the ID of the sequence.', 'genbank' => 'Follows the same format as the first option ' . 'except that the first "word" is of the following form: ' . 'gb|accession|locus. The accession will be used as the ID of the sequence.', 'embl' => 'Follows the same format as the first option ' . 'except that the first "word" is of the following form: ' . 'emb|accession|locus. The accession will be used as the ID of the sequence.', 'swissprot' => 'Follows the same format as the first option ' . 'except that the first "word" is of the following form: ' . 'sp|accession|entry name. The accession will be used as the ID of the sequence.', 'custom' => 'Allows you to use a regular expression (define one below) to ' . 'extract a specifc portion of the FASTA header to be used as the ID.' ); $form['dbxref']['dbxref_id_type'] = array( '#type' => 'radios', '#title' => 'FASTA header format', '#description' => 'Choose the format that matches the format of the FASTA ' . 'headers in this BLAST database or choose custom to define your own ' . 'using regular expressions. This ID will be appended to the URL Prefix ' . ' of the database selected below.', '#options' => array( 'default' => 'Generic', 'genbank' => 'NCBI GenBank', 'embl' => 'EMBL Data Library', 'swissprot' => 'SWISS-PROT', 'custom' => 'Custom Format', ), '#default_value' => ($node->linkout->regex_type) ? $node->linkout->regex_type : 'default', '#ajax' => array( 'callback' => 'ajax_blast_ui_node_linkout_custom_callback', 'wrapper' => 'link-regex', ) ); $hide_regex = TRUE; if (isset($form_state['values']['dbxref_id_type'])) { if ($form_state['values']['dbxref_id_type'] == 'custom') { $hide_regex = FALSE; } } $form['dbxref']['regex'] = array( '#type' => 'textfield', '#title' => 'Regular Expression', '#description' => t('A PHP Regular expression with curved brackets ' . 'surrounding the ID that should be used in the URL to provide a link-' . 'out to additional information. See PHP.net Regular ' . 'Expression Documentation for more information. Be sure ' . 'to include the opening and closing slashes. This is only ' . 'available if custom was choosen for the FASTA header format above.', array('@url' => 'http://php.net/manual/en/reference.pcre.pattern.syntax.php')), '#disabled' => $hide_regex, '#prefix' => '