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 static String[] getOri(StudyEntry studyEntry) { List<FileEntry> files = studyEntry.getFiles(); Set<String> calls = new HashSet<>(); String call = null; if (!files.isEmpty()) { for (FileEntry file : files) { call = file.getCall(); // if (call != null) { calls.add(call); // } } } if (calls.size() == 1 && StringUtils.isNotEmpty(call)) { // Return this CALL only if all the files have the same one return calls.iterator().next().split(":"); } return null; }
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; }
@Override protected void parseStats(Variant variant, StudyEntry study, int numAllele, String reference, String[] alternateAlleles, Map<String, String> info) { FileEntry fileEntry = study.getFiles().get(0); // EVS params are not rearranged when normalizing. Use original call if (fileEntry.getCall() != null && !fileEntry.getCall().isEmpty()) { String[] ori = fileEntry.getCall().split(":"); numAllele = Integer.parseInt(ori[3]); alternateAlleles = ori[2].split(","); reference = ori[1]; } VariantStats stats = new VariantStats(); if (info.containsKey("MAF")) { String splitsMAF[] = info.get("MAF").split(","); if (splitsMAF.length == 3) { float maf = Float.parseFloat(splitsMAF[2]) / 100; stats.setMaf(maf); } } if (info.containsKey("GTS") && info.containsKey("GTC")) { String splitsGTC[] = info.get("GTC").split(","); addGenotypeWithGTS(study.getAttributes(), splitsGTC, reference, alternateAlleles, numAllele, stats); } study.setStats(StudyEntry.DEFAULT_COHORT, stats); }
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; }
private boolean samePhase(Variant variant1, Variant variant2) { if (variant1.getStudies() != null && !variant1.getStudies().isEmpty()) { if (variant2.getStudies() != null && !variant2.getStudies().isEmpty()) { int psIdx1 = variant1.getStudies().get(0).getFormat().indexOf("PS"); if (psIdx1 != -1) { int psIdx2 = variant2.getStudies().get(0).getFormat().indexOf("PS"); if (psIdx2 != -1 && // variant2 does have PS set // same phase set value in both variants variant2.getStudies().get(0).getSamplesData().get(0).get(psIdx2) .equals(variant1.getStudies().get(0).getSamplesData().get(0).get(psIdx1)) // Same genotype call in both variants (e.g. 1|0=1|0). // WARNING: assuming variant1 and variant2 do have Files. && variant1.getStudies().get(0).getFiles().get(0).getCall() .equals(variant2.getStudies().get(0).getFiles().get(0).getCall())) { return true; } } } } return false; }
private boolean samePhase(Variant variant1, Variant variant2) { if (variant1.getStudies() != null && !variant1.getStudies().isEmpty()) { if (variant2.getStudies() != null && !variant2.getStudies().isEmpty()) { int psIdx1 = variant1.getStudies().get(0).getFormat().indexOf("PS"); if (psIdx1 != -1) { int psIdx2 = variant2.getStudies().get(0).getFormat().indexOf("PS"); if (psIdx2 != -1 && // variant2 does have PS set // same phase set value in both variants variant2.getStudies().get(0).getSamplesData().get(0).get(psIdx2) .equals(variant1.getStudies().get(0).getSamplesData().get(0).get(psIdx1)) // Same genotype call in both variants (e.g. 1|0=1|0). // WARNING: assuming variant1 and variant2 do have Files. && variant1.getStudies().get(0).getFiles().get(0).getCall() .equals(variant2.getStudies().get(0).getFiles().get(0).getCall())) { return true; } } } } return false; }
String call = studyEntry.getFile(Integer.toString(fileId)).getCall(); if (call != null && !call.isEmpty()) { int indexOf = call.lastIndexOf(":");
int numAllele, String reference, String[] alternateAlleles, Map<String, String> info) { FileEntry fileEntry = studyEntry.getFiles().get(0); if (fileEntry.getCall() != null && !fileEntry.getCall().isEmpty()) { String[] ori = fileEntry.getCall().split(":"); numAllele = Integer.parseInt(ori[3]); alternateAlleles = ori[2].split(",");
if (!current.toString().equals(other.toString())) { for (FileEntry file : files) { if (StringUtils.isEmpty(file.getCall())) { file.setCall(call);
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)); } } } } }
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));
if (StringUtils.isEmpty(fileEntry.getCall())) { fileEntry.setCall(archiveVariant.getStart() + ":" + archiveVariant.getReference() + ":" + archiveVariant.getAlternate() + ":0");
.map(StudyEntry::getFiles) .flatMap(Collection::stream) .filter(fileEntry -> sameVariant(variant, fileEntry.getCall())) .map(FileEntry::getFileId) .collect(Collectors.toSet());
System.out.println(); Collection<Variant> resolved = new VariantLocalConflictResolver().resolveConflicts(variants); resolved.forEach(res -> System.out.println("res = " + res.toString() + " call: " + res.getStudies().get(0).getFiles().get(0).getCall()));
.map(StudyEntry::getFiles) .flatMap(Collection::stream) .filter(fileEntry -> sameVariant(variant, fileEntry.getCall())) .map(FileEntry::getFileId) .anyMatch(fileName1::equals)) {
}); for (FileEntry fileEntry : loadedStudy.getFiles()) { if(StringUtils.isEmpty(fileEntry.getCall())) { fileEntry.setCall(null);