2009-07-17 22:36:12 +08:00
|
|
|
package org.broadinstitute.sting.gatk.refdata;
|
|
|
|
|
|
|
|
|
|
import org.broadinstitute.sting.utils.GenomeLoc;
|
|
|
|
|
import org.broadinstitute.sting.utils.GenomeLocParser;
|
|
|
|
|
|
|
|
|
|
import java.util.*;
|
|
|
|
|
|
2009-07-28 11:25:03 +08:00
|
|
|
public class SimpleIndelROD extends TabularROD implements Genotype, AllelicVariant {
|
|
|
|
|
|
|
|
|
|
private boolean KGENOMES_FORMAT = false, checkedFormat = false;
|
2009-07-17 22:36:12 +08:00
|
|
|
|
|
|
|
|
public SimpleIndelROD(String name) {
|
|
|
|
|
super(name);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public GenomeLoc getLocation() {
|
|
|
|
|
return GenomeLocParser.createGenomeLoc(this.get("0"), Long.parseLong(this.get("1")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public List<String> getFWDAlleles() {
|
2009-07-28 11:25:03 +08:00
|
|
|
if ( is1KGFormat() )
|
|
|
|
|
return Arrays.asList(this.get("4"));
|
|
|
|
|
|
2009-07-17 22:36:12 +08:00
|
|
|
String str = this.get("3");
|
|
|
|
|
return Arrays.asList(str.substring(0, str.indexOf(":")));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public String getFWDRefBases() { return ""; }
|
2009-07-28 11:25:03 +08:00
|
|
|
public String getAltBasesFWD() { return getFWDAlleles().get(0); }
|
|
|
|
|
public String getRefBasesFWD() { return ""; }
|
|
|
|
|
public char getRefSnpFWD() { throw new IllegalStateException("I'm an indel, not a SNP"); }
|
|
|
|
|
public char getAltSnpFWD() { throw new IllegalStateException("I'm an indel, not a SNP"); }
|
2009-07-17 22:36:12 +08:00
|
|
|
public char getRef() { return 'N'; }
|
2009-07-28 11:25:03 +08:00
|
|
|
public List<String> getGenotype() { return getFWDAlleles(); }
|
|
|
|
|
public boolean isGenotype() { return false; }
|
2009-07-17 22:36:12 +08:00
|
|
|
public boolean isPointGenotype() { return false; }
|
|
|
|
|
public boolean isIndelGenotype() { return true; }
|
|
|
|
|
public boolean isSNP() { return false; }
|
|
|
|
|
public boolean isReference() { return false; }
|
2009-07-28 11:25:03 +08:00
|
|
|
public boolean isInsertion() {
|
|
|
|
|
if ( is1KGFormat() )
|
|
|
|
|
return this.get("3").equals("I");
|
|
|
|
|
return this.get("3").charAt(0) == '+';
|
|
|
|
|
}
|
|
|
|
|
public boolean isDeletion() {
|
|
|
|
|
if ( is1KGFormat() )
|
|
|
|
|
return this.get("3").equals("D");
|
|
|
|
|
return this.get("3").charAt(0) == '-';
|
|
|
|
|
}
|
|
|
|
|
public boolean isIndel() { return true; }
|
2009-07-17 22:36:12 +08:00
|
|
|
public double getVariantConfidence() { return 0.0; }
|
2009-07-28 11:25:03 +08:00
|
|
|
public double getVariationConfidence() { return 0.0; }
|
2009-07-17 22:36:12 +08:00
|
|
|
public double getConsensusConfidence() { return 0.0; }
|
|
|
|
|
public boolean isBiallelic() { return true; }
|
|
|
|
|
public boolean isHom() { return false; }
|
|
|
|
|
public boolean isHet() { return false; }
|
2009-07-28 11:25:03 +08:00
|
|
|
public double getHeterozygosity() { return 0.0; }
|
|
|
|
|
public double getMAF() { return 0.0; }
|
|
|
|
|
public int getPloidy() { return 2; }
|
|
|
|
|
public int length() {
|
|
|
|
|
if ( is1KGFormat() )
|
|
|
|
|
return Integer.parseInt(this.get("2"));
|
|
|
|
|
return getFWDAlleles().get(0).length();
|
|
|
|
|
}
|
2009-07-17 22:36:12 +08:00
|
|
|
|
|
|
|
|
public String toString() {
|
|
|
|
|
StringBuffer sb = new StringBuffer();
|
2009-07-17 23:59:18 +08:00
|
|
|
sb.append(getLocation().getContig() + "\t" + getLocation().getStart() + "\t");
|
|
|
|
|
String indel = getFWDAlleles().get(0);
|
|
|
|
|
sb.append((indel.length()-1) + "\t" + (isInsertion() ? "I" : "D") + "\t" + indel.substring(1));
|
2009-07-17 22:36:12 +08:00
|
|
|
return sb.toString();
|
|
|
|
|
}
|
2009-07-28 11:25:03 +08:00
|
|
|
|
|
|
|
|
private boolean is1KGFormat() {
|
|
|
|
|
if ( !checkedFormat ) {
|
|
|
|
|
checkedFormat = true;
|
|
|
|
|
KGENOMES_FORMAT = this.get("3").equals("D") || this.get("3").equals("I");
|
|
|
|
|
}
|
|
|
|
|
return KGENOMES_FORMAT;
|
|
|
|
|
}
|
2009-07-17 22:36:12 +08:00
|
|
|
}
|