@Test public void testCreateMultiForm() throws Exception { assertThat(snpAssociationFormService.createForm(OR_MULTI_ASSOCIATION)).isInstanceOf( SnpAssociationStandardMultiForm.class); SnpAssociationStandardMultiForm form = (SnpAssociationStandardMultiForm) snpAssociationFormService.createForm(OR_MULTI_ASSOCIATION); 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()); assertThat(form.getEfoTraits()).extracting("id", "trait", "uri") .contains(tuple(988L, "atrophic rhinitis", "http: tuple(989L, "HeLa", "http: assertNull(form.getBetaDirection()); assertNull(form.getBetaNum()); assertNull(form.getBetaUnit()); 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"); 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"))); }
@Override public SnpAssociationForm createForm(Association association) { SnpAssociationStandardMultiForm form = new SnpAssociationStandardMultiForm(); form.setAssociationId(association.getId()); form.setAssociationExtension(association.getAssociationExtension()); 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()); form.setOrPerCopyNum(association.getOrPerCopyNum()); form.setOrPerCopyRecip(association.getOrPerCopyRecip()); form.setOrPerCopyRecipRange(association.getOrPerCopyRecipRange()); form.setBetaNum(association.getBetaNum()); form.setBetaUnit(association.getBetaUnit()); form.setBetaDirection(association.getBetaDirection()); form.setEfoTraits(association.getEfoTraits()); Collection<Locus> loci = association.getLoci(); Collection<Gene> locusGenes = new ArrayList<>(); Collection<RiskAllele> locusRiskAlleles = new ArrayList<RiskAllele>(); 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())); form.setMultiSnpHaplotypeNum(locus.getHaplotypeSnpCount()); form.setMultiSnpHaplotypeDescr(locus.getDescription()); } Collection<String> authorReportedGenes = new ArrayList<>(); for (Gene locusGene : locusGenes) { authorReportedGenes.add(locusGene.getGeneName()); } form.setAuthorReportedGenes(authorReportedGenes); 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); } 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; }
SingleSnpMultiSnpAssociationService implements SnpAssociationFormService { @Override public SnpAssociationForm createForm(Association association) { SnpAssociationStandardMultiForm form = new SnpAssociationStandardMultiForm(); form.setAssociationId(association.getId()); form.setAssociationExtension(association.getAssociationExtension()); 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()); form.setOrPerCopyNum(association.getOrPerCopyNum()); form.setOrPerCopyRecip(association.getOrPerCopyRecip()); form.setOrPerCopyRecipRange(association.getOrPerCopyRecipRange()); form.setBetaNum(association.getBetaNum()); form.setBetaUnit(association.getBetaUnit()); form.setBetaDirection(association.getBetaDirection()); form.setEfoTraits(association.getEfoTraits()); Collection<Locus> loci = association.getLoci(); Collection<Gene> locusGenes = new ArrayList<>(); Collection<RiskAllele> locusRiskAlleles = new ArrayList<RiskAllele>(); 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())); form.setMultiSnpHaplotypeNum(locus.getHaplotypeSnpCount()); form.setMultiSnpHaplotypeDescr(locus.getDescription()); } Collection<String> authorReportedGenes = new ArrayList<>(); for (Gene locusGene : locusGenes) { authorReportedGenes.add(locusGene.getGeneName()); } form.setAuthorReportedGenes(authorReportedGenes); 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); } 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; } }
SingleSnpMultiSnpAssociationService implements SnpAssociationFormService { @Override public SnpAssociationForm createForm(Association association) { SnpAssociationStandardMultiForm form = new SnpAssociationStandardMultiForm(); form.setAssociationId(association.getId()); form.setAssociationExtension(association.getAssociationExtension()); 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()); form.setOrPerCopyNum(association.getOrPerCopyNum()); form.setOrPerCopyRecip(association.getOrPerCopyRecip()); form.setOrPerCopyRecipRange(association.getOrPerCopyRecipRange()); form.setBetaNum(association.getBetaNum()); form.setBetaUnit(association.getBetaUnit()); form.setBetaDirection(association.getBetaDirection()); form.setEfoTraits(association.getEfoTraits()); Collection<Locus> loci = association.getLoci(); Collection<Gene> locusGenes = new ArrayList<>(); Collection<RiskAllele> locusRiskAlleles = new ArrayList<RiskAllele>(); 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())); form.setMultiSnpHaplotypeNum(locus.getHaplotypeSnpCount()); form.setMultiSnpHaplotypeDescr(locus.getDescription()); } Collection<String> authorReportedGenes = new ArrayList<>(); for (Gene locusGene : locusGenes) { authorReportedGenes.add(locusGene.getGeneName()); } form.setAuthorReportedGenes(authorReportedGenes); 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); } 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; } @Autowired  SingleSnpMultiSnpAssociationService(GenomicContextRepository genomicContextRepository,
                                               LociAttributesService lociAttributesService); }
SingleSnpMultiSnpAssociationService implements SnpAssociationFormService { @Override public SnpAssociationForm createForm(Association association) { SnpAssociationStandardMultiForm form = new SnpAssociationStandardMultiForm(); form.setAssociationId(association.getId()); form.setAssociationExtension(association.getAssociationExtension()); 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()); form.setOrPerCopyNum(association.getOrPerCopyNum()); form.setOrPerCopyRecip(association.getOrPerCopyRecip()); form.setOrPerCopyRecipRange(association.getOrPerCopyRecipRange()); form.setBetaNum(association.getBetaNum()); form.setBetaUnit(association.getBetaUnit()); form.setBetaDirection(association.getBetaDirection()); form.setEfoTraits(association.getEfoTraits()); Collection<Locus> loci = association.getLoci(); Collection<Gene> locusGenes = new ArrayList<>(); Collection<RiskAllele> locusRiskAlleles = new ArrayList<RiskAllele>(); 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())); form.setMultiSnpHaplotypeNum(locus.getHaplotypeSnpCount()); form.setMultiSnpHaplotypeDescr(locus.getDescription()); } Collection<String> authorReportedGenes = new ArrayList<>(); for (Gene locusGene : locusGenes) { authorReportedGenes.add(locusGene.getGeneName()); } form.setAuthorReportedGenes(authorReportedGenes); 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); } 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; } @Autowired  SingleSnpMultiSnpAssociationService(GenomicContextRepository genomicContextRepository,
                                               LociAttributesService lociAttributesService); @Override SnpAssociationForm createForm(Association association); Association createAssociation(SnpAssociationStandardMultiForm form); }
SingleSnpMultiSnpAssociationService implements SnpAssociationFormService { @Override public SnpAssociationForm createForm(Association association) { SnpAssociationStandardMultiForm form = new SnpAssociationStandardMultiForm(); form.setAssociationId(association.getId()); form.setAssociationExtension(association.getAssociationExtension()); 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()); form.setOrPerCopyNum(association.getOrPerCopyNum()); form.setOrPerCopyRecip(association.getOrPerCopyRecip()); form.setOrPerCopyRecipRange(association.getOrPerCopyRecipRange()); form.setBetaNum(association.getBetaNum()); form.setBetaUnit(association.getBetaUnit()); form.setBetaDirection(association.getBetaDirection()); form.setEfoTraits(association.getEfoTraits()); Collection<Locus> loci = association.getLoci(); Collection<Gene> locusGenes = new ArrayList<>(); Collection<RiskAllele> locusRiskAlleles = new ArrayList<RiskAllele>(); 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())); form.setMultiSnpHaplotypeNum(locus.getHaplotypeSnpCount()); form.setMultiSnpHaplotypeDescr(locus.getDescription()); } Collection<String> authorReportedGenes = new ArrayList<>(); for (Gene locusGene : locusGenes) { authorReportedGenes.add(locusGene.getGeneName()); } form.setAuthorReportedGenes(authorReportedGenes); 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); } 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; } @Autowired  SingleSnpMultiSnpAssociationService(GenomicContextRepository genomicContextRepository,
                                               LociAttributesService lociAttributesService); @Override SnpAssociationForm createForm(Association association); Association createAssociation(SnpAssociationStandardMultiForm form);  }