private List<FileEntry> normalizeFilesInfo(List<FileEntry> files, VariantAlternateRearranger rearranger) { if (rearranger == null) { return files; } for (FileEntry file : files) { for (Map.Entry<String, String> entry : file.getAttributes().entrySet()) { String data = rearranger.rearrange(entry.getKey(), entry.getValue()); entry.setValue(data); } } return files; }
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 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); }
HashMap<String, String> attributes = new HashMap<>(file.getAttributes()); //TODO: Check file attributes files.add(new FileEntry(file.getFileId(), file.getCall(), attributes));
.map(fileEntry -> FileEntry.newBuilder(fileEntry).build()) .collect(Collectors.toList()); if (!current.toString().equals(other.toString())) { for (FileEntry file : files) { if (StringUtils.isEmpty(file.getCall())) { file.setCall(call); for (Map.Entry<String, String> entry : file.getAttributes().entrySet()) { String data = entry.getValue(); if (rearranger != null) {
public Variant convert(VcfSliceProtos.VcfRecord vcfRecord, String chromosome, int slicePosition) { int start = getStart(vcfRecord, slicePosition); int end = getEnd(vcfRecord, slicePosition); Variant variant = new Variant(chromosome, start, end, vcfRecord.getReference(), vcfRecord.getAlternate()); variant.setType(getVariantType(vcfRecord.getType())); variant.setIds(vcfRecord.getIdNonDefaultList()); variant.resetLength(); FileEntry fileEntry = new FileEntry(); fileEntry.setFileId(fileId); Map<String, String> attributes = getFileAttributes(vcfRecord); fileEntry.setAttributes(attributes); fileEntry.setCall(vcfRecord.getCall().isEmpty() ? null : vcfRecord.getCall()); if (vcfRecord.getType().equals(VariantProto.VariantType.NO_VARIATION)) { attributes.put("END", Integer.toString(end)); } StudyEntry studyEntry = new StudyEntry(studyId); studyEntry.setFiles(Collections.singletonList(fileEntry)); studyEntry.setFormat(getFormat(vcfRecord)); studyEntry.setSamplesData(getSamplesData(vcfRecord, studyEntry.getFormatPositions())); studyEntry.setSamplesPosition(retrieveSamplePosition()); studyEntry.getFormatPositions(); // Initialize the map List<VariantProto.AlternateCoordinate> alts = vcfRecord.getSecondaryAlternatesList(); studyEntry.setSecondaryAlternates(getAlternateCoordinates(alts)); variant.addStudyEntry(studyEntry); studyEntry.getFormatPositions(); // Initialize the map return variant; }
fileEntry.getAttributes().remove(VCFConstants.END_KEY); if (StringUtils.isEmpty(fileEntry.getCall())) { fileEntry.setCall(archiveVariant.getStart() + ":" + archiveVariant.getReference() + ":" + archiveVariant.getAlternate() + ":0");
protected static String[] getOri(StudyEntry studyEntry) { List<FileEntry> files = studyEntry.getFiles(); if (!files.isEmpty()) { String call = files.get(0).getCall(); if (call != null && !call.isEmpty()) { return call.split(":"); } } return null; }
private List<String> remapFileData(Variant variant, StudyEntry studyEntry, FileEntry fileEntry, VariantOverlappingStatus overlappingStatus) { int capacity = fileAttributes.size() + HBaseToStudyEntryConverter.FILE_INFO_START_IDX; List<String> fileColumn = Arrays.asList(new String[capacity]); Map<String, String> attributes = fileEntry.getAttributes(); fileColumn.set(HBaseToStudyEntryConverter.FILE_CALL_IDX, fileEntry.getCall()); if (addSecondaryAlternates && studyEntry.getSecondaryAlternates() != null && !studyEntry.getSecondaryAlternates().isEmpty()) { fileColumn.set(HBaseToStudyEntryConverter.FILE_SEC_ALTS_IDX, getSecondaryAlternates(variant, studyEntry)); } fileColumn.set(HBaseToStudyEntryConverter.FILE_VARIANT_OVERLAPPING_STATUS_IDX, overlappingStatus.toString()); fileColumn.set(HBaseToStudyEntryConverter.FILE_QUAL_IDX, attributes.get(StudyEntry.QUAL)); fileColumn.set(HBaseToStudyEntryConverter.FILE_FILTER_IDX, attributes.get(StudyEntry.FILTER)); int attributeIdx = HBaseToStudyEntryConverter.FILE_INFO_START_IDX; for (String fileAttribute : fileAttributes) { fileColumn.set(attributeIdx, attributes.get(fileAttribute)); attributeIdx++; } // Trim all leading null values fileColumn = trimLeadingNullValues(fileColumn, HBaseToStudyEntryConverter.FILE_INFO_START_IDX); return fileColumn; }
studyEntry.getFile(fileEntry.getFileId()).setAttributes(fileEntry.getAttributes());
FileEntry fileEntry = new FileEntry(fields[2], null, new HashMap<>()); try { fileEntry.setCall(fileInfoAttributes.get("fileCall")); fileInfoAttributes.remove("fileCall"); fileEntry.setAttributes(fileInfoAttributes);
StudyEntry studyEntry = variant.getStudies().get(0); studyEntry.setStudyId(STUDY_NAME); studyEntry.getFiles().get(0).setFileId(fileId); variant.setStudies(Collections.singletonList(studyEntry)); }); for (FileEntry fileEntry : loadedStudy.getFiles()) { if(StringUtils.isEmpty(fileEntry.getCall())) { fileEntry.setCall(null);
studyEntry.getFiles().add(new FileEntry(fileName, call, attributes));
fileId = 2; studyEntry = new StudyEntry(studyId.toString()); FileEntry fileEntry = new FileEntry(fileId.toString(), null, new HashMap<>()); fileEntry.getAttributes().put("QUAL", "0.01"); fileEntry.getAttributes().put("AN", "2.0"); fileEntry.getAttributes().put("do.we.accept.attribute.with.dots?", "yes"); studyEntry.setFiles(Collections.singletonList(fileEntry)); studyEntry.setFormatAsString("GT");
studyEntry = new StudyEntry(fileId.toString(), studyId.toString()); FileEntry fileEntry = studyEntry.getFile(fileId.toString()); fileEntry.getAttributes().put("QUAL", "0.01"); fileEntry.getAttributes().put("AN", "2"); fileEntry.setCall(null); studyEntry.setFormatAsString("GT:DP");
@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()); } }
se.setSecondaryAlternates(new ArrayList<>()); for (FileEntry fe : se.getFiles()) { Map<String, String> feAttr = fe.getAttributes(); if (null == feAttr) { feAttr = new HashMap<>(); fe.setAttributes(feAttr);