Creates fields describing the genotype data for the submission.
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',
tpps_page_4_marker_info(array &$fields, $id)
tpps_page_4_ref(array &$fields, array &$form_state, $id)