Search in sources :

Example 1 with DisequilibriumElementComparator

use of org.dash.valid.DisequilibriumElementComparator in project ImmunogeneticDataTools by nmdp-bioinformatics.

the class DisequilibriumElementComparatorTest method testComparisonByRace.

@Test
public void testComparisonByRace() {
    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);
    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) ArrayList(java.util.ArrayList) DisequilibriumElementByRace(org.dash.valid.race.DisequilibriumElementByRace) 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 2 with DisequilibriumElementComparator

use of org.dash.valid.DisequilibriumElementComparator 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 3 with DisequilibriumElementComparator

use of org.dash.valid.DisequilibriumElementComparator 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)3 HashMap (java.util.HashMap)3 List (java.util.List)3 DisequilibriumElementComparator (org.dash.valid.DisequilibriumElementComparator)3 Locus (org.dash.valid.Locus)3 DetectedDisequilibriumElement (org.dash.valid.report.DetectedDisequilibriumElement)3 Test (org.junit.Test)3 DisequilibriumElementByRace (org.dash.valid.race.DisequilibriumElementByRace)2 FrequencyByRace (org.dash.valid.race.FrequencyByRace)2 LinkageElementsSet (org.dash.valid.LinkageElementsSet)1 BaseDisequilibriumElement (org.dash.valid.base.BaseDisequilibriumElement)1