function tripal_feature_seq_extract_form_validate

2.x tripal_feature.seq_extract.inc tripal_feature_seq_extract_form_validate($form, &$form_state)
1.x seq_extract.inc tripal_feature_seq_extract_form_validate($form, &$form_state)

Validate the extract sequence form

Related topics

File

tripal_feature/includes/tripal_feature.seq_extract.inc, line 435
Interface for downloading feature sequences

Code

function tripal_feature_seq_extract_form_validate($form, &$form_state) {
  $genus = $form_state['values']['genus'];
  $species = $form_state['values']['species'];
  $analysis = $form_state['values']['analysis'];
  $ftype = $form_state['values']['ftype'];
  $fnames = $form_state['values']['fnames'];
  $upstream = $form_state['values']['upstream'];
  $downstream = $form_state['values']['downstream'];
  $use_parent = $form_state['values']['use_parent'];
  $aggregate = $form_state['values']['aggregate'];
  $agg_types = $form_state['values']['agg_types'];

  if ($upstream and !preg_match('/^\d+$/', $upstream)) {
    form_set_error('upstream', 'Please enter a positive numeric value for the upstream bases');
  }
  if ($downstream and !preg_match('/^\d+$/', $downstream)) {
    form_set_error('downstream', 'Please enter a positive numeric value for the downstream bases');
  }
  if (!$genus and !$species and !$ftype and !$fnames) {
    form_set_error('', 'Please provide a feature name, a feature type or a genus.');
  }
  if ($ftype == 'polypeptide' and $upstream) {
    form_set_error('upstream', 'When the sequence type is protein the upstream value must be unset.');
  }
  if ($ftype == 'polypeptide' and $downstream) {
    form_set_error('downstream', 'When the sequence type is protein the downstream value must be unset.');
  }
  if ($ftype == 'polypeptide' and $use_parent) {
    form_set_error('use_parent', 'When the sequence type is protein the "Use Parent" option must not be set.');
  }
}