|
@@ -303,6 +303,49 @@ function chado_analysis_update($node){
|
|
|
*/
|
|
|
function chado_analysis_form ($node){
|
|
|
|
|
|
+ $analysis = $node->analysis;
|
|
|
+
|
|
|
+ // get form defaults
|
|
|
+ $analysis_id = $node->analysis_id;
|
|
|
+ if(!$analysis_id){
|
|
|
+ $analysis_id = $analysis->analysis_id;
|
|
|
+ }
|
|
|
+ $analysisname = $node->analysisname;
|
|
|
+ if(!$analysisname){
|
|
|
+ $analysisname = $analysis->name;
|
|
|
+ }
|
|
|
+ $program = $node->program;
|
|
|
+ if(!$program){
|
|
|
+ $program = $analysis->program;
|
|
|
+ }
|
|
|
+ $programversion = $node->programversion;
|
|
|
+ if(!$programversion){
|
|
|
+ $programversion = $analysis->programversion;
|
|
|
+ }
|
|
|
+ $algorithm = $node->algorithm;
|
|
|
+ if(!$algorithm){
|
|
|
+ $algorithm = $analysis->algorithm;
|
|
|
+ }
|
|
|
+ $sourcename = $node->sourcename;
|
|
|
+ if(!$sourcename){
|
|
|
+ $sourcename = $analysis->sourcename;
|
|
|
+ }
|
|
|
+ $sourceversion = $node->sourceversion;
|
|
|
+ if(!$sourceversion){
|
|
|
+ $sourceversion = $analysis->sourceversion;
|
|
|
+ }
|
|
|
+ $sourceuri = $node->sourceuri;
|
|
|
+ if(!$sourceuri){
|
|
|
+ $sourceuri = $analysis->sourceuri;
|
|
|
+ }
|
|
|
+ $timeexecuted = $node->timeexecuted;
|
|
|
+ if(!$timeexecuted){
|
|
|
+ $timeexecuted = $analysis->timeexecuted;
|
|
|
+ }
|
|
|
+ $description = $node->description;
|
|
|
+ if(!$description){
|
|
|
+ $description = $analysis->description;
|
|
|
+ }
|
|
|
$form = array();
|
|
|
$form['title']= array(
|
|
|
'#type' => 'hidden',
|
|
@@ -310,13 +353,13 @@ function chado_analysis_form ($node){
|
|
|
);
|
|
|
$form['analysis_id']= array(
|
|
|
'#type' => 'hidden',
|
|
|
- '#default_value' => $node->analysis->analysis_id,
|
|
|
+ '#default_value' => $analysis_id,
|
|
|
);
|
|
|
$form['analysisname']= array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Analysis Name'),
|
|
|
'#required' => FALSE,
|
|
|
- '#default_value' => $node->analysis->name,
|
|
|
+ '#default_value' => $analysisname,
|
|
|
'#description' => t("This should be a handy short identifier that
|
|
|
describes the analysis succintly as possible which helps the user find analyses."),
|
|
|
);
|
|
@@ -324,28 +367,28 @@ function chado_analysis_form ($node){
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Program'),
|
|
|
'#required' => TRUE,
|
|
|
- '#default_value' => $node->analysis->program,
|
|
|
+ '#default_value' => $program,
|
|
|
'#description' => t("Program name, e.g. blastx, blastp, sim4, genscan."),
|
|
|
);
|
|
|
$form['programversion']= array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Program Version'),
|
|
|
'#required' => TRUE,
|
|
|
- '#default_value' => $node->analysis->programversion,
|
|
|
+ '#default_value' => $programversion,
|
|
|
'#description' => t("Version description, e.g. TBLASTX 2.0MP-WashU [09-Nov-2000]"),
|
|
|
);
|
|
|
$form['algorithm']= array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Algorithm'),
|
|
|
'#required' => FALSE,
|
|
|
- '#default_value' => $node->analysis->algorithm,
|
|
|
+ '#default_value' => $algorithm,
|
|
|
'#description' => t("Algorithm name, e.g. blast."),
|
|
|
);
|
|
|
$form['sourcename']= array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Source Name'),
|
|
|
'#required' => TRUE,
|
|
|
- '#default_value' => $node->analysis->sourcename,
|
|
|
+ '#default_value' => $sourcename,
|
|
|
'#description' => t('The name of the source data. This could be a file name, data set name or a
|
|
|
small description for how the data was collected. For long descriptions use the description field below'),
|
|
|
|
|
@@ -354,20 +397,20 @@ function chado_analysis_form ($node){
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Source Version'),
|
|
|
'#required' => FALSE,
|
|
|
- '#default_value' => $node->analysis->sourceversion,
|
|
|
+ '#default_value' => $sourceversion,
|
|
|
'#description' => t('If the source dataset has a version, include it here'),
|
|
|
);
|
|
|
$form['sourceuri']= array(
|
|
|
'#type' => 'textfield',
|
|
|
'#title' => t('Source URI'),
|
|
|
'#required' => FALSE,
|
|
|
- '#default_value' => $node->analysis->sourceuri,
|
|
|
+ '#default_value' => $sourceuri,
|
|
|
'#description' => t("This is a permanent URL or URI for the source of the analysis.
|
|
|
Someone could recreate the analysis directly by going to this URI and
|
|
|
fetching the source data (e.g. the blast database, or the training model)."),
|
|
|
);
|
|
|
// Get time saved in chado
|
|
|
- $default_time = $node->analysis->timeexecuted;
|
|
|
+ $default_time = $timeexecuted;
|
|
|
$year = preg_replace("/^(\d+)-\d+-\d+ .*/", "$1", $default_time);
|
|
|
$month = preg_replace("/^\d+-0?(\d+)-\d+ .*/", "$1", $default_time);
|
|
|
$day = preg_replace("/^\d+-\d+-0?(\d+) .*/", "$1", $default_time);
|
|
@@ -393,7 +436,7 @@ function chado_analysis_form ($node){
|
|
|
'#rows' => 15,
|
|
|
'#title' => t('Description and/or Program Settings'),
|
|
|
'#required' => FALSE,
|
|
|
- '#default_value' => $node->analysis->description,
|
|
|
+ '#default_value' => $description,
|
|
|
'#description' => t('Please provide all necessary information to allow
|
|
|
someone to recreate the analysis, including materials and methods
|
|
|
for collection of the source data and performing the analysis'),
|
|
@@ -409,38 +452,15 @@ function chado_analysis_form ($node){
|
|
|
* @ingroup tripal_analysis
|
|
|
*/
|
|
|
function chado_analysis_load($node){
|
|
|
- $additions = new stdClass();
|
|
|
|
|
|
- // get the analysis_id for this node:
|
|
|
- $sql = "SELECT analysis_id FROM {chado_analysis} WHERE nid = %d";
|
|
|
- $ana_node = db_fetch_object(db_query($sql, $node->nid));
|
|
|
- if ($ana_node) {
|
|
|
- // get analysis information
|
|
|
- $sql = "SELECT Analysis_id, name, description, program, ".
|
|
|
- " programversion, algorithm, sourcename, sourceversion, ".
|
|
|
- " sourceuri, timeexecuted ".
|
|
|
- "FROM {Analysis} ".
|
|
|
- "WHERE Analysis_id = $ana_node->analysis_id";
|
|
|
- $previous_db = tripal_db_set_active('chado'); // use chado database
|
|
|
- $additions->analysis = db_fetch_object(db_query($sql));
|
|
|
+ // get the feature details from chado
|
|
|
+ $analysis_id = chado_get_id_for_node('analysis',$node);
|
|
|
|
|
|
- // get number of features assc with this analysis
|
|
|
-// $sql = "SELECT count(feature_id) as featurecount ".
|
|
|
-// "FROM {Analysisfeature} ".
|
|
|
-// "WHERE Analysis_id = %d";
|
|
|
-// $additions->featurecount = db_result(db_query($sql, $ana_node->analysis_id));
|
|
|
+ $values = array('analysis_id' => $analysis_id);
|
|
|
+ $analysis = tripal_core_generate_chado_var('analysis',$values);
|
|
|
|
|
|
- tripal_db_set_active($previous_db); // now use drupal database
|
|
|
- }
|
|
|
- // If the analysis has a name, use it as the node title. If not, construct
|
|
|
- // the title using program programversion, and sourcename
|
|
|
- if ($additions->analysis->name) {
|
|
|
- $additions->title = $additions->analysis->name;
|
|
|
- } else {
|
|
|
- // Construct node title as "program version (source)
|
|
|
- $additions->title = "$additions->analysis->program ($additions->analysis->programversion)";
|
|
|
- }
|
|
|
- return $additions;
|
|
|
+ $additions->analysis = $analysis;
|
|
|
+ return $additions;
|
|
|
}
|
|
|
|
|
|
/*******************************************************************************
|