28 'affiliation' => $state[
'saved_values'][TPPS_PAGE_1][
'organization'],
31 for ($i = 1; $i <= $state[
'saved_values'][
TPPS_PAGE_1][
'publication'][
'secondaryAuthors'][
'number']; $i++) {
32 $creators[] = (object) array(
33 'name' =>
tpps_doi_format_name($state[
'saved_values'][TPPS_PAGE_1][
'publication'][
'secondaryAuthors'][$i]),
38 for ($i = 1; $i <= $state[
'saved_values'][
TPPS_PAGE_1][
'organism'][
'number']; $i++) {
39 $keywords[] = $state[
'saved_values'][
TPPS_PAGE_1][
'organism'][$i][
'name'];
42 $study_type_options = array(
43 1 =>
'Natural Population (Landscape)',
44 2 =>
'Growth Chamber',
46 4 =>
'Experimental/Common Garden',
50 $keywords[] = $study_type_options[$state[
'saved_values'][
TPPS_PAGE_2][
'study_type']];
52 $metadata = (object) array(
53 'title' => $state[
'saved_values'][TPPS_PAGE_1][
'publication'][
'title'],
54 'upload_type' =>
'dataset',
55 'description' => $state[
'saved_values'][TPPS_PAGE_1][
'publication'][
'abstract'],
56 'creators' => $creators,
58 'keywords' => $keywords,
59 'notes' => $state[
'saved_values'][
'summarypage'][
'comments'],
60 'related_identifiers' => array(
62 'relation' =>
'isAlternateIdentifier',
63 'identifier' =>
"$base_url/tpps/details/$accession",
82 $token = variable_get(
'tpps_zenodo_api_key', NULL);
83 $prefix = variable_get(
'tpps_zenodo_prefix',
'');
84 $ch = curl_init(
"https://{$prefix}zenodo.org/api/deposit/depositions?" . http_build_query(array(
'access_token' => $token)));
85 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
86 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json'));
87 curl_setopt($ch, CURLOPT_POST, 1);
88 curl_setopt($ch, CURLOPT_POSTFIELDS,
'{}');
90 $out = json_decode(curl_exec($ch));
108 $data =
new stdClass();
109 $data->metadata = $metadata;
110 $data_json = json_encode($data);
112 $token = variable_get(
'tpps_zenodo_api_key', NULL);
113 $prefix = variable_get(
'tpps_zenodo_prefix',
'');
114 $ch = curl_init(
"https://{$prefix}zenodo.org/api/deposit/depositions/$id?" . http_build_query(array(
'access_token' => $token)));
115 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
116 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
117 'Content-Type: application/json',
118 'Content-Length: ' . strlen($data_json),
120 curl_setopt($ch, CURLOPT_CUSTOMREQUEST,
'PUT');
121 curl_setopt($ch, CURLOPT_POSTFIELDS, $data_json);
123 $out = json_decode(curl_exec($ch));
137 $token = variable_get(
'tpps_zenodo_api_key', NULL);
138 $prefix = variable_get(
'tpps_zenodo_prefix',
'');
141 for ($i = 1; $i <= $state[
'stats'][
'species_count']; $i++) {
142 $files[] = $state[
'saved_values'][
TPPS_PAGE_3][
'tree-accession'][
"species-$i"][
'file'];
143 if (empty($state[
'saved_values'][
TPPS_PAGE_3][
'tree-accession'][
'check'])) {
148 for ($i = 1; $i <= $state[
'saved_values'][
TPPS_PAGE_1][
'organism'][
'number']; $i++) {
149 if (isset($state[
'saved_values'][
TPPS_PAGE_4][
"organism-$i"][
'phenotype'])) {
150 $phenotype = &$state[
'saved_values'][
TPPS_PAGE_4][
"organism-$i"][
'phenotype'];
151 if (!empty($phenotype[
'normal-check'])) {
152 $files[] = $phenotype[
'file'];
153 if ($phenotype[
'check']) {
154 $files[] = $phenotype[
'metadata'];
158 if (!empty($phenotype[
'iso-check'])) {
159 $files[] = $phenotype[
'iso'];
163 if (isset($state[
'saved_values'][TPPS_PAGE_4][
"organism-$i"][
'genotype'])) {
164 $genotype = &$state[
'saved_values'][
TPPS_PAGE_4][
"organism-$i"][
'genotype'];
165 if ($genotype[
'ref-genome'] ==
'manual' or $genotype[
'ref-genome'] ==
'manual2' or $genotype[
'ref-genome'] ==
'url') {
166 if ($genotype[
'tripal_fasta'][
'file_upload']) {
167 $files[] = $genotype[
'tripal_fasta'][
'file_upload'];
170 if ($genotype[
'tripal_fasta'][
'file_upload_existing']) {
171 $files[] = $genotype[
'tripal_fasta'][
'file_upload_existing'];
175 if (!empty($genotype[
'files'][
'file-type'][
'SNPs Genotype Assay'])) {
176 $files[] = $genotype[
'files'][
'snps-assay'];
179 if (!empty($genotype[
'files'][
'file-type'][
'Assay Design']) and $genotype[
'marker-type'][
'SNPs']) {
180 $files[] = $genotype[
'files'][
'assay-design'];
183 if (!empty($genotype[
'files'][
'file-type'][
'SSRs/cpSSRs Genotype Spreadsheet'])) {
184 $files[] = $genotype[
'files'][
'ssrs'];
187 if (!empty($genotype[
'files'][
'file-type'][
'Other Marker Genotype Spreadsheet'])) {
188 $files[] = $genotype[
'files'][
'other'];
191 if (!empty($genotype[
'files'][
'file-type'][
'VCF'])) {
192 $files[] = $genotype[
'files'][
'vcf'];
197 foreach ($files as $file) {
198 $file = file_load($file);
199 if ($file->filesize < 20000000000) {
200 $path = drupal_realpath($file->uri);
202 'file' => curl_file_create($path, $file->filemime, $file->filename),
205 $ch = curl_init(
"https://{$prefix}zenodo.org/api/deposit/depositions/$id/files?" . http_build_query(array(
'access_token' => $token)));
206 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
207 curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: multipart/form-data'));
208 curl_setopt($ch, CURLOPT_POST, 1);
209 curl_setopt($ch, CURLOPT_POSTFIELDS, $data);
226 $token = variable_get(
'tpps_zenodo_api_key', NULL);
227 $prefix = variable_get(
'tpps_zenodo_prefix',
'');
228 $ch = curl_init(
"https://{$prefix}zenodo.org/api/deposit/depositions/$id/actions/publish?" . http_build_query(array(
'access_token' => $token)));
229 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
230 curl_setopt($ch, CURLOPT_POST, 1);
231 curl_setopt($ch, CURLOPT_POSTFIELDS,
'');
233 $out = json_decode(curl_exec($ch));
248 $token = variable_get(
'tpps_zenodo_api_key', NULL);
249 $prefix = variable_get(
'tpps_zenodo_prefix',
'');
250 $ch = curl_init(
"https://{$prefix}zenodo.org/api/deposit/depositions/$id?" . http_build_query(array(
'access_token' => $token)));
251 curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
253 $out = json_decode(curl_exec($ch));
268 $parts = explode(
' ', $name);
270 $last = implode(
' ', array_slice($parts, 1));
271 return "$last, $first";
tpps_doi_format_name($name)
tpps_doi_upload_files($id, array &$state)
tpps_load_submission($accession, $state=TRUE)
tpps_generate_doi($accession)
tpps_doi_metadata($id, $metadata)