Search in sources :

Example 1 with SnpFormColumn

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

the class AssociationController method addRows.

// Add multiple rows to table
@RequestMapping(value = "/studies/{studyId}/associations/add_interaction", params = { "addCols" })
public String addRows(SnpAssociationInteractionForm snpAssociationInteractionForm, Model model, @PathVariable Long studyId, @RequestParam(required = true) String measurementType) {
    Integer numberOfCols = snpAssociationInteractionForm.getNumOfInteractions();
    // Add number of cols curator selected
    while (numberOfCols != 0) {
        snpAssociationInteractionForm.getSnpFormColumns().add(new SnpFormColumn());
        numberOfCols--;
    }
    // Pass back required attributes
    model.addAttribute("form", snpAssociationInteractionForm);
    model.addAttribute("measurementType", measurementType);
    model.addAttribute("study", studyRepository.findOne(studyId));
    return "add_snp_interaction_association";
}
Also used : SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SnpFormColumn

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

the class AssociationController method addColEditMode.

// Add single column to table
@RequestMapping(value = "/associations/{associationId}", params = { "addCol" })
public String addColEditMode(SnpAssociationInteractionForm snpAssociationInteractionForm, Model model, @PathVariable Long associationId) {
    snpAssociationInteractionForm.getSnpFormColumns().add(new SnpFormColumn());
    // Pass back updated form
    model.addAttribute("form", snpAssociationInteractionForm);
    // Also passes back study object to view so we can create links back to main study page
    Association currentAssociation = associationRepository.findOne(associationId);
    Study associationStudy = currentAssociation.getStudy();
    Long studyId = associationStudy.getId();
    model.addAttribute("study", studyRepository.findOne(studyId));
    // Determine if association is an OR or BETA type
    String measurementType = associationOperationsService.determineIfAssociationIsOrType(currentAssociation);
    model.addAttribute("measurementType", measurementType);
    // Get mapping details
    MappingDetails mappingDetails = associationOperationsService.createMappingDetails(currentAssociation);
    model.addAttribute("mappingDetails", mappingDetails);
    // Return any association errors
    model.addAttribute("errors", associationValidationReportService.generateAssociationWarningsListView(associationId));
    return "edit_snp_interaction_association";
}
Also used : LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 3 with SnpFormColumn

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

the class SnpInteractionAssociationService method createForm.

// Create a form to return to view from Association model object
@Override
public SnpAssociationForm createForm(Association association) {
    // Create form
    SnpAssociationInteractionForm form = new SnpAssociationInteractionForm();
    // Set simple string and boolean values
    form.setAssociationId(association.getId());
    form.setAssociationExtension(association.getAssociationExtension());
    form.setPvalueDescription(association.getPvalueDescription());
    form.setSnpType(association.getSnpType());
    form.setSnpApproved(association.getSnpApproved());
    form.setPvalueMantissa(association.getPvalueMantissa());
    form.setPvalueExponent(association.getPvalueExponent());
    form.setStandardError(association.getStandardError());
    form.setRange(association.getRange());
    form.setDescription(association.getDescription());
    form.setRiskFrequency(association.getRiskFrequency());
    // Set OR/Beta values
    form.setOrPerCopyNum(association.getOrPerCopyNum());
    form.setOrPerCopyRecip(association.getOrPerCopyRecip());
    form.setOrPerCopyRecipRange(association.getOrPerCopyRecipRange());
    form.setBetaNum(association.getBetaNum());
    form.setBetaUnit(association.getBetaUnit());
    form.setBetaDirection(association.getBetaDirection());
    // Add collection of Efo traits
    form.setEfoTraits(association.getEfoTraits());
    // Create form columns
    List<SnpFormColumn> snpFormColumns = new ArrayList<>();
    // For each locus get genes and risk alleles
    Collection<Locus> loci = association.getLoci();
    Collection<GenomicContext> snpGenomicContexts = new ArrayList<GenomicContext>();
    Collection<SingleNucleotidePolymorphism> snps = new ArrayList<SingleNucleotidePolymorphism>();
    List<SnpMappingForm> snpMappingForms = new ArrayList<SnpMappingForm>();
    // Create a column per locus
    if (loci != null && !loci.isEmpty()) {
        for (Locus locus : loci) {
            SnpFormColumn snpFormColumn = new SnpFormColumn();
            // Set genes
            Collection<String> authorReportedGenes = new ArrayList<>();
            for (Gene gene : locus.getAuthorReportedGenes()) {
                authorReportedGenes.add(gene.getGeneName());
            }
            snpFormColumn.setAuthorReportedGenes(authorReportedGenes);
            // Set risk allele
            Collection<RiskAllele> locusRiskAlleles = locus.getStrongestRiskAlleles();
            String strongestRiskAllele = null;
            String snp = null;
            Collection<String> proxySnps = new ArrayList<>();
            Boolean genomeWide = false;
            Boolean limitedList = false;
            String riskFrequency = null;
            // For snp x snp interaction studies should only have one risk allele per locus
            if (locusRiskAlleles != null && locusRiskAlleles.size() == 1) {
                for (RiskAllele riskAllele : locusRiskAlleles) {
                    strongestRiskAllele = riskAllele.getRiskAlleleName();
                    snp = riskAllele.getSnp().getRsId();
                    SingleNucleotidePolymorphism snp_obj = riskAllele.getSnp();
                    snps.add(snp_obj);
                    Collection<Location> locations = snp_obj.getLocations();
                    for (Location location : locations) {
                        SnpMappingForm snpMappingForm = new SnpMappingForm(snp, location);
                        snpMappingForms.add(snpMappingForm);
                    }
                    snpGenomicContexts.addAll(genomicContextRepository.findBySnpId(snp_obj.getId()));
                    // Set proxy
                    if (riskAllele.getProxySnps() != null) {
                        for (SingleNucleotidePolymorphism riskAlleleProxySnp : riskAllele.getProxySnps()) {
                            proxySnps.add(riskAlleleProxySnp.getRsId());
                        }
                    }
                    if (riskAllele.getGenomeWide() != null && riskAllele.getGenomeWide()) {
                        genomeWide = true;
                    }
                    if (riskAllele.getLimitedList() != null && riskAllele.getLimitedList()) {
                        limitedList = true;
                    }
                    riskFrequency = riskAllele.getRiskFrequency();
                }
            } else {
                throw new RuntimeException("More than one risk allele found for locus " + locus.getId() + ", this is not supported yet for SNP interaction associations");
            }
            // Set column attributes
            snpFormColumn.setStrongestRiskAllele(strongestRiskAllele);
            snpFormColumn.setSnp(snp);
            snpFormColumn.setProxySnps(proxySnps);
            snpFormColumn.setGenomeWide(genomeWide);
            snpFormColumn.setLimitedList(limitedList);
            snpFormColumn.setRiskFrequency(riskFrequency);
            snpFormColumns.add(snpFormColumn);
        }
    }
    form.setSnpMappingForms(snpMappingForms);
    form.setGenomicContexts(snpGenomicContexts);
    form.setSnps(snps);
    form.setSnpFormColumns(snpFormColumns);
    form.setNumOfInteractions(snpFormColumns.size());
    return form;
}
Also used : SnpAssociationInteractionForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm) RiskAllele(uk.ac.ebi.spot.goci.model.RiskAllele) ArrayList(java.util.ArrayList) GenomicContext(uk.ac.ebi.spot.goci.model.GenomicContext) SnpMappingForm(uk.ac.ebi.spot.goci.curation.model.SnpMappingForm) 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) Location(uk.ac.ebi.spot.goci.model.Location)

Example 4 with SnpFormColumn

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

the class AssociationOperationsService method checkSnpAssociationInteractionFormErrors.

/**
 * Check a SNP association interaction form for errors, these are critical errors that would prevent creating an
 * association
 *
 * @param form            The form to validate
 * @param measurementType Determine if user has selected and populated essential value on the form
 */
public Collection<ValidationError> checkSnpAssociationInteractionFormErrors(SnpAssociationInteractionForm form, String measurementType) {
    Collection<ValidationError> errors = new ArrayList<>();
    for (SnpFormColumn column : form.getSnpFormColumns()) {
        errors.add(errorCreationService.checkSnpValueIsPresent(column.getSnp()));
        errors.add(errorCreationService.checkStrongestAlleleValueIsPresent(column.getStrongestRiskAllele()));
    }
    // Ensure user has entered required information on the form
    if (measurementType.equals("or")) {
        errors.add(errorCreationService.checkOrIsPresent(form.getOrPerCopyNum()));
    }
    if (measurementType.equals("beta")) {
        errors.add(errorCreationService.checkBetaIsPresentAndIsNotNegative(form.getBetaNum()));
    }
    Collection<ValidationError> updatedError = ErrorProcessingService.checkForValidErrors(errors);
    return updatedError;
}
Also used : SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn)

Example 5 with SnpFormColumn

use of uk.ac.ebi.spot.goci.curation.model.SnpFormColumn 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)

Aggregations

SnpFormColumn (uk.ac.ebi.spot.goci.curation.model.SnpFormColumn)7 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)3 ArrayList (java.util.ArrayList)2 SnpAssociationInteractionForm (uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm)2 Gene (uk.ac.ebi.spot.goci.model.Gene)2 Locus (uk.ac.ebi.spot.goci.model.Locus)2 RiskAllele (uk.ac.ebi.spot.goci.model.RiskAllele)2 SingleNucleotidePolymorphism (uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism)2 Test (org.junit.Test)1 LastViewedAssociation (uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation)1 MappingDetails (uk.ac.ebi.spot.goci.curation.model.MappingDetails)1 SnpMappingForm (uk.ac.ebi.spot.goci.curation.model.SnpMappingForm)1 Association (uk.ac.ebi.spot.goci.model.Association)1 GenomicContext (uk.ac.ebi.spot.goci.model.GenomicContext)1 Location (uk.ac.ebi.spot.goci.model.Location)1