public Map<String, StudyEntry> getStudiesMap() { if (impl.getStudies() != null) { if (studyEntries == null) { studyEntries = new HashMap<>(impl.getStudies().size()); } if (studyEntries.size() != impl.getStudies().size()) { for (org.opencb.biodata.models.variant.avro.StudyEntry studyEntry : impl.getStudies()) { studyEntries.putIfAbsent(studyEntry.getStudyId(), new StudyEntry(studyEntry)); } } return Collections.unmodifiableMap(studyEntries); } return null; }
protected StudyEntry newStudyEntry(StudyConfiguration studyConfiguration, List<String> fixedFormat) { StudyEntry studyEntry; if (studyNameAsStudyId) { studyEntry = new StudyEntry(studyConfiguration.getStudyName()); } else { studyEntry = new StudyEntry(String.valueOf(studyConfiguration.getStudyId())); } if (expectedFormat == null) { studyEntry.setFormat(new ArrayList<>(fixedFormat)); } else { studyEntry.setFormat(new ArrayList<>(expectedFormat)); } LinkedHashMap<String, Integer> returnedSamplesPosition; if (mutableSamplesPosition) { returnedSamplesPosition = new LinkedHashMap<>(getReturnedSamplesPosition(studyConfiguration)); } else { returnedSamplesPosition = getReturnedSamplesPosition(studyConfiguration); } studyEntry.setSamplesData(new ArrayList<>(returnedSamplesPosition.size())); studyEntry.setSortedSamplesPosition(returnedSamplesPosition); return studyEntry; }
.map(a -> new AlternateCoordinate(chromosome, null, null, null, a, null)) .collect(Collectors.toList()); StudyEntry entry = new StudyEntry(metadata.getId(), secondaryAlternatesMap, Arrays.asList(format.split(":"))); VariantFileMetadata fileMetadata = new VariantFileMetadata(metadata.getFiles().get(0)); entry.setFileId(fileMetadata.getId());
/** * @param n * @return studyEntryList */ public List<StudyEntry> getStudies(int n) { int studyID = 2; int fieldID = 3; List<StudyEntry> studyEntryList = new ArrayList<>(); StudyEntry studyEntry = new StudyEntry(); studyEntry.setStudyId(Integer.toString(studyID)); studyEntry.setFileId(Integer.toString(fieldID)); Map<String, String> attributes = genAttributes(); studyEntry.setAttributes(attributes); studyEntry.setFormat(getFormat()); List<List<String>> sampleList = new ArrayList<>(getFormat().size()); for (int i = 0; i < n; i++) { sampleList.add(getRandomample()); } studyEntry.setSamplesData(sampleList); studyEntryList.add(studyEntry); return studyEntryList; }
/** * 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; }
public void writeVariant(MongoDBVariantStageConverterTask converterTask, MongoDBVariantStageLoader loader, String variantStr) { Variant variant = new Variant(variantStr); variant.setNames(Collections.emptyList()); StudyEntry studyEntry = new StudyEntry("1", "1"); studyEntry.setFormat(Collections.emptyList()); variant.addStudyEntry(studyEntry); variantMap.put(variant.getChromosome(), variant); loader.write(converterTask.apply(Collections.singletonList(variant))); }
variant.getReference(), variant.getAlternate()); StudyEntry studyEntry = new StudyEntry(); studyEntry.setFormat(archiveVariant.getStudies().get(0).getFormat()); studyEntry.setSortedSamplesPosition(new LinkedHashMap<>());
variant.setSv(sv); if (hasStudyId()) { StudyEntry studyEntry = new StudyEntry(studyId); if (fileId != null) { FileEntry fileEntry = new FileEntry(fileId, call, attributes);
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; }
variant.getAlternate()); StudyEntry studyEntry = new StudyEntry(); studyEntry.setFormat(archiveVariant.getStudies().get(0).getFormat()); studyEntry.setSortedSamplesPosition(new LinkedHashMap<>());
StudyEntry se = new StudyEntry(); se.setStudyId(vse.getStudyId()); if (null != vse.getSamplesPosition()) {
StudyEntry se = new StudyEntry("1"); se.setFiles(Collections.singletonList(new FileEntry("1", "", new HashMap<>()))); v1.setStudies(Collections.singletonList(se)); se = new StudyEntry("1"); se.setFiles(Collections.singletonList(new FileEntry("1", "", new HashMap<>()))); v2.setStudies(Collections.singletonList(se));
StudyEntry st = new StudyEntry(sc.getStudyName(), Collections.emptyList(), Collections.singletonList("GT")); BiMap<Integer, String> samplesMap = sc.getSampleIds().inverse(); for (Integer sampleId : samples) {
studyEntry = new StudyEntry(studyId.toString()); FileEntry fileEntry = new FileEntry(fileId.toString(), null, new HashMap<>()); fileEntry.getAttributes().put("QUAL", "0.01");
@Test public void testConvertBasic() throws Exception { List<Pair<Integer, List<String>>> fixedValues = new ArrayList<>(); fixedValues.add(Pair.of(1, listOf("0/0", "PASS"))); fixedValues.add(Pair.of(3, listOf("0/1", "PASS"))); StudyEntry s = converter.convert(fixedValues, Collections.emptyList(), new Variant("1:1000:A:C"), 1); StudyEntry expected = new StudyEntry("1", Collections.emptyList(), listOf("GT", "FT")) .addSampleData("S1", listOf("0/0", "PASS")) .addSampleData("S2", listOf("?/?", ".")) .addSampleData("S3", listOf("0/1", "PASS")) .addSampleData("S4", listOf("?/?", ".")) .addSampleData("S5", listOf("?/?", ".")) .addSampleData("S6", listOf("?/?", ".")); Assert.assertEquals(s.toString(), expected, s); }
private Variant createVariantSecAlt(String varString, String secAlt) { Variant secAltVar = new Variant(secAlt); Variant variant = new Variant(varString); StudyEntry se = new StudyEntry("1"); AlternateCoordinate ac = new AlternateCoordinate( secAltVar.getChromosome(), secAltVar.getStart(), secAltVar.getEnd(), secAltVar.getReference(), secAltVar.getAlternate(), secAltVar.getType()); se.setSecondaryAlternates(Collections.singletonList(ac)); variant.setStudies(Collections.singletonList(se)); return variant; }
studyEntry = new StudyEntry(fileId.toString(), studyId.toString()); FileEntry fileEntry = studyEntry.getFile(fileId.toString()); fileEntry.getAttributes().put("QUAL", "0.01");
@Test public void testConvertExtendedFormat() throws Exception { sc.getAttributes().put(VariantStorageEngine.Options.EXTRA_GENOTYPE_FIELDS.key(), "AD,DP"); scm.updateStudyConfiguration(sc, null); List<Pair<Integer, List<String>>> fixedValues = new ArrayList<>(); fixedValues.add(Pair.of(1, listOf("0/0", "1,2", "10"))); fixedValues.add(Pair.of(3, listOf("0/1", "3,4", "20"))); StudyEntry s = converter.convert(fixedValues, Collections.emptyList(), new Variant("1:1000:A:C"), 1); StudyEntry expected = new StudyEntry("1", Collections.emptyList(), listOf("GT", "AD", "DP")) .addSampleData("S1", listOf("0/0", "1,2", "10")) .addSampleData("S2", listOf("?/?", ".", ".")) .addSampleData("S3", listOf("0/1", "3,4", "20")) .addSampleData("S4", listOf("?/?", ".", ".")) .addSampleData("S5", listOf("?/?", ".", ".")) .addSampleData("S6", listOf("?/?", ".", ".")); Assert.assertEquals(s.toString(), expected, s); }
StudyEntry expected = new StudyEntry("1", Collections.emptyList(), listOf("GT", "AD", "DP")) .addSampleData("S1", listOf("0/0", "1,2", "10")) .addSampleData("S2", listOf("1/1", "8,9", "70"))
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; }