Search in sources :

Example 1 with SnpFormRow

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

the class AssociationController method editAssociation.

// Edit existing association
// We tried to remap if the snp or genes changed.
// TODO : implement something for SNP:SNP iteration. Actually we remap.
@RequestMapping(value = "/associations/{associationId}", produces = MediaType.TEXT_HTML_VALUE, method = RequestMethod.POST)
public // TODO COULD REFACTOR TO JUST USE SUPERCLASS AS METHOD PARAMETER
String editAssociation(@ModelAttribute SnpAssociationStandardMultiForm snpAssociationStandardMultiForm, @ModelAttribute SnpAssociationInteractionForm snpAssociationInteractionForm, @PathVariable Long associationId, @RequestParam(value = "associationtype", required = true) String associationType, Model model, HttpServletRequest request, RedirectAttributes redirectAttributes) throws EnsemblMappingException {
    // Establish study and association we are editing
    Collection<String> previousAuthorReportedGenes = new HashSet<>();
    Collection<String> authorReportedGenes = new HashSet<>();
    Collection<String> previousSnps = new HashSet<>();
    Collection<String> snps = new HashSet<>();
    String isToRemapping = "yes";
    Association associationToEdit = associationRepository.findOne(associationId);
    Long studyId = associationToEdit.getStudy().getId();
    Study study = studyRepository.findOne(studyId);
    model.addAttribute("study", study);
    AssociationReport oldAssociationReport = associationToEdit.getAssociationReport();
    previousAuthorReportedGenes = associationOperationsService.getGenesIds(associationToEdit.getLoci());
    previousSnps = associationOperationsService.getSpnsName(associationToEdit.getSnps());
    // Determine if association is an OR or BETA type
    String measurementType = associationOperationsService.determineIfAssociationIsOrType(associationToEdit);
    model.addAttribute("measurementType", measurementType);
    // Validate returned form depending on association type
    List<AssociationValidationView> criticalErrors = new ArrayList<>();
    if (associationType.equalsIgnoreCase("interaction")) {
        criticalErrors = associationOperationsService.checkSnpAssociationInteractionFormErrorsForView(snpAssociationInteractionForm, measurementType);
    } else {
        criticalErrors = associationOperationsService.checkSnpAssociationFormErrors(snpAssociationStandardMultiForm, measurementType);
    }
    // If errors found then return the edit form with all information entered by curator preserved
    if (!criticalErrors.isEmpty()) {
        // Get mapping details
        model.addAttribute("mappingDetails", associationOperationsService.createMappingDetails(associationToEdit));
        // Return any association errors
        model.addAttribute("errors", criticalErrors);
        model.addAttribute("criticalErrorsFound", true);
        if (associationType.equalsIgnoreCase("interaction")) {
            model.addAttribute("form", snpAssociationInteractionForm);
            return "edit_snp_interaction_association";
        } else {
            model.addAttribute("form", snpAssociationStandardMultiForm);
            // Determine view
            if (associationToEdit.getMultiSnpHaplotype()) {
                return "edit_multi_snp_association";
            } else {
                return "edit_standard_snp_association";
            }
        }
    } else {
        // Create association
        Association editedAssociation;
        // Request parameter determines how to process form and also which form to process
        if (associationType.equalsIgnoreCase("interaction")) {
            editedAssociation = snpInteractionAssociationService.createAssociation(snpAssociationInteractionForm);
        } else {
            editedAssociation = singleSnpMultiSnpAssociationService.createAssociation(snpAssociationStandardMultiForm);
            // New snps to compare with the previousSnps.
            Collection<SnpFormRow> newSnpsList = snpAssociationStandardMultiForm.getSnpFormRows();
            if (newSnpsList != null && !newSnpsList.isEmpty()) {
                for (SnpFormRow snp : newSnpsList) {
                    snps.add(snp.getSnp());
                }
            }
        }
        authorReportedGenes = associationOperationsService.getGenesIds(editedAssociation.getLoci());
        if (oldAssociationReport != null) {
            if ((previousAuthorReportedGenes.size() == authorReportedGenes.size()) && (snps.size() == snps.size())) {
                // check the values
                if ((authorReportedGenes.equals(previousAuthorReportedGenes)) && (snps.equals(previousSnps))) {
                    editedAssociation.setLastMappingDate(associationToEdit.getLastMappingDate());
                    editedAssociation.setLastMappingPerformedBy(associationToEdit.getLastMappingPerformedBy());
                    editedAssociation.setAssociationReport(oldAssociationReport);
                    isToRemapping = "no";
                }
            }
        }
        if ((oldAssociationReport != null) && (isToRemapping.compareTo("yes") == 0)) {
            associationOperationsService.deleteAssocationReport(associationToEdit.getAssociationReport().getId());
        }
        // Save and validate form
        String eRelease = ensemblRestTemplateService.getRelease();
        Collection<AssociationValidationView> errors = associationOperationsService.saveEditedAssociationFromForm(study, editedAssociation, associationId, currentUserDetailsService.getUserFromRequest(request), eRelease);
        // Determine if we have any errors rather than warnings
        long errorCount = errors.stream().filter(validationError -> !validationError.getWarning()).count();
        if (errorCount > 0) {
            // Get mapping details for association we're editing
            model.addAttribute("mappingDetails", associationOperationsService.createMappingDetails(associationToEdit));
            model.addAttribute("errors", errors);
            model.addAttribute("criticalErrorsFound", true);
            if (associationType.equalsIgnoreCase("interaction")) {
                model.addAttribute("form", snpAssociationInteractionForm);
                return "edit_snp_interaction_association";
            } else {
                model.addAttribute("form", snpAssociationStandardMultiForm);
                // Determine view
                if (associationToEdit.getMultiSnpHaplotype()) {
                    return "edit_multi_snp_association";
                } else {
                    return "edit_standard_snp_association";
                }
            }
        } else {
            redirectAttributes.addFlashAttribute("isToRemapping", isToRemapping);
            return "redirect:/associations/" + associationId;
        }
    }
}
Also used : PathVariable(org.springframework.web.bind.annotation.PathVariable) RequestParam(org.springframework.web.bind.annotation.RequestParam) CheckMappingService(uk.ac.ebi.spot.goci.curation.service.CheckMappingService) LoggerFactory(org.slf4j.LoggerFactory) SnpAssociationInteractionForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationInteractionForm) Autowired(org.springframework.beans.factory.annotation.Autowired) Valid(javax.validation.Valid) AssociationOperationsService(uk.ac.ebi.spot.goci.curation.service.AssociationOperationsService) PreDestroy(javax.annotation.PreDestroy) Model(org.springframework.ui.Model) Future(java.util.concurrent.Future) AssociationDeletionService(uk.ac.ebi.spot.goci.curation.service.AssociationDeletionService) uk.ac.ebi.spot.goci.model(uk.ac.ebi.spot.goci.model) StudyRepository(uk.ac.ebi.spot.goci.repository.StudyRepository) Pageable(org.springframework.data.domain.Pageable) Sort(org.springframework.data.domain.Sort) EnsemblRestTemplateService(uk.ac.ebi.spot.goci.service.EnsemblRestTemplateService) DateFormat(java.text.DateFormat) RedirectAttributes(org.springframework.web.servlet.mvc.support.RedirectAttributes) HttpSession(javax.servlet.http.HttpSession) MediaType(org.springframework.http.MediaType) EventsViewService(uk.ac.ebi.spot.goci.curation.service.EventsViewService) PageRequest(org.springframework.data.domain.PageRequest) RequestMethod(org.springframework.web.bind.annotation.RequestMethod) Page(org.springframework.data.domain.Page) SnpFormColumn(uk.ac.ebi.spot.goci.curation.model.SnpFormColumn) AssociationUploadErrorView(uk.ac.ebi.spot.goci.curation.model.AssociationUploadErrorView) FileNotFoundException(java.io.FileNotFoundException) Executors(java.util.concurrent.Executors) SingleSnpMultiSnpAssociationService(uk.ac.ebi.spot.goci.curation.service.SingleSnpMultiSnpAssociationService) SnpAssociationTableViewService(uk.ac.ebi.spot.goci.curation.service.SnpAssociationTableViewService) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) SnpInteractionAssociationService(uk.ac.ebi.spot.goci.curation.service.SnpInteractionAssociationService) InitBinder(org.springframework.web.bind.annotation.InitBinder) CurrentUserDetailsService(uk.ac.ebi.spot.goci.curation.service.CurrentUserDetailsService) FileUploadException(uk.ac.ebi.spot.goci.curation.exception.FileUploadException) Async(org.springframework.scheduling.annotation.Async) java.util(java.util) SnpAssociationTableView(uk.ac.ebi.spot.goci.curation.model.SnpAssociationTableView) RequestMapping(org.springframework.web.bind.annotation.RequestMapping) SimpleDateFormat(java.text.SimpleDateFormat) BindingResult(org.springframework.validation.BindingResult) Callable(java.util.concurrent.Callable) Controller(org.springframework.stereotype.Controller) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) EfoTraitRepository(uk.ac.ebi.spot.goci.repository.EfoTraitRepository) AssociationService(uk.ac.ebi.spot.goci.service.AssociationService) Value(org.springframework.beans.factory.annotation.Value) AssociationValidationReportService(uk.ac.ebi.spot.goci.curation.service.AssociationValidationReportService) HttpServletRequest(javax.servlet.http.HttpServletRequest) ModelAttribute(org.springframework.web.bind.annotation.ModelAttribute) Qualifier(org.springframework.beans.factory.annotation.Qualifier) ExceptionHandler(org.springframework.web.bind.annotation.ExceptionHandler) ExecutorService(java.util.concurrent.ExecutorService) DataIntegrityException(uk.ac.ebi.spot.goci.curation.exception.DataIntegrityException) Logger(org.slf4j.Logger) AssociationUploadService(uk.ac.ebi.spot.goci.curation.service.AssociationUploadService) AssociationRepository(uk.ac.ebi.spot.goci.repository.AssociationRepository) HttpServletResponse(javax.servlet.http.HttpServletResponse) SnpAssociationForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationForm) EnsemblMappingException(uk.ac.ebi.spot.goci.exception.EnsemblMappingException) SheetProcessingException(uk.ac.ebi.spot.goci.exception.SheetProcessingException) IOException(java.io.IOException) CheckEfoTermAssignmentService(uk.ac.ebi.spot.goci.curation.service.CheckEfoTermAssignmentService) ResponseBody(org.springframework.web.bind.annotation.ResponseBody) StudyAssociationBatchDeletionEventService(uk.ac.ebi.spot.goci.curation.service.StudyAssociationBatchDeletionEventService) ExecutionException(java.util.concurrent.ExecutionException) TimeUnit(java.util.concurrent.TimeUnit) MapCatalogService(uk.ac.ebi.spot.goci.service.MapCatalogService) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) WebDataBinder(org.springframework.web.bind.WebDataBinder) MultipartFile(org.springframework.web.multipart.MultipartFile) AssociationDownloadService(uk.ac.ebi.spot.goci.curation.service.AssociationDownloadService) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) MappingDetails(uk.ac.ebi.spot.goci.curation.model.MappingDetails) AssociationValidationView(uk.ac.ebi.spot.goci.curation.model.AssociationValidationView) LastViewedAssociation(uk.ac.ebi.spot.goci.curation.model.LastViewedAssociation) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) RequestMapping(org.springframework.web.bind.annotation.RequestMapping)

Example 2 with SnpFormRow

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

the class SingleSnpMultiSnpAssociationServiceTest method testCreateMultiForm.

@Test
public void testCreateMultiForm() throws Exception {
    assertThat(snpAssociationFormService.createForm(OR_MULTI_ASSOCIATION)).isInstanceOf(SnpAssociationStandardMultiForm.class);
    SnpAssociationStandardMultiForm form = (SnpAssociationStandardMultiForm) snpAssociationFormService.createForm(OR_MULTI_ASSOCIATION);
    // Check values we would expect in form
    assertThat(form.getAssociationId()).as("Check form ID").isEqualTo(OR_MULTI_ASSOCIATION.getId());
    assertThat(form.getSnpType()).as("Check form SNP TYPE").isEqualTo(OR_MULTI_ASSOCIATION.getSnpType());
    assertThat(form.getMultiSnpHaplotype()).as("Check form MULTI SNP HAPLOTYPE").isEqualTo(OR_MULTI_ASSOCIATION.getMultiSnpHaplotype());
    assertThat(form.getSnpApproved()).as("Check form SNP APPROVED").isEqualTo(OR_MULTI_ASSOCIATION.getSnpApproved());
    assertThat(form.getPvalueExponent()).as("Check form PVALUE EXPONENT").isEqualTo(OR_MULTI_ASSOCIATION.getPvalueExponent());
    assertThat(form.getPvalueMantissa()).as("Check form PVALUE MANTISSA").isEqualTo(OR_MULTI_ASSOCIATION.getPvalueMantissa());
    assertThat(form.getStandardError()).as("Check form STANDARD ERROR").isEqualTo(OR_MULTI_ASSOCIATION.getStandardError());
    assertThat(form.getRange()).as("Check form RANGE").isEqualTo(OR_MULTI_ASSOCIATION.getRange());
    assertThat(form.getPvalueDescription()).as("Check form PVALUE DESCRIPTION").isEqualTo(OR_MULTI_ASSOCIATION.getPvalueDescription());
    assertThat(form.getRiskFrequency()).as("Check form RISK FREQUENCY").isEqualTo(OR_MULTI_ASSOCIATION.getRiskFrequency());
    assertThat(form.getDescription()).as("Check form DESCRIPTION").isEqualTo(OR_MULTI_ASSOCIATION.getDescription());
    // Check EFO traits
    assertThat(form.getEfoTraits()).extracting("id", "trait", "uri").contains(tuple(988L, "atrophic rhinitis", "http://www.ebi.ac.uk/efo/EFO_0007159"), tuple(989L, "HeLa", "http://www.ebi.ac.uk/efo/EFO_0001185"));
    // Check null values
    assertNull(form.getBetaDirection());
    assertNull(form.getBetaNum());
    assertNull(form.getBetaUnit());
    // Test locus attributes
    assertThat(form.getMultiSnpHaplotypeDescr()).as("Check form MULTI HAPLOTYPE DESCRIPTION").isEqualTo("2-SNP haplotype");
    assertThat(form.getMultiSnpHaplotypeNum()).as("Check form MULTI HAPLOTYPE NUMBER").isEqualTo(2);
    assertThat(form.getAuthorReportedGenes()).isInstanceOf(Collection.class);
    assertThat(form.getAuthorReportedGenes()).containsOnly("ELF1");
    // Test the row values
    Collection<SnpFormRow> rows = form.getSnpFormRows();
    assertThat(rows).hasSize(2);
    assertThat(rows).extracting("snp", "strongestRiskAllele", "proxySnps").contains(tuple("rs9533090", "rs9533090-?", Collections.singletonList("rs7329174")), tuple("rs114205691", "rs114205691-?", Collections.singletonList("rs1234567")));
}
Also used : SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) Test(org.junit.Test)

Example 3 with SnpFormRow

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

the class SingleSnpMultiSnpAssociationService method createForm.

// Creates form which we can then return to view for editing etc.
@Override
public SnpAssociationForm createForm(Association association) {
    SnpAssociationStandardMultiForm form = new SnpAssociationStandardMultiForm();
    // Set association ID
    form.setAssociationId(association.getId());
    form.setAssociationExtension(association.getAssociationExtension());
    // Set simple string and float association attributes
    form.setRiskFrequency(association.getRiskFrequency());
    form.setPvalueDescription(association.getPvalueDescription());
    form.setSnpType(association.getSnpType());
    form.setMultiSnpHaplotype(association.getMultiSnpHaplotype());
    form.setSnpApproved(association.getSnpApproved());
    form.setPvalueMantissa(association.getPvalueMantissa());
    form.setPvalueExponent(association.getPvalueExponent());
    form.setStandardError(association.getStandardError());
    form.setRange(association.getRange());
    form.setDescription(association.getDescription());
    // 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());
    // For each locus get genes and risk alleles
    Collection<Locus> loci = association.getLoci();
    Collection<Gene> locusGenes = new ArrayList<>();
    Collection<RiskAllele> locusRiskAlleles = new ArrayList<RiskAllele>();
    // For multi-snp and standard snps we assume their is only one locus
    for (Locus locus : loci) {
        locusGenes.addAll(locus.getAuthorReportedGenes());
        locusRiskAlleles.addAll(locus.getStrongestRiskAlleles().stream().sorted((v1, v2) -> Long.compare(v1.getId(), v2.getId())).collect(Collectors.toList()));
        // There should only be one locus thus should be safe to set these here
        form.setMultiSnpHaplotypeNum(locus.getHaplotypeSnpCount());
        form.setMultiSnpHaplotypeDescr(locus.getDescription());
    }
    // Get name of gene and add to form
    Collection<String> authorReportedGenes = new ArrayList<>();
    for (Gene locusGene : locusGenes) {
        authorReportedGenes.add(locusGene.getGeneName());
    }
    form.setAuthorReportedGenes(authorReportedGenes);
    // Handle snp rows
    Collection<GenomicContext> snpGenomicContexts = new ArrayList<GenomicContext>();
    Collection<SingleNucleotidePolymorphism> snps = new ArrayList<>();
    List<SnpFormRow> snpFormRows = new ArrayList<SnpFormRow>();
    List<SnpMappingForm> snpMappingForms = new ArrayList<SnpMappingForm>();
    for (RiskAllele riskAllele : locusRiskAlleles) {
        SnpFormRow snpFormRow = new SnpFormRow();
        snpFormRow.setStrongestRiskAllele(riskAllele.getRiskAlleleName());
        SingleNucleotidePolymorphism snp = riskAllele.getSnp();
        snps.add(snp);
        String rsID = snp.getRsId();
        snpFormRow.setSnp(rsID);
        Collection<Location> locations = snp.getLocations();
        for (Location location : locations) {
            SnpMappingForm snpMappingForm = new SnpMappingForm(rsID, location);
            snpMappingForms.add(snpMappingForm);
        }
        // Set proxy if one is present
        Collection<String> proxySnps = new ArrayList<>();
        if (riskAllele.getProxySnps() != null) {
            for (SingleNucleotidePolymorphism riskAlleleProxySnp : riskAllele.getProxySnps()) {
                proxySnps.add(riskAlleleProxySnp.getRsId());
            }
        }
        snpFormRow.setProxySnps(proxySnps);
        snpGenomicContexts.addAll(genomicContextRepository.findBySnpId(snp.getId()));
        snpFormRows.add(snpFormRow);
    }
    form.setSnpMappingForms(snpMappingForms);
    form.setGenomicContexts(snpGenomicContexts);
    form.setSnps(snps);
    form.setSnpFormRows(snpFormRows);
    return form;
}
Also used : 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) SnpAssociationStandardMultiForm(uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) Gene(uk.ac.ebi.spot.goci.model.Gene) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) Locus(uk.ac.ebi.spot.goci.model.Locus) Location(uk.ac.ebi.spot.goci.model.Location)

Example 4 with SnpFormRow

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

the class AssociationOperationsService method checkSnpAssociationFormErrors.

/**
 * Check a standard SNP association 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 List<AssociationValidationView> checkSnpAssociationFormErrors(SnpAssociationStandardMultiForm form, String measurementType) {
    Collection<ValidationError> errors = new ArrayList<>();
    for (SnpFormRow row : form.getSnpFormRows()) {
        errors.add(errorCreationService.checkSnpValueIsPresent(row.getSnp()));
        errors.add(errorCreationService.checkStrongestAlleleValueIsPresent(row.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 processAssociationValidationErrors(updatedError);
}
Also used : SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow)

Example 5 with SnpFormRow

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

the class SingleSnpMultiSnpAssociationService method createAssociation.

public Association createAssociation(SnpAssociationStandardMultiForm form) {
    // Set common string, boolean and float association attributes
    Association association = setCommonAssociationElements(form);
    association.setSnpInteraction(false);
    // Add loci to association, for multi-snp and standard snps we assume their is only one locus
    Collection<Locus> loci = new ArrayList<>();
    Locus locus = new Locus();
    // Set locus description and haplotype count
    // Set this number to the number of rows entered by curator
    Integer numberOfRows = form.getSnpFormRows().size();
    if (numberOfRows > 1) {
        locus.setHaplotypeSnpCount(numberOfRows);
        association.setMultiSnpHaplotype(true);
    }
    if (form.getMultiSnpHaplotypeDescr() != null && !form.getMultiSnpHaplotypeDescr().isEmpty()) {
        locus.setDescription(form.getMultiSnpHaplotypeDescr());
    } else {
        if (numberOfRows > 1) {
            locus.setDescription(numberOfRows + "-SNP haplotype");
        } else {
            locus.setDescription("Single variant");
        }
    }
    // Create gene from each string entered, may sure to check pre-existence
    Collection<String> authorReportedGenes = form.getAuthorReportedGenes();
    Collection<Gene> locusGenes = lociAttributesService.createGene(authorReportedGenes);
    // Set locus genes
    locus.setAuthorReportedGenes(locusGenes);
    // Handle rows entered for haplotype by curator
    Collection<SnpFormRow> rows = form.getSnpFormRows();
    Collection<RiskAllele> locusRiskAlleles = new ArrayList<>();
    for (SnpFormRow row : rows) {
        // Create snps from row information
        String curatorEnteredSNP = row.getSnp();
        SingleNucleotidePolymorphism snp = lociAttributesService.createSnp(curatorEnteredSNP);
        // Get the curator entered risk allele
        String curatorEnteredRiskAllele = row.getStrongestRiskAllele();
        // Create a new risk allele and assign newly created snp
        RiskAllele riskAllele = lociAttributesService.createRiskAllele(curatorEnteredRiskAllele, snp);
        // If association is not a multi-snp haplotype save frequency to risk allele
        if (!form.getMultiSnpHaplotype()) {
            riskAllele.setRiskFrequency(form.getRiskFrequency());
        }
        // Check for proxies and if we have one create a proxy snps
        if (row.getProxySnps() != null && !row.getProxySnps().isEmpty()) {
            Collection<SingleNucleotidePolymorphism> riskAlleleProxySnps = new ArrayList<>();
            for (String curatorEnteredProxySnp : row.getProxySnps()) {
                SingleNucleotidePolymorphism proxySnp = lociAttributesService.createSnp(curatorEnteredProxySnp);
                riskAlleleProxySnps.add(proxySnp);
            }
            riskAllele.setProxySnps(riskAlleleProxySnps);
        }
        locusRiskAlleles.add(riskAllele);
    }
    // Assign all created risk alleles to locus
    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) SnpFormRow(uk.ac.ebi.spot.goci.curation.model.SnpFormRow) Gene(uk.ac.ebi.spot.goci.model.Gene) SingleNucleotidePolymorphism(uk.ac.ebi.spot.goci.model.SingleNucleotidePolymorphism) Locus(uk.ac.ebi.spot.goci.model.Locus)

Aggregations

SnpFormRow (uk.ac.ebi.spot.goci.curation.model.SnpFormRow)10 RequestMapping (org.springframework.web.bind.annotation.RequestMapping)5 SnpAssociationStandardMultiForm (uk.ac.ebi.spot.goci.curation.model.SnpAssociationStandardMultiForm)5 ArrayList (java.util.ArrayList)2 Test (org.junit.Test)2 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 DateFormat (java.text.DateFormat)1 SimpleDateFormat (java.text.SimpleDateFormat)1 java.util (java.util)1 Callable (java.util.concurrent.Callable)1 ExecutionException (java.util.concurrent.ExecutionException)1 ExecutorService (java.util.concurrent.ExecutorService)1 Executors (java.util.concurrent.Executors)1 Future (java.util.concurrent.Future)1 TimeUnit (java.util.concurrent.TimeUnit)1 PreDestroy (javax.annotation.PreDestroy)1 HttpServletRequest (javax.servlet.http.HttpServletRequest)1 HttpServletResponse (javax.servlet.http.HttpServletResponse)1 HttpSession (javax.servlet.http.HttpSession)1