} catch (UnsupportedOperationException e) { study.setFiles(new LinkedList<>(study.getFiles())); study.getFiles().addAll(files);
study.setFiles(files);
/** * Create an empty Variant (position, ref, alt) from a template with basic Study information without samples. * @param target Variant to take as a template * @return Variant filled with chromosome, start, end, ref, alt, study ID and format set to GT only, BUT no samples. */ public Variant createFromTemplate(Variant target) { Variant var = new Variant(target.getChromosome(), target.getStart(), target.getEnd(), target.getReference(), target.getAlternate()); var.setType(target.getType()); for(StudyEntry tse : target.getStudies()){ StudyEntry se = new StudyEntry(tse.getStudyId()); se.setFiles(Collections.singletonList(new FileEntry("", "", new HashMap<>()))); se.setFormat(Arrays.asList(getGtKey(), getFilterKey())); se.setSamplesPosition(new HashMap<>()); se.setSamplesData(new ArrayList<>()); var.addStudyEntry(se); } return var; }
if (fileId != null) { FileEntry fileEntry = new FileEntry(fileId, call, attributes); studyEntry.setFiles(Collections.singletonList(fileEntry));
public static Variant getVariant(String var) { Variant v = new Variant(var); StudyEntry sb = new StudyEntry("1", "1"); String call = v.getStart() + ":" + v.getReference() + ":" + v.getAlternate() + ":" + 0; sb.setFiles(Collections.singletonList(new FileEntry("1", "", new HashMap<>()))); v.setStudies(Collections.singletonList(sb)); if (v.getAlternate().contains(",")) { String[] alternates = v.getAlternate().split(","); v.setAlternate(alternates[0]); for (int i = 1; i < alternates.length; i++) { v.getStudies().get(0).getSecondaryAlternates().add(new AlternateCoordinate(null, null, null, null, alternates[i], null)); } } return v; }
files.add(new FileEntry(file.getFileId(), file.getCall(), attributes)); se.setFiles(files);
studyEntry.setFiles(Collections.singletonList(new FileEntry(keyFields.getPhaseSet(), call, null))); normalizedVariant.setStudies(Collections.singletonList(studyEntry)); files.add(new FileEntry(file.getFileId(), sameVariant ? null : call, attributes)); normalizedEntry.setFiles(files); normalizedVariant.addStudyEntry(normalizedEntry); samplesData = newSamplesData(entry.getSamplesData().size(), entry.getFormat().size()); if (!normalizedEntry.getFiles().isEmpty()) { List<FileEntry> files = normalizeFilesInfo(normalizedEntry.getFiles(), rearranger); normalizedEntry.setFiles(files); normalizedEntry.setFiles(Collections.singletonList(new FileEntry(keyFields.getPhaseSet(), call, null)));
fileEntry.getAttributes().put("AN", "2.0"); fileEntry.getAttributes().put("do.we.accept.attribute.with.dots?", "yes"); studyEntry.setFiles(Collections.singletonList(fileEntry)); studyEntry.setFormatAsString("GT");
files.add(new FileEntry(id.toString(), "", Collections.emptyMap())); st.setFiles(files); }); variants.add(variant);
se.setFiles(Collections.singletonList(new FileEntry("1", "", new HashMap<>()))); v1.setStudies(Collections.singletonList(se)); se.setFormat(Arrays.asList(GENOTYPE_KEY, GENOTYPE_FILTER_KEY)); se.setFiles(Collections.singletonList(new FileEntry("1", "", new HashMap<>()))); v2.setStudies(Collections.singletonList(se)); se.setSamplesPosition(asMap("S1", 0));
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; }