@Test public void testCreateAssociationFromUploadRowHaplotype() throws Exception { when(associationAttributeService.createSnp("rs456")).thenReturn(SNP_04); when(associationAttributeService.createSnp("rs678")).thenReturn(SNP_05); when(associationAttributeService.createRiskAllele("rs456-T", SNP_04)).thenReturn(RA_04); when(associationAttributeService.createRiskAllele("rs678-?", SNP_05)).thenReturn(RA_05); when(associationCalculationService.reverseCI("[0.87-0.94]")).thenReturn("[1.06-1.15]"); Association association = associationRowProcessor.createAssociationFromUploadRow(HAPLOTYPE_ROW); verify(associationCalculationService, times(1)).reverseCI(Matchers.anyString()); verify(associationCalculationService, never()).setRange(Matchers.anyDouble(), Matchers.anyDouble()); verify(associationAttributeService, never()).getEfoTraitsFromRepository(Collections.EMPTY_LIST); verify(associationAttributeService, never()).createLocusGenes(Matchers.anyString(), Matchers.anyString()); verify(associationAttributeService, times(1)).createSnp("rs456"); verify(associationAttributeService, times(1)).createSnp("rs678"); verify(associationAttributeService, times(1)).createRiskAllele("rs456-T", SNP_04); verify(associationAttributeService, times(1)).createRiskAllele("rs678-?", SNP_05); 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, null, "(description)", 2, -7, true, false, false, null, null, "[1.06-1.15]", null, 1.2048193f, 0.83f, "[0.87-0.94]", 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<RiskAllele> locusRiskAlleles = new ArrayList<>(); association.getLoci().stream().forEach(locus -> { locusRiskAlleles.addAll(locus.getStrongestRiskAlleles()); } ); Collection<Gene> locusGenes = new ArrayList<>(); association.getLoci().stream().forEach(locus -> { locusGenes.addAll(locus.getAuthorReportedGenes()); } ); assertThat(association.getLoci()).extracting(Locus::getDescription).containsOnly("2-SNP haplotype"); assertThat(locusGenes).isEmpty(); assertThat(locusRiskAlleles).hasSize(2).contains(RA_04, RA_05); assertThat(locusRiskAlleles).extracting(RiskAllele::getRiskFrequency).containsNull(); assertThat(locusRiskAlleles).extracting("riskAlleleName", "riskFrequency", "snp.rsId") .contains(tuple("rs456-T", null, "rs456"), tuple("rs678-?", null, "rs678")); assertThat(locusRiskAlleles).extracting(RiskAllele::getSnp).containsExactly(SNP_04, SNP_05); }
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);  }