Просмотр исходного кода

Adding Example Sequence button to both forms

deepaksomanadh 10 лет назад
Родитель
Сommit
30815e2dcf
3 измененных файлов с 92 добавлено и 1 удалено
  1. 5 0
      css/form.css
  2. 27 1
      includes/blast_ui.blastn.inc
  3. 60 0
      includes/blast_ui.blastp.inc

+ 5 - 0
css/form.css

@@ -0,0 +1,5 @@
+div.center {
+  margin-left: auto;
+  margin-right: auto;
+  width:70%
+} 

Разница между файлами не показана из-за своего большого размера
+ 27 - 1
includes/blast_ui.blastn.inc


+ 60 - 0
includes/blast_ui.blastp.inc

@@ -14,6 +14,11 @@
  */
 function blast_protein_form($form, &$form_state) {
 
+	//  CSS support to the form
+	$form['#attached']['css'] = array(
+		drupal_get_path('module', 'blast_ui') . '/css/form.css',
+		);
+
   // PROTEIN QUERY
   //.........................
 
@@ -23,12 +28,33 @@ function blast_protein_form($form, &$form_state) {
     '#description' => t('Enter one or more queries in the top text box or use the browse button to upload a file from your local disk. The file may contain a single sequence or a list of sequences. In both cases, the data must be in FASTA format. <a href="http://www.ncbi.nlm.nih.gov/BLAST/blastcgihelp.shtml" target="_blank">More information..</a> '),
     '#collapsible' => TRUE,
     '#collapsed' => FALSE,
+   	'#prefix' => '<div class="two-col">',
+    '#suffix' => '</div>', 
+  );
+  $form['query']['example_sequence'] = array(
+    '#type' => 'button', 
+    '#button_type'=> 'button',
+    '#limit_validation_errors' => array(),
+    '#value' => t('Example Sequence'), 
+    '#prefix' => '<div class="center">',
+    '#suffix' => '</div>',
+    '#validate' => array(),
+    '#ajax' => array(
+    	'callback' => 'ajax_nucleotide_text_area_callback',
+    	'wrapper'  => 'fasta_seq',
+        'method'   => 'replace',
+        'effect'   => 'fade',
+        ),
+	  '#attributes' => array('onclick' => 'return false;'),
   );
 
+
   $form['query']['FASTA'] = array(
     '#type' => 'textarea',
     '#title' => t('Enter FASTA sequence(s)'),
     '#description'=>t('Enter query sequence(s) in the text area.'),
+    '#prefix' => '<div id="fasta_seq">',
+    '#suffix' => '</div>',
   );
 
   // Upload a file as an alternative to enter a query sequence
@@ -38,6 +64,24 @@ function blast_protein_form($form, &$form_state) {
   	'#type' => 'file',
   	'#description' => t('The file should be a plain-text FASTA file and not a .doc, .docx, etc. It cannot be greater than 10 Mb in size.'),
   );
+ 
+    
+	$form['query']['example_sequence'] = array(
+			'#type' => 'button', 
+			'#button_type'=> 'button',
+			'#limit_validation_errors' => array(),
+			'#value' => t('Example Sequence'), 
+			'#prefix' => '<div class="center">',
+			'#suffix' => '</div>',
+			'#validate' => array(),
+			'#ajax' => array(
+				'callback' => 'ajax_protein_text_area_callback',
+				'wrapper'  => 'fasta_seq',
+					'method'   => 'replace',
+					'effect'   => 'fade',
+					),
+		'#attributes' => array('onclick' => 'return false;'),
+		);
 
 
   // BLAST DATABASE
@@ -857,4 +901,20 @@ function ajax_example_dependent_dropdown_callback($form, $form_state) {
 }
 
 
+// call back function for example sequence
+function ajax_protein_text_area_callback($form, $form_state) {
+ $element = $form['query']['FASTA']; // Get example Protein sequence
+ 
+$element['#value'] =  
+	'>gi|166477|gb|AAA96434.1| resveratrol synthase [Arachis hypogaea]
+MVSVSGIRKVQRAEGPATVLAIGTANPPNCIDQSTYADYYFRVTNSEHMTDLKKKFQRICERTQIKNRHM
+YLTEEILKENPNMCAYKAPSLDAREDMMIREVPRVGKEAATKAIKEWGQPMSKITHLIFCTTSGVALPGV
+DYELIVLLGLDPCVKRYMMYHQGCFAGGTVLRLAKDLAENNKDARVLIVCSENTAVTFRGPSETDMDSLV
+GQALFADGAAAIIIGSDPVPEVEKPIFELVSTDQKLVPGSHGAIGGLLREVGLTFYLNKSVPDIISQNIN
+DALNKAFDPLGISDYNSIFWIAHPGGRAILDQVEQKVNLKPEKMKATRDVLSNYGNMSSACVFFIMDLMR
+KRSLEEGLKTTGEGLDWGVLFGFGPGLTIETVVLRSVAI';
+
+return $element;
+}
+
 

Некоторые файлы не были показаны из-за большого количества измененных файлов