use of org.dash.valid.Locus in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class DisequilibriumElementComparatorTest method testBaseComparison.
@Test
public void testBaseComparison() {
HashMap<Locus, List<String>> hlaElementMap = new HashMap<Locus, List<String>>();
List<String> val = new ArrayList<String>();
val.add("HLA-B*52:01");
hlaElementMap.put(Locus.HLA_B, val);
val = new ArrayList<String>();
val.add("HLA-C*04:01");
hlaElementMap.put(Locus.HLA_C, val);
BaseDisequilibriumElement element1 = new BaseDisequilibriumElement(hlaElementMap, "1", "Some note");
hlaElementMap = new HashMap<Locus, List<String>>();
val = new ArrayList<String>();
val.add("HLA-B*07:01");
hlaElementMap.put(Locus.HLA_B, val);
val = new ArrayList<String>();
val.add("HLA-C*01:01");
hlaElementMap.put(Locus.HLA_C, val);
BaseDisequilibriumElement element2 = new BaseDisequilibriumElement(hlaElementMap, "2", "Another note");
DisequilibriumElementComparator comparator = new DisequilibriumElementComparator();
assertTrue(comparator.compare(new DetectedDisequilibriumElement(element1), new DetectedDisequilibriumElement(element2)) > 0);
}
use of org.dash.valid.Locus in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class LinkageElementsMapTest method test.
@Test
public void test() {
List<FrequencyByRace> frequenciesByRace = new ArrayList<FrequencyByRace>();
FrequencyByRace freq = new FrequencyByRace(new Double(.2), "1", "AAFA");
frequenciesByRace.add(freq);
HashMap<Locus, List<String>> hlaElementMap = new HashMap<Locus, List<String>>();
List<String> val = new ArrayList<String>();
val.add("HLA-B*07:01");
hlaElementMap.put(Locus.HLA_B, val);
val = new ArrayList<String>();
val.add("HLA-C*01:01");
hlaElementMap.put(Locus.HLA_C, val);
DisequilibriumElementByRace element1 = new DisequilibriumElementByRace(hlaElementMap, frequenciesByRace);
frequenciesByRace = new ArrayList<FrequencyByRace>();
freq = new FrequencyByRace(new Double(.3), "2", "CAU");
frequenciesByRace.add(freq);
freq = new FrequencyByRace(new Double(.4), "3", "API");
frequenciesByRace.add(freq);
hlaElementMap = new HashMap<Locus, List<String>>();
val = new ArrayList<String>();
val.add("HLA-B*52:01");
hlaElementMap.put(Locus.HLA_B, val);
val = new ArrayList<String>();
val.add("HLA-C*04:01");
hlaElementMap.put(Locus.HLA_C, val);
DisequilibriumElementByRace element2 = new DisequilibriumElementByRace(hlaElementMap, frequenciesByRace);
Set<DetectedDisequilibriumElement> set = new LinkageElementsSet(new DisequilibriumElementComparator());
set.add(new DetectedDisequilibriumElement(element1));
set.add(new DetectedDisequilibriumElement(element2));
int idx = 0;
for (DetectedDisequilibriumElement obj : set) {
if (idx == 0) {
assertTrue(obj.getDisequilibriumElement().equals(element2));
} else {
assertTrue(obj.getDisequilibriumElement().equals(element1));
}
idx++;
}
}
use of org.dash.valid.Locus in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class LinkageDisequilibriumGenotypeList method decomposeMug.
private void decomposeMug() {
String locusVal = null;
Locus locus = null;
HashMap<String, Locus> locusMap = new HashMap<String, Locus>();
List<GenotypeList> genotypeLists = mug.getGenotypeLists();
for (GenotypeList gl : genotypeLists) {
List<Genotype> genotypes = gl.getGenotypes();
for (Genotype genotype : genotypes) {
List<Haplotype> haplotypes = genotype.getHaplotypes();
for (Haplotype haplotype : haplotypes) {
List<AlleleList> alleleLists = haplotype.getAlleleLists();
for (AlleleList alleleList : alleleLists) {
List<Allele> alleles = alleleList.getAlleles();
List<String> alleleStrings = new ArrayList<String>();
for (Allele allele : alleles) {
alleleStrings.add(allele.getGlstring());
locusVal = allele.getLocus().toString();
}
if (locusMap.containsKey(locusVal)) {
locus = locusMap.get(locusVal);
} else {
locus = Locus.normalizeLocus(Locus.lookup(locusVal));
locusMap.put(locusVal, locus);
}
setAlleles(locus, alleleStrings);
}
}
}
}
}
use of org.dash.valid.Locus in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class LinkageDisequilibriumGenotypeList method getAlleles.
private List<?>[] getAlleles(Locus... loci) {
List<?>[] allelesByLocus = new List[loci.length];
int i = 0;
for (Locus locus : loci) {
allelesByLocus[i] = getAlleles(locus);
i++;
}
return allelesByLocus;
}
use of org.dash.valid.Locus in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class LinkageDisequilibriumGenotypeList method constructPossibleHaplotypes.
@SuppressWarnings("unchecked")
public Set<MultiLocusHaplotype> constructPossibleHaplotypes(Set<Locus> loci) {
HashMap<Locus, SingleLocusHaplotype> singleLocusHaplotypes = new HashMap<Locus, SingleLocusHaplotype>();
Set<MultiLocusHaplotype> possibleHaplotypes = new HashSet<MultiLocusHaplotype>();
Locus[] locusArray = loci.toArray(new Locus[loci.size()]);
List<?>[] allelesByLocus = (List<?>[]) getAlleles(locusArray);
List<List<Object>> haplotypeCombinations = cartesianProduct(allelesByLocus);
String[] alleleParts;
Locus locus;
HashMap<String, Locus> locusMap = new HashMap<String, Locus>();
for (List<Object> haplotypeCombo : haplotypeCombinations) {
boolean drb345Homozygous = false;
for (Object haplotypePart : haplotypeCombo) {
List<String> alleles = (List<String>) haplotypePart;
alleleParts = alleles.iterator().next().split(GLStringUtilities.ESCAPED_ASTERISK);
if (locusMap.containsKey(alleleParts[0])) {
locus = locusMap.get(alleleParts[0]);
} else {
locus = Locus.normalizeLocus(Locus.lookup(alleleParts[0]));
locusMap.put(alleleParts[0], locus);
}
if (Locus.HLA_DRB345.equals(locus) && hasHomozygous(locus)) {
drb345Homozygous = true;
}
singleLocusHaplotypes.put(locus, new SingleLocusHaplotype(locus, (List<String>) haplotypePart, getHaplotypeIndex(locus, (List<String>) haplotypePart)));
}
possibleHaplotypes.add(new MultiLocusHaplotype(singleLocusHaplotypes, drb345Homozygous));
}
return possibleHaplotypes;
}
Aggregations