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;
}
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);
}
Aggregations