'fieldset', '#title' => t('Step 2: Define the columns of the file'), ); $columns = $form_state['storage']['columns']; // $form['debug']= array( // '#value' => "Columns: $columns", // '#weight' => -1 // ); $fields = array(); $fields[''] = ''; /* $form_fields = array( 'Feature details' => array ( 'name' => array( 'description' => 'Feature Name (human readable)', 'table' => array( 'table name' => 'feature', 'fields' => array('name'), ), ), 'uniquename' => array( 'description' => 'Unique Name (must be unique for this organism and feature type)', 'table' => array( 'table name' => 'feature', 'fields' => array('uniquename'), ), ), 'type_id' => array( 'description' => 'Feature type (must be a valid SO term', 'table' => array( 'table name' => 'feature', 'fields' => array('uniquename'), ), ), 'residues' => array( 'description' => 'Residues', 'table' => array( 'table name' => 'feature', 'fields' => array('residues'), ), ), ), 'Organism specification' => array ( 'organism_id' => array( 'description' => 'Organism ID number', 'table' => array( 'table name' => 'organism', 'fields' => array('organism_id'), ), ), 'genus' => array( 'description' => 'Genus', 'table' => array( 'table name' => 'organism', 'fields' => array('genus'), ), 'valid values' => 'this' ), 'species' => array( 'description' => 'Species', 'table' => array( 'table name' => 'organism', 'fields' => array('species'), ), ), 'full_name' => array( 'description' => 'Scientific Name (genus + species)', 'table' => array( 'table name' => 'organism', 'fields' => array('genus','species'), 'parser' => '/^(.*?)\s+(.*?)$/', ), ), 'common_name' => array( 'description' => 'Common Name', 'table' => array( 'table name' => 'organism', 'fields' => array('common_name'), ), ), ), 1. allow the user to specify the term from a specific vocabulary 2. allow the user to specify the vocabulary to choose from 3. 'Feature Property' => array ( 'property' => array( 'description' => 'Feature property value', 'table' => array( 'table name' => 'featureprop', 'fields' => array('value'), 'check' => array( 'type_id' => { ), ). ), ), ); */ // these fields correspond with the columns of the feature table and // the foreign key contraints for the feature table. $fields = array( '' => '', 'ignore' => 'Ignore this column', 'Feature details' => array ( 'name' => 'Feature Name (human readable)', 'uniquename' => 'Unique Feature Name', 'type' => 'Feature type (must be a valid SO term)', 'alt_type' => 'Additional ontology term', 'residues' => 'Residues', ), 'Organism specification' => array ( 'organism_id' => 'Organism ID number', 'genus' => 'Genus', 'species' => 'Species', 'full_name' => 'Scientific Name (genus + species)', 'common_name' => 'Common Name', ), 'External Database Cross-Reference' => array( 'db_id' => 'Database ID number', 'db_name' => 'Database name (must exists in the database)', 'accession' => 'Accession', ), 'Feature Relationship' => array ( 'rel_type' => 'Relationship Type (must be a valid relationship term)', 'parent' => 'Parent unique name', 'parent type' => 'Parent Type (must be a valid SO term)', ), 'Feature Location' => array ( 'srcfeature' => 'Reference feature (must already exist in the database)', 'srcfeature_type' => 'Reference feature type (must be a valid SO term)', 'fmin' => 'Start position', 'fmax' => 'Stop position', 'strand' => 'Strand (valid values: 0,-1,+1)', 'phase' => 'Phase (valid values: (+,-,.)', ), 'Feature Property' => array ( 'property' => 'Feature property value', ), 'Feature Synonym' => array ( 'syn_name' => 'Synonym name', ), 'Library specification' => array ( 'library_id' => 'Library ID number', 'library_name' => 'Library name', ), 'Analysis specification' => array ( 'analysis_id' => 'Analysis ID number', 'analysis_source' => 'Analysis identifying name (sourcename column in Chado)', 'analysis_desc' => 'Analysis description', 'analysis_program' => 'Analysis program', 'analysis_program_version' => 'Analysis program version' ), ); // organism foreign key identifies. These are used to find the organism // for which the feature belongs. $form['columns'] = array( '#type' => 'hidden', '#value' => $columns, ); // get the list of organisms $sql = "SELECT * FROM {organism} ORDER BY genus, species"; $previous_db = tripal_db_set_active('chado'); // use chado database $org_rset = db_query($sql); tripal_db_set_active($previous_db); // now use drupal database $organisms = array(); $genus = array(); $species = array(); $common_names = array(); $genera[''] = ''; $species[''] = ''; $common_names[''] = ''; $full_names[''] = ''; while($organism = db_fetch_object($org_rset)){ $full_names["$organism->genus $organism->species"] = "$organism->genus $organism->species"; $genera[$organism->genus] = "$organism->genus"; $species[$organism->species] = "$organism->species"; $common_names[$organism->common_name] = "$organism->common_name"; } for($i = 1; $i <= $columns; $i++){ $form['bulk_loader']["col_$i"] = array( '#type' => 'fieldset', '#title' => t("Column $i of the input file"), ); $form['bulk_loader']["col_$i"]["col_type_$i"] = array( '#title' => t('Field Selection'), '#type' => 'select', '#options' => $fields, '#weight' => 0, // this field will use AJAX to populate and information needed // for specific types, such as for feature properties. It // calls the step2_get_type URL and passes the column ($i). // the return value is additional form items or text '#ahah' => array( 'event' => 'change', 'wrapper' => "type_cols_$i", 'path' => "/admin/tripal/bulk_load/step2_get_type/$i", 'effect' => 'fade', 'method' => 'replace' ), ); // these next fields are hidden (access = false) and will be shown // if the user selects the feature property type in the drop down // above. //------------------------------------------------------------------------- // default text box for allowed values $form['bulk_loader']["col_$i"]["col_prop_valid_$i"] = array( '#title' => t('Allowed Values'), '#type' => 'textarea', '#weight' => 0, '#description' => 'Please provide a list of allowed values for this field. Separate these values with a space. Leave blank to allow any value', '#access' => FALSE ); //------------------------------------------------------------------------- // Organism allowed values $form['bulk_loader']["col_$i"]["col_prop_genera_$i"] = array ( '#title' => t('Allowed Values'), '#type' => t('select'), '#description' => t("Choose all allowed genera values for this column (ctrl+click to select multiple values). Select none to allow all"), '#required' => FALSE, '#options' => $genera, '#weight' => 2, '#multiple' => TRUE, '#size' => 10, '#access' => FALSE ); $form['bulk_loader']["col_$i"]["col_prop_species_$i"] = array ( '#title' => t('Allowed Values'), '#type' => t('select'), '#description' => t("Choose all allowed species values for this column (ctrl+click to select multiple values). Select none to allow all"), '#required' => FALSE, '#options' => $species, '#weight' => 2, '#multiple' => TRUE, '#size' => 10, '#access' => FALSE ); $form['bulk_loader']["col_$i"]["col_prop_common_name_$i"] = array ( '#title' => t('Allowed Values'), '#type' => t('select'), '#description' => t("Choose all allowed values for this column (ctrl+click to select multiple values). Select none to allow all"), '#required' => FALSE, '#options' => $common_names, '#weight' => 2, '#multiple' => TRUE, '#size' => 10, '#access' => FALSE ); $form['bulk_loader']["col_$i"]["col_prop_full_name_$i"] = array ( '#title' => t('Allowed Values'), '#type' => t('select'), '#description' => t("Choose all allowed values for this column (shift+click to select multiple values). Select none to allow all"), '#required' => FALSE, '#options' => $full_names, '#weight' => 2, '#multiple' => TRUE, '#size' => 10, '#access' => FALSE ); //------------------------------------------------------------------------- // feature property fields $form['bulk_loader']["col_$i"]["col_prop_name_$i"] = array( '#title' => t('Property Name'), '#type' => 'textfield', '#weight' => 1, '#description' => 'Please provide a name for this property. It should be a single word with only alphanumeric characters and underscores. If this name exists as a CV term in Chado already it will be reused, otherwise a new CV term with this name will be added.', '#required' => TRUE, '#access' => FALSE ); $form['bulk_loader']["col_$i"]["col_prop_full_name_$i"] = array( '#title' => t('Property Full Name'), '#type' => 'textfield', '#weight' => 3, '#description' => 'Please provide a human readable name for this property. This will be used when displaying the property title', '#access' => FALSE ); $form['bulk_loader']["col_$i"]["col_prop_desc_$i"] = array( '#title' => t('Property Description'), '#type' => 'textarea', '#weight' => 4, '#description' => 'Please provide a description of this property.', '#access' => FALSE ); // this is an empty div box that gets put on the form. This is the // box where the hidden form elements will be rendered when the // AJAX call returns $form['bulk_loader']["col_$i"]["type_wrap_$i"] = array( '#prefix' => "