function tripal_feature_seq_extract_form
2.x tripal_feature.seq_extract.inc | tripal_feature_seq_extract_form( |
1.x seq_extract.inc | tripal_feature_seq_extract_form(&$form_state = NULL) |
*
3 string references to 'tripal_feature_seq_extract_form'
- tripal_feature_seq_extract_form_ahah_update in tripal_feature/
includes/ seq_extract.inc - tripal_feature_seq_extract_page in tripal_feature/
includes/ seq_extract.inc - tripal_feature_theme in tripal_feature/
tripal_feature.module - We need to let drupal know about our theme functions and their arguments. We create theme functions to allow users of the module to customize the look and feel of the output generated in this module
File
- tripal_feature/
includes/ seq_extract.inc, line 105
Code
function tripal_feature_seq_extract_form(&$form_state = NULL) {
tripal_core_ahah_init_form();
// we want to allow the query string to provide values for the form
if ($_GET['fnames']) {
$form_state['values']['fnames']['items'] = $_GET['fnames'];
}
if ($_GET['genus']) {
$form_state['values']['genus'] = $_GET['genus'];
}
if ($_GET['species']) {
$form_state['values']['species'] = $_GET['species'];
}
if ($_GET['ftype']) {
$form_state['values']['ftype'] = $_GET['ftype'];
}
if ($_GET['analysis']) {
$form_state['values']['analysis'] = $_GET['analysis'];
}
if ($_GET['upstream']) {
$form_state['values']['upstream'] = $_GET['upstream'];
}
if ($_GET['downstream']) {
$form_state['values']['downstream'] = $_GET['downstream'];
}
if ($_GET['use_parent']) {
$form_state['values']['use_parent'] = $_GET['use_parent'];
}
if ($_GET['aggregate']) {
$form_state['values']['aggregate'] = $_GET['aggregate'];
}
if ($_GET['agg_types']) {
$form_state['values']['agg_types'] = $_GET['agg_types'];
}
// get defaults
$dgenus = isset($form_state['values']['genus']) ? $form_state['values']['genus'] : $_SESSION['tripal_feature_seq_extract']['genus'];
$dspecies = isset($form_state['values']['species']) ? $form_state['values']['species'] : $_SESSION['tripal_feature_seq_extract']['species'];
$danalysis = isset($form_state['values']['analysis']) ? $form_state['values']['analysis'] : $_SESSION['tripal_feature_seq_extract']['analysis'];
$dftype = isset($form_state['values']['ftype']) ? $form_state['values']['ftype'] : $_SESSION['tripal_feature_seq_extract']['ftype'];
$dfnames = isset($form_state['values']['fnames']) ? $form_state['values']['fnames'] : $_SESSION['tripal_feature_seq_extract']['fnames'];
$dupstream = isset($form_state['values']['upstream']) ? $form_state['values']['upstream'] : $_SESSION['tripal_feature_seq_extract']['upstream'];
$ddownstream = isset($form_state['values']['downstream']) ? $form_state['values']['downstream'] : $_SESSION['tripal_feature_seq_extract']['downstream'];
$dformat = isset($form_state['values']['format']) ? $form_state['values']['format'] : 'fasta_txt';
$duse_parent = isset($form_state['values']['use_parent']) ? $form_state['values']['use_parent'] : $_SESSION['tripal_feature_seq_extract']['use_parent'];
$daggregate = isset($form_state['values']['aggregate']) ? $form_state['values']['aggregate'] : $_SESSION['tripal_feature_seq_extract']['aggregate'];
$dagg_types = isset($form_state['values']['agg_types']) ? $form_state['values']['agg_types'] : $_SESSION['tripal_feature_seq_extract']['agg_types'];
$form = array();
// because we're using Tripal's file_upload_combo form element we
// need to allow the form to upload files
$form['#attributes']['enctype'] = 'multipart/form-data';
$form['#method'] = 'POST';
$form['description'] = array(
'#type' => 'markup',
'#value' => t('Use this form to retrieve sequences in FASTA format.')
);
$sql = "
SELECT DISTINCT genus
FROM {organism}
ORDER BY genus
";
$results = chado_query($sql);
$genus = array();
$genus[] = '';
while ($organism = db_fetch_object($results)) {
$genus[$organism->genus] = $organism->genus;
}
$form['genus'] = array(
'#title' => t('Genus'),
'#type' => 'select',
'#options' => $genus,
'#default_value' => $dgenus,
'#multiple' => FALSE,
'#description' => t('The organism\'s genus. If specified, features for all organism with this genus will be retrieved.'),
'#ahah' => array(
'path' => 'find/sequences/ajax',
'wrapper' => 'tripal-feature-seq-extract-form-block',
'event' => 'change',
'method' => 'replace',
),
);
$species = array();
$species[] = '';
if ($dgenus) {
$sql = "
SELECT DISTINCT species
FROM {organism}
WHERE genus = '%s'
ORDER BY species
";
$results = chado_query($sql, $dgenus);
while ($organism = db_fetch_object($results)) {
$species[$organism->species] = $organism->species;
}
}
$form['species'] = array(
'#title' => t('Species'),
'#type' => 'select',
'#options' => $species,
'#default_value' => $dspecies,
'#multiple' => FALSE,
'#description' => t('The organism\'s species name. If specified, features for all organisms with this species will be retrieved. Please first select a genus'),
'#ahah' => array(
'path' => 'find/sequences/ajax',
'wrapper' => 'tripal-feature-seq-extract-form-block',
'event' => 'change',
'method' => 'replace',
),
);
$analyses = array();
$analyses[] = '';
if ($dgenus) {
$sql = "
SELECT DISTINCT A.analysis_id, A.name
FROM {analysis_organism} AO
INNER JOIN {analysis} A ON A.analysis_id = AO.analysis_id
INNER JOIN {organism} O ON O.organism_id = AO.organism_id
WHERE O.genus = '%s'
";
$args = array();
$args[] = $dgenus;
if ($dspecies) {
$sql .= " AND O.species = '%s' ";
$args[] = $dspecies;
}
$sql .= " ORDER BY A.name ";
$results = chado_query($sql, $args);
while ($analysis = db_fetch_object($results)) {
$analyses[$analysis->name] = $analysis->name;
}
}
$form['analysis'] = array(
'#title' => t('Analyses'),
'#type' => 'select',
'#options' => $analyses,
'#default_value' => $danalysis,
'#multiple' => FALSE,
'#description' => t('You can limit sequences by the analyses to which it was derived or was used. If specified, only features associated with the specific analysis will be retrieved.'),
);
$ftype = array();
$ftype[] = '';
if ($dgenus) {
$sql = "
SELECT DISTINCT OFC.cvterm_id, OFC.feature_type
FROM {organism_feature_count} OFC
WHERE OFC.genus = '%s'
";
$args = array();
$args[] = $dgenus;
if ($dspecies) {
$sql .= " AND OFC.species = '%s'";
$args[] = $dspecies;
}
$sql .= " ORDER BY OFC.feature_type ";
$results = chado_query($sql, $args);
while ($type = db_fetch_object($results)) {
$ftype[$type->feature_type] = $type->feature_type;
}
}
$form['ftype'] = array(
'#title' => t('Feature Type'),
'#type' => 'select',
'#options' => $ftype,
'#multiple' => FALSE,
'#default_value' => $dftype,
'#description' => t('The type of feature to retrieve (e.g. mRNA). All features that match this type will be retrieved.'),
);
$form['fnames'] = array(
'#title' => t('Feature Name'),
'#type' => 'file_upload_combo',
'#default_value' => $dfnames,
'#description' => t('The names of the features to retrieve. Separate each with a new line or comma. Leave blank to retrieve all features matching other criteria.'),
'#rows' => 8
);
$form['upstream'] = array(
'#title' => t('Upstream Bases'),
'#type' => 'textfield',
'#description' => t('A numeric value specifying the number of upstream bases to include. Only works if the feature is aligned to a larger sequence.'),
'#default_value' => $dupstream,
'#size' => 5,
);
$form['downstream'] = array(
'#title' => t('Downstream Bases'),
'#type' => 'textfield',
'#description' => t('A numeric value specifying the number of downstream bases to incldue. Only works if the feature is aligned to a larger sequence.'),
'#default_value' => $ddownstream,
'#size' => 5,
);
$form['format'] = array(
'#title' => t('Output Format'),
'#type' => 'hidden',
'#default_value' => $dformat,
'#options' => array(
'fasta_html' => 'FASTA (in browser)',
'fasta_txt' => 'FASTA (download)',
),
);
$form['advanced'] = array(
'#type' => 'fieldset',
'#title' => 'Advanced',
'#collapsible' => TRUE,
'#collapsed' => TRUE
);
$form['advanced']['use_parent'] = array(
'#title' => t('Use Parent'),
'#type' => 'checkbox',
'#default_value' => $duse_parent,
'#description' => t('Check this box to retrieve the sequence from the parent in an alignment rather than the feature itself. This is useful if the same feature is aligned to multiple parents and you would like to retrieve the underlying sequence from each parent.'),
);
$form['advanced']['aggregate'] = array(
'#title' => t('Aggregate'),
'#type' => 'checkbox',
'#default_value' => $daggregate,
'#description' => t('Check this box to aggregate sub features into a single sequence. This is useful, for example, for obtaining CDS sequence from an mRNA. Rather than retrieve the mRNA sequence, the sub features of the mRNA will be aggregated and that will be returned.')
);
$form['advanced']['agg_types'] = array(
'#title' => t('Types to aggregate'),
'#type' => 'textarea',
'#default_value' => $dagg_types,
'#description' => t('Set this argument to the type of children to aggregate. This is useful in the case where a gene has exons, CDSs and UTRs. In this case, you may only want to aggregate CDSs and exclude exons. If you want to aggregate both CDSs and UTRs you could specify both.')
);
$form['retrieve_btn'] = array(
'#type' => 'submit',
'#value' => 'Retrieve',
);
$form['reset_btn'] = array(
'#type' => 'submit',
'#value' => 'Reset',
);
return $form;
}