Search in sources :

Example 11 with Locus

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);
}
Also used : DisequilibriumElementComparator(org.dash.valid.DisequilibriumElementComparator) HashMap(java.util.HashMap) DetectedDisequilibriumElement(org.dash.valid.report.DetectedDisequilibriumElement) ArrayList(java.util.ArrayList) BaseDisequilibriumElement(org.dash.valid.base.BaseDisequilibriumElement) List(java.util.List) ArrayList(java.util.ArrayList) Locus(org.dash.valid.Locus) Test(org.junit.Test)

Example 12 with Locus

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++;
    }
}
Also used : DisequilibriumElementComparator(org.dash.valid.DisequilibriumElementComparator) HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) DisequilibriumElementByRace(org.dash.valid.race.DisequilibriumElementByRace) LinkageElementsSet(org.dash.valid.LinkageElementsSet) DetectedDisequilibriumElement(org.dash.valid.report.DetectedDisequilibriumElement) List(java.util.List) ArrayList(java.util.ArrayList) Locus(org.dash.valid.Locus) FrequencyByRace(org.dash.valid.race.FrequencyByRace) Test(org.junit.Test)

Example 13 with Locus

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);
                }
            }
        }
    }
}
Also used : HashMap(java.util.HashMap) ArrayList(java.util.ArrayList) MultilocusUnphasedGenotype(org.nmdp.gl.MultilocusUnphasedGenotype) Genotype(org.nmdp.gl.Genotype) AlleleList(org.nmdp.gl.AlleleList) GenotypeList(org.nmdp.gl.GenotypeList) Allele(org.nmdp.gl.Allele) Locus(org.dash.valid.Locus) MultiLocusHaplotype(org.dash.valid.gl.haplo.MultiLocusHaplotype) SingleLocusHaplotype(org.dash.valid.gl.haplo.SingleLocusHaplotype) Haplotype(org.nmdp.gl.Haplotype)

Example 14 with Locus

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;
}
Also used : AlleleList(org.nmdp.gl.AlleleList) ArrayList(java.util.ArrayList) List(java.util.List) GenotypeList(org.nmdp.gl.GenotypeList) Locus(org.dash.valid.Locus)

Example 15 with Locus

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;
}
Also used : HashMap(java.util.HashMap) SingleLocusHaplotype(org.dash.valid.gl.haplo.SingleLocusHaplotype) AlleleList(org.nmdp.gl.AlleleList) ArrayList(java.util.ArrayList) List(java.util.List) GenotypeList(org.nmdp.gl.GenotypeList) Locus(org.dash.valid.Locus) MultiLocusHaplotype(org.dash.valid.gl.haplo.MultiLocusHaplotype) HashSet(java.util.HashSet)

Aggregations

Locus (org.dash.valid.Locus)18 HashMap (java.util.HashMap)10 ArrayList (java.util.ArrayList)9 List (java.util.List)8 HashSet (java.util.HashSet)5 DisequilibriumElement (org.dash.valid.DisequilibriumElement)4 BaseDisequilibriumElement (org.dash.valid.base.BaseDisequilibriumElement)4 MultiLocusHaplotype (org.dash.valid.gl.haplo.MultiLocusHaplotype)4 DisequilibriumElementByRace (org.dash.valid.race.DisequilibriumElementByRace)4 FrequencyByRace (org.dash.valid.race.FrequencyByRace)4 Test (org.junit.Test)4 BufferedReader (java.io.BufferedReader)3 FileInputStream (java.io.FileInputStream)3 InputStreamReader (java.io.InputStreamReader)3 DisequilibriumElementComparator (org.dash.valid.DisequilibriumElementComparator)3 HaplotypePair (org.dash.valid.gl.haplo.HaplotypePair)3 SingleLocusHaplotype (org.dash.valid.gl.haplo.SingleLocusHaplotype)3 DetectedDisequilibriumElement (org.dash.valid.report.DetectedDisequilibriumElement)3 AlleleList (org.nmdp.gl.AlleleList)3 GenotypeList (org.nmdp.gl.GenotypeList)3