Skip to content

Commit

Permalink
storage: Fix junit tests. #TASK-6765
Browse files Browse the repository at this point in the history
  • Loading branch information
j-coll committed Sep 9, 2024
1 parent 717beac commit 53bf816
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -118,17 +118,15 @@ protected int toBytes(int relativeStart, String reference, String alternate, byt
}

public Variant toVariant(String chromosome, int batchStart, byte[] bytes) {
return toVariant(chromosome, batchStart, bytes, 0, bytes.length);
return toVariant(chromosome, batchStart, bytes, 0);
}

public Variant toVariant(String chromosome, int batchStart, byte[] bytes, int offset, int length) {
public Variant toVariant(String chromosome, int batchStart, byte[] bytes, int offset) {
if (hasEncodedAlleles(bytes, offset)) {
return toVariantEncodedAlleles(chromosome, batchStart, bytes, offset);
} else {
int currentOffset = INT24_LENGTH;
int referenceLength = readNextSeparator(bytes, offset + currentOffset, length - currentOffset);
currentOffset += referenceLength + SEPARATOR_LENGTH;
int alternateLength = readNextSeparator(bytes, offset + currentOffset, length - currentOffset);
int referenceLength = readNextSeparator(bytes, offset + INT24_LENGTH);
int alternateLength = readNextSeparator(bytes, offset + INT24_LENGTH + referenceLength + SEPARATOR_LENGTH);
return toVariant(chromosome, batchStart, bytes, offset, referenceLength, alternateLength);
}
}
Expand Down Expand Up @@ -704,16 +702,12 @@ private Variant toVariant(String chromosome, int batchStart, byte[] bytes, int o
}

private int readNextSeparator(byte[] bytes, int offset) {
return readNextSeparator(bytes, offset, bytes.length - offset);
}

private int readNextSeparator(byte[] bytes, int offset, int length) {
for (int i = offset; i < (offset + length); i++) {
for (int i = offset; i < bytes.length; i++) {
if (bytes[i] == 0) {
return i - offset;
}
}
return length - offset;
return bytes.length - offset;
}

protected int getRelativeStart(Variant variant) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -169,7 +169,7 @@ public void resolveConflictIndelCase1() throws Exception {
se.setSampleDataKeys(Arrays.asList(GENOTYPE_KEY, GENOTYPE_FILTER_KEY));
se.setSamplesPosition(asMap("S1", 0));
se.addSampleData("S1", Arrays.asList("1/2", "LowGQXHetDel"));
se.getSecondaryAlternates().add(new AlternateCoordinate(null, null, 328, "CTT", "CTTTC", INDEL));
se.getSecondaryAlternates().add(new AlternateCoordinate(null, 328, 330, "CTT", "CTTTC", INDEL));
addAttribute(v1, FILTER, "LowGQXHetDel");


Expand Down

0 comments on commit 53bf816

Please sign in to comment.