Always use phasing info when converting genotypes to strings
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@3482 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
e2b41082af
commit
597b3744ab
|
|
@ -10,6 +10,10 @@ import java.util.*;
|
||||||
* @author Mark DePristo
|
* @author Mark DePristo
|
||||||
*/
|
*/
|
||||||
public class Genotype {
|
public class Genotype {
|
||||||
|
|
||||||
|
public final static String PHASED_ALLELE_SEPARATOR = "|";
|
||||||
|
public final static String UNPHASED_ALLELE_SEPARATOR = "/";
|
||||||
|
|
||||||
protected InferredGeneticContext commonInfo;
|
protected InferredGeneticContext commonInfo;
|
||||||
public final static double NO_NEG_LOG_10PERROR = InferredGeneticContext.NO_NEG_LOG_10PERROR;
|
public final static double NO_NEG_LOG_10PERROR = InferredGeneticContext.NO_NEG_LOG_10PERROR;
|
||||||
protected List<Allele> alleles = new ArrayList<Allele>();
|
protected List<Allele> alleles = new ArrayList<Allele>();
|
||||||
|
|
@ -50,20 +54,6 @@ public class Genotype {
|
||||||
return alleles.get(i);
|
return alleles.get(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
private final static String ALLELE_SEPARATOR = "/";
|
|
||||||
|
|
||||||
public String getGenotypeString() {
|
|
||||||
return Utils.join(ALLELE_SEPARATOR, getAllelesString());
|
|
||||||
}
|
|
||||||
|
|
||||||
private List<String> getAllelesString() {
|
|
||||||
List<String> al = new ArrayList<String>();
|
|
||||||
for ( Allele a : alleles )
|
|
||||||
al.add(new String(a.getBases()));
|
|
||||||
|
|
||||||
return al;
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean genotypesArePhased() { return genotypesArePhased; }
|
public boolean genotypesArePhased() { return genotypesArePhased; }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
@ -126,19 +116,33 @@ public class Genotype {
|
||||||
throw new IllegalArgumentException("BUG: alleles include some No Calls and some Calls, an illegal state " + this);
|
throw new IllegalArgumentException("BUG: alleles include some No Calls and some Calls, an illegal state " + this);
|
||||||
}
|
}
|
||||||
|
|
||||||
private String haplotypesString() {
|
public String getGenotypeString() {
|
||||||
if ( genotypesArePhased() )
|
return getGenotypeString(true);
|
||||||
return Utils.join("|", getAlleles());
|
}
|
||||||
else
|
|
||||||
return Utils.join("/", Utils.sorted(getAlleles()));
|
public String getGenotypeString(boolean ignoreRefState) {
|
||||||
|
// Notes:
|
||||||
|
// 1. Make sure to use the appropriate separator depending on whether the genotype is phased
|
||||||
|
// 2. If ignoreRefState is true, then we want just the bases of the Alleles (ignoring the '*' indicating a ref Allele)
|
||||||
|
// 3. So that everything is deterministic with regards to integration tests, we sort Alleles (when the genotype isn't phased, of course)
|
||||||
|
return Utils.join(genotypesArePhased() ? PHASED_ALLELE_SEPARATOR : UNPHASED_ALLELE_SEPARATOR,
|
||||||
|
ignoreRefState ? getAlleleStrings() : (genotypesArePhased() ? getAlleles() : Utils.sorted(getAlleles())));
|
||||||
|
}
|
||||||
|
|
||||||
|
private List<String> getAlleleStrings() {
|
||||||
|
List<String> al = new ArrayList<String>();
|
||||||
|
for ( Allele a : alleles )
|
||||||
|
al.add(new String(a.getBases()));
|
||||||
|
|
||||||
|
return al;
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.format("[GT: %s %s %s Q%.2f %s]", getSampleName(), haplotypesString(), getType(), getPhredScaledQual(), Utils.sortedString(getAttributes()));
|
return String.format("[GT: %s %s %s Q%.2f %s]", getSampleName(), getGenotypeString(false), getType(), getPhredScaledQual(), Utils.sortedString(getAttributes()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public String toBriefString() {
|
public String toBriefString() {
|
||||||
return String.format("%s:Q%.2f", haplotypesString(), getPhredScaledQual());
|
return String.format("%s:Q%.2f", getGenotypeString(false), getPhredScaledQual());
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean sameGenotype(Genotype other) {
|
public boolean sameGenotype(Genotype other) {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue