23 function tpps_phenotype(array &$form, array &$form_state, array $values, $id) {
24 $phenotype_upload_location =
'public://' . variable_get(
'tpps_phenotype_files_dir',
'tpps_phenotype');
26 $form[$id][
'phenotype'] = array(
27 '#type' =>
'fieldset',
28 '#title' => t(
'<div class="fieldset-title">Phenotype Information:</div>'),
30 '#prefix' =>
"<div id=\"phenotype-main-$id\">",
31 '#suffix' =>
'</div>',
32 '#description' => t(
'Upload a file and/or fill in form fields below to provide us with metadata about your phenotypes.'),
33 '#collapsible' => TRUE,
36 $form[$id][
'phenotype'][
'normal-check'] = array(
37 '#type' =>
'checkbox',
38 '#title' => t(
'My phenotypes include traits and/or environmental information other than mass spectrometry or isotope analysis'),
40 'callback' =>
'tpps_update_phenotype',
41 'wrapper' =>
"phenotype-main-$id",
50 $form[$id][
'phenotype'][
'iso-check'] = array(
51 '#type' =>
'checkbox',
52 '#title' => t(
'My phenotypes include results from a mass spectrometry or isotope analysis'),
54 'callback' =>
'tpps_update_phenotype',
55 'wrapper' =>
"phenotype-main-$id",
71 if (!empty($iso_check)) {
72 $form[$id][
'phenotype'][
'iso'] = array(
73 '#type' =>
'managed_file',
74 '#title' => t(
'Phenotype Isotope/Mass Spectrometry file: *'),
75 '#upload_location' => $phenotype_upload_location,
76 '#upload_validators' => array(
77 'file_validate_extensions' => array(
'csv tsv xlsx'),
79 '#description' => t(
'Please upload a file containing all of your isotope/mass spectrometry data. The format of this file is very important! The first column of your file should contain plant identifiers which match the plant identifiers you provided in your plant accession file, and all of the remaining columns should contain isotope or mass spectrometry data.'),
83 if (!empty($normal_check)) {
84 $attr_options = array(0 =>
'- Select -');
86 'absorbance' => t(
'Absorbance'),
88 'alive' => t(
'Alive'),
89 'amount' => t(
'Amount'),
90 'angle' => t(
'Angle'),
93 'carbon-13 atom' => t(
'Carbon-13 Atom'),
94 'chlorophyll' => t(
'Chlorophyll'),
95 'circumference' => t(
'Circumerence'),
96 'color' => t(
'Color'),
97 'composition' => t(
'Composition'),
98 'concentration_of' => t(
'Concentration of'),
99 'damage' => t(
'Damage'),
100 'delta' => t(
'Delta'),
101 'description' => t(
'Description'),
102 'diameter' => t(
'Diameter'),
103 'distance' => t(
'Distance'),
104 'gravity' => t(
'Gravity'),
105 'growth_quality_of_occurrent' => t(
'Growth Quality of Occurrent'),
106 'growth_rate' => t(
'Growth Rate'),
107 'has_number_of' => t(
'Has number of'),
108 'height' => t(
'Height'),
109 'humidity_level' => t(
'Humidity Level'),
110 'intensity' => t(
'Intensity'),
111 'length' => t(
'Length'),
112 'lesioned' => t(
'Lesioned'),
113 'maturity' => t(
'Maturity'),
114 'photosynthesis' => t(
'Photosynthesis'),
115 'position' => t(
'Position'),
116 'precipitation' => t(
'Precipitation'),
117 'pressure' => t(
'Pressure'),
118 'proportionality_to' => t(
'Proportionality to'),
120 'rough' => t(
'Rough'),
122 'shape' => t(
'Shape'),
124 'temperature' => t(
'Temperature'),
125 'texture' => t(
'Texture'),
126 'thickness' => t(
'Thickness'),
128 'transpiration' => t(
'Transpiration'),
129 'volume' => t(
'Volume'),
130 'water use efficiency' => t(
'Water use efficiency'),
131 'weight' => t(
'Weight'),
132 'width' => t(
'Width'),
134 foreach ($terms as $term => $label) {
136 $attr_options[$attr_id] = $label;
139 $attr_options[
'other'] =
'My attribute term is not in this list';
141 $unit_options = array();
143 'absorbance unit' => t(
'Absorbance Unit'),
144 'boolean' => t(
'Boolean (Binary)'),
145 'centimeter' => t(
'Centimeter'),
146 'centimeters per day' => t(
'Centimeters per Day'),
147 'cubic_centimeter' => t(
'Cubic Centimeter'),
148 'cubic_meter' => t(
'Cubic Meter'),
150 'degrees_celsius' => t(
'Degrees Celsius'),
151 'degrees celsius per millimeter' => t(
'Degrees Celsius per Millimeter'),
152 'degrees_fahrenheit' => t(
'Degrees Fahrenheit'),
153 'grams_per_square_meter' => t(
'Grams per Square Meter'),
155 'kilogram' => t(
'Kilogram'),
156 'kilogram_per_cubic_meter' => t(
'Kilogram per Cubic Meter'),
157 'kilograms per meter cubed' => t(
'Kilograms per Meter Cubed'),
158 'liter' => t(
'Liter'),
159 'log(centimeters per day)' => t(
'Log (Centimeters per day)'),
160 'log(centimeters cubed per day)' => t(
'Log (Centimeters cubed per day)'),
161 'luminous_intensity_unit' => t(
'Luminous Intensity Unit'),
162 'meter' => t(
'Meter'),
163 'milligram' => t(
'Milligram'),
164 'milligrams per millimeter' => t(
'Milligrams per Millimeter'),
165 'milligrams per millimeter squared' => t(
'Milligrams per Millimeter Squared'),
166 'milligrams per milligram' => t(
'Milligrams per Milligram'),
167 'milliliter' => t(
'Milliliter'),
168 'millimeter' => t(
'Millimeter'),
169 'micrometer' => t(
'Micrometer'),
170 'micromoles carbon dioxide per meter squared per second' => t(
'Micromoles Carbon Dioxide per Meter Squared per Second'),
171 'micromoles carbon dioxide per gram per second' => t(
'Micromoles Carbon Dioxide per Gram per Second'),
172 'micromoles carbon dioxide per gram Nitrogen per second' => t(
'Micromoles Carbon Dioxide per Gram Nitrogen per Second'),
173 'micromoles carbon dioxide per millimole water' => t(
'Micromoles Carbon Dioxide per Millimole Water'),
174 'moles water per meter squared per second' => t(
'Moles Water per Meter Squared per Second'),
175 'no unit' => t(
'No Unit'),
176 'number' => t(
'Number'),
177 'pascal' => t(
'Pascal'),
178 'percent' => t(
'Percent'),
179 'qualitative' => t(
'Qualitative'),
180 'square_micrometer' => t(
'Square Micrometer'),
181 'square_millimeter' => t(
'Square Millimeter'),
182 'watt_per_square_meter' => t(
'Watt per Square Meter'),
185 foreach ($terms as $term => $label) {
187 $unit_options[$unit_id] = $label;
190 $unit_options[
'other'] =
'My unit is not in this list';
192 $struct_options = array();
194 'whole plant' => t(
'Whole Plant'),
196 'branch' => t(
'Branch'),
198 'catkin_inflorescence' => t(
'Catkin Inflorescence'),
199 'endocarp' => t(
'Endocarp'),
200 'floral_organ' => t(
'Floral Organ'),
201 'flower' => t(
'Flower'),
202 'flower_bud' => t(
'Flower Bud'),
203 'flower_fascicle' => t(
'Flower Fascicle'),
204 'fruit' => t(
'Fruit'),
206 'leaf_rachis' => t(
'Leaf Rachis'),
207 'leaflet' => t(
'Leaflet'),
208 'nut_fruit' => t(
'Nut Fruit (Acorn)'),
209 'petal' => t(
'Petal'),
210 'petiole' => t(
'Petiole'),
211 'phloem' => t(
'Phloem'),
212 'plant_callus' => t(
'Plant Callus (Callus)'),
213 'primary_thickening_meristem' => t(
'Primary Thickening Meristem'),
215 'secondary_xylem' => t(
'Secondary Xylem (Wood)'),
217 'shoot_system' => t(
'Shoot System (Crown)'),
218 'stem' => t(
'Stem (Trunk, Primary Stem)'),
219 'stomatal_complex' => t(
'Stomatal Complex (Stomata)'),
220 'strobilus' => t(
'Strobilus'),
221 'terminal_bud' => t(
'Terminal Bud'),
222 'vascular_leaf' => t(
'Vascular Leaf (Needle)'),
224 foreach ($terms as $term => $label) {
226 $struct_options[$struct_id] = $label;
229 $struct_options[
'other'] =
'My structure term is not in this list';
232 '#type' =>
'fieldset',
234 '#prefix' =>
"<div id=\"org_{$id}_phenotype_!num_meta\">",
235 '#suffix' =>
"</div>",
237 '#type' =>
'textfield',
238 '#title' =>
'Phenotype !num Name: *',
240 '#prefix' =>
"<label><b>Phenotype !num:</b></label>",
241 '#attributes' => array(
242 'data-toggle' => array(
'tooltip'),
243 'data-placement' => array(
'right'),
245 'title' => array(
'If your phenotype name does not exist in our database, don\'t worry about it! We will create new phenotype metadata in the database for you.'),
247 '#description' => t(
'Phenotype "name" is the human-readable name of the phenotype, where "attribute" is the thing that the phenotype is describing. Phenotype "name" should match the data in the "Phenotype Name/Identifier" column that you select in your <a href="@url">Phenotype file</a> below.', array(
'@url' => url(
'/tpps', array(
'fragment' =>
"edit-$id-phenotype-file-ajax-wrapper")))),
249 'env-check' => array(
250 '#type' =>
'checkbox',
251 '#title' =>
'Phenotype !num is an environmental phenotype',
253 'callback' =>
'tpps_update_phenotype_meta',
254 'wrapper' =>
"org_{$id}_phenotype_!num_meta",
257 'attribute' => array(
259 '#title' =>
'Phenotype !num Attribute: *',
260 '#options' => $attr_options,
262 'callback' =>
'tpps_update_phenotype_meta',
263 'wrapper' =>
"org_{$id}_phenotype_!num_meta",
266 'attr-other' => array(
267 '#type' =>
'textfield',
268 '#title' =>
'Phenotype !num Custom Attribute: *',
269 '#autocomplete_path' =>
'tpps/autocomplete/attribute',
270 '#attributes' => array(
271 'data-toggle' => array(
'tooltip'),
272 'data-placement' => array(
'right'),
273 'title' => array(
'If your attribute is not in the autocomplete list, don\'t worry about it! We will create new phenotype metadata in the database for you.'),
275 '#description' => t(
'Some examples of attributes include: "amount", "width", "mass density", "area", "height", "age", "broken", "time", "color", "composition", etc.'),
278 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][attribute]"]' => array(
'value' =>
'other'),
282 'description' => array(
283 '#type' =>
'textfield',
284 '#title' =>
'Phenotype !num Description: *',
285 '#description' => t(
'Please provide a short description of Phenotype !num'),
289 '#title' =>
'Phenotype !num Units: *',
290 '#options' => $unit_options,
292 'unit-other' => array(
293 '#type' =>
'textfield',
294 '#title' =>
'Phenotype !num Custom Units: *',
295 '#autocomplete_path' =>
'tpps/autocomplete/units',
296 '#attributes' => array(
297 'data-toggle' => array(
'tooltip'),
298 'data-placement' => array(
'right'),
299 'title' => array(
'If your unit is not in the autocomplete list, don\'t worry about it! We will create new phenotype metadata in the database for you.'),
301 '#description' => t(
'Some examples of units include: "m", "meters", "in", "inches", "Degrees Celsius", "°C", etc.'),
304 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]' => array(
'value' =>
'other'),
308 'val-check' => array(
309 '#type' =>
'checkbox',
310 '#title' =>
'Phenotype !num has a value range',
312 'invisible' => array(
315 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]' => array(
'value' =>
tpps_load_cvterm(
'boolean')->cvterm_id),
319 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][bin-check]"]' => array(
'checked' => TRUE),
325 'bin-check' => array(
326 '#type' =>
'checkbox',
327 '#title' =>
'Phenotype !num is a binary phenotype',
329 'invisible' => array(
332 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]' => array(
'value' =>
tpps_load_cvterm(
'boolean')->cvterm_id),
336 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][val-check]"]' => array(
'checked' => TRUE),
342 'structure' => array(
344 '#title' =>
'Phenotype !num Structure: *',
345 '#options' => $struct_options,
348 'struct-other' => array(
349 '#type' =>
'textfield',
350 '#title' =>
'Phenotype !num Custom Structure: *',
351 '#autocomplete_path' =>
'tpps/autocomplete/structure',
352 '#attributes' => array(
353 'data-toggle' => array(
'tooltip'),
354 'data-placement' => array(
'right'),
355 'title' => array(
'If your structure is not in the autocomplete list, don\'t worry about it! We will create new phenotype metadata in the database for you.'),
357 '#description' => t(
'Some examples of structure descriptors include: "stem", "bud", "leaf", "xylem", "whole plant", "meristematic apical cell", etc.'),
360 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][structure]"]' => array(
'value' =>
'other'),
365 '#type' =>
'textfield',
366 '#title' =>
'Phenotype !num Minimum Value (type 1 for binary): *',
371 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]' => array(
'value' =>
tpps_load_cvterm(
'boolean')->cvterm_id),
375 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][val-check]"]' => array(
'checked' => TRUE),
379 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][bin-check]"]' => array(
'checked' => TRUE),
386 '#type' =>
'textfield',
387 '#title' =>
'Phenotype !num Maximum Value (type 2 for binary): *',
392 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]' => array(
'value' =>
tpps_load_cvterm(
'boolean')->cvterm_id),
396 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][val-check]"]' => array(
'checked' => TRUE),
400 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][bin-check]"]' => array(
'checked' => TRUE),
409 'label' =>
'Phenotype',
411 'callback' =>
'tpps_update_phenotype',
412 'parents' => array($id,
'phenotype'),
413 'wrapper' =>
"phenotype-main-$id",
414 'name_suffix' => $id,
415 'alternative_buttons' => array(
416 "Add 5 Phenotypes" => 5,
417 "Add 10 Phenotypes" => 10,
418 "Clear All Phenotypes" =>
'tpps_phenotype_number_clear',
420 'button_weights' => array(
421 "Add Phenotype" => -5,
422 "Add 5 Phenotypes" => -4,
423 "Add 10 Phenotypes" => -3,
424 "Remove Phenotype" => -2,
425 "Clear All Phenotypes" => -1,
427 'substitute_fields' => array(
429 array(
'name',
'#title'),
430 array(
'name',
'#prefix'),
431 array(
'env-check',
'#title'),
432 array(
'env-check',
'#ajax',
'wrapper'),
433 array(
'attribute',
'#title'),
434 array(
'attribute',
'#ajax',
'wrapper'),
435 array(
'attr-other',
'#title'),
436 array(
'description',
'#title'),
437 array(
'description',
'#description'),
438 array(
'units',
'#title'),
439 array(
'unit-other',
'#title'),
440 array(
'val-check',
'#title'),
441 array(
'bin-check',
'#title'),
442 array(
'structure',
'#title'),
443 array(
'struct-other',
'#title'),
444 array(
'min',
'#title'),
445 array(
'max',
'#title'),
447 'substitute_keys' => array(
452 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][attribute]"]',
458 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]',
466 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]',
474 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][bin-check]"]',
482 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]',
490 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][val-check]"]',
496 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][structure]"]',
504 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]',
512 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][val-check]"]',
520 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][bin-check]"]',
528 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][units]"]',
536 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][val-check]"]',
544 ':input[name="' . $id .
'[phenotype][phenotypes-meta][!num][bin-check]"]',
560 for ($i = 1; $i <= $phenotype_number; $i++) {
561 if (empty($phenotypes[$i])) {
564 switch ($phenotypes[$i][
'attribute']) {
624 'degrees_fahrenheit',
630 'grams_per_square_meter',
640 $new_options = array();
641 foreach ($terms as $term) {
645 if (!empty($new_options)) {
646 $new_options[
'other'] =
'My unit is not in this list';
647 $form[$id][
'phenotype'][
'phenotypes-meta'][$i][
'units'][
'#options'] = $new_options;
650 if ($phenotypes[$i][
'env-check']) {
652 'whole plant' =>
'Whole Plant',
653 'soil_type' =>
'Soil',
654 'atmosphere' =>
'Atmosphere',
657 $new_options = array();
658 foreach ($terms as $term => $label) {
662 $form[$id][
'phenotype'][
'phenotypes-meta'][$i][
'structure'][
'#options'] = $new_options;
666 $form[$id][
'phenotype'][
'check'] = array(
667 '#type' =>
'checkbox',
668 '#title' => t(
'I would like to upload a phenotype metadata file'),
669 '#attributes' => array(
670 'data-toggle' => array(
'tooltip'),
671 'data-placement' => array(
'right'),
672 'title' => array(
'Upload a file'),
674 '#description' => t(
'We encourage that you only upload a phenotype metadata file if you have > 20 phenotypes. Using the fields above instead of uploading a metadata file allows you to select from standardized controlled vocabulary terms, which makes your data more findable, interoperable, and reusable.'),
678 $form[$id][
'phenotype'][
'metadata'] = array(
679 '#type' =>
'managed_file',
680 '#title' => t(
'Phenotype Metadata File: Please upload a file containing columns with the name, attribute, structure, description, and units of each of your phenotypes: *'),
681 '#upload_location' =>
"$phenotype_upload_location",
682 '#upload_validators' => array(
683 'file_validate_extensions' => array(
'csv tsv xlsx'),
687 ':input[name="' . $id .
'[phenotype][check]"]' => array(
'checked' => TRUE),
693 $form[$id][
'phenotype'][
'metadata'][
'empty'] = array(
694 '#default_value' => isset($values[
"$id"][
'phenotype'][
'metadata'][
'empty']) ? $values[
"$id"][
'phenotype'][
'metadata'][
'empty'] :
'NA',
697 $form[$id][
'phenotype'][
'metadata'][
'columns'] = array(
698 '#description' => t(
'Please define which columns hold the required data: Phenotype name'),
701 $column_options = array(
703 'Phenotype Name/Identifier',
712 $form[$id][
'phenotype'][
'metadata'][
'columns-options'] = array(
714 '#value' => $column_options,
717 $form[$id][
'phenotype'][
'metadata'][
'no-header'] = array();
731 $phenotype_names = array();
732 for ($i = 1; $i <= $number; $i++) {
733 if (!empty($meta[$i][
'name'])) {
734 $phenotype_names[] = is_array($meta[$i][
'name']) ? $meta[$i][
'name'][
'#value'] : $meta[$i][
'name'];
744 ), array(),
'metadata');
751 foreach ($columns as $key => $info) {
752 if (preg_match(
'/^[A-Z]+$/', $key)) {
753 $val = !empty($info[
'#value']) ? $info[
'#value'] : $info;
754 if (!empty($val) and $column_options[$val] ==
'Phenotype Name/Identifier') {
762 if (!empty($name_col) and !is_array($meta_fid) and !empty(file_load($meta_fid))) {
764 $phenotype_names = array_merge($phenotype_names, $names);
768 $time_default = NULL;
769 foreach ($phenotype_names as $name) {
770 if (preg_match(
'/[0-9]{4}$/', $name)) {
771 $time_default = TRUE;
775 $form[$id][
'phenotype'][
'time'] = array(
776 '#type' =>
'fieldset',
777 '#title' => t(
'Time options'),
781 $message = t(
'It looks like some of your phenotypes might be time-based. If this is the case, please indicate which ones are time-based with the section below.');
782 $form[$id][
'phenotype'][
'time'][
'#prefix'] =
"<div class=\"alert alert-block alert-dismissible alert-warning messages warning\"> 783 <a class=\"close\" data-dismiss=\"alert\" href=\"#\">×</a> 784 <h4 class=\"element-invisible\">Warning message</h4> 788 $form[$id][
'phenotype'][
'time'][
'time-check'] = array(
789 '#type' =>
'checkbox',
790 '#title' => t(
'Some of my phenotypes are time-based'),
791 '#default_value' => $time_default,
793 'callback' =>
'tpps_update_phenotype',
794 'wrapper' =>
"phenotype-main-$id",
805 $time_options = array();
806 foreach ($phenotype_names as $name) {
807 $time_options[strtolower($name)] = $name;
809 $form[$id][
'phenotype'][
'time'][
'time_phenotypes'] = array(
810 '#type' =>
'checkboxes',
811 '#title' => t(
'Time-based Phenotypes: *'),
812 '#options' => $time_options,
813 '#description' => t(
'Please select the phenotypes which are time-based'),
816 $form[$id][
'phenotype'][
'time'][
'time_values'] = array(
817 '#type' =>
'fieldset',
818 '#title' => t(
'Phenotype Time values:'),
821 foreach ($time_options as $key => $name) {
822 $form[$id][
'phenotype'][
'time'][
'time_values'][$key] = array(
823 '#type' =>
'textfield',
824 '#title' => t(
'(Optional) @name time:', array(
'@name' => $name)),
827 ':input[name="' . $id .
'[phenotype][time][time_phenotypes][' . $key .
']"]' => array(
'checked' => TRUE),
835 return $form[$id][
'phenotype'];
868 function tpps_genotype(array &$form, array &$form_state, array $values, $id) {
870 $genotype_upload_location =
'public://' . variable_get(
'tpps_genotype_files_dir',
'tpps_genotype');
873 '#type' =>
'fieldset',
874 '#title' => t(
'<div class="fieldset-title">Genotype Information:</div>'),
875 '#collapsible' => TRUE,
882 $marker_parents = array(
887 $parents = array_merge($marker_parents, array(
'SNPs'));
890 $parents = array_merge($marker_parents, array(
'SSRs/cpSSRs'));
893 $parents = array_merge($marker_parents, array(
'Indels'));
896 $parents = array_merge($marker_parents, array(
'Other'));
899 $fields[
'files'] = array(
900 '#type' =>
'fieldset',
901 '#prefix' =>
"<div id='$id-genotype-files'>",
902 '#suffix' =>
'</div>',
905 if (!empty($ssrs_check)) {
906 $fields[
'files'][
'ploidy'] = array(
908 '#title' => t(
'Ploidy'),
910 0 => t(
'- Select -'),
911 'Haploid' => t(
'Haploid'),
912 'Diploid' => t(
'Diploid'),
913 'Polyploid' => t(
'Polyploid'),
916 'callback' =>
'tpps_genotype_files_callback',
917 'wrapper' =>
"$id-genotype-files",
922 $file_type_parents = array(
929 if (!empty($snps_check)) {
930 $options[
'SNPs Genotype Assay'] =
'SNPs Genotype Assay';
931 $parents = array_merge($file_type_parents, array(
'SNPs Genotype Assay'));
934 if (!empty($snps_assay_check)) {
935 $options[
'Assay Design'] =
'Assay Design';
937 $parents = array_merge($file_type_parents, array(
'Assay Design'));
940 if (!empty($snps_assay_check) and !empty($form[$id][
'phenotype'])) {
941 $options[
'SNPs Associations'] =
'SNPs Associations';
943 $parents = array_merge($file_type_parents, array(
'SNPs Associations'));
946 if (!empty($ssrs_check)) {
947 $options[
'SSRs/cpSSRs Genotype Spreadsheet'] =
'SSRs/cpSSRs Genotype Spreadsheet';
948 $parents = array_merge($file_type_parents, array(
'SSRs/cpSSRs Genotype Spreadsheet'));
951 if (!empty($indel_check)) {
952 $options[
'Indel Genotype Spreadsheet'] =
'Indel Genotype Spreadsheet';
953 $parents = array_merge($file_type_parents, array(
'Indel Genotype Spreadsheet'));
956 if (!empty($other_marker_check)) {
957 $options[
'Other Marker Genotype Spreadsheet'] =
'Other Marker Genotype Spreadsheet';
958 $parents = array_merge($file_type_parents, array(
'Other Marker Genotype Spreadsheet'));
961 $options[
'VCF'] =
'VCF';
963 $fields[
'files'][
'file-type'] = array(
964 '#type' =>
'checkboxes',
965 '#title' => t(
'Genotype File Types (select all that apply): *'),
966 '#options' => $options,
968 'callback' =>
'tpps_genotype_files_callback',
969 'wrapper' =>
"$id-genotype-files",
973 $parents = array_merge($file_type_parents, array(
'VCF'));
977 if (!empty($snps_assay_check)) {
978 $fields[
'files'][
'file-selector'] = array(
979 '#type' =>
'checkbox',
980 '#title' => t(
'Reference Existing SNP File'),
982 'callback' =>
'tpps_genotype_files_type_change_callback',
983 'wrapper' =>
"$id-genotype-files",
986 $file_type_parents = array(
992 $parents = array_merge($file_type_parents, array(
'file-selector'));
995 if (empty($file_selector_check)) {
996 $fields[
'files'][
'snps-assay'] = array(
997 '#type' =>
'managed_file',
998 '#title' => t(
'SNPs Genotype Assay File: please provide a spreadsheet with columns for the Plant ID of genotypes used in this study: *'),
999 '#upload_location' =>
"$genotype_upload_location",
1000 '#upload_validators' => array(
1001 'file_validate_extensions' => array(
'csv tsv xlsx'),
1003 '#description' => t(
"Please upload a spreadsheet file containing SNP Genotype Assay data. The format of this file is very important! The first column of your file should contain plant identifiers which match the plant identifiers you provided in your plant accession file, and all of the remaining columns should contain SNP data."),
1007 if (isset($fields[
'files'][
'snps-assay'][
'#value'][
'fid'])) {
1008 $fields[
'files'][
'snps-assay'][
'#default_value'] = $fields[
'files'][
'snps-assay'][
'#value'][
'fid'];
1010 if (!empty($fields[
'files'][
'snps-assay'][
'#default_value']) and ($file = file_load($fields[
'files'][
'snps-assay'][
'#default_value']))) {
1012 file_usage_delete($file,
'tpps',
'tpps_project', substr($form_state[
'accession'], 4));
1017 $fields[
'files'][
'snps-assay'] = array(
1018 '#type' =>
'textfield',
1019 '#title' => t(
'SNPs Genotype Assay File: please select an already existing spreadsheet with columns for the Plant ID of genotypes used in this study: *'),
1020 '#upload_location' =>
"$genotype_upload_location",
1021 '#autocomplete_path' =>
'snp-assay-file/upload',
1022 '#description' => t(
"Please select an already existing spreadsheet file containing SNP Genotype Assay data. The format of this file is very important! The first column of your file should contain plant identifiers which match the plant identifiers you provided in your plant accession file, and all of the remaining columns should contain SNP data."),
1027 $fields[
'files'][
'snps-assay'] = array(
1028 '#type' =>
'managed_file',
1034 if (!empty($assay_design_check)) {
1035 $design_options = array(0 =>
'- Select -');
1036 $firstpage = $form_state[
'saved_values'][
TPPS_PAGE_1];
1037 for ($i = 1; $i <= $firstpage[
'organism'][
'number']; $i++) {
1038 $parts = explode(
" ", $firstpage[
'organism'][$i][
'name']);
1040 $query = db_select(
'chado.organism',
'o');
1041 $query->join(
'chado.project_organism',
'po',
'o.organism_id = po.organism_id');
1042 $query->join(
'public.tpps_project_file_managed',
'pf',
'pf.project_id = po.project_id');
1043 $query->join(
'public.file_managed',
'f',
'f.fid = pf.fid');
1044 $query->join(
'chado.project',
'p',
'p.project_id = po.project_id');
1045 $query->fields(
'f');
1046 $query->fields(
'p');
1047 $query->condition(
'o.genus', $genus);
1048 $query->condition(
'f.filename',
'%assay_design%',
'ILIKE');
1049 $results = $query->execute();
1050 while (($record = $results->fetchObject())) {
1051 $design_options[$record->fid] =
"{$record->filename} (from \"{$record->name}\")";
1054 $design_options[
'new'] =
'I would like to upload a new assay design file';
1055 $fields[
'files'][
'assay-load'] = array(
1056 '#type' =>
'select',
1057 '#title' =>
'Genotype Assay Design: *',
1058 '#options' => $design_options,
1059 '#description' => t(
'Please select an assay design. Some design files from the same genus as this species are available, or you can choose to upload your own assay design file.'),
1062 $fields[
'files'][
'assay-design'] = array(
1063 '#type' =>
'managed_file',
1064 '#title' =>
'Genotype Assay Design File: *',
1065 '#upload_location' =>
"$genotype_upload_location",
1066 '#upload_validators' => array(
1067 'file_validate_extensions' => array(
'csv tsv xlsx'),
1072 ':input[name="' . $id .
'[genotype][files][assay-load]"]' => array(
'value' =>
'new'),
1077 if (isset($fields[
'files'][
'assay-design'][
'#value'])) {
1078 $fields[
'files'][
'assay-design'][
'#default_value'] = $fields[
'files'][
'assay-design'][
'#value'];
1080 if (!empty($fields[
'files'][
'assay-design'][
'#default_value']) and ($file = file_load($fields[
'files'][
'assay-design'][
'#default_value']))) {
1082 file_usage_delete($file,
'tpps',
'tpps_project', substr($form_state[
'accession'], 4));
1085 $fields[
'files'][
'assay-citation'] = array(
1086 '#type' =>
'textfield',
1087 '#title' => t(
'Genotype Assay Design Citation (Optional):'),
1088 '#description' => t(
'If your assay design file is from a different paper, please include the citation for that paper here.'),
1091 ':input[name="' . $id .
'[genotype][files][assay-load]"]' => array(
'value' =>
'new'),
1097 $fields[
'files'][
'assay-design'] = array(
1098 '#type' =>
'managed_file',
1104 if (!empty($association_check)) {
1105 $fields[
'files'][
'snps-association'] = array(
1106 '#type' =>
'managed_file',
1107 '#title' => t(
'SNPs Association File: *'),
1108 '#upload_location' => $genotype_upload_location,
1109 '#upload_validators' => array(
1110 'file_validate_extensions' => array(
'csv tsv xlsx'),
1112 '#description' => t(
'Please upload a spreadsheet file containing SNPs Association data. When your file is uploaded, you will be shown a table with your column header names, several drop-downs, and the first few rows of your file. You will be asked to define the data type for each column, using the drop-downs provided to you. If a column data type does not fit any of the options in the drop-down menu, you may set that drop-down menu to "N/A". Your file must contain columns with the SNP ID, Scaffold, Position (formatted like "start:stop"), Allele (formatted like "major:minor"), Associated Trait Name (must match a phenotype from the above section), and Confidence Value. Optionally, you can also specify a Gene ID (which should match the gene reference) and a SNP Annotation (non synonymous, coding, etc).'),
1115 '#default_value' => $values[$id][
'genotype'][
'files'][
'snps-association'][
'empty'] ??
'NA',
1118 '#description' => t(
'Please define which columns hold the required data: SNP ID, Scaffold, Position, Allele, Associated Trait, Confidence Value.'),
1120 'columns-options' => array(
1121 '#type' =>
'hidden',
1133 'no-header' => array(),
1137 $fields[
'files'][
'snps-association-type'] = array(
1138 '#type' =>
'select',
1139 '#title' => t(
'Confidence Value Type: *'),
1140 '#options' => array(
1141 0 => t(
'- Select -'),
1142 'P value' => t(
'P value'),
1143 'Genomic Inflation Factor (GIF)' => t(
'Genomic Inflation Factor (GIF)'),
1144 'P-adjusted (FDR) / Q value' => t(
'P-adjusted (FDR) / Q value'),
1145 'P-adjusted (FWE)' => t(
'P-adjusted (FWE)'),
1146 'P-adjusted (Bonferroni)' => t(
'P-adjusted (Bonferroni)'),
1150 $fields[
'files'][
'snps-association-tool'] = array(
1151 '#type' =>
'select',
1152 '#title' => t(
'Association Analysis Tool: *'),
1153 '#options' => array(
1154 0 => t(
'- Select -'),
1155 'GEMMA' => t(
'GEMMA'),
1156 'EMMAX' => t(
'EMMAX'),
1157 'Plink' => t(
'Plink'),
1158 'Tassel' => t(
'Tassel'),
1159 'Sambada' => t(
'Sambada'),
1160 'Bayenv' => t(
'Bayenv'),
1161 'BayeScan' => t(
'BayeScan'),
1162 'LFMM' => t(
'LFMM'),
1166 $fields[
'files'][
'snps-pop-struct'] = array(
1167 '#type' =>
'managed_file',
1168 '#title' =>
'SNPs Population Structure File: ',
1169 '#upload_location' =>
"$genotype_upload_location",
1170 '#upload_validators' => array(
1171 'file_validate_extensions' => array(
'csv tsv xlsx'),
1176 if (isset($fields[
'files'][
'snps-pop-struct'][
'#value'])) {
1177 $fields[
'files'][
'snps-pop-struct'][
'#default_value'] = $fields[
'files'][
'snps-pop-struct'][
'#value'];
1179 if (!empty($fields[
'files'][
'snps-pop-struct'][
'#default_value']) and ($file = file_load($fields[
'files'][
'snps-pop-struct'][
'#default_value']))) {
1181 file_usage_delete($file,
'tpps',
'tpps_project', substr($form_state[
'accession'], 4));
1184 $fields[
'files'][
'snps-kinship'] = array(
1185 '#type' =>
'managed_file',
1186 '#title' =>
'SNPs Kinship File: ',
1187 '#upload_location' =>
"$genotype_upload_location",
1188 '#upload_validators' => array(
1189 'file_validate_extensions' => array(
'csv tsv xlsx'),
1194 if (isset($fields[
'files'][
'snps-kinship'][
'#value'])) {
1195 $fields[
'files'][
'snps-kinship'][
'#default_value'] = $fields[
'files'][
'snps-kinship'][
'#value'];
1197 if (!empty($fields[
'files'][
'snps-kinship'][
'#default_value']) and ($file = file_load($fields[
'files'][
'snps-kinship'][
'#default_value']))) {
1199 file_usage_delete($file,
'tpps',
'tpps_project', substr($form_state[
'accession'], 4));
1203 $fields[
'files'][
'snps-association'] = array(
1204 '#type' =>
'managed_file',
1209 $fields[
'files'][
'snps-pop-struct'] = array(
1210 '#type' =>
'managed_file',
1215 $fields[
'files'][
'snps-kinship'] = array(
1216 '#type' =>
'managed_file',
1222 if (!empty($ssrs_file_check)) {
1223 $fields[
'files'][
'ssrs'] = array(
1224 '#type' =>
'managed_file',
1225 '#title' => t(
'SSRs/cpSSRs Spreadsheet: *'),
1226 '#upload_location' =>
"$genotype_upload_location",
1227 '#upload_validators' => array(
1228 'file_validate_extensions' => array(
'csv tsv xlsx'),
1230 '#description' => t(
'Please upload a spreadsheet containing your SSRs/cpSSRs data. The format of this file is very important! TPPS will parse your file based on the ploidy you have selected above. For any ploidy, TPPS will assume that the first column of your file is the column that holds the Plant Identifier that matches your accession file.'),
1233 '#default_value' => isset($values[
"organism-$id"][
'genotype'][
'files'][
'ssrs']) ? $values[
"organism-$id"][
'genotype'][
'files'][
'ssrs'] :
'NA',
1246 $fields[
'files'][
'ssrs'][
'#description'] .=
' For haploid, TPPS assumes that each remaining column in the spreadsheet is a marker.';
1250 $fields[
'files'][
'ssrs'][
'#description'] .=
' For diploid, TPPS will assume that pairs of columns together are describing an individual marker, so the second and third columns would be the first marker, the fourth and fifth columns would be the second marker, etc.';
1254 $fields[
'files'][
'ssrs'][
'#description'] .=
' For polyploid, TPPS will read columns until it arrives at a non-empty column with a different name from the last.';
1261 if (isset($fields[
'files'][
'ssrs'][
'#value'][
'fid'])) {
1262 $fields[
'files'][
'ssrs'][
'#default_value'] = $fields[
'files'][
'ssrs'][
'#value'][
'fid'];
1264 if (!empty($fields[
'files'][
'ssrs'][
'#default_value']) and ($file = file_load($fields[
'files'][
'ssrs'][
'#default_value']))) {
1266 file_usage_delete($file,
'tpps',
'tpps_project', substr($form_state[
'accession'], 4));
1269 $fields[
'files'][
'ssr-extra-check'] = array(
1270 '#type' =>
'checkbox',
1271 '#title' => t(
'I would like to include an additional SSRs/cpSSRs Spreadsheet (this is typically used when the study includes both SSR and cpSSR data)'),
1273 'callback' =>
'tpps_genotype_files_callback',
1274 'wrapper' =>
"$id-genotype-files",
1285 if ($ssrs_extra_check) {
1286 $fields[
'files'][
'extra-ssr-type'] = array(
1287 '#type' =>
'textfield',
1288 '#title' => t(
'Define Additional SSRs/cpSSRs Type: *'),
1291 $fields[
'files'][
'extra-ploidy'] = array(
1292 '#type' =>
'select',
1293 '#title' => t(
'Additional SSRs/cpSSRs Ploidy'),
1294 '#options' => array(
1295 0 => t(
'- Select -'),
1296 'Haploid' => t(
'Haploid'),
1297 'Diploid' => t(
'Diploid'),
1298 'Polyploid' => t(
'Polyploid'),
1301 'callback' =>
'tpps_genotype_files_callback',
1302 'wrapper' =>
"$id-genotype-files",
1306 $fields[
'files'][
'ssrs_extra'] = array(
1307 '#type' =>
'managed_file',
1308 '#title' => t(
'SSRs/cpSSRs Additional Spreadsheet: *'),
1309 '#upload_location' =>
"$genotype_upload_location",
1310 '#upload_validators' => array(
1311 'file_validate_extensions' => array(
'csv tsv xlsx'),
1313 '#description' => t(
'Please upload an additional spreadsheet containing your SSRs/cpSSRs data. The format of this file is very important! TPPS will parse your file based on the ploidy you have selected above. For any ploidy, TPPS will assume that the first column of your file is the column that holds the Plant Identifier that matches your accession file.'),
1324 switch ($extra_ploidy) {
1326 $fields[
'files'][
'ssrs_extra'][
'#description'] .=
' For haploid, TPPS assumes that each remaining column in the spreadsheet is a marker.';
1330 $fields[
'files'][
'ssrs_extra'][
'#description'] .=
' For diploid, TPPS will assume that pairs of columns together are describing an individual marker, so the second and third columns would be the first marker, the fourth and fifth columns would be the second marker, etc.';
1334 $fields[
'files'][
'ssrs_extra'][
'#description'] .=
' For polyploid, TPPS will read columns until it arrives at a non-empty column with a different name from the last.';
1341 if (isset($fields[
'files'][
'ssrs_extra'][
'#value'][
'fid'])) {
1342 $fields[
'files'][
'ssrs_extra'][
'#default_value'] = $fields[
'files'][
'ssrs_extra'][
'#value'][
'fid'];
1344 if (!empty($fields[
'files'][
'ssrs_extra'][
'#default_value']) and ($file = file_load($fields[
'files'][
'ssrs_extra'][
'#default_value']))) {
1346 file_usage_delete($file,
'tpps',
'tpps_project', substr($form_state[
'accession'], 4));
1350 $fields[
'files'][
'ssrs-extra'] = array(
1351 '#type' =>
'managed_file',
1358 $fields[
'files'][
'ssrs'] = array(
1359 '#type' =>
'managed_file',
1364 $fields[
'files'][
'ssrs-extra'] = array(
1365 '#type' =>
'managed_file',
1371 if (!empty($indel_file_check)) {
1372 $fields[
'files'][
'indels'] = array(
1373 '#type' =>
'managed_file',
1374 '#title' => t(
'Indel Genotype Spreadsheet: *'),
1375 '#upload_location' =>
"$genotype_upload_location",
1376 '#upload_validators' => array(
1377 'file_validate_extensions' => array(
'csv tsv xlsx'),
1379 '#description' => t(
'Please upload a spreadsheet containing your Indels data. The first column of your file should contain plant identifiers which match the plant identifiers you provided in your plant accession file, and all of the remaining columns should contain Indel data.'),
1383 if (isset($fields[
'files'][
'indels'][
'#value'][
'fid'])) {
1384 $fields[
'files'][
'indels'][
'#default_value'] = $fields[
'files'][
'indels'][
'#value'][
'fid'];
1386 if (!empty($fields[
'files'][
'indels'][
'#default_value']) and ($file = file_load($fields[
'files'][
'indels'][
'#default_value']))) {
1388 file_usage_delete($file,
'tpps',
'tpps_project', substr($form_state[
'accession'], 4));
1392 $fields[
'files'][
'indels'] = array(
1393 '#type' =>
'managed_file',
1399 if (!empty($other_file_check)) {
1400 $fields[
'files'][
'other'] = array(
1401 '#type' =>
'managed_file',
1402 '#title' => t(
'Other Marker Genotype Spreadsheet: please provide a spreadsheet with columns for the Plant ID of genotypes used in this study: *'),
1403 '#upload_location' =>
"$genotype_upload_location",
1404 '#upload_validators' => array(
1405 'file_validate_extensions' => array(
'csv tsv xlsx'),
1407 '#description' => t(
'Please upload a spreadsheet file containing Genotype data. When your file is uploaded, you will be shown a table with your column header names, several drop-downs, and the first few rows of your file. You will be asked to define the data type for each column, using the drop-downs provided to you. If a column data type does not fit any of the options in the drop-down menu, you may set that drop-down menu to "N/A". Your file must contain one column with the Plant Identifier.'),
1411 $fields[
'files'][
'other'][
'empty'] = array(
1412 '#default_value' => $values[$id][
'genotype'][
'files'][
'other'][
'empty'] ??
'NA',
1415 $default_dynamic = !empty($form_state[
'saved_values'][
TPPS_PAGE_4][$id][
'genotype'][
'files'][
'other-columns']);
1416 $fields[
'files'][
'other'][
'dynamic'] = array(
1417 '#type' =>
'checkbox',
1418 '#title' => t(
'This file needs dynamic dropdown options for column data type specification'),
1420 'wrapper' =>
"edit-$id-genotype-files-other-ajax-wrapper",
1421 'callback' =>
'tpps_page_4_file_dynamic',
1423 '#default_value' => $default_dynamic,
1432 ), $default_dynamic,
'other');
1434 $fields[
'files'][
'other'][
'columns'] = array(
1435 '#description' => t(
'Please define which columns hold the required data: Plant Identifier, Genotype Data'),
1438 $fields[
'files'][
'other'][
'columns-options'] = array(
1439 '#type' =>
'hidden',
1448 $fields[
'files'][
'other'][
'no-header'] = array();
1451 $fields[
'files'][
'other'] = array(
1452 '#type' =>
'managed_file',
1458 if (!empty($vcf_file_check)) {
1459 $fields[
'files'][
'vcf'] = array(
1460 '#type' =>
'managed_file',
1461 '#title' => t(
'Genotype VCF File: *'),
1462 '#upload_location' =>
"$genotype_upload_location",
1463 '#upload_validators' => array(
1464 'file_validate_extensions' => array(
'gz tar zip'),
1469 ':input[name="' . $id .
'[genotype][files][local_vcf_check]"]' => array(
'checked' => FALSE),
1474 if (isset($fields[
'files'][
'vcf'][
'#value'])) {
1475 $fields[
'files'][
'vcf'][
'#default_value'] = $fields[
'files'][
'vcf'][
'#value'];
1477 if (!empty($fields[
'files'][
'vcf'][
'#default_value']) and ($file = file_load($fields[
'files'][
'vcf'][
'#default_value']))) {
1479 file_usage_delete($file,
'tpps',
'tpps_project', substr($form_state[
'accession'], 4));
1482 if (isset($form_state[
'tpps_type']) and $form_state[
'tpps_type'] ==
'tppsc') {
1484 $parts = explode(
'://', $base_url);
1485 $hostname = $parts[1];
1486 $fields[
'files'][
'local_vcf_check'] = array(
1487 '#type' =>
'checkbox',
1488 '#title' => t(
"My VCF file is stored locally on @hostname", array(
'@hostname' => $hostname)),
1491 $fields[
'files'][
'local_vcf'] = array(
1492 '#type' =>
'textfield',
1493 '#title' => t(
'Path to local VCF File: *'),
1496 ':input[name="' . $id .
'[genotype][files][local_vcf_check]"]' => array(
'checked' => TRUE),
1499 '#description' => t(
"Please provide the full path to your vcf file stored locally on @hostname", array(
'@hostname' => $hostname)),
1504 $fields[
'files'][
'vcf'] = array(
1505 '#type' =>
'managed_file',
1528 $cartogratree_env = variable_get(
'tpps_cartogratree_env', FALSE);
1530 $form[$id][
'environment'] = array(
1531 '#type' =>
'fieldset',
1532 '#title' => t(
'<div class="fieldset-title">Environmental Information:</div>'),
1533 '#collapsible' => TRUE,
1537 if ($cartogratree_env and db_table_exists(
'cartogratree_groups') and db_table_exists(
'cartogratree_layers') and db_table_exists(
'cartogratree_fields')) {
1539 $query = db_select(
'variable',
'v')
1541 ->condition(
'name', db_like(
'tpps_layer_group_') .
'%',
'LIKE');
1543 $results = $query->execute();
1546 while (($result = $results->fetchObject())) {
1547 $group_id = substr($result->name, 17);
1548 $group = db_select(
'cartogratree_groups',
'g')
1549 ->fields(
'g', array(
'group_id',
'group_name'))
1550 ->condition(
'group_id', $group_id)
1553 $group_is_enabled = variable_get(
"tpps_layer_group_$group_id", FALSE);
1555 if ($group_is_enabled) {
1556 if ($group->group_name ==
'WorldClim v.2 (WorldClim)') {
1557 $subgroups_query = db_select(
'cartogratree_layers',
'c')
1559 ->fields(
'c', array(
'subgroup_id'))
1560 ->condition(
'c.group_id', $group_id)
1562 while (($subgroup = $subgroups_query->fetchObject())) {
1563 $subgroup_title = db_select(
'cartogratree_subgroups',
's')
1564 ->fields(
's', array(
'subgroup_name'))
1565 ->condition(
'subgroup_id', $subgroup->subgroup_id)
1567 ->fetchObject()->subgroup_name;
1568 $options[
"worldclim_subgroup_{$subgroup->subgroup_id}"] = array(
1569 'group_id' => $group_id,
1570 'group' => $group->group_name,
1571 'title' => $subgroup_title,
1577 $layers_query = db_select(
'cartogratree_layers',
'c')
1578 ->fields(
'c', array(
'title',
'group_id',
'layer_id'))
1579 ->condition(
'c.group_id', $group_id);
1580 $layers_results = $layers_query->execute();
1581 while (($layer = $layers_results->fetchObject())) {
1582 $params_query = db_select(
'cartogratree_fields',
'f')
1583 ->fields(
'f', array(
'display_name',
'field_id'))
1584 ->condition(
'f.layer_id', $layer->layer_id);
1585 $params_results = $params_query->execute();
1587 while (($param = $params_results->fetchObject())) {
1588 $params[$param->field_id] = $param->display_name;
1590 $options[$layer->layer_id] = array(
1591 'group_id' => $layer->group_id,
1592 'group' => $group->group_name,
1593 'title' => $layer->title,
1594 'params' => $params,
1601 $form[$id][
'environment'][
'env_layers_groups'] = array(
1602 '#type' =>
'fieldset',
1603 '#title' =>
'CartograPlant Environmental Layer Groups: *',
1604 '#collapsible' => TRUE,
1607 $form[$id][
'environment'][
'layer_search'] = array(
1608 '#type' =>
'textfield',
1609 '#title' => t(
'Layers Search'),
1610 '#description' => t(
'You can use this field to filter the layers in the following section.'),
1613 $form[$id][
'environment'][
'env_layers'] = array(
1614 '#type' =>
'fieldset',
1615 '#title' =>
'CartograPlant Environmental Layers: *',
1616 '#collapsible' => TRUE,
1619 $form[$id][
'environment'][
'env_params'] = array(
1620 '#type' =>
'fieldset',
1621 '#title' =>
'CartograPlant Environmental Layer Parameters: *',
1622 '#collapsible' => TRUE,
1625 foreach ($options as $layer_id => $layer_info) {
1626 $layer_title = $layer_info[
'title'];
1627 $layer_group = $layer_info[
'group'];
1628 $layer_params = $layer_info[
'params'];
1630 $form[$id][
'environment'][
'env_layers_groups'][$layer_group] = array(
1631 '#type' =>
'checkbox',
1632 '#title' => $layer_group,
1633 '#return_value' => $layer_info[
'group_id'],
1636 $form[$id][
'environment'][
'env_layers'][$layer_title] = array(
1637 '#type' =>
'checkbox',
1638 '#title' =>
"<strong>$layer_title</strong> - $layer_group",
1641 ':input[name="' . $id .
'[environment][env_layers_groups][' . $layer_group .
']"]' => array(
'checked' => TRUE),
1644 '#return_value' => $layer_id,
1647 if (!empty($layer_params)) {
1648 $form[$id][
'environment'][
'env_params'][
"$layer_title"] = array(
1649 '#type' =>
'fieldset',
1650 '#title' =>
"$layer_title Parameters",
1651 '#description' => t(
'Please select the parameters you used from the @title layer.', array(
'@title' => $layer_title)),
1654 ':input[name="' . $id .
'[environment][env_layers_groups][' . $layer_group .
']"]' => array(
'checked' => TRUE),
1655 ':input[name="' . $id .
'[environment][env_layers][' . $layer_title .
']"]' => array(
'checked' => TRUE),
1660 foreach ($layer_params as $param_id => $param) {
1661 $form[$id][
'environment'][
'env_params'][
"$layer_title"][$param] = array(
1662 '#type' =>
'checkbox',
1664 '#return_value' => $param_id,
1670 $form[$id][
'environment'][
'env_layers'][
'other'] = array(
1671 '#type' =>
'checkbox',
1672 '#title' =>
"<strong>Other custom layer</strong>",
1673 '#return_value' =>
'other',
1676 $form[$id][
'environment'][
'env_layers'][
'other_db'] = array(
1677 '#type' =>
'textfield',
1678 '#title' => t(
'Layer DB URL: *'),
1679 '#description' => t(
'The url of the DB providing this layer'),
1682 ':input[name="' . $id .
'[environment][env_layers][other]"]' => array(
'checked' => TRUE),
1687 $form[$id][
'environment'][
'env_layers'][
'other_name'] = array(
1688 '#type' =>
'textfield',
1689 '#title' => t(
'Layer Name: *'),
1690 '#description' => t(
'The name of the layer'),
1693 ':input[name="' . $id .
'[environment][env_layers][other]"]' => array(
'checked' => TRUE),
1698 $form[$id][
'environment'][
'env_layers'][
'other_params'] = array(
1699 '#type' =>
'textfield',
1700 '#title' => t(
'Parameters Used: *'),
1701 '#description' => t(
'Comma-delimited list of parameters from the layer used. For example, when using parameters "rainfall" and "humidity", this field should look something like "rainfall,humidity"'),
1704 ':input[name="' . $id .
'[environment][env_layers][other]"]' => array(
'checked' => TRUE),
1710 return $form[$id][
'environment'];
1731 'key' =>
'filename',
1735 $genome_dir = variable_get(
'tpps_local_genome_dir', NULL);
1736 $ref_genome_arr = array();
1737 $ref_genome_arr[0] =
'- Select -';
1740 $existing_genomes = array();
1741 $results = file_scan_directory($genome_dir,
'/^([A-Z][a-z]{3})$/', $options);
1743 foreach ($results as $key => $value) {
1744 $org_id_query = chado_select_record(
'organismprop', array(
'organism_id'), array(
1746 'type_id' => $code_cvterm,
1749 if (!empty($org_id_query)) {
1750 $org_query = chado_select_record(
'organism', array(
'genus',
'species'), array(
1751 'organism_id' => current($org_id_query)->organism_id,
1753 $result = current($org_query);
1755 $versions = file_scan_directory(
"$genome_dir/$key",
'/^v([0-9]|.)+$/', $options);
1756 foreach ($versions as $item) {
1757 $opt_string = $result->genus .
" " . $result->species .
" " . $item->filename;
1758 $existing_genomes[$opt_string] = $opt_string;
1762 ksort($existing_genomes);
1763 $ref_genome_arr += $existing_genomes;
1766 $ref_genome_arr[
"url"] =
'I can provide a URL to the website of my reference file(s)';
1767 $ref_genome_arr[
"bio"] =
'I can provide a GenBank accession number (BioProject, WGS, TSA) and select assembly file(s) from a list';
1768 $ref_genome_arr[
"manual"] =
'I can upload my own reference genome file';
1769 $ref_genome_arr[
"manual2"] =
'I can upload my own reference transcriptome file';
1770 $ref_genome_arr[
"none"] =
'I am unable to provide a reference assembly';
1772 $fields[
'ref-genome'] = array(
1773 '#type' =>
'select',
1774 '#title' => t(
'Reference Assembly used: *'),
1775 '#options' => $ref_genome_arr,
1778 require_once drupal_get_path(
'module',
'tripal') .
'/includes/tripal.importer.inc';
1779 $class =
'EutilsImporter';
1780 tripal_load_include_importer_class($class);
1781 $eutils = tripal_get_importer_form(array(), $form_state, $class);
1782 $eutils[
'#type'] =
'fieldset';
1783 $eutils[
'#title'] =
'Tripal Eutils BioProject Loader';
1784 $eutils[
'#states'] = array(
1786 ':input[name="' . $id .
'[genotype][ref-genome]"]' => array(
'value' =>
'bio'),
1789 $eutils[
'accession'][
'#description'] = t(
'Valid examples: 12384, 394253, 66853, PRJNA185471');
1790 $eutils[
'db'] = array(
1791 '#type' =>
'hidden',
1792 '#value' =>
'bioproject',
1794 unset($eutils[
'options']);
1795 $eutils[
'options'][
'linked_records'] = array(
1796 '#type' =>
'hidden',
1799 $eutils[
'callback'][
'#ajax'] = array(
1800 'callback' =>
'tpps_ajax_bioproject_callback',
1801 'wrapper' =>
"$id-tripal-eutils",
1803 $eutils[
'#prefix'] =
"<div id=\"$id-tripal-eutils\">";
1804 $eutils[
'#suffix'] =
'</div>';
1806 if (!empty($form_state[
'values'][$id][
'genotype'][
'tripal_eutils'])) {
1807 $eutils_vals = $form_state[
'values'][$id][
'genotype'][
'tripal_eutils'];
1808 if (!empty($eutils_vals[
'accession']) and !empty($eutils_vals[
'db'])) {
1809 $connection = new \EUtils();
1811 $connection->setPreview(TRUE);
1812 $eutils[
'data'] = $connection->get($eutils_vals[
'db'], $eutils_vals[
'accession']);
1813 foreach ($_SESSION[
'messages'][
'status'] as $key => $message) {
1814 if ($message ==
'<pre>biosample</pre>') {
1815 unset($_SESSION[
'messages'][
'status'][$key]);
1816 if (empty($_SESSION[
'messages'][
'status'])) {
1817 unset($_SESSION[
'messages'][
'status']);
1823 catch (\Exception $e) {
1824 tripal_set_message($e->getMessage(), TRIPAL_ERROR);
1828 unset($eutils[
'button']);
1829 unset($eutils[
'instructions']);
1830 $fields[
'tripal_eutils'] = $eutils;
1832 $class =
'FASTAImporter';
1833 tripal_load_include_importer_class($class);
1834 $tripal_upload_location =
"public://tripal/users/$uid";
1836 $fasta = tripal_get_importer_form(array(), $form_state, $class);
1837 $fasta[
'#type'] =
'fieldset';
1838 $fasta[
'#title'] =
'Tripal FASTA Loader';
1839 $fasta[
'#states'] = array(
1842 array(
':input[name="' . $id .
'[genotype][ref-genome]"]' => array(
'value' =>
'url')),
1844 array(
':input[name="' . $id .
'[genotype][ref-genome]"]' => array(
'value' =>
'manual')),
1846 array(
':input[name="' . $id .
'[genotype][ref-genome]"]' => array(
'value' =>
'manual2')),
1851 unset($fasta[
'file'][
'file_local']);
1852 unset($fasta[
'organism_id']);
1853 unset($fasta[
'method']);
1854 unset($fasta[
'match_type']);
1855 $db = $fasta[
'additional'][
'db'];
1856 unset($fasta[
'additional']);
1858 $fasta[
'db'][
'#collapsible'] = TRUE;
1859 unset($fasta[
'button']);
1862 '#type' =>
'managed_file',
1864 '#description' => t(
'Remember to click the "Upload" button below to send your file to the server. This interface is capable of uploading very large files. If you are disconnected you can return, reload the file and it will resume where it left off. Once the file is uploaded the "Upload Progress" will indicate "Complete". If the file is already present on the server then the status will quickly update to "Complete".'),
1865 '#upload_validators' => array(
1866 'file_validate_extensions' => array(implode(
' ', $class::$file_types)),
1868 '#upload_location' => $tripal_upload_location,
1871 $fasta[
'file'][
'file_upload'] = $upload;
1872 $fasta[
'analysis_id'][
'#required'] = $fasta[
'seqtype'][
'#required'] = FALSE;
1873 $fasta[
'file'][
'file_upload'][
'#states'] = $fasta[
'file'][
'file_upload_existing'][
'#states'] = array(
1876 array(
':input[name="' . $id .
'[genotype][ref-genome]"]' => array(
'value' =>
'manual')),
1878 array(
':input[name="' . $id .
'[genotype][ref-genome]"]' => array(
'value' =>
'manual2')),
1882 $fasta[
'file'][
'file_remote'][
'#states'] = array(
1884 ':input[name="]' . $id .
'[genotype][ref-genome]"]' => array(
'value' =>
'url'),
1888 $fields[
'tripal_fasta'] = $fasta;
1901 $fields[
'marker-type'] = array(
1902 '#type' =>
'checkboxes',
1903 '#title' => t(
'Marker Type (select all that apply): *'),
1904 '#options' => drupal_map_assoc(array(
1912 $fields[
'marker-type'][
'#ajax'] = array(
1913 'callback' =>
'tpps_genotype_files_callback',
1914 'wrapper' =>
"$id-genotype-files",
1917 $fields[
'SNPs'] = array(
1918 '#type' =>
'fieldset',
1919 '#title' => t(
'<div class="fieldset-title">SNPs Information:</div>'),
1922 ':input[name="' . $id .
'[genotype][marker-type][SNPs]"]' => array(
'checked' => TRUE),
1925 '#collapsible' => TRUE,
1928 $fields[
'SNPs'][
'genotyping-design'] = array(
1929 '#type' =>
'select',
1930 '#title' => t(
'Define Experimental Design: *'),
1931 '#options' => array(
1932 0 => t(
'- Select -'),
1934 2 => t(
'Targeted Capture'),
1935 3 => t(
'Whole Genome Resequencing'),
1937 5 => t(
'Genotyping Array'),
1941 $fields[
'SNPs'][
'GBS'] = array(
1942 '#type' =>
'select',
1943 '#title' => t(
'GBS Type: *'),
1944 '#options' => array(
1945 0 => t(
'- Select -'),
1947 2 => t(
'ddRAD-Seq'),
1954 ':input[name="' . $id .
'[genotype][SNPs][genotyping-design]"]' => array(
'value' =>
'1'),
1959 $fields[
'SNPs'][
'GBS-other'] = array(
1960 '#type' =>
'textfield',
1963 ':input[name="' . $id .
'[genotype][SNPs][GBS]"]' => array(
'value' =>
'5'),
1964 ':input[name="' . $id .
'[genotype][SNPs][genotyping-design]"]' => array(
'value' =>
'1'),
1969 $fields[
'SNPs'][
'targeted-capture'] = array(
1970 '#type' =>
'select',
1971 '#title' => t(
'Targeted Capture Type: *'),
1972 '#options' => array(
1973 0 => t(
'- Select -'),
1974 1 => t(
'Exome Capture'),
1979 ':input[name="' . $id .
'[genotype][SNPs][genotyping-design]"]' => array(
'value' =>
'2'),
1984 $fields[
'SNPs'][
'targeted-capture-other'] = array(
1985 '#type' =>
'textfield',
1988 ':input[name="' . $id .
'[genotype][SNPs][targeted-capture]"]' => array(
'value' =>
'2'),
1989 ':input[name="' . $id .
'[genotype][SNPs][genotyping-design]"]' => array(
'value' =>
'2'),
1994 $fields[
'SSRs/cpSSRs'] = array(
1995 '#type' =>
'textfield',
1996 '#title' => t(
'Define SSRs/cpSSRs Type: *'),
1999 ':input[name="' . $id .
'[genotype][marker-type][SSRs/cpSSRs]"]' => array(
'checked' => TRUE),
2004 $fields[
'other-marker'] = array(
2005 '#type' =>
'textfield',
2006 '#title' => t(
'Define Other Marker Type: *'),
2009 ':input[name="' . $id .
'[genotype][marker-type][Other]"]' => array(
'checked' => TRUE),
tpps_genotype(array &$form, array &$form_state, array $values, $id)
tpps_environment(array &$form, array &$form_state, $id)
tpps_phenotype(array &$form, array &$form_state, array $values, $id)
tpps_phenotype_number_clear($button_name, $value)
tpps_page_4_marker_info(array &$fields, $id)
tpps_parse_file_column($fid, $column, $no_header=FALSE)
tpps_load_cvterm($term, array $options=array(), $version=NULL, $refresh_cache=FALSE)
tpps_page_4_ref(array &$fields, array &$form_state, $id)