diff --git a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/HTPExpressionDatasetSampleAnnotationFmsDTOValidator.java b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/HTPExpressionDatasetSampleAnnotationFmsDTOValidator.java index b441b5798..83f9f3fee 100644 --- a/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/HTPExpressionDatasetSampleAnnotationFmsDTOValidator.java +++ b/src/main/java/org/alliancegenome/curation_api/services/validation/dto/fms/HTPExpressionDatasetSampleAnnotationFmsDTOValidator.java @@ -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; @@ -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())) { @@ -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 params = new HashMap<>(); + params.put("name", dto.getSex()); + params.put("query_operator", "or"); + params.put("synonyms", dto.getSex()); + SearchResponse 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() + ")"); } } @@ -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); } @@ -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() + ")"); } } } diff --git a/src/main/resources/db/migration/v0.38.0.4__adding_synonyms_htpsample_genetic_sex.sql b/src/main/resources/db/migration/v0.38.0.4__adding_synonyms_htpsample_genetic_sex.sql new file mode 100644 index 000000000..38311b0f4 --- /dev/null +++ b/src/main/resources/db/migration/v0.38.0.4__adding_synonyms_htpsample_genetic_sex.sql @@ -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';