Search in sources :

Example 1 with LinkageElementsSet

use of org.dash.valid.LinkageElementsSet 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)

Aggregations

ArrayList (java.util.ArrayList)1 HashMap (java.util.HashMap)1 List (java.util.List)1 DisequilibriumElementComparator (org.dash.valid.DisequilibriumElementComparator)1 LinkageElementsSet (org.dash.valid.LinkageElementsSet)1 Locus (org.dash.valid.Locus)1 DisequilibriumElementByRace (org.dash.valid.race.DisequilibriumElementByRace)1 FrequencyByRace (org.dash.valid.race.FrequencyByRace)1 DetectedDisequilibriumElement (org.dash.valid.report.DetectedDisequilibriumElement)1 Test (org.junit.Test)1