@Test public void testCreateAssociationFromUploadRow() throws Exception { when(associationAttributeService.createLocusGenes(STANDARD_ROW.getAuthorReportedGene(), ",")).thenReturn(Arrays.asList( GENE_01, GENE_02)); when(associationAttributeService.createSnp(STANDARD_ROW.getSnp())).thenReturn(SNP_01); when(associationAttributeService.createRiskAllele(STANDARD_ROW.getStrongestAllele(), SNP_01)).thenReturn(RA_01); when(associationAttributeService.createSnp(STANDARD_ROW.getProxy())).thenReturn(PROXY); Association association = associationRowProcessor.createAssociationFromUploadRow(STANDARD_ROW); verify(associationCalculationService, never()).reverseCI(STANDARD_ROW.getRange()); verify(associationCalculationService, never()).setRange(STANDARD_ROW.getStandardError(), STANDARD_ROW.getOrPerCopyNum()); verify(associationAttributeService, never()).getEfoTraitsFromRepository(Collections.EMPTY_LIST); verify(associationAttributeService, times(1)).createLocusGenes(STANDARD_ROW.getAuthorReportedGene(), ","); verify(associationAttributeService, times(1)).createSnp(STANDARD_ROW.getSnp()); verify(associationAttributeService, times(1)).createSnp(STANDARD_ROW.getProxy()); verify(associationAttributeService, times(1)).createRiskAllele(STANDARD_ROW.getStrongestAllele(), SNP_01); assertThat(association).extracting("id", "riskFrequency", "pvalueDescription", "pvalueMantissa", "pvalueExponent", "multiSnpHaplotype", "snpInteraction", "snpApproved", "snpType", "standardError", "range", "description", "orPerCopyNum", "orPerCopyRecip", "orPerCopyRecipRange", "betaNum", "betaUnit", "betaDirection", "study", "associationReport", "lastMappingDate", "lastMappingPerformedBy", "lastUpdateDate") .containsExactly(null, "0.52", "(some pvalue description)", 2, -7, false, false, false, null, (float) 0.6, "[0.82-0.92]", null, (float) 1.22, null, null, null, null, null, null, null, null, null, null); assertThat(association.getEfoTraits()).isEmpty(); assertThat(association.getEvents()).isEmpty(); assertThat(association.getStudy()).isNull(); assertThat(association.getLoci()).hasSize(1); Collection<Gene> locusGenes = new ArrayList<>(); association.getLoci().stream().forEach(locus -> { locusGenes.addAll(locus.getAuthorReportedGenes()); } ); Collection<RiskAllele> locusRiskAlleles = new ArrayList<>(); association.getLoci().stream().forEach(locus -> { locusRiskAlleles.addAll(locus.getStrongestRiskAlleles()); } ); Collection<SingleNucleotidePolymorphism> proxies = new ArrayList<>(); locusRiskAlleles.stream().forEach(riskAllele -> { proxies.addAll(riskAllele.getProxySnps()); }); assertThat(association.getLoci()).extracting(Locus::getDescription).containsOnly("Single variant"); assertThat(locusGenes).hasSize(2).contains(GENE_01, GENE_02); assertThat(locusRiskAlleles).hasSize(1).contains(RA_01); assertThat(locusRiskAlleles).extracting("riskAlleleName", "riskFrequency", "snp.rsId") .contains(tuple("rs123-?", "0.52", "rs123")); assertThat(locusRiskAlleles).extracting(RiskAllele::getSnp).contains(SNP_01); assertThat(proxies).contains(PROXY); assertThat(proxies).extracting(SingleNucleotidePolymorphism::getRsId).containsExactly("rs99"); }
public Association createAssociationFromUploadRow(AssociationUploadRow row) { Association newAssociation = new Association(); if (row.getEfoTrait() != null) { String[] uris = row.getEfoTrait().split(","); Collection<String> efoUris = new ArrayList<>(); for (String uri : uris) { String trimmedUri = uri.trim(); efoUris.add(trimmedUri); } Collection<EfoTrait> efoTraits = associationAttributeService.getEfoTraitsFromRepository(efoUris); newAssociation.setEfoTraits(efoTraits); } newAssociation.setOrPerCopyRecip(row.getOrPerCopyRecip()); newAssociation.setOrPerCopyRecipRange(row.getOrPerCopyRecipRange()); newAssociation.setBetaNum(row.getBetaNum()); newAssociation.setBetaUnit(row.getBetaUnit()); newAssociation.setBetaDirection(row.getBetaDirection()); boolean recipReverse = false; if ((row.getOrPerCopyRecip() != null) && (row.getOrPerCopyNum() == null)) { getLog().info("Calculating OR from OR recip value"); newAssociation.setOrPerCopyNum(((100 / row.getOrPerCopyRecip()) / 100)); recipReverse = true; } else { newAssociation.setOrPerCopyNum(row.getOrPerCopyNum()); } if ((row.getOrPerCopyRecipRange() != null) && recipReverse) { newAssociation.setRange(associationCalculationService.reverseCI(row.getOrPerCopyRecipRange())); } else if ((row.getRange() == null) && (row.getStandardError() != null)) { if (row.getOrPerCopyNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getOrPerCopyNum())); } else { if (row.getBetaNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getBetaNum())); } } } else { newAssociation.setRange(row.getRange()); } if (row.getPvalueDescription() != null && !row.getPvalueDescription().isEmpty()) { if (!row.getPvalueDescription().startsWith("(") && !row.getPvalueDescription().endsWith(")")) { StringJoiner newPvalueDescription = new StringJoiner("", "(", ")"); newPvalueDescription.add(row.getPvalueDescription()); newAssociation.setPvalueDescription(newPvalueDescription.toString()); } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } newAssociation.setRiskFrequency(row.getAssociationRiskFrequency()); newAssociation.setPvalueMantissa(row.getPvalueMantissa()); newAssociation.setPvalueExponent(row.getPvalueExponent()); newAssociation.setSnpType(row.getSnpType()); newAssociation.setStandardError(row.getStandardError()); newAssociation.setDescription(row.getDescription()); if (row.getMultiSnpHaplotype() != null) { if (row.getMultiSnpHaplotype().equalsIgnoreCase("Y")) { newAssociation.setMultiSnpHaplotype(true); } } else { newAssociation.setMultiSnpHaplotype(false); } if (row.getSnpInteraction() != null) { if (row.getSnpInteraction().equalsIgnoreCase("Y")) { newAssociation.setSnpInteraction(true); } } else { newAssociation.setSnpInteraction(false); } if (row.getStrongestAllele() != null) { newAssociation.setLoci(createLoci(row, newAssociation.getSnpInteraction(), newAssociation.getMultiSnpHaplotype())); } if(row.getOtherAllele() != null){ newAssociation.getAssociationExtension().setOtherAllele(row.getOtherAllele()); } if(row.getEffectAllele() != null){ newAssociation.getAssociationExtension().setEffectAllele(row.getEffectAllele()); } return newAssociation; }
AssociationRowProcessor { public Association createAssociationFromUploadRow(AssociationUploadRow row) { Association newAssociation = new Association(); if (row.getEfoTrait() != null) { String[] uris = row.getEfoTrait().split(","); Collection<String> efoUris = new ArrayList<>(); for (String uri : uris) { String trimmedUri = uri.trim(); efoUris.add(trimmedUri); } Collection<EfoTrait> efoTraits = associationAttributeService.getEfoTraitsFromRepository(efoUris); newAssociation.setEfoTraits(efoTraits); } newAssociation.setOrPerCopyRecip(row.getOrPerCopyRecip()); newAssociation.setOrPerCopyRecipRange(row.getOrPerCopyRecipRange()); newAssociation.setBetaNum(row.getBetaNum()); newAssociation.setBetaUnit(row.getBetaUnit()); newAssociation.setBetaDirection(row.getBetaDirection()); boolean recipReverse = false; if ((row.getOrPerCopyRecip() != null) && (row.getOrPerCopyNum() == null)) { getLog().info("Calculating OR from OR recip value"); newAssociation.setOrPerCopyNum(((100 / row.getOrPerCopyRecip()) / 100)); recipReverse = true; } else { newAssociation.setOrPerCopyNum(row.getOrPerCopyNum()); } if ((row.getOrPerCopyRecipRange() != null) && recipReverse) { newAssociation.setRange(associationCalculationService.reverseCI(row.getOrPerCopyRecipRange())); } else if ((row.getRange() == null) && (row.getStandardError() != null)) { if (row.getOrPerCopyNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getOrPerCopyNum())); } else { if (row.getBetaNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getBetaNum())); } } } else { newAssociation.setRange(row.getRange()); } if (row.getPvalueDescription() != null && !row.getPvalueDescription().isEmpty()) { if (!row.getPvalueDescription().startsWith("(") && !row.getPvalueDescription().endsWith(")")) { StringJoiner newPvalueDescription = new StringJoiner("", "(", ")"); newPvalueDescription.add(row.getPvalueDescription()); newAssociation.setPvalueDescription(newPvalueDescription.toString()); } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } newAssociation.setRiskFrequency(row.getAssociationRiskFrequency()); newAssociation.setPvalueMantissa(row.getPvalueMantissa()); newAssociation.setPvalueExponent(row.getPvalueExponent()); newAssociation.setSnpType(row.getSnpType()); newAssociation.setStandardError(row.getStandardError()); newAssociation.setDescription(row.getDescription()); if (row.getMultiSnpHaplotype() != null) { if (row.getMultiSnpHaplotype().equalsIgnoreCase("Y")) { newAssociation.setMultiSnpHaplotype(true); } } else { newAssociation.setMultiSnpHaplotype(false); } if (row.getSnpInteraction() != null) { if (row.getSnpInteraction().equalsIgnoreCase("Y")) { newAssociation.setSnpInteraction(true); } } else { newAssociation.setSnpInteraction(false); } if (row.getStrongestAllele() != null) { newAssociation.setLoci(createLoci(row, newAssociation.getSnpInteraction(), newAssociation.getMultiSnpHaplotype())); } if(row.getOtherAllele() != null){ newAssociation.getAssociationExtension().setOtherAllele(row.getOtherAllele()); } if(row.getEffectAllele() != null){ newAssociation.getAssociationExtension().setEffectAllele(row.getEffectAllele()); } return newAssociation; } }
AssociationRowProcessor { public Association createAssociationFromUploadRow(AssociationUploadRow row) { Association newAssociation = new Association(); if (row.getEfoTrait() != null) { String[] uris = row.getEfoTrait().split(","); Collection<String> efoUris = new ArrayList<>(); for (String uri : uris) { String trimmedUri = uri.trim(); efoUris.add(trimmedUri); } Collection<EfoTrait> efoTraits = associationAttributeService.getEfoTraitsFromRepository(efoUris); newAssociation.setEfoTraits(efoTraits); } newAssociation.setOrPerCopyRecip(row.getOrPerCopyRecip()); newAssociation.setOrPerCopyRecipRange(row.getOrPerCopyRecipRange()); newAssociation.setBetaNum(row.getBetaNum()); newAssociation.setBetaUnit(row.getBetaUnit()); newAssociation.setBetaDirection(row.getBetaDirection()); boolean recipReverse = false; if ((row.getOrPerCopyRecip() != null) && (row.getOrPerCopyNum() == null)) { getLog().info("Calculating OR from OR recip value"); newAssociation.setOrPerCopyNum(((100 / row.getOrPerCopyRecip()) / 100)); recipReverse = true; } else { newAssociation.setOrPerCopyNum(row.getOrPerCopyNum()); } if ((row.getOrPerCopyRecipRange() != null) && recipReverse) { newAssociation.setRange(associationCalculationService.reverseCI(row.getOrPerCopyRecipRange())); } else if ((row.getRange() == null) && (row.getStandardError() != null)) { if (row.getOrPerCopyNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getOrPerCopyNum())); } else { if (row.getBetaNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getBetaNum())); } } } else { newAssociation.setRange(row.getRange()); } if (row.getPvalueDescription() != null && !row.getPvalueDescription().isEmpty()) { if (!row.getPvalueDescription().startsWith("(") && !row.getPvalueDescription().endsWith(")")) { StringJoiner newPvalueDescription = new StringJoiner("", "(", ")"); newPvalueDescription.add(row.getPvalueDescription()); newAssociation.setPvalueDescription(newPvalueDescription.toString()); } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } newAssociation.setRiskFrequency(row.getAssociationRiskFrequency()); newAssociation.setPvalueMantissa(row.getPvalueMantissa()); newAssociation.setPvalueExponent(row.getPvalueExponent()); newAssociation.setSnpType(row.getSnpType()); newAssociation.setStandardError(row.getStandardError()); newAssociation.setDescription(row.getDescription()); if (row.getMultiSnpHaplotype() != null) { if (row.getMultiSnpHaplotype().equalsIgnoreCase("Y")) { newAssociation.setMultiSnpHaplotype(true); } } else { newAssociation.setMultiSnpHaplotype(false); } if (row.getSnpInteraction() != null) { if (row.getSnpInteraction().equalsIgnoreCase("Y")) { newAssociation.setSnpInteraction(true); } } else { newAssociation.setSnpInteraction(false); } if (row.getStrongestAllele() != null) { newAssociation.setLoci(createLoci(row, newAssociation.getSnpInteraction(), newAssociation.getMultiSnpHaplotype())); } if(row.getOtherAllele() != null){ newAssociation.getAssociationExtension().setOtherAllele(row.getOtherAllele()); } if(row.getEffectAllele() != null){ newAssociation.getAssociationExtension().setEffectAllele(row.getEffectAllele()); } return newAssociation; } @Autowired  AssociationRowProcessor(AssociationAttributeService associationAttributeService,
                                   AssociationCalculationService associationCalculationService); }
AssociationRowProcessor { public Association createAssociationFromUploadRow(AssociationUploadRow row) { Association newAssociation = new Association(); if (row.getEfoTrait() != null) { String[] uris = row.getEfoTrait().split(","); Collection<String> efoUris = new ArrayList<>(); for (String uri : uris) { String trimmedUri = uri.trim(); efoUris.add(trimmedUri); } Collection<EfoTrait> efoTraits = associationAttributeService.getEfoTraitsFromRepository(efoUris); newAssociation.setEfoTraits(efoTraits); } newAssociation.setOrPerCopyRecip(row.getOrPerCopyRecip()); newAssociation.setOrPerCopyRecipRange(row.getOrPerCopyRecipRange()); newAssociation.setBetaNum(row.getBetaNum()); newAssociation.setBetaUnit(row.getBetaUnit()); newAssociation.setBetaDirection(row.getBetaDirection()); boolean recipReverse = false; if ((row.getOrPerCopyRecip() != null) && (row.getOrPerCopyNum() == null)) { getLog().info("Calculating OR from OR recip value"); newAssociation.setOrPerCopyNum(((100 / row.getOrPerCopyRecip()) / 100)); recipReverse = true; } else { newAssociation.setOrPerCopyNum(row.getOrPerCopyNum()); } if ((row.getOrPerCopyRecipRange() != null) && recipReverse) { newAssociation.setRange(associationCalculationService.reverseCI(row.getOrPerCopyRecipRange())); } else if ((row.getRange() == null) && (row.getStandardError() != null)) { if (row.getOrPerCopyNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getOrPerCopyNum())); } else { if (row.getBetaNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getBetaNum())); } } } else { newAssociation.setRange(row.getRange()); } if (row.getPvalueDescription() != null && !row.getPvalueDescription().isEmpty()) { if (!row.getPvalueDescription().startsWith("(") && !row.getPvalueDescription().endsWith(")")) { StringJoiner newPvalueDescription = new StringJoiner("", "(", ")"); newPvalueDescription.add(row.getPvalueDescription()); newAssociation.setPvalueDescription(newPvalueDescription.toString()); } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } newAssociation.setRiskFrequency(row.getAssociationRiskFrequency()); newAssociation.setPvalueMantissa(row.getPvalueMantissa()); newAssociation.setPvalueExponent(row.getPvalueExponent()); newAssociation.setSnpType(row.getSnpType()); newAssociation.setStandardError(row.getStandardError()); newAssociation.setDescription(row.getDescription()); if (row.getMultiSnpHaplotype() != null) { if (row.getMultiSnpHaplotype().equalsIgnoreCase("Y")) { newAssociation.setMultiSnpHaplotype(true); } } else { newAssociation.setMultiSnpHaplotype(false); } if (row.getSnpInteraction() != null) { if (row.getSnpInteraction().equalsIgnoreCase("Y")) { newAssociation.setSnpInteraction(true); } } else { newAssociation.setSnpInteraction(false); } if (row.getStrongestAllele() != null) { newAssociation.setLoci(createLoci(row, newAssociation.getSnpInteraction(), newAssociation.getMultiSnpHaplotype())); } if(row.getOtherAllele() != null){ newAssociation.getAssociationExtension().setOtherAllele(row.getOtherAllele()); } if(row.getEffectAllele() != null){ newAssociation.getAssociationExtension().setEffectAllele(row.getEffectAllele()); } return newAssociation; } @Autowired  AssociationRowProcessor(AssociationAttributeService associationAttributeService,
                                   AssociationCalculationService associationCalculationService); Association createAssociationFromUploadRow(AssociationUploadRow row); }
AssociationRowProcessor { public Association createAssociationFromUploadRow(AssociationUploadRow row) { Association newAssociation = new Association(); if (row.getEfoTrait() != null) { String[] uris = row.getEfoTrait().split(","); Collection<String> efoUris = new ArrayList<>(); for (String uri : uris) { String trimmedUri = uri.trim(); efoUris.add(trimmedUri); } Collection<EfoTrait> efoTraits = associationAttributeService.getEfoTraitsFromRepository(efoUris); newAssociation.setEfoTraits(efoTraits); } newAssociation.setOrPerCopyRecip(row.getOrPerCopyRecip()); newAssociation.setOrPerCopyRecipRange(row.getOrPerCopyRecipRange()); newAssociation.setBetaNum(row.getBetaNum()); newAssociation.setBetaUnit(row.getBetaUnit()); newAssociation.setBetaDirection(row.getBetaDirection()); boolean recipReverse = false; if ((row.getOrPerCopyRecip() != null) && (row.getOrPerCopyNum() == null)) { getLog().info("Calculating OR from OR recip value"); newAssociation.setOrPerCopyNum(((100 / row.getOrPerCopyRecip()) / 100)); recipReverse = true; } else { newAssociation.setOrPerCopyNum(row.getOrPerCopyNum()); } if ((row.getOrPerCopyRecipRange() != null) && recipReverse) { newAssociation.setRange(associationCalculationService.reverseCI(row.getOrPerCopyRecipRange())); } else if ((row.getRange() == null) && (row.getStandardError() != null)) { if (row.getOrPerCopyNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getOrPerCopyNum())); } else { if (row.getBetaNum() != null) { newAssociation.setRange(associationCalculationService.setRange(row.getStandardError(), row.getBetaNum())); } } } else { newAssociation.setRange(row.getRange()); } if (row.getPvalueDescription() != null && !row.getPvalueDescription().isEmpty()) { if (!row.getPvalueDescription().startsWith("(") && !row.getPvalueDescription().endsWith(")")) { StringJoiner newPvalueDescription = new StringJoiner("", "(", ")"); newPvalueDescription.add(row.getPvalueDescription()); newAssociation.setPvalueDescription(newPvalueDescription.toString()); } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } } else { newAssociation.setPvalueDescription(row.getPvalueDescription()); } newAssociation.setRiskFrequency(row.getAssociationRiskFrequency()); newAssociation.setPvalueMantissa(row.getPvalueMantissa()); newAssociation.setPvalueExponent(row.getPvalueExponent()); newAssociation.setSnpType(row.getSnpType()); newAssociation.setStandardError(row.getStandardError()); newAssociation.setDescription(row.getDescription()); if (row.getMultiSnpHaplotype() != null) { if (row.getMultiSnpHaplotype().equalsIgnoreCase("Y")) { newAssociation.setMultiSnpHaplotype(true); } } else { newAssociation.setMultiSnpHaplotype(false); } if (row.getSnpInteraction() != null) { if (row.getSnpInteraction().equalsIgnoreCase("Y")) { newAssociation.setSnpInteraction(true); } } else { newAssociation.setSnpInteraction(false); } if (row.getStrongestAllele() != null) { newAssociation.setLoci(createLoci(row, newAssociation.getSnpInteraction(), newAssociation.getMultiSnpHaplotype())); } if(row.getOtherAllele() != null){ newAssociation.getAssociationExtension().setOtherAllele(row.getOtherAllele()); } if(row.getEffectAllele() != null){ newAssociation.getAssociationExtension().setEffectAllele(row.getEffectAllele()); } return newAssociation; } @Autowired  AssociationRowProcessor(AssociationAttributeService associationAttributeService,
                                   AssociationCalculationService associationCalculationService); Association createAssociationFromUploadRow(AssociationUploadRow row);  }