public VariantBuilder setCiEnd(int left, int right) { initSv(); sv.setCiEndLeft(left); sv.setCiEndRight(right); return this; }
private void parseEnd(String end, String variantString) { if (StringUtils.contains(end, '<')) { String[] split = end.split("<", -1); if (split.length != 3) { throw new IllegalArgumentException("Error parsing end from variant " + variantString + ". Expected 3 fields separated by '<'. " + "Format: \"" + VARIANT_STRING_FORMAT + "\""); } initSv(); if (!split[0].isEmpty()) { sv.setCiEndLeft(Integer.parseInt(split[0])); } setEnd(Integer.parseInt(split[1])); if (!split[2].isEmpty()) { sv.setCiEndRight(Integer.parseInt(split[2])); } } else { setEnd(Integer.parseInt(end)); } }
parts = value.split(","); sv.setCiEndLeft(end + Integer.parseInt(parts[0])); sv.setCiEndRight(end + Integer.parseInt(parts[1])); break;
structuralVariation.setCiStartRight(variant.getStart()); structuralVariation.setCiEndLeft(variant.getEnd()); structuralVariation.setCiEndRight(variant.getEnd());
sv.setCiStartRight(ciStart.get(1)); sv.setCiEndLeft(ciEnd.get(0)); sv.setCiEndRight(ciEnd.get(1)); sv.setLeftSvInsSeq(insSeq.get(0)); sv.setRightSvInsSeq(insSeq.get(1));
@Deprecated public static StructuralVariation getStructuralVariation(Variant variant, StructuralVariantType tandemDuplication) { int[] impreciseStart = getImpreciseStart(variant); int[] impreciseEnd = getImpreciseEnd(variant); String[] svInsSeq = getSvInsSeq(variant); StructuralVariation sv = new StructuralVariation(); sv.setCiStartLeft(impreciseStart[0]); sv.setCiStartRight(impreciseStart[1]); sv.setCiEndLeft(impreciseEnd[0]); sv.setCiEndRight(impreciseEnd[1]); sv.setLeftSvInsSeq(svInsSeq[0]); sv.setRightSvInsSeq(svInsSeq[1]); // If it's not a tandem duplication, this will set the type to null sv.setType(tandemDuplication); // Will properly set the type if it's a CNV if (variant.getType().equals(VariantType.CNV)) { Integer copyNumber = getCopyNumberFromAlternate(variant.getAlternate()); if (copyNumber != null) { sv.setCopyNumber(copyNumber); sv.setType(getCNVSubtype(copyNumber)); } } return sv; }
private Variant newVariant(Variant variant, VariantKeyFields keyFields, StructuralVariation sv) { Variant normalizedVariant = new Variant(variant.getChromosome(), keyFields.getStart(), keyFields.getEnd(), keyFields.getReference(), keyFields.getAlternate()) .setId(variant.getId()) .setNames(variant.getNames()) .setStrand(variant.getStrand()); if (sv != null) { if (normalizedVariant.getSv() != null) { // CI positions may change during the normalization. Update them. normalizedVariant.getSv().setCiStartLeft(sv.getCiStartLeft()); normalizedVariant.getSv().setCiStartRight(sv.getCiStartRight()); normalizedVariant.getSv().setCiEndLeft(sv.getCiEndLeft()); normalizedVariant.getSv().setCiEndRight(sv.getCiEndRight()); } else { normalizedVariant.setSv(sv); } // Variant will never have CopyNumber, because the Alternate is normalized from <CNxx> to <CNV> normalizedVariant.getSv().setCopyNumber(keyFields.getCopyNumber()); normalizedVariant.getSv().setType(VariantBuilder.getCNVSubtype(keyFields.getCopyNumber())); } return normalizedVariant; // normalizedVariant.setAnnotation(variant.getAnnotation()); // if (isSymbolic(variant)) { // StructuralVariation sv = getStructuralVariation(normalizedVariant, keyFields, null); // normalizedVariant.setSv(sv); // } }
@Test public void cnv() { // CNV Variant v = new Variant("1", 1000, 2000, "A", "<CN5>"); assertEquals(" 1: 1000:A:<CN5>", converter.buildId(v)); assertEquals(v, converter.buildVariant(converter.buildId(v), 2000, "A", "<CN5>")); v.getSv().setCiStartLeft(999); v.getSv().setCiStartRight(1010); assertEquals(" 1: 1000:A:<CN5>:999:1010::", converter.buildId(v)); assertEquals(v, converter.buildVariant(converter.buildId(v), 2000, "A", "<CN5>")); v.getSv().setCiEndLeft(1999); v.getSv().setCiEndRight(2010); assertEquals(" 1: 1000:A:<CN5>:999:1010:1999:2010", converter.buildId(v)); assertEquals(v, converter.buildVariant(converter.buildId(v), 2000, "A", "<CN5>")); }