use of uk.ac.ebi.spot.goci.model.AssociationReport in project goci by EBISPOT.
the class AssociationReportService method updateAssociationReportDetails.
/**
* This method is used when the mapping pipeline returns no errors. It removes any existing association reports and
* replaces with a new one with no errors. This ensures errors from previous runs of the mapping pipeline do not
* remain in database if they are no longer appearing as mapping pipeline errors.
*
* @param association association, used to create new association report
*/
public void updateAssociationReportDetails(Association association) {
// Create association report object
AssociationReport associationReport = new AssociationReport();
associationReport.setLastUpdateDate(new Date());
// Before setting link to association remove any existing reports linked to this association
AssociationReport existingReport = associationReportRepository.findByAssociationId(association.getId());
if (existingReport != null) {
associationReportRepository.delete(existingReport);
}
associationReport.setAssociation(association);
// Save association report
associationReportRepository.save(associationReport);
}
use of uk.ac.ebi.spot.goci.model.AssociationReport in project goci by EBISPOT.
the class MapCatalogService method mapCatalogContents.
/**
* Get all associations in database and map
*
* @param performer name of curator/job carrying out the mapping
*/
public void mapCatalogContents(String performer) throws EnsemblMappingException {
// Get all old association reports so we can compare with new ones, do this before we remap
Collection<AssociationReport> oldAssociationReports = associationReportRepository.findAll();
// Get all associations via service
Collection<Association> associations = associationService.findAllAssociations();
getLog().info("Mapping all associations in database, total number: " + associations.size());
try {
mappingService.validateAndMapAllAssociations(associations, performer);
} catch (EnsemblMappingException e) {
throw new EnsemblMappingException("Attempt to map all associations failed", e);
}
mappingErrorComparisonService.compareOldVersusNewErrors(oldAssociationReports, false, 0, 0);
}
use of uk.ac.ebi.spot.goci.model.AssociationReport in project goci by EBISPOT.
the class MappingErrorComparisonService method compareOldVersusNewErrors.
/**
* Method used to compare errors from a previous mapping run. Looking for SNPs with new errors, or SNPs with a
* different type of error.
*
* @param oldErrors collection of all association reports in database before mapping to latest Ensembl release
*/
public void compareOldVersusNewErrors(Collection<AssociationReport> oldErrors, boolean isLSF, Integer min, Integer max) {
// Find all the latest association reports containing mapping errors
getLog().debug("Method used to compare errors from a previous mapping run");
Collection<AssociationReport> newAssociationReports = getnewAssociationReports(isLSF, min, max);
Map<Long, AssociationReport> associationIdToNewAssociationReportMap = createNewReportsMap(newAssociationReports);
Collection<MappingErrorComparisonReport> comparisonReports = new ArrayList<>();
// Create report
for (AssociationReport oldErrorReport : oldErrors) {
MappingErrorComparisonReport mappingErrorComparisonReport = new MappingErrorComparisonReport();
// Establish association and study details
Long associationId = oldErrorReport.getAssociation().getId();
Study study = studyRepository.findByAssociationsId(associationId);
String pubmedId = study.getPubmedId();
Long studyId = study.getId();
mappingErrorComparisonReport.setStudyId(studyId);
mappingErrorComparisonReport.setAssociationId(associationId);
mappingErrorComparisonReport.setPubmedId(pubmedId);
// Compare errors
AssociationReport newErrorReport = associationIdToNewAssociationReportMap.get(associationId);
String oldSnpError = oldErrorReport.getSnpError();
String newSnpError = newErrorReport.getSnpError();
Boolean differenceInSnpErrors = compareDifferences(oldSnpError, newSnpError);
if (differenceInSnpErrors) {
mappingErrorComparisonReport.setOldSnpError(oldSnpError);
mappingErrorComparisonReport.setNewSnpError(newSnpError);
}
String oldSnpGeneOnDiffChr = oldErrorReport.getSnpGeneOnDiffChr();
String newSnpGeneOnDiffChr = newErrorReport.getSnpGeneOnDiffChr();
Boolean differenceInSnpGeneOnDiffChr = compareDifferences(oldSnpGeneOnDiffChr, newSnpGeneOnDiffChr);
if (differenceInSnpGeneOnDiffChr) {
mappingErrorComparisonReport.setOldSnpGeneOnDiffChr(oldSnpGeneOnDiffChr);
mappingErrorComparisonReport.setNewSnpGeneOnDiffChr(newSnpGeneOnDiffChr);
}
String oldNoGeneForSymbol = oldErrorReport.getNoGeneForSymbol();
String newNoGeneForSymbol = newErrorReport.getNoGeneForSymbol();
Boolean differenceNoGeneForSymbol = compareDifferences(oldNoGeneForSymbol, newNoGeneForSymbol);
if (differenceNoGeneForSymbol) {
mappingErrorComparisonReport.setOldNoGeneForSymbol(oldNoGeneForSymbol);
mappingErrorComparisonReport.setNewNoGeneForSymbol(newNoGeneForSymbol);
}
String oldGeneError = oldErrorReport.getGeneError();
String newGeneError = newErrorReport.getGeneError();
Boolean differenceGeneError = compareDifferences(oldGeneError, newGeneError);
if (differenceGeneError) {
mappingErrorComparisonReport.setOldGeneError(oldGeneError);
mappingErrorComparisonReport.setNewGeneError(newGeneError);
}
String oldRestServiceError = oldErrorReport.getRestServiceError();
String newRestServiceError = newErrorReport.getRestServiceError();
Boolean differenceRestServiceError = compareDifferences(oldRestServiceError, newRestServiceError);
if (differenceRestServiceError) {
mappingErrorComparisonReport.setOldRestServiceError(oldRestServiceError);
mappingErrorComparisonReport.setNewRestServiceError(newRestServiceError);
}
String oldSuspectVariationError = oldErrorReport.getSuspectVariationError();
String newSuspectVariationError = newErrorReport.getSuspectVariationError();
Boolean differenceSuspectVariationError = compareDifferences(oldSuspectVariationError, newSuspectVariationError);
if (differenceSuspectVariationError) {
mappingErrorComparisonReport.setOldSuspectVariationError(oldSuspectVariationError);
mappingErrorComparisonReport.setNewSuspectVariationError(newSuspectVariationError);
}
// Only add reports if a significant difference has been found
if (differenceInSnpErrors || differenceInSnpGeneOnDiffChr || differenceNoGeneForSymbol || differenceGeneError || differenceRestServiceError || differenceSuspectVariationError) {
comparisonReports.add(mappingErrorComparisonReport);
}
}
getLog().debug("create file");
createFile(comparisonReports);
}
use of uk.ac.ebi.spot.goci.model.AssociationReport in project goci by EBISPOT.
the class AssociationReportService method processAssociationErrors.
/**
* Method used to format data returned from view via form so it can be stored in database
*
* @param association association, used to create new association report
* @param errors collection of errors returned from mapping pipeline
*/
public void processAssociationErrors(Association association, Collection<String> errors) {
// Lists and maps use to translate errors
List<String> listOfStandardEnsemblErrors = createStandardErrorList();
Map<String, String> standardEnsemblErrorToErrorType = createErrorMap();
Map<String, String> errorToErrorTypeMap = new HashMap<>();
// Check list of standard errors to see if error returned from pipeline matches standard list
for (String error : errors) {
for (String standardEnsemblError : listOfStandardEnsemblErrors) {
if (error.contains(standardEnsemblError)) {
String errorType = standardEnsemblErrorToErrorType.get(standardEnsemblError);
errorToErrorTypeMap.put(error, errorType);
} else {
// Check error message isn't already in list
if (!errorToErrorTypeMap.containsKey(error)) {
errorToErrorTypeMap.put(error, "unknown type");
}
}
}
}
// Populate arrays that will hold various errors
Collection<String> snpErrors = new ArrayList<>();
Collection<String> snpGeneOnDiffChrErrors = new ArrayList<>();
Collection<String> noGeneForSymbolErrors = new ArrayList<>();
Collection<String> restServiceErrors = new ArrayList<>();
Collection<String> suspectVariationErrors = new ArrayList<>();
Collection<String> geneErrors = new ArrayList<>();
for (Map.Entry<String, String> entry : errorToErrorTypeMap.entrySet()) {
String errorMessage = entry.getKey();
String errorType = entry.getValue();
switch(errorType) {
case "restServiceError":
restServiceErrors.add(errorMessage);
break;
case "suspectVariationError":
suspectVariationErrors.add(errorMessage);
break;
case "snpError":
snpErrors.add(errorMessage);
break;
case "snpGeneOnDiffChrError":
snpGeneOnDiffChrErrors.add(errorMessage);
break;
case "noGeneForSymbolError":
noGeneForSymbolErrors.add(errorMessage);
break;
case "geneError":
geneErrors.add(errorMessage);
break;
default:
getLog().warn("For association ID: " + association.getId() + ", cannot determine error type for error " + errorMessage);
break;
}
}
// Format errors into string so they can be stored in database
String allSnpErrors = null;
String allSnpGeneOnDiffChrErrors = null;
String allNoGeneForSymbolErrors = null;
String allRestServiceErrors = null;
String allSuspectVariationErrors = null;
String allGeneErrors = null;
if (!snpErrors.isEmpty()) {
allSnpErrors = String.join(", ", snpErrors);
}
if (!snpGeneOnDiffChrErrors.isEmpty()) {
allSnpGeneOnDiffChrErrors = String.join(", ", snpGeneOnDiffChrErrors);
}
if (!noGeneForSymbolErrors.isEmpty()) {
allNoGeneForSymbolErrors = String.join(", ", noGeneForSymbolErrors);
}
if (!restServiceErrors.isEmpty()) {
allRestServiceErrors = String.join(", ", restServiceErrors);
}
if (!suspectVariationErrors.isEmpty()) {
allSuspectVariationErrors = String.join(", ", suspectVariationErrors);
}
if (!geneErrors.isEmpty()) {
allGeneErrors = String.join(", ", geneErrors);
}
// Create association report object
AssociationReport associationReport = new AssociationReport();
associationReport.setLastUpdateDate(new Date());
associationReport.setSnpError(allSnpErrors);
associationReport.setSnpGeneOnDiffChr(allSnpGeneOnDiffChrErrors);
associationReport.setNoGeneForSymbol(allNoGeneForSymbolErrors);
associationReport.setRestServiceError(allRestServiceErrors);
associationReport.setSuspectVariationError(allSuspectVariationErrors);
associationReport.setGeneError(allGeneErrors);
// Before setting link to association check for any existing reports linked to this association
AssociationReport existingReport = associationReportRepository.findByAssociationId(association.getId());
if (existingReport != null) {
associationReportRepository.delete(existingReport);
}
associationReport.setAssociation(association);
// Save association report
associationReportRepository.save(associationReport);
}
use of uk.ac.ebi.spot.goci.model.AssociationReport in project goci by EBISPOT.
the class CheckMappingService method checkAssociationMappingAssignment.
public Boolean checkAssociationMappingAssignment(Association association) {
Boolean mappingAssigned = true;
AssociationReport associationReport = association.getAssociationReport();
if (associationReport == null) {
mappingAssigned = false;
}
return mappingAssigned;
}
Aggregations