Skip to content

Commit

Permalink
storage: Fix multi-allelic fetch. Add QUAL. #TASK-4794
Browse files Browse the repository at this point in the history
  • Loading branch information
j-coll committed Jul 21, 2023
1 parent 1c2db28 commit c21e416
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 13 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -390,15 +390,15 @@ public Variant convert(SampleVariantIndexEntry entry) {
switch (role) {
case MOTHER:
studyEntry.getSamples().add(new SampleEntry(motherName, null,
Collections.singletonList(GenotypeCodec.decodeMother(entry.getParentsCode()))));
Arrays.asList(GenotypeCodec.decodeMother(entry.getParentsCode()))));
break;
case FATHER:
studyEntry.getSamples().add(new SampleEntry(fatherName, null,
Collections.singletonList(GenotypeCodec.decodeFather(entry.getParentsCode()))));
Arrays.asList(GenotypeCodec.decodeFather(entry.getParentsCode()))));
break;
case SAMPLE:
studyEntry.getSamples().add(new SampleEntry(sampleName, null,
Collections.singletonList(entry.getGenotype())));
Arrays.asList(entry.getGenotype())));
break;
default:
throw new IllegalStateException("Unexpected value: " + role);
Expand All @@ -412,11 +412,11 @@ public Variant convert(SampleVariantIndexEntry entry) {
filter = "NA";
}
fileAttributes.put(StudyEntry.FILTER, filter);
// String qual = qualField.readAndDecode(fileIndexBitBuffer);
// if (qual == null) {
// qual = "NA";
// }
// fileAttributes.put(StudyEntry.QUAL, qual);
String qual = qualField.readAndDecode(fileIndexBitBuffer);
if (qual == null) {
qual = "NA";
}
fileAttributes.put(StudyEntry.QUAL, qual);
String fileName = files.get(0);
studyEntry.setFiles(new ArrayList<>());
studyEntry.getFiles().add(new FileEntry(fileName, null, fileAttributes));
Expand Down Expand Up @@ -513,7 +513,7 @@ public List<Variant> apply(List<Variant> variants) {
// Should end in few seconds
future.get(90, TimeUnit.SECONDS);
} catch (InterruptedException | ExecutionException | TimeoutException e) {
throw new VariantQueryException("Error fetching original call for INDELs");
throw new VariantQueryException("Error fetching extra data", e);
}
}
logger.info("Fetch {} partial variants in {} in {} threads",
Expand Down Expand Up @@ -564,8 +564,11 @@ private void addSecondaryAlternates(List<Variant> toReadFull) {
fe.setCall(newFe.getCall());
});
// merge sampleEntries
for (SampleEntry sampleExtra : studyExtra.getSamples()) {
SampleEntry sample = study.getSample(sampleExtra.getSampleId());
for (int i = 0; i < samples.size(); i++) {
// String sampleName = samples.get(i);
SampleEntry sample = study.getSample(i);
SampleEntry sampleExtra = studyExtra.getSample(i);

sample.getData().set(gtIdx, sampleExtra.getData().get(0));
// if (sampleExtra.getFileIndex() != null) {
// String fileIdFromFull = fullStudy.getFiles().get(sampleExtra.getFileIndex()).getFileId();
Expand Down Expand Up @@ -608,7 +611,7 @@ private void addOriginalCall(List<Variant> variants, String study) {
continue;
}
StudyEntry studyEntry = variant.getStudies().get(0);
mergeFileEntries(studyEntry, fileEntries, (fe, newFe)->{
mergeFileEntries(studyEntry, fileEntries, (fe, newFe) -> {
fe.setCall(newFe.getCall());
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ public int encode(Double value) {

@Override
public Double decode(int code) {
return code == thresholds.length ? max : code < 0 ? min : thresholds[code];
return code <= 0 ? min : thresholds[code - 1];
}

@Override
Expand Down

0 comments on commit c21e416

Please sign in to comment.