public FileEntry getFile(String fileId) { for (FileEntry fileEntry : impl.getFiles()) { if (fileEntry.getFileId().equals(fileId)) { return fileEntry; } } return null; }
public Map<String, String> getAllAttributes() { Map<String, String> attributes = new HashMap<>(); impl.getFiles().stream().forEach(fileEntry -> attributes.putAll(fileEntry.getAttributes().entrySet().stream() .collect(Collectors.toMap(entry -> fileEntry.getFileId() + "_" + entry.getKey(), Map.Entry::getValue)) ) ); return Collections.unmodifiableMap(attributes); }
protected Map<String, List<String>> parseInfo(List<FileEntry> files) { Map<String, List<String>> parsedInfo = new HashMap<>(); List<String> fileIds = new ArrayList<>(files.size()); List<String> ori = new ArrayList<>(files.size()); parsedInfo.put("FID", fileIds); parsedInfo.put("ORI", ori); int fileIdx = 0; for (FileEntry file : files) { fileIds.add(file.getFileId() == null ? "" : file.getFileId()); ori.add(file.getCall() == null ? "" : file.getCall()); Map<String, String> attributes = file.getAttributes(); for (Map.Entry<String, String> field : attributes.entrySet()) { List<String> value; if (parsedInfo.containsKey(field.getKey())) { value = parsedInfo.get(field.getKey()); } else { value = Arrays.asList(new String[files.size()]); parsedInfo.put(field.getKey(), value); } value.set(fileIdx, field.getValue()); } fileIdx++; } return parsedInfo; }
public String getFileId() { return !impl.getFiles().isEmpty() ? impl.getFiles().get(0).getFileId() : null; }
@Override public List<Document> apply(List<Variant> batch) { progressLogger.increment(batch.size(), () -> "up to position " + batch.get(batch.size() - 1)); return batch.stream().map(variant -> { for (StudyEntry studyEntry : variant.getStudies()) { studyEntry.setStudyId(studiesIdRemap.getOrDefault(studyEntry.getStudyId(), studyEntry.getStudyId())); for (FileEntry file : studyEntry.getFiles()) { if (file.getFileId().isEmpty()) { file.setFileId("-1"); } else if (fileIdRemap.containsKey(file.getFileId())) { file.setFileId(fileIdRemap.get(file.getFileId())); } } if (studyEntry.getSamplesData() == null) { studyEntry.setSamplesData(Collections.emptyList()); } } return variant; }).map(variantConverter::convertToStorageType).collect(Collectors.toList()); } }
protected Document convertFileDocument(StudyEntry studyEntry, FileEntry file) { int fileId = Integer.parseInt(file.getFileId()); Document fileObject = new Document(FILEID_FIELD, fileId);
int fileId = Integer.parseInt(fileEntry.getFileId()); if (writeAllFileAttributes || filesToWrite.contains(fileId)) { byte[] fileColumnKey = VariantPhoenixHelper
studyEntry.getFile(fileEntry.getFileId()).setAttributes(fileEntry.getAttributes());
for (FileEntry file : vse.getFiles()) { HashMap<String, String> attributes = new HashMap<>(file.getAttributes()); //TODO: Check file attributes files.add(new FileEntry(file.getFileId(), file.getCall(), attributes));
private void checkStudyEntry(StudyEntry expectedStudy, StudyEntry actualStudy) { if (!expectedStudy.getStudyId().equals(actualStudy.getStudyId())) { fail("Study entry ID mismatch: " + expectedStudy.getStudyId() + ", " + actualStudy.getStudyId()); } int expectedStudyNumFiles = 0; if (expectedStudy.getFiles() != null) { expectedStudyNumFiles = expectedStudy.getFiles().size(); } int actualStudyNumFiles = 0; if (expectedStudy.getFiles() != null) { actualStudyNumFiles = actualStudy.getFiles().size(); } if (actualStudyNumFiles != expectedStudyNumFiles) { fail(); } Map<String, FileEntry> expectedFileEntryMap = new HashMap<>(); for (FileEntry fileEntry: expectedStudy.getFiles()) { expectedFileEntryMap.put(fileEntry.getFileId(), fileEntry); } for (FileEntry fileEntry: actualStudy.getFiles()) { if (!expectedFileEntryMap.containsKey(fileEntry.getFileId())) { fail(); } else { checkFileEntry(expectedFileEntryMap.get(fileEntry.getFileId()), fileEntry); } } }
private void checkFileEntry(FileEntry expectedFileEntry, FileEntry actualFileEntry) { if (!expectedFileEntry.getFileId().equals(actualFileEntry.getFileId())) { fail("File entry ID mismatch: " + expectedFileEntry.getFileId() + ", " + actualFileEntry.getFileId()); } if (expectedFileEntry.getCall() != null || actualFileEntry.getCall() != null) { if (expectedFileEntry.getCall() == null || !expectedFileEntry.getCall().equals(actualFileEntry.getCall())) { fail("File entry call mismatch: " + expectedFileEntry.getCall() + ", " + actualFileEntry.getCall()); } } if (expectedFileEntry.getAttributes() != null || actualFileEntry.getAttributes() != null) { if (expectedFileEntry.getAttributes().size() != actualFileEntry.getAttributes().size()) { fail("File entry attribute size mismatch: " + expectedFileEntry.getAttributes().size() + ", " + actualFileEntry.getAttributes().size()); } for (String key : actualFileEntry.getAttributes().keySet()) { if (!expectedFileEntry.getAttributes().containsKey(key)) { fail("File entry attribute '" + key + "' not found"); } if (!expectedFileEntry.getAttributes().get(key).equals(actualFileEntry.getAttributes().get(key))) { fail("File entry attribute '" + key + "' mismatch: " + expectedFileEntry.getAttributes().get(key) + ", " + actualFileEntry.getAttributes().get(key)); } } } } }
if (StringUtils.isNotEmpty(qual)) { variantSearchModel.getQual().put("qual" + VariantSearchUtils.FIELD_SEPARATOR + studyId + VariantSearchUtils.FIELD_SEPARATOR + fileEntry.getFileId(), Float.parseFloat(qual)); if (StringUtils.isNotEmpty(filter)) { variantSearchModel.getFilter().put("filter" + VariantSearchUtils.FIELD_SEPARATOR + studyId + VariantSearchUtils.FIELD_SEPARATOR + fileEntry.getFileId(), filter); try { variantSearchModel.getFileInfo().put("fileInfo" + VariantSearchUtils.FIELD_SEPARATOR + studyId + VariantSearchUtils.FIELD_SEPARATOR + fileEntry.getFileId(), writer.writeValueAsString(fileInfoMap)); } catch (JsonProcessingException e) { logger.info("Error converting fileInfo for study {} and file {}", studyId, fileEntry.getFileId());
for (FileEntry file : entry.getFiles()) { HashMap<String, String> attributes = new HashMap<>(file.getAttributes()); files.add(new FileEntry(file.getFileId(), sameVariant ? null : call, attributes));
.getFiles().get(0).getFileId())) .append(DocumentToStudyVariantEntryConverter.ATTRIBUTES_FIELD, new Document("QUAL", 0.01).append("AN", 2)) .append(DocumentToStudyVariantEntryConverter.SAMPLE_DATA_FIELD, new Document("dp", new Binary(VariantMongoDBProto.OtherFields.newBuilder()
List<FileEntry> files = study.getFiles(); assertEquals(1, files.size()); assertEquals("1", files.get(0).getFileId());
assertEquals(Collections.singleton("SAMPLE_2"), variant.getStudy(STUDY_NAME).getSamplesName()); if (!variant.getStudy(STUDY_NAME).getFiles().isEmpty()) { assertEquals("variant-test-somatic_2.vcf", variant.getStudy(STUDY_NAME).getFiles().get(0).getFileId());