
org.opencb.biodata.tools.variant.tasks.VariantStatsTask Maven / Gradle / Ivy
/*
*
*
*/
package org.opencb.biodata.tools.variant.tasks;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import org.opencb.biodata.formats.variant.io.VariantReader;
import org.opencb.biodata.models.variant.StudyEntry;
import org.opencb.biodata.models.variant.Variant;
import org.opencb.biodata.models.variant.VariantSource;
import org.opencb.biodata.models.variant.stats.VariantSourceStats;
import org.opencb.biodata.models.variant.stats.VariantStats;
import org.opencb.biodata.tools.variant.stats.VariantAggregatedEVSStatsCalculator;
import org.opencb.biodata.tools.variant.stats.VariantAggregatedExacStatsCalculator;
import org.opencb.biodata.tools.variant.stats.VariantAggregatedStatsCalculator;
import org.opencb.biodata.tools.variant.stats.VariantStatsCalculator;
import org.opencb.commons.run.Task;
/**
* @author Alejandro Aleman Ramos <[email protected]>
* @author Cristina Yenyxe Gonzalez Garcia <[email protected]>
*/
public class VariantStatsTask extends Task {
@Deprecated
private VariantReader reader;
private VariantSource source;
private VariantSourceStats stats;
public VariantStatsTask(VariantSource study) {
super();
this.source = study;
stats = new VariantSourceStats(study.getFileId(), study.getStudyId());
}
public VariantStatsTask(VariantReader reader, VariantSource study) {
super();
this.reader = reader;
this.source = study;
stats = new VariantSourceStats(study.getFileId(), study.getStudyId());
}
public VariantStatsTask(VariantReader reader, VariantSource study, int priority) {
super(priority);
this.reader = reader;
this.source = study;
stats = new VariantSourceStats(study.getFileId(), study.getStudyId());
}
@Override
public boolean apply(List batch) {
// VariantStats.calculateStatsForVariantsList(batch, source.getPedigree());
for (Variant variant : batch) {
for (StudyEntry study : variant.getSourceEntries().values()) {
VariantStats variantStats = new VariantStats(variant);
study.setStats(StudyEntry.DEFAULT_COHORT, variantStats);
Map attributes = study.getFile(source.getFileId()).getAttributes();
switch (source.getAggregation()) {
case NONE:
VariantStatsCalculator.calculate(study, attributes, source.getPedigree(), variantStats);
break;
case BASIC:
new VariantAggregatedStatsCalculator().calculate(variant, study);
break;
case EVS:
new VariantAggregatedEVSStatsCalculator().calculate(variant, study);
break;
case EXAC:
new VariantAggregatedExacStatsCalculator().calculate(variant, study);
break;
}
}
}
stats.updateFileStats(batch);
stats.updateSampleStats(batch, source.getPedigree());
return true;
}
@Override
public boolean post() {
source.setStats(stats.getFileStats());
return true;
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy