use of uk.ac.ebi.spot.goci.model.Association in project goci by EBISPOT.
the class StudyController method viewStudyToDelete.
// Delete an existing study
@RequestMapping(value = "/{studyId}/delete", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.GET)
public String viewStudyToDelete(Model model, @PathVariable Long studyId) {
Study studyToDelete = studyRepository.findOne(studyId);
// Check if it has any associations
Collection<Association> associations = associationRepository.findByStudyId(studyId);
Long housekeepingId = studyToDelete.getHousekeeping().getId();
Housekeeping housekeepingAttachedToStudy = housekeepingRepository.findOne(housekeepingId);
model.addAttribute("studyToDelete", studyToDelete);
if (housekeepingAttachedToStudy.getCatalogPublishDate() != null) {
return "delete_published_study_warning";
} else if (!associations.isEmpty()) {
return "delete_study_with_associations_warning";
} else {
return "delete_study";
}
}
use of uk.ac.ebi.spot.goci.model.Association in project goci by EBISPOT.
the class SolrIndexer method mapAssociations.
Integer mapAssociations() {
Sort sort = new Sort(new Sort.Order("id"));
Pageable pager = new PageRequest(0, pageSize, sort);
Page<Association> associationPage = associationService.findPublishedAssociations(pager);
associationMapper.map(associationPage.getContent());
while (associationPage.hasNext()) {
if (maxPages != -1 && associationPage.getNumber() >= maxPages - 1) {
break;
}
pager = pager.next();
associationPage = associationService.findPublishedAssociations(pager);
associationMapper.map(associationPage.getContent());
if (sysOutLogging) {
System.out.print(".");
}
}
return (int) associationPage.getTotalElements();
}
use of uk.ac.ebi.spot.goci.model.Association in project goci by EBISPOT.
the class DataDeletionService method deleteStudy.
private void deleteStudy(Study study) {
System.out.println("Removing study \t" + study.getAuthor() + "\t (ID:" + study.getId() + ") with \t" + study.getAssociations().size() + "\t association and \t" + study.getAncestries().size() + "\t ancestries");
getLog().debug("Removing study \t" + study.getAuthor() + "\t (ID:" + study.getId() + ") with \t" + study.getAssociations().size() + "\t association and \t" + study.getAncestries().size() + "\t ancestries");
Collection<Association> associations = study.getAssociations();
associations.forEach(this::deleteAssociation);
Collection<Ancestry> ancestries = ancestryRepository.findByStudyId(study.getId());
for (Ancestry ancestry : ancestries) {
ancestryRepository.delete(ancestry);
}
// WeeklyTracking, CuratorTracking and Note. Please use this method!
// Shared with === DataDeletionService ===
studyService.deleteRelatedInfoByStudy(study);
// Delete study
studyService.deleteByStudyId(study.getId());
}
use of uk.ac.ebi.spot.goci.model.Association in project goci by EBISPOT.
the class AssociationRowProcessorTest method testCreateAssociationFromUploadRowSnpInteraction.
@Test
public void testCreateAssociationFromUploadRowSnpInteraction() throws Exception {
// Stubbing mock object behaviour
when(associationAttributeService.createLocusGenes("PMS1 ", ",")).thenReturn(Arrays.asList(GENE_03));
when(associationAttributeService.createLocusGenes(" HIBCH", ",")).thenReturn(Arrays.asList(GENE_04));
when(associationAttributeService.createSnp("rs2562796")).thenReturn(SNP_02);
when(associationAttributeService.createSnp("rs16832404")).thenReturn(SNP_03);
when(associationAttributeService.createRiskAllele("rs2562796-T", SNP_02)).thenReturn(RA_02);
when(associationAttributeService.createRiskAllele("rs16832404-G", SNP_03)).thenReturn(RA_03);
Association association = associationRowProcessor.createAssociationFromUploadRow(SNP_INTERACTION_ROW);
verify(associationCalculationService, never()).reverseCI(SNP_INTERACTION_ROW.getRange());
verify(associationCalculationService, never()).setRange(SNP_INTERACTION_ROW.getStandardError(), SNP_INTERACTION_ROW.getOrPerCopyNum());
verify(associationAttributeService, never()).getEfoTraitsFromRepository(Collections.EMPTY_LIST);
verify(associationAttributeService, times(1)).createLocusGenes("PMS1 ", ",");
verify(associationAttributeService, times(1)).createLocusGenes(" HIBCH", ",");
verify(associationAttributeService, times(1)).createSnp("rs2562796");
verify(associationAttributeService, times(1)).createSnp("rs16832404");
verify(associationAttributeService, times(1)).createRiskAllele("rs2562796-T", SNP_02);
verify(associationAttributeService, times(1)).createRiskAllele("rs16832404-G", SNP_03);
assertThat(association).extracting("id", "riskFrequency", "pvalueDescription", "pvalueMantissa", "pvalueExponent", "multiSnpHaplotype", "snpInteraction", "snpApproved", "snpType", "standardError", "range", "description", "orPerCopyNum", "orPerCopyRecip", "orPerCopyRecipRange", "betaNum", "betaUnit", "betaDirection", "study", "associationReport", "lastMappingDate", "lastMappingPerformedBy", "lastUpdateDate").containsExactly(null, "0.52", null, 2, -7, false, true, false, null, (float) 0.6, "[0.82-0.92]", null, (float) 1.22, null, null, null, null, null, null, null, null, null, null);
assertThat(association.getEfoTraits()).isEmpty();
assertThat(association.getEvents()).isEmpty();
assertThat(association.getStudy()).isNull();
assertThat(association.getLoci()).hasSize(2);
// Check locus attributes
Collection<Gene> locusGenes = new ArrayList<>();
association.getLoci().stream().forEach(locus -> {
locusGenes.addAll(locus.getAuthorReportedGenes());
});
Collection<RiskAllele> locusRiskAlleles = new ArrayList<>();
association.getLoci().stream().forEach(locus -> {
locusRiskAlleles.addAll(locus.getStrongestRiskAlleles());
});
assertThat(association.getLoci()).extracting(Locus::getDescription).containsOnly("SNP x SNP interaction");
assertThat(locusGenes).hasSize(2).contains(GENE_03, GENE_04);
assertThat(locusRiskAlleles).hasSize(2).contains(RA_02, RA_03);
assertThat(locusRiskAlleles).extracting("riskAlleleName", "riskFrequency", "snp.rsId").contains(tuple("rs2562796-T", "0.3", "rs2562796"), tuple("rs16832404-G", "0.4", "rs16832404"));
assertThat(locusRiskAlleles).extracting(RiskAllele::getSnp).containsExactly(SNP_02, SNP_03);
}
use of uk.ac.ebi.spot.goci.model.Association in project goci by EBISPOT.
the class AssociationRowProcessorTest method testCreateAssociationFromUploadRowErrorRow.
@Test
public void testCreateAssociationFromUploadRowErrorRow() throws Exception {
Association association = associationRowProcessor.createAssociationFromUploadRow(ROW_THAT_SHOULD_FAIL);
verify(associationCalculationService, never()).reverseCI(Matchers.anyString());
verify(associationCalculationService, never()).setRange(Matchers.anyDouble(), Matchers.anyDouble());
verify(associationAttributeService, never()).getEfoTraitsFromRepository(Collections.EMPTY_LIST);
verify(associationAttributeService, never()).createLocusGenes(Matchers.anyString(), Matchers.anyString());
verify(associationAttributeService, never()).createSnp(Matchers.anyString());
verify(associationAttributeService, never()).createRiskAllele(Matchers.anyString(), Matchers.any(SingleNucleotidePolymorphism.class));
assertThat(association).extracting("id", "riskFrequency", "pvalueDescription", "pvalueMantissa", "pvalueExponent", "multiSnpHaplotype", "snpInteraction", "snpApproved", "snpType", "standardError", "range", "description", "orPerCopyNum", "orPerCopyRecip", "orPerCopyRecipRange", "betaNum", "betaUnit", "betaDirection", "study", "associationReport", "lastMappingDate", "lastMappingPerformedBy", "lastUpdateDate").containsExactly(null, null, null, 2, -7, false, false, false, null, null, null, null, null, null, null, null, null, null, null, null, null, null, null);
assertThat(association.getEfoTraits()).isEmpty();
assertThat(association.getEvents()).isEmpty();
assertThat(association.getStudy()).isNull();
assertThat(association.getLoci()).isEmpty();
}
Aggregations