public function FASTAImporter::formValidate
3.x FASTAImporter.inc | public FASTAImporter::formValidate($form, &$form_state) |
Overrides TripalImporter::formValidate
See also
TripalImporter::formValidate()
File
- tripal_chado/
includes/ TripalImporter/ FASTAImporter.inc, line 241
Class
Code
public function formValidate($form, &$form_state) {
$organism_id = $form_state['values']['organism_id'];
$type = trim($form_state['values']['seqtype']);
$method = trim($form_state['values']['method']);
$match_type = trim($form_state['values']['match_type']);
$re_name = trim($form_state['values']['re_name']);
$re_uname = trim($form_state['values']['re_uname']);
$re_accession = trim($form_state['values']['re_accession']);
$db_id = $form_state['values']['db_id'];
$rel_type = $form_state['values']['rel_type'];
$re_subject = trim($form_state['values']['re_subject']);
$parent_type = trim($form_state['values']['parent_type']);
if ($method == 0) {
$method = 'Insert only';
}
if ($method == 1) {
$method = 'Update only';
}
if ($method == 2) {
$method = 'Insert and update';
}
if ($match_type == 0) {
$match_type = 'Name';
}
if ($match_type == 1) {
$match_type = 'Unique name';
}
if ($re_name and !$re_uname and strcmp($match_type, 'Unique name') == 0) {
form_set_error('re_uname', t("You must provide a regular expression to identify the sequence unique name"));
}
if (!$re_name and $re_uname and strcmp($match_type, 'Name') == 0) {
form_set_error('re_name', t("You must provide a regular expression to identify the sequence name"));
}
// make sure if a relationship is specified that all fields are provided.
if (($rel_type or $parent_type) and !$re_subject) {
form_set_error('re_subject', t("Please provide a regular expression for the parent"));
}
if (($rel_type or $re_subject) and !$parent_type) {
form_set_error('parent_type', t("Please provide a SO term for the parent"));
}
if (($parent_type or $re_subject) and !$rel_type) {
form_set_error('rel_type', t("Please select a relationship type"));
}
// make sure if a database is specified that all fields are provided
if ($db_id and !$re_accession) {
form_set_error('re_accession', t("Please provide a regular expression for the accession"));
}
if ($re_accession and !$db_id) {
form_set_error('db_id', t("Please select a database"));
}
// check to make sure the types exists
$cvtermsql = "
SELECT CVT.cvterm_id
FROM {cvterm} CVT
INNER JOIN {cv} CV on CVT.cv_id = CV.cv_id
LEFT JOIN {cvtermsynonym} CVTS on CVTS.cvterm_id = CVT.cvterm_id
WHERE cv.name = :cvname and (CVT.name = :name or CVTS.synonym = :synonym)
";
$cvterm = chado_query($cvtermsql,
array(':cvname' => 'sequence', ':name' => $type, ':synonym' => $type))->fetchObject();
if (!$cvterm) {
form_set_error('type', t("The Sequence Ontology (SO) term selected for the sequence type is not available in the database. Please check spelling or select another."));
}
if ($rel_type) {
$cvterm = chado_query($cvtermsql, array(':cvname' => 'sequence', ':name' => $parent_type,
':synonym' => $parent_type
))->fetchObject();
if (!$cvterm) {
form_set_error('parent_type', t("The Sequence Ontology (SO) term selected for the parent relationship is not available in the database. Please check spelling or select another."));
}
}
}