'fieldset', '#title' => t('Standard Nucleotide BLAST'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); $form['nBLAST']['FASTA'] = array( '#type' => 'textarea', '#title' => t('Enter FASTA sequence(s)'), '#description'=>t('Enter query sequence(s) in the text area.'), ); // Upload a file as an alternative to enter a query sequence $form['#attributes']['enctype'] = 'multipart/form-data'; $form['nBLAST']['UPLOAD'] = array( '#prefix' => 'Or upload your query files: ', '#type' => 'file', '#description' => t('Please give a text a FASTA file, not a MS-Word or other document, you can upload up to 10 Mb.'), ); //DATABASE// $form['DB'] = array( '#type' => 'fieldset', '#title' => t('BLAST Assembled KnowPulse Genomes'), '#collapsible' => TRUE, '#collapsed' => FALSE, ); // //$options = _DB_options(); // $form['DB']['SELECT_DB'] = array( // '#type' => 'select', // '#title' => t('KnowPulse Databases:'), // '#options' => $options, // '#default_value' => NULL, // ); // Upload a file as an alternative to enter a query sequence $form['#attributes']['enctype'] = 'multipart/form-data'; $form['DB']['DBUPLOAD'] = array( '#prefix' => 'Or upload your own dataset: ', '#type' => 'file', '#description' => t('Please give a text or a FASTA file, not a MS-Word or other document, you can upload up to 10 Mb.'), ); //Algorithm parameters $form['ALG'] = array( '#type' => 'fieldset', '#title' => t('Algorithm parameters'), '#collapsible' => TRUE, '#collapsed' => TRUE, ); //General parameters $form['ALG']['GParam'] = array( '#type' => 'fieldset', '#title' => t('General parameters'), '#collapsible' => FALSE, ); $form['ALG']['GParam']['maxTarget'] = array( '#type' => 'select', '#title' => t('Max target sequences:'), '#options' => array( 0 => t('10'), 1 => t('50'), 2 => t('100'), 3 => t('250'), 4 => t('500'), 5 => t('1000'), 6 => t('5000'), 7 => t('10000'), 8 => t('20000'), ), '#default_value' => 2, '#description' => t('Select the maximum number of aligned sequences to display'), ); $form['ALG']['GParam']['shortQueries'] = array( '#type' => 'checkbox', '#title' => t('Automatically adjust parameters for short input sequences'), '#default_value' => TRUE, ); $form['ALG']['GParam']['eVal'] = array( '#type' => 'textfield', '#title' => t('Expect threshold'), '#default_value' => 10, '#size' => 12, '#maxlength' => 20, '#description' => t('Expected number of chance matches in a random model.'), ); $form['ALG']['GParam']['wordSize'] = array( '#type' => 'select', '#title' => t('Word size:'), '#options' => array( 0 => t('16'), 1 => t('20'), 2 => t('24'), 3 => t('28'), 4 => t('32'), 5 => t('48'), 6 => t('64'), 7 => t('128'), 8 => t('256'), ), '#default_value' => 3, '#description' => t('The length of the seed that initiates an alignment'), ); $form['ALG']['GParam']['qRange'] = array( '#type' => 'textfield', '#title' => t('Max matches in a query range'), '#default_value' => 0, '#size' => 12, '#maxlength' => 20, '#description' => t('Limit the number of matches to a query range. This option is useful if many strong matches to one part of a query may prevent BLAST from presenting weaker matches to another part of the query.'), ); // Scoring parameters $form['ALG']['SParam'] = array( '#type' => 'fieldset', '#title' => t('Scoring parameters'), '#collapsible' => FALSE, ); $form['ALG']['SParam']['M&MScores'] = array( '#type' => 'select', '#title' => t('Match/Mismatch Scores:'), '#options' => array( 0 => t('1,-2'), 1 => t('1,-3'), 2 => t('1,-4'), 3 => t('2,-3'), 4 => t('4,-5'), 5 => t('1,-1'), ), '#default_value' => 0, '#description' => t('Reward and penalty for matching and mismatching bases.'), ); $form['ALG']['SParam']['gapCost'] = array( '#type' => 'select', '#title' => t('Gap Costs:'), '#options' => array( 0 => t('Linear'), 1 => t('Extension: 5 Extension: 2'), 2 => t('Extension: 2 Extension: 2'), 3 => t('Extension: 1 Extension: 2'), 4 => t('Extension: 0 Extension: 2'), 5 => t('Extension: 3 Extension: 1'), 6 => t('Extension: 2 Extension: 1'), 7 => t('Extension: 1 Extension: 1'), ), '#default_value' => 0, '#description' => t('Cost to create and extend a gap in an alignment. Linear costs are available only with megablast and are determined by the match/mismatch scores.'), ); //Submit $form['submit'] = array( '#type' => 'submit', '#default_value' => ' BLAST ', ); return $form; } function blast_nucleotide_form_validate($form, &$form_state) { $fastaSeq = $form_state['input']['FASTA']; dpm($form_state, $name = NULL); if (isset($fastaSeq)) { if(_validateFasta($fastaSeq)){ form_set_error('nBLAST', t('Error: Failed to read the Blast query: Wrong format provided for FASTA nucleotide sequence')); } else { // } } $upQuery = file_save_upload('UPLOAD', array('file_validate_extensions' => array('txt fasta fa fna')), FILE_EXISTS_RENAME); if ($upQuery) { $upQuery_uri = $upQuery->uri; $upQuery_path = drupal_realpath($upQuery_uri); $upQuery_content = file_get_contents($upQuery_path); if(_validateFasta($upQuery_content)){ form_set_error('nBLAST', t('Error: Failed to upload the Blast query: Wrong format provided for FASTA nucleotide sequence')); } else { // } } $upDB = file_save_upload('DBUPLOAD', array('file_validate_extensions' => array('txt fasta fa fna')), FILE_EXISTS_RENAME); if ($upDB) { $upDB_uri = $upDB->uri; $upDB_path = drupal_realpath($upDB_uri); $upDB_content = file_get_contents($upDB_path); if(_validateFasta($upDB_content)){ form_set_error('DB', t('Error: Failed to upload the Blast reference file: Wrong format provided for FASTA nucleotide sequence')); } else { //Build a Blast DB? } } } function blast_nucleotide_form_submit($form, &$form_state) { //dpm($form_state['values'], $name = NULL); //$output = shell_exec("water -asequence $aSeq -bsequence $selectedDB -gapopen 10 -gapextend 2 -outfile /tmp/$jobID.water "); } function _validateFasta($sequence) { $fastaIdRegEx = '/^>.*(\\n|\\r)/'; $fastaSeqRegEx = '/[^acgntuACGNTU\n\r]/'; if ( preg_match($fastaSeqRegEx,$sequence) && !(preg_match($fastaIdRegEx,$sequence)) ) { $flag = 1; } else { $flag = 0; } return $flag; } function _DB_options() { $type = 'BLASTDB'; $nodes = node_load_multiple(array(), array('type' => $type)); return $nodes; }