convenience method to deal with genotypes that are unsorted (e.g. CA vs. AC)
git-svn-id: file:///humgen/gsa-scr1/gsa-engineering/svn_contents/trunk@1997 348d0f76-0448-11de-a6fe-93d51630548a
This commit is contained in:
parent
7fde6c0bf4
commit
cff645e98b
|
|
@ -61,4 +61,17 @@ public enum DiploidGenotype {
|
||||||
public static DiploidGenotype createHomGenotype(char hom) {
|
public static DiploidGenotype createHomGenotype(char hom) {
|
||||||
return DiploidGenotype.valueOf((String.valueOf(hom) + String.valueOf(hom)).toUpperCase());
|
return DiploidGenotype.valueOf((String.valueOf(hom) + String.valueOf(hom)).toUpperCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* get the genotype, given a string of 2 chars which may not necessarily be ordered correctly
|
||||||
|
* @param genotype the string representation
|
||||||
|
* @return the diploid genotype
|
||||||
|
*/
|
||||||
|
public static DiploidGenotype unorderedValueOf(String genotype) {
|
||||||
|
if ( genotype == null || genotype.length() != 2 )
|
||||||
|
throw new IllegalArgumentException("Diploid genotypes are represented by 2 characters");
|
||||||
|
if ( genotype.charAt(0) > genotype.charAt(1) )
|
||||||
|
genotype = String.format("%c%c", genotype.charAt(1), genotype.charAt(0));
|
||||||
|
return valueOf(genotype);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
Loading…
Reference in New Issue