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

Adding vocabulary terms to genetic sex vocabulary #1708

Merged
merged 4 commits into from
Nov 8, 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 @@ -29,6 +29,7 @@
import org.alliancegenome.curation_api.model.ingest.dto.fms.BioSampleGenomicInformationFmsDTO;
import org.alliancegenome.curation_api.model.ingest.dto.fms.HTPExpressionDatasetSampleAnnotationFmsDTO;
import org.alliancegenome.curation_api.model.ingest.dto.fms.WhereExpressedFmsDTO;
import org.alliancegenome.curation_api.model.input.Pagination;
import org.alliancegenome.curation_api.response.ObjectResponse;
import org.alliancegenome.curation_api.response.SearchResponse;
import org.alliancegenome.curation_api.services.AffectedGenomicModelService;
Expand Down Expand Up @@ -167,7 +168,7 @@ public HTPExpressionDatasetSampleAnnotation validateHTPExpressionDatasetSampleAn
} else if (htpSampleAnnotation.getGenomicInformation().getBioSampleAllele() != null) {
identifierString = htpSampleAnnotation.getGenomicInformation().getBioSampleAllele().getIdentifier();
}
if (!identifierString.equals(dto.getGenomicInformation().getBiosampleId())) {
if (!identifierString.equals(dto.getGenomicInformation().getBiosampleId()) || htpSampleAnnotation.getGenomicInformation().getBioSampleAgmType() == null && StringUtils.isNotEmpty(dto.getGenomicInformation().getIdType())) {
validateGenomicInformation(dto.getGenomicInformation(), htpSampleAnnotation, htpSampleAnnotationResponse);
}
if (StringUtils.isNotEmpty(dto.getGenomicInformation().getBioSampleText())) {
Expand All @@ -181,9 +182,22 @@ public HTPExpressionDatasetSampleAnnotation validateHTPExpressionDatasetSampleAn
}

if (StringUtils.isNotEmpty(dto.getSex())) {
VocabularyTerm geneticSex = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.GENETIC_SEX_VOCABULARY, dto.getSex()).getEntity();
if (geneticSex != null) {
htpSampleAnnotation.setGeneticSex(geneticSex);
Map<String, Object> params = new HashMap<>();
params.put("name", dto.getSex());
params.put("query_operator", "or");
params.put("synonyms", dto.getSex());
SearchResponse<VocabularyTerm> searchResponse = vocabularyTermService.findByParams(new Pagination(), params);
boolean added = false;
if (searchResponse.getTotalResults() > 0) {
for (VocabularyTerm tag : searchResponse.getResults()) {
if (tag.getVocabulary().getName().equals("Genetic Sex") && (tag.getName().equals(dto.getSex()) || tag.getSynonyms().contains(dto.getSex()))) {
htpSampleAnnotation.setGeneticSex(tag);
added = true;
}
}
}
if (!added) {
htpSampleAnnotationResponse.addErrorMessage("Sex", ValidationConstants.INVALID_MESSAGE + " (" + dto.getSex() + ")");
}
}

Expand Down Expand Up @@ -221,7 +235,7 @@ public HTPExpressionDatasetSampleAnnotation validateHTPExpressionDatasetSampleAn
}

if (StringUtils.isNotEmpty(dto.getSequencingFormat())) {
VocabularyTerm sequencingFormat = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.HTP_DATASET_SAMPLE_SEQUENCE_FORMAT_VOCABULARY, dto.getSequencingFormat()).getEntity();
VocabularyTerm sequencingFormat = vocabularyTermService.getTermInVocabulary(VocabularyConstants.HTP_DATASET_SAMPLE_SEQUENCE_FORMAT_VOCABULARY, dto.getSequencingFormat()).getEntity();
if (sequencingFormat != null) {
htpSampleAnnotation.setSequencingFormat(sequencingFormat);
}
Expand Down Expand Up @@ -281,9 +295,11 @@ protected void validateGenomicInformation(BioSampleGenomicInformationFmsDTO dto,
htpSampleAnnotationResponse.addErrorMessage("GenomicInformation - BioSampleId", ValidationConstants.INVALID_MESSAGE + " (" + identifierString + ")");
} else {
htpSampleAnnotation.getGenomicInformation().setBioSampleAgm(agm);
VocabularyTerm agmType = vocabularyTermService.getTermInVocabularyTermSet(VocabularyConstants.AGM_SUBTYPE_VOCABULARY, dto.getIdType()).getEntity();
VocabularyTerm agmType = vocabularyTermService.getTermInVocabulary(VocabularyConstants.AGM_SUBTYPE_VOCABULARY, dto.getIdType()).getEntity();
if (agmType != null) {
htpSampleAnnotation.getGenomicInformation().setBioSampleAgmType(agmType);
} else {
htpSampleAnnotationResponse.addErrorMessage("GenomicInformation - IdType", ValidationConstants.INVALID_MESSAGE + " (" + dto.getIdType() + ")");
}
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
INSERT INTO vocabularyterm_synonyms (vocabularyterm_id, synonyms) SELECT id, 'unknown' FROM vocabularyterm WHERE name = 'unknown sex';
INSERT INTO vocabularyterm_synonyms (vocabularyterm_id, synonyms) SELECT id, 'pooled' FROM vocabularyterm WHERE name = 'pooled sexes';
Loading