Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: extend Bioschemas to cover samples with no projects #1099

Merged
merged 2 commits into from
Apr 4, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -238,13 +238,17 @@ 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($study->project->name.'.'.$sample->name);
$sampleSchema->name($prefix.$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 @@ -451,7 +455,11 @@ public function datasetLite($dataset)
{
$nmriumInfo = $this->prepareNMRiumInfo($dataset);
if ($nmriumInfo) {
$prefix = $dataset->study->project->name.':'.$dataset->study->name.'.';
$study = $dataset->study;
$prefix = $dataset->study->name.'.';
if (property_exists($study, 'project')) {
$prefix = $study->project->name.':'.$prefix;
}
$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']);
Expand Down Expand Up @@ -504,7 +512,10 @@ public function dataset($dataset)
*/
public function studyLite($study)
{
$prefix = $study->project->name.':';
$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']);
Expand Down Expand Up @@ -534,7 +545,9 @@ public function studyLite($study)
public function study($study)
{
$studySchema = $this->studyLite($study);
$studySchema->isPartOf($this->projectLite($study->project));
if (property_exists($study, 'project')) {
$studySchema->isPartOf($this->projectLite($study->project));
}
$studySchema->hasPart($this->prepareDatasets($study));

return $studySchema;
Expand Down
11 changes: 8 additions & 3 deletions app/Http/Controllers/API/Schemas/Bioschemas/BioschemasHelper.php
Original file line number Diff line number Diff line change
Expand Up @@ -127,7 +127,6 @@ public static function prepareCitations($model)
$citationsSchemas = [];
foreach ($model->citations as &$citation) {
$citationSchema = Schema::CreativeWork();
$citationSchema->abstract($citation->abstract);
$citationSchema->author($citation->authors);
$citationSchema->headline($citation->title);
$citationSchema->identifier($citation->doi);
Expand All @@ -149,11 +148,17 @@ public static function prepareDataDownload($dataset)
{
$url = env('APP_URL');
$user = $dataset->owner->username;
$slug = $dataset->project->slug;
if (property_exists($dataset, 'project')) {
$slug = $dataset->project->slug;
$name = $dataset->project->name;
} else {
$slug = $dataset->study->slug;
$name = $dataset->study->name;
}
$contentURL = $url.'/'.$user.'/datasets/'.$slug;

$DataDownloadSchema = Schema::DataDownload();
$DataDownloadSchema->name($dataset->project->name);
$DataDownloadSchema->name($name);
$DataDownloadSchema->encodingFormat('zip');
$DataDownloadSchema->contentURL($contentURL);

Expand Down