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);
}
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");
}
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;
}
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;
}
Aggregations