AlleleConverter { public static AlleleProperties mergeProperties(AlleleProperties originalProperties, AlleleProperties properties) { String updatedRsId = (originalProperties.getRsId() .isEmpty()) ? properties.getRsId() : originalProperties.getRsId(); return AlleleProperties.newBuilder() .mergeFrom(originalProperties) .mergeFrom(properties) .setRsId(updatedRsId) .build(); } private  AlleleConverter(); static AlleleKey toAlleleKey(Allele allele); static AlleleProperties mergeProperties(AlleleProperties originalProperties, AlleleProperties properties); static AlleleProperties toAlleleProperties(Allele allele); static ClinVar toProtoClinVar(ClinVarData clinVarData);  }
@Test public void mergeProperties() { AlleleProperties toMerge = AlleleProperties.newBuilder().putProperties("POLYPHEN", 1f).build(); AlleleProperties expected = AlleleProperties.newBuilder() .setRsId("rs678910") .putProperties("EXAC_AFR", 0.00056f) .putProperties("POLYPHEN", 1f) .setClinVar(PROTO_CLINVAR) .build(); assertThat(AlleleConverter.mergeProperties(ALLELE_PROPERTIES, toMerge), equalTo(expected)); }
@Test public void mergePropertiesUsesOriginalRsidWhenPresent() { AlleleProperties toMerge = AlleleProperties.newBuilder() .setRsId("Shouldn't be present in merged") .putProperties("POLYPHEN", 1f).build(); AlleleProperties expected = AlleleProperties.newBuilder() .setRsId("rs678910") .putProperties("EXAC_AFR", 0.00056f) .putProperties("POLYPHEN", 1f) .setClinVar(PROTO_CLINVAR) .build(); assertThat(AlleleConverter.mergeProperties(ALLELE_PROPERTIES, toMerge), equalTo(expected)); }
@Test public void mergePropertiesUsesNewRsidIfOriginalAbsent() { AlleleProperties original = AlleleProperties.newBuilder() .putProperties("EXAC_AFR", 0.00056f) .build(); AlleleProperties toMerge = AlleleProperties.newBuilder() .setRsId("rs45789") .putProperties("POLYPHEN", 1f).build(); AlleleProperties expected = AlleleProperties.newBuilder() .setRsId("rs45789") .putProperties("EXAC_AFR", 0.00056f) .putProperties("POLYPHEN", 1f) .build(); assertThat(AlleleConverter.mergeProperties(original, toMerge), equalTo(expected)); }