All Downloads are FREE. Search and download functionalities are using the official Maven repository.

org.opencb.biodata.tools.variant.tasks.VariantRunner Maven / Gradle / Ivy

There is a newer version: 3.4.0
Show newest version
/*
 * 
 *
 */

package org.opencb.biodata.tools.variant.tasks;

import java.util.List;
import org.opencb.biodata.formats.pedigree.io.PedigreeReader;
import org.opencb.biodata.formats.variant.io.VariantReader;
import org.opencb.biodata.formats.variant.io.VariantWriter;
import org.opencb.biodata.models.variant.Variant;
import org.opencb.biodata.models.variant.VariantSource;
import org.opencb.biodata.tools.variant.VariantFileUtils;
import org.opencb.commons.run.Runner;
import org.opencb.commons.run.Task;
/**
 * @author Alejandro Aleman Ramos <[email protected]>
 * @author Cristina Yenyxe Gonzalez Garcia <[email protected]>
 */
public class VariantRunner extends Runner {

    protected VariantSource source;

    public VariantRunner(VariantSource study, VariantReader reader, PedigreeReader pedReader, 
            List writer, List> tasks) {
        super(reader, writer, tasks);
        this.source = study;
        parsePhenotypes(pedReader);
    }

    public VariantRunner(VariantSource study, VariantReader reader, PedigreeReader pedReader, 
            List writer, List> tasks, int batchSize) {
        super(reader, writer, tasks, batchSize);
        this.source = study;
        parsePhenotypes(pedReader);
    }

    private void parsePhenotypes(PedigreeReader pedReader) {
        if (pedReader != null) {
            pedReader.open();
            source.setPedigree(pedReader.read().get(0));
            pedReader.close();
        }
    }

    public VariantSource getStudy() {
        return source;
    }

    public void setStudy(VariantSource study) {
        this.source = study;
    }

    @Override
    protected void readerInit() {
        super.readerInit();
        source.addMetadata(VariantFileUtils.VARIANT_FILE_HEADER, ((VariantReader) reader).getHeader());
    }

}




© 2015 - 2025 Weber Informatics LLC | Privacy Policy