Search in sources :

Example 1 with BaseDisequilibriumElement

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

the class HLAFrequenciesLoader method loadLinkageReferenceData.

public List<DisequilibriumElement> loadLinkageReferenceData(String filename, Locus[] locusPositions) throws FileNotFoundException, IOException {
    BufferedReader reader = new BufferedReader(new InputStreamReader(HLAFrequenciesLoader.class.getClassLoader().getResourceAsStream(filename)));
    String row;
    String[] columns;
    HashMap<Locus, List<String>> hlaElementMap;
    List<DisequilibriumElement> disequilibriumElements = new ArrayList<DisequilibriumElement>();
    while ((row = reader.readLine()) != null) {
        hlaElementMap = new HashMap<Locus, List<String>>();
        columns = row.split(GLStringConstants.TAB);
        for (int i = 0; i < locusPositions.length; i++) {
            List<String> val = new ArrayList<String>();
            val.add(GLStringConstants.DASH.equals(columns[i]) ? GLStringConstants.NNNN : columns[i]);
            hlaElementMap.put(locusPositions[i], val);
        }
        disequilibriumElements.add(new BaseDisequilibriumElement(hlaElementMap, columns[locusPositions.length], columns[locusPositions.length + 1]));
    }
    reader.close();
    return disequilibriumElements;
}
Also used : InputStreamReader(java.io.InputStreamReader) ArrayList(java.util.ArrayList) BaseDisequilibriumElement(org.dash.valid.base.BaseDisequilibriumElement) DisequilibriumElement(org.dash.valid.DisequilibriumElement) BufferedReader(java.io.BufferedReader) BaseDisequilibriumElement(org.dash.valid.base.BaseDisequilibriumElement) ArrayList(java.util.ArrayList) List(java.util.List) Locus(org.dash.valid.Locus)

Example 2 with BaseDisequilibriumElement

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

Aggregations

ArrayList (java.util.ArrayList)2 List (java.util.List)2 Locus (org.dash.valid.Locus)2 BaseDisequilibriumElement (org.dash.valid.base.BaseDisequilibriumElement)2 BufferedReader (java.io.BufferedReader)1 InputStreamReader (java.io.InputStreamReader)1 HashMap (java.util.HashMap)1 DisequilibriumElement (org.dash.valid.DisequilibriumElement)1 DisequilibriumElementComparator (org.dash.valid.DisequilibriumElementComparator)1 DetectedDisequilibriumElement (org.dash.valid.report.DetectedDisequilibriumElement)1 Test (org.junit.Test)1