Skip to content

Commit

Permalink
Merge pull request #1162 from NFDI4Chem/datacite-bioschemas
Browse files Browse the repository at this point in the history
fix: unify studies and datasets naming in bioschemas and datacite
  • Loading branch information
CS76 authored Aug 14, 2024
2 parents 3ed669a + 31ed8e9 commit 79bd14c
Showing 1 changed file with 11 additions and 18 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -238,17 +238,13 @@ public function prepareMoleculesSchemas($sample)
*/
public function getSample($study)
{
$prefix = '';
if (property_exists($study, 'project')) {
$prefix = $study->project->name.'.';
}
$sample = $study->sample;
$molecules = $this->prepareMoleculesSchemas($sample);

$sampleSchema = Schema::ChemicalSubstance();
$sampleSchema['@id'] = $study->doi;
$sampleSchema['dct:conformsTo'] = BioschemasHelper::conformsTo(['https://bioschemas.org/types/ChemicalSubstance/0.3-RELEASE-2019_09_02']);
$sampleSchema->name($prefix.$sample->name);
$sampleSchema->name($sample->name);
$sampleSchema->description($sample->description);
$sampleSchema->url(env('APP_URL').'/'.explode(':', $study->identifier ? $study->identifier : ':')[1]);
$sampleSchema->hasBioChemEntityPart($this->prepareMoleculesSchemas($sample));
Expand Down Expand Up @@ -455,14 +451,12 @@ public function datasetLite($dataset)
$nmriumInfo = $this->prepareNMRiumInfo($dataset);
if ($nmriumInfo) {
$study = $dataset->study;
$prefix = $dataset->study->name.'.';
if (property_exists($study, 'project')) {
$prefix = $study->project->name.':'.$prefix;
}
$prefix = $dataset->study->name;

$datasetSchema = Schema::Dataset();
$datasetSchema['@id'] = $dataset->doi;
$datasetSchema['dct:conformsTo'] = BioschemasHelper::conformsTo(['https://schema.org/Dataset', 'https://isa-specs.readthedocs.io/en/latest/isamodel.html#assay']);
$datasetSchema->name($prefix.$nmriumInfo[2]);
$datasetSchema->name($prefix.'['.$dataset->name.']');
$datasetSchema->description($dataset->description);
$datasetSchema->keywords($nmriumInfo[0]);
$datasetSchema->license($dataset->study->license->url);
Expand Down Expand Up @@ -491,11 +485,13 @@ public function datasetLite($dataset)
*/
public function dataset($dataset)
{
$projectSchema = $this->projectLite($dataset->project);
$studySchema = $this->studyLite($dataset->study);
$datasetSchema = $this->datasetLite($dataset);
$studySchema = $this->studyLite($dataset->study);

$studySchema->isPartOf($projectSchema);
if ($dataset->project) {
$projectSchema = $this->projectLite($dataset->project);
$studySchema->isPartOf($projectSchema);
}
$datasetSchema->isPartOf($studySchema);

return $datasetSchema;
Expand All @@ -511,14 +507,11 @@ public function dataset($dataset)
*/
public function studyLite($study)
{
$prefix = '';
if (property_exists($study, 'project')) {
$prefix = $study->project->name.':';
}

$studySchema = Bioschemas::Study();
$studySchema['@id'] = $study->doi;
$studySchema['dct:conformsTo'] = BioschemasHelper::conformsTo(['https://bioschemas.org/types/Study/0.3-DRAFT', 'https://isa-specs.readthedocs.io/en/latest/isamodel.html#study']);
$studySchema->name($prefix.$study->name);
$studySchema->name($study->name);
$studySchema->description($study->description);
$studySchema->keywords(BioschemasHelper::getTags($study));
$studySchema->license($study->license->url);
Expand Down

0 comments on commit 79bd14c

Please sign in to comment.