public List<String> getSampleIds() { return impl.getSampleIds() == null ? null : Collections.unmodifiableList(impl.getSampleIds()); }
public VariantFileMetadata addSampleIds(List<String> newSampleIds) { impl.getSampleIds().addAll(newSampleIds); samplesPosition = null; return this; }
/** * Print to the standard output a summary of the variant metadata manager. * * @throws IOException IOException */ public void printSummary() { StringBuilder res = new StringBuilder(); res.append("Num. studies: ").append(variantMetadata.getStudies().size()).append("\n"); int counter, studyCounter = 0; for (VariantStudyMetadata study: variantMetadata.getStudies()) { studyCounter++; res.append("\tStudy #").append(studyCounter).append(": ").append(study.getId()).append("\n"); res.append("\tNum. files: ").append(study.getFiles().size()).append("\n"); counter = 0; for (VariantFileMetadata file: study.getFiles()) { counter++; res.append("\t\tFile #").append(counter).append(": ").append(file.getId()); res.append(" (").append(file.getSampleIds().size()).append(" samples)\n"); } res.append("\tNum. cohorts: ").append(study.getCohorts().size()).append("\n"); counter = 0; for (Cohort cohort: study.getCohorts()) { counter++; res.append("\t\tCohort #").append(counter).append(": ").append(cohort.getId()); res.append(" (").append(cohort.getSampleIds().size()).append(" samples)\n"); } } System.out.println(res.toString()); }
public VcfSliceToVariantListConverter(VariantStudyMetadata metadata) { this(VariantFileMetadata.getSamplesPositionMap(metadata.getFiles().get(0).getSampleIds()), metadata.getFiles().get(0).getId(), metadata.getId()); }
/** * Calculate global statistics for the whole study. i.e. cohort ALL * @param metadata VariantStudyMetadata */ public VariantSetStatsCalculator(VariantStudyMetadata metadata) { this.studyId = metadata.getId(); this.metadata = metadata; files = metadata.getFiles() .stream() .map(org.opencb.biodata.models.variant.metadata.VariantFileMetadata::getId) .collect(Collectors.toSet()); samples = metadata.getFiles() .stream() .flatMap(fileMetadata -> fileMetadata.getSampleIds().stream()) .collect(Collectors.toSet()); header = metadata.getAggregatedHeader(); stats = new VariantSetStats(); if (metadata.getStats() == null) { metadata.setStats(new VariantStudyStats(new HashMap<>(), new HashMap<>())); } if (metadata.getStats().getCohortStats() == null) { metadata.getStats().setCohortStats(new HashMap<>()); } metadata.getStats().getCohortStats().put(StudyEntry.DEFAULT_COHORT, stats.getImpl()); }
for (String sampleId: fileMetadata.getSampleIds()) { for (org.opencb.biodata.models.metadata.Individual individual: variantStudyMetadata.getIndividuals()) { for (Sample sample: individual.getSamples()) { for (String sampleId: fileMetadata.getSampleIds()) { List<Sample> samples = new ArrayList<>(); Sample sample = new Sample();
public List<StudyConfiguration> toStudyConfigurations(VariantMetadata variantMetadata) { List<StudyConfiguration> studyConfigurations = new ArrayList<>(variantMetadata.getStudies().size()); int id = 1; VariantMetadataManager metadataManager = new VariantMetadataManager().setVariantMetadata(variantMetadata); for (VariantStudyMetadata studyMetadata : variantMetadata.getStudies()) { StudyConfiguration sc = new StudyConfiguration(id++, studyMetadata.getId()); studyConfigurations.add(sc); List<Sample> samples = metadataManager.getSamples(studyMetadata.getId()); for (Sample sample : samples) { sc.getSampleIds().put(sample.getId(), id++); } for (VariantFileMetadata fileMetadata : studyMetadata.getFiles()) { int fileId = id++; sc.getIndexedFiles().add(fileId); sc.getFileIds().put(fileMetadata.getPath(), fileId); List<Integer> sampleIds = toSampleIds(sc, fileMetadata.getSampleIds()); sc.getSamplesInFiles().put(fileId, new LinkedHashSet<>(sampleIds)); } for (Cohort cohort : studyMetadata.getCohorts()) { int cohortId = id++; sc.getCohortIds().put(cohort.getId(), cohortId); sc.getCalculatedStats().add(cohortId); sc.getCohorts().put(cohortId, new HashSet<>(toSampleIds(sc, cohort.getSampleIds()))); } sc.setVariantHeader(studyMetadata.getAggregatedHeader()); sc.setAggregation(studyMetadata.getAggregation()); studyMetadata.getAttributes().forEach(sc.getAttributes()::put); } return studyConfigurations; }