Search in sources :

Example 11 with MappingDetails

use of uk.ac.ebi.spot.goci.curation.model.MappingDetails in project goci by EBISPOT.

the class MappingDetailsServiceTest method testCreateMappingSummaryForStudyWithAssociationsWithNoMapping.

@Test
public void testCreateMappingSummaryForStudyWithAssociationsWithNoMapping() {
    // Stubbing association repository
    when(associationRepository.findByStudyId(STU_ASS_NO_MAPPING.getId())).thenReturn(Arrays.asList(ASS_NO_MAPPING_01, ASS_NO_MAPPING_02));
    MappingDetails mappingDetails = mappingDetailsService.createMappingSummary(STU_ASS_NO_MAPPING);
    verify(associationRepository, times(1)).findByStudyId(STU_ASS_NO_MAPPING.getId());
    assertThat(mappingDetails).isInstanceOf(MappingDetails.class);
    assertThat(mappingDetails).hasFieldOrPropertyWithValue("mappingDate", null);
    assertThat(mappingDetails).hasFieldOrPropertyWithValue("performer", null);
}
Also used : MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) Test(org.junit.Test)

Example 12 with MappingDetails

use of uk.ac.ebi.spot.goci.curation.model.MappingDetails in project goci by EBISPOT.

the class MappingDetailsServiceTest method testCreateMappingSummaryForStudyWithAssociationsWithAutomaticMapping.

@Test
public void testCreateMappingSummaryForStudyWithAssociationsWithAutomaticMapping() {
    // Stubbing association repository
    when(associationRepository.findByStudyId(STU_AUTO_MAPPING.getId())).thenReturn(Arrays.asList(ASS1, ASS2));
    MappingDetails mappingDetails = mappingDetailsService.createMappingSummary(STU_AUTO_MAPPING);
    verify(associationRepository, times(1)).findByStudyId(STU_AUTO_MAPPING.getId());
    assertThat(mappingDetails).isInstanceOf(MappingDetails.class);
    assertThat(mappingDetails.getMappingDate()).isInstanceOf(Date.class);
    assertThat(mappingDetails).hasFieldOrPropertyWithValue("performer", "automatic_mapping_process");
}
Also used : MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) Test(org.junit.Test)

Example 13 with MappingDetails

use of uk.ac.ebi.spot.goci.curation.model.MappingDetails in project goci by EBISPOT.

the class MappingDetailsService method createMappingSummary.

/**
     * An additional date should be added to the "Curator information" tab called "Last automated mapping date". This
     * should record the last date all SNPs were mapped using the automated mapping pipeline i.e. when there has been an
     * Ensembl release. This should be left blank for studies where SNPs have different mapping dates or were mapped by
     * a curator, indicating that the curator should check the "SNP associations page" for last mapping info.
     *
     * @param study Study with mapping details
     */
public MappingDetails createMappingSummary(Study study) {
    MappingDetails mappingSummary = new MappingDetails();
    Collection<Association> studyAssociations = associationRepository.findByStudyId(study.getId());
    if (studyAssociations != null && !studyAssociations.isEmpty()) {
        // Determine if we have more than one performer
        Set<String> allAssociationMappingPerformers = new HashSet<String>();
        for (Association association : studyAssociations) {
            allAssociationMappingPerformers.add(association.getLastMappingPerformedBy());
        }
        Map<String, String> mappingDateToPerformerMap = new HashMap<>();
        SimpleDateFormat dt = new SimpleDateFormat("yyyy-MM-dd");
        // If only one performer we need to check dates to see mapping didn't happen at different times
        if (allAssociationMappingPerformers.size() == 1) {
            String performer = allAssociationMappingPerformers.iterator().next();
            // Only care about automated mapping
            if (performer != null) {
                if (performer.equals("automatic_mapping_process")) {
                    // Go through all associations and store mapping performer and date
                    for (Association association : studyAssociations) {
                        String date = dt.format(association.getLastMappingDate());
                        mappingDateToPerformerMap.put(date, performer);
                    }
                }
            }
        }
        // If its only been mapped by an automated process, all with same date
        if (mappingDateToPerformerMap.size() == 1) {
            for (String date : mappingDateToPerformerMap.keySet()) {
                Date newDate = null;
                try {
                    newDate = dt.parse(date);
                } catch (ParseException e) {
                    e.printStackTrace();
                }
                mappingSummary.setMappingDate(newDate);
                mappingSummary.setPerformer(mappingDateToPerformerMap.get(date));
            }
        }
    }
    return mappingSummary;
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) HashMap(java.util.HashMap) MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) ParseException(java.text.ParseException) SimpleDateFormat(java.text.SimpleDateFormat) Date(java.util.Date) HashSet(java.util.HashSet)

Example 14 with MappingDetails

use of uk.ac.ebi.spot.goci.curation.model.MappingDetails in project goci by EBISPOT.

the class AssociationOperationsService method createMappingDetails.

/**
     * Gather mapping details for an association
     *
     * @param association Association with mapping details
     */
public MappingDetails createMappingDetails(Association association) {
    MappingDetails mappingDetails = new MappingDetails();
    if (association.getAssociationReport() != null) {
        mappingDetails.setPerformer(association.getLastMappingPerformedBy());
        mappingDetails.setMappingDate(association.getLastMappingDate());
        mappingDetails.setAssociationErrorMap(associationMappingErrorService.createAssociationErrorMap(association.getAssociationReport()));
    }
    return mappingDetails;
}
Also used : MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails)

Aggregations

MappingDetails (uk.ac.ebi.spot.goci.curation.model.MappingDetails)14 LastViewedAssociation (uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation)7 Test (org.junit.Test)4 SimpleDateFormat (java.text.SimpleDateFormat)3 SnpAssociationForm (uk.ac.ebi.spot.goci.curation.model.SnpAssociationForm)3 SnpFormColumn (uk.ac.ebi.spot.goci.curation.model.SnpFormColumn)3 SnpFormRow (uk.ac.ebi.spot.goci.curation.model.SnpFormRow)3 GetRequest (com.mashape.unirest.request.GetRequest)2 FileNotFoundException (java.io.FileNotFoundException)2 IOException (java.io.IOException)2 DateFormat (java.text.DateFormat)2 java.util (java.util)2 HttpServletRequest (javax.servlet.http.HttpServletRequest)2 HttpServletResponse (javax.servlet.http.HttpServletResponse)2 Valid (javax.validation.Valid)2 Logger (org.slf4j.Logger)2 LoggerFactory (org.slf4j.LoggerFactory)2 Autowired (org.springframework.beans.factory.annotation.Autowired)2 Qualifier (org.springframework.beans.factory.annotation.Qualifier)2 Value (org.springframework.beans.factory.annotation.Value)2