@Test public void testCreateAssociationFromUploadRowErrorRow() throws Exception { Association association = associationRowProcessor.createAssociationFromUploadRow(ROW_THAT_SHOULD_FAIL); verify(associationCalculationService, never()).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, never()).createSnp(Matchers.anyString()); verify(associationAttributeService, never()).createRiskAllele(Matchers.anyString(), Matchers.any(SingleNucleotidePolymorphism.class)); 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, null, 2, -7, false, false, false, null, null, null, null, null, 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()).isEmpty(); }
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);  }