Search in sources :

Example 1 with Association

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";
    }
}
Also used : Housekeeping(uk.ac.ebi.spot.goci.model.Housekeeping) Study(uk.ac.ebi.spot.goci.model.Study) Association(uk.ac.ebi.spot.goci.model.Association) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with Association

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();
}
Also used : PageRequest(org.springframework.data.domain.PageRequest) Pageable(org.springframework.data.domain.Pageable) Association(uk.ac.ebi.spot.goci.model.Association) Sort(org.springframework.data.domain.Sort)

Example 3 with Association

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());
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) Ancestry(uk.ac.ebi.spot.goci.model.Ancestry)

Example 4 with Association

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);
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) Gene(uk.ac.ebi.spot.goci.model.Gene) RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) Test(org.junit.Test)

Example 5 with Association

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();
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) Test(org.junit.Test)

Aggregations

Association (uk.ac.ebi.spot.goci.model.Association)38 ArrayList (java.util.ArrayList)14 SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)10 RiskAllele (uk.ac.ebi.spot.goci.model.RiskAllele)9 Study (uk.ac.ebi.spot.goci.model.Study)7 Test (org.junit.Test)6 Gene (uk.ac.ebi.spot.goci.model.Gene)6 SimpleDateFormat (java.text.SimpleDateFormat)5 EnsemblMappingException (uk.ac.ebi.spot.goci.exception.EnsemblMappingException)5 Locus (uk.ac.ebi.spot.goci.model.Locus)5 EfoTrait (uk.ac.ebi.spot.goci.model.EfoTrait)4 Filter (uk.ac.ebi.spot.goci.pussycat.lang.Filter)4 Collection (java.util.Collection)3 Autowired (org.springframework.beans.factory.annotation.Autowired)3 Service (org.springframework.stereotype.Service)3 IOException (java.io.IOException)2 URI (java.net.URI)2 DateFormat (java.text.DateFormat)2 ParseException (java.text.ParseException)2 Date (java.util.Date)2