2010-01-30 06:50:03 +08:00
|
|
|
package org.broadinstitute.sting.oneoffprojects.refdata;
|
2010-01-29 23:19:50 +08:00
|
|
|
|
2010-01-30 06:50:03 +08:00
|
|
|
import org.broadinstitute.sting.gatk.refdata.BasicReferenceOrderedDatum;
|
|
|
|
|
import org.broadinstitute.sting.gatk.refdata.RodVCF;
|
|
|
|
|
import org.broadinstitute.sting.gatk.refdata.VariationRod;
|
2010-01-29 23:19:50 +08:00
|
|
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
|
|
|
|
import org.broadinstitute.sting.utils.StingException;
|
|
|
|
|
import org.broadinstitute.sting.utils.genotype.DiploidGenotype;
|
|
|
|
|
import org.broadinstitute.sting.utils.genotype.Genotype;
|
|
|
|
|
import org.broadinstitute.sting.utils.genotype.Variation;
|
|
|
|
|
import org.broadinstitute.sting.utils.genotype.vcf.VCFHeader;
|
|
|
|
|
import org.broadinstitute.sting.utils.genotype.vcf.VCFReader;
|
|
|
|
|
import org.broadinstitute.sting.utils.genotype.vcf.VCFRecord;
|
|
|
|
|
|
|
|
|
|
import java.io.File;
|
|
|
|
|
import java.io.FileNotFoundException;
|
|
|
|
|
import java.util.Iterator;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
|
2010-01-30 06:50:03 +08:00
|
|
|
/*
|
2010-01-29 23:19:50 +08:00
|
|
|
* Created by IntelliJ IDEA.
|
|
|
|
|
* User: chartl
|
|
|
|
|
* Date: Jan 29, 2010
|
|
|
|
|
*/
|
2010-04-17 02:59:29 +08:00
|
|
|
public class HapmapVCFROD extends BasicReferenceOrderedDatum implements VariationRod, Iterator<HapmapVCFROD> {
|
2010-01-29 23:19:50 +08:00
|
|
|
// This is a (hopefully temporary) wrapper class for certain VCF files that we want to protect from
|
|
|
|
|
// utilities that grab genotypes or sample names across all VCF files
|
|
|
|
|
|
|
|
|
|
private RodVCF rod;
|
|
|
|
|
|
|
|
|
|
public VCFReader getReader() {
|
|
|
|
|
return rod.getReader();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public VCFRecord getRecord() {
|
|
|
|
|
return rod.getRecord();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HapmapVCFROD(String name) {
|
|
|
|
|
super(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HapmapVCFROD(String name, VCFRecord currentRecord, VCFReader reader) {
|
|
|
|
|
super(name);
|
|
|
|
|
rod = new RodVCF(name,currentRecord,reader);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HapmapVCFROD(String name, RodVCF rod) {
|
|
|
|
|
super(name);
|
|
|
|
|
this.rod = rod;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Object initialize(final File source) throws FileNotFoundException {
|
|
|
|
|
rod = new RodVCF(name);
|
|
|
|
|
rod.initialize(source);
|
|
|
|
|
return rod.getHeader();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean parseLine(Object obj, String[] args) {
|
|
|
|
|
try {
|
|
|
|
|
return rod.parseLine(obj,args);
|
|
|
|
|
} catch (Exception e) {
|
|
|
|
|
throw new UnsupportedOperationException("Parse line not supported",e);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double getNegLog10PError() {
|
|
|
|
|
return rod.getNegLog10PError();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<Genotype> getGenotypes() {
|
2010-03-09 11:41:07 +08:00
|
|
|
return null;
|
|
|
|
|
//return rod.getGenotypes();
|
2010-01-29 23:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getReference() {
|
|
|
|
|
return rod.getReference();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
|
return rod.toString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getAlternateAlleleList() {
|
|
|
|
|
return rod.getAlternateAlleleList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isDeletion() {
|
|
|
|
|
return rod.isDeletion();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GenomeLoc getLocation() {
|
|
|
|
|
return rod.getLocation();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isBiallelic() {
|
|
|
|
|
return rod.isBiallelic();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isIndel() {
|
|
|
|
|
return rod.isIndel();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Variation.VARIANT_TYPE getType() {
|
|
|
|
|
return rod.getType();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isSNP() {
|
|
|
|
|
return rod.isSNP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isReference() {
|
|
|
|
|
return rod.isReference();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public double getNonRefAlleleFrequency() {
|
|
|
|
|
return rod.getNonRefAlleleFrequency();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public char getAlternativeBaseForSNP() {
|
|
|
|
|
return rod.getAlternativeBaseForSNP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean isInsertion() {
|
|
|
|
|
return rod.isInsertion();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getAlleleList() {
|
|
|
|
|
return rod.getAlleleList();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public Genotype getCalledGenotype() {
|
2010-03-09 11:41:07 +08:00
|
|
|
return null;
|
|
|
|
|
//return rod.getCalledGenotype();
|
2010-01-29 23:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public char getReferenceForSNP() {
|
|
|
|
|
return rod.getReferenceForSNP();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasGenotype(DiploidGenotype g) {
|
2010-03-09 11:41:07 +08:00
|
|
|
return false;
|
|
|
|
|
//return rod.hasGenotype(g);
|
2010-01-29 23:19:50 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public VCFHeader getHeader() {
|
|
|
|
|
return rod.getHeader();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public boolean hasNext() {
|
|
|
|
|
return rod.hasNext();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public HapmapVCFROD next() {
|
|
|
|
|
return new HapmapVCFROD(name,rod.next());
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void remove() {
|
|
|
|
|
rod.remove();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static HapmapVCFROD createIterator(String name, File file) {
|
|
|
|
|
RodVCF vcf = new RodVCF(name);
|
|
|
|
|
try {
|
|
|
|
|
vcf.initialize(file);
|
|
|
|
|
} catch (FileNotFoundException e) {
|
|
|
|
|
throw new StingException("Unable to find file " + file);
|
|
|
|
|
}
|
|
|
|
|
return new HapmapVCFROD(name,vcf);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|