Search in sources :

Example 31 with Association

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

the class SnpInteractionAssociationService method createAssociation.

public Association createAssociation(SnpAssociationInteractionForm form) {
    // Set simple string, boolean and float association attributes
    Association association = setCommonAssociationElements(form);
    // Set multi-snp and snp interaction checkboxes
    association.setMultiSnpHaplotype(false);
    association.setSnpInteraction(true);
    // For each column create a loci
    Collection<Locus> loci = new ArrayList<>();
    for (SnpFormColumn col : form.getSnpFormColumns()) {
        Locus locus = new Locus();
        locus.setDescription("SNP x SNP interaction");
        // Set locus genes
        Collection<String> authorReportedGenes = col.getAuthorReportedGenes();
        Collection<Gene> locusGenes = lociAttributesService.createGene(authorReportedGenes);
        locus.setAuthorReportedGenes(locusGenes);
        // Create SNP
        String curatorEnteredSNP = col.getSnp();
        SingleNucleotidePolymorphism snp = lociAttributesService.createSnp(curatorEnteredSNP);
        // One risk allele per locus
        String curatorEnteredRiskAllele = col.getStrongestRiskAllele();
        RiskAllele riskAllele = lociAttributesService.createRiskAllele(curatorEnteredRiskAllele, snp);
        Collection<RiskAllele> locusRiskAlleles = new ArrayList<>();
        // Set risk allele attributes
        riskAllele.setGenomeWide(col.getGenomeWide());
        riskAllele.setLimitedList(col.getLimitedList());
        riskAllele.setRiskFrequency(col.getRiskFrequency());
        // Check for a proxy and if we have one create a proxy snp
        Collection<String> curatorEnteredProxySnps = col.getProxySnps();
        if (curatorEnteredProxySnps != null && !curatorEnteredProxySnps.isEmpty()) {
            Collection<SingleNucleotidePolymorphism> riskAlleleProxySnps = new ArrayList<>();
            for (String curatorEnteredProxySnp : curatorEnteredProxySnps) {
                SingleNucleotidePolymorphism proxySnp = lociAttributesService.createSnp(curatorEnteredProxySnp);
                riskAlleleProxySnps.add(proxySnp);
            }
            riskAllele.setProxySnps(riskAlleleProxySnps);
        }
        // Link risk allele to locus
        locusRiskAlleles.add(riskAllele);
        locus.setStrongestRiskAlleles(locusRiskAlleles);
        // Add locus to collection and link to our association
        loci.add(locus);
    }
    association.setLoci(loci);
    return association;
}
Also used : RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) Association(uk.ac.ebi.spot.goci.model.Association) Gene(uk.ac.ebi.spot.goci.model.Gene) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) Locus(uk.ac.ebi.spot.goci.model.Locus) SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn)

Example 32 with Association

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

the class EmailMappingErrorsService method getMappingDetails.

public CurationSystemEmailToCurator getMappingDetails(Study study, CurationSystemEmailToCurator email) {
    String associationSummary = "";
    Collection<Association> associations = study.getAssociations();
    if (associations.isEmpty()) {
        associationSummary = "No associations for this study";
    } else {
        for (Association association : associations) {
            SimpleDateFormat dateFormat = new SimpleDateFormat("dd-MMM-yyyy HH:mm:ss");
            String mappingDate = "";
            String performer = "";
            if (association.getLastMappingDate() != null) {
                mappingDate = dateFormat.format(association.getLastMappingDate());
            }
            if (association.getLastMappingPerformedBy() != null) {
                performer = association.getLastMappingPerformedBy();
            }
            String associationLink = email.getLink() + "associations/" + association.getId();
            Set<String> validationWarnings = associationValidationReportService.getWarningSet(association.getId());
            String validationWarningsForEmailBody = formatWarnings(validationWarnings);
            // In future we may want to include all association details can remove this if condition
            if (!validationWarningsForEmailBody.contains("No validation warnings found")) {
                associationSummary = associationSummary + "Association: " + associationLink + "\n" + "Validation Results: " + validationWarningsForEmailBody + "Last Mapping Date: " + mappingDate + "\n" + "Last Mapping Performed By: " + performer + "\n\n";
            }
        }
    }
    if (associationSummary.isEmpty()) {
        associationSummary = "Note: No validation warnings detected for any association in this study.";
    }
    email.addToBody(associationSummary);
    return email;
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) SimpleDateFormat(java.text.SimpleDateFormat)

Example 33 with Association

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

the class AssociationUploadService method saveAssociations.

private void saveAssociations(Collection<AssociationSummary> associationSummaries, Study study, SecureUser user) throws EnsemblMappingException {
    for (AssociationSummary associationSummary : associationSummaries) {
        Association newAssociation = associationSummary.getAssociation();
        // Add creation event
        associationOperationsService.createAssociationCreationEvent(newAssociation, user);
        // Save association
        associationOperationsService.saveAssociation(newAssociation, study, associationSummary.getErrors());
    // associationOperationsService.runMapping(study.getHousekeeping().getCurator(), newAssociation, user);
    }
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) AssociationSummary(uk.ac.ebi.spot.goci.model.AssociationSummary)

Example 34 with Association

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

the class AssociationValidationReportService method createAssociationValidationReport.

/**
     * Create association validation reports and add to association
     *
     * @param errors List of errors
     * @param id     Association ID
     */
public void createAssociationValidationReport(Collection<ValidationError> errors, Long id) {
    // Get list of existing reports and create list of existing warnings
    Association association = associationRepository.findOne(id);
    Collection<AssociationValidationReport> existingReports = associationValidationReportRepository.findByAssociationId(id);
    existingReports.forEach(associationValidationReport -> associationValidationReportRepository.delete(associationValidationReport));
    // Create association validation reports
    errors.forEach(validationError -> {
        AssociationValidationReport associationValidationReport = new AssociationValidationReport(validationError.getError(), validationError.getField(), association);
        associationValidationReportRepository.save(associationValidationReport);
    });
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association) AssociationValidationReport(uk.ac.ebi.spot.goci.model.AssociationValidationReport)

Example 35 with Association

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

the class AssociationDownloadService method processAssociations.

private String processAssociations(Collection<Association> associations) {
    String header = "Gene(s)\tStrongest SNP-Risk Allele\tSNP\tProxy SNP" + "\tIndependent SNP risk allele frequency in controls" + "\tRisk element (allele, haplotype or SNPxSNP interaction) frequency in controls" + "\tP-value mantissa\tP-value exponent\tP-value description" + "\tOR\tOR reciprocal" + "\tBeta\tBeta unit\tBeta direction" + "\tRange\tOR reciprocal range" + "\tStandard Error\tOR/Beta description" + "\tMulti-SNP Haplotype?\tSNP:SNP interaction?\tSNP Status\tSNP type\tEFO traits\r\n";
    StringBuilder output = new StringBuilder();
    output.append(header);
    for (Association association : associations) {
        StringBuilder line = new StringBuilder();
        extractGeneticData(association, line);
        String measurementType = associationOperationsService.determineIfAssociationIsOrType(association);
        if (association.getRiskFrequency() == null) {
            line.append("");
        } else {
            line.append(association.getRiskFrequency());
        }
        line.append("\t");
        if (association.getPvalueMantissa() == null) {
            line.append("");
        } else {
            line.append(association.getPvalueMantissa());
        }
        line.append("\t");
        if (association.getPvalueExponent() == null) {
            line.append("");
        } else {
            line.append(association.getPvalueExponent());
        }
        line.append("\t");
        if (association.getPvalueDescription() == null) {
            line.append("");
        } else {
            line.append(association.getPvalueDescription());
        }
        line.append("\t");
        // OR
        if (association.getOrPerCopyNum() == null) {
            line.append("");
        } else {
            line.append(association.getOrPerCopyNum());
        }
        line.append("\t");
        // OR reciprocal
        if (association.getOrPerCopyRecip() == null) {
            line.append("");
        } else {
            line.append(association.getOrPerCopyRecip());
        }
        line.append("\t");
        // Beta num
        if (association.getBetaNum() == null) {
            line.append("");
        } else {
            line.append(association.getBetaNum());
        }
        line.append("\t");
        // Beta unit
        if (association.getBetaUnit() == null) {
            line.append("");
        } else {
            line.append(association.getBetaUnit());
        }
        line.append("\t");
        // Beta direction
        if (association.getBetaDirection() == null) {
            line.append("");
        } else {
            line.append(association.getBetaDirection());
        }
        line.append("\t");
        // Range
        if (association.getRange() == null) {
            line.append("");
        } else {
            line.append(association.getRange());
        }
        line.append("\t");
        // OR recip range
        if (association.getOrPerCopyRecipRange() == null) {
            line.append("");
        } else {
            line.append(association.getOrPerCopyRecipRange());
        }
        line.append("\t");
        // Standard error
        if (association.getStandardError() == null) {
            line.append("");
        } else {
            line.append(association.getStandardError());
        }
        line.append("\t");
        // Description
        if (association.getDescription() == null) {
            line.append("");
        } else {
            line.append(association.getDescription());
        }
        line.append("\t");
        if (association.getMultiSnpHaplotype()) {
            line.append("Y");
        } else {
            line.append("");
        }
        line.append("\t");
        if (association.getSnpInteraction()) {
            line.append("Y");
        } else {
            line.append("");
        }
        line.append("\t");
        // SNP Status
        extractSNPStatus(association, line);
        if (association.getSnpType() == null) {
            line.append("");
        } else {
            line.append(association.getSnpType().toLowerCase());
        }
        line.append("\t");
        if (association.getEfoTraits() == null) {
            line.append("");
        } else {
            extractEfoTraits(association.getEfoTraits(), line);
        }
        line.append("\r\n");
        output.append(line.toString());
    }
    return output.toString();
}
Also used : Association(uk.ac.ebi.spot.goci.model.Association)

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