use of org.dash.valid.race.FrequencyByRace in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class NormalizeFrequencyFile method call.
@Override
public Integer call() throws Exception {
PrintWriter writer = new PrintWriter(outputFile);
if (SINGLE.equals(frequencies)) {
List<String> singleLocusFrequencies = HLAFrequenciesLoader.loadIndividualLocusFrequency(new FileInputStream(inputFile));
for (String allele : singleLocusFrequencies) {
writer.write(allele + GLStringConstants.NEWLINE);
}
} else {
HashSet<String> linkageNames = new HashSet<String>();
linkageNames.add(frequencies);
Set<Linkages> linkagesSet = Linkages.lookup(linkageNames);
LinkagesLoader.getInstance(linkagesSet);
List<DisequilibriumElement> disequilibriumElements = HLAFrequenciesLoader.loadNMDPLinkageReferenceData(new FileInputStream(inputFile), LOCUS_POSITION_MAP.get(Linkages.lookup(frequencies).getLoci()));
for (DisequilibriumElement element : disequilibriumElements) {
StringBuffer sb = new StringBuffer();
int locusCounter = 0;
for (Locus locus : Locus.lookup(element.getLoci())) {
if (locusCounter > 0) {
sb.append(GLStringConstants.GENE_PHASE_DELIMITER);
}
sb.append(element.getHlaElement(locus).get(0));
locusCounter++;
}
List<FrequencyByRace> frequencies = ((DisequilibriumElementByRace) element).getFrequenciesByRace();
for (FrequencyByRace frequency : frequencies) {
writer.write(frequency.getRace() + GLStringConstants.COMMA + sb + GLStringConstants.COMMA + frequency.getFrequency() + GLStringConstants.COMMA + frequency.getRank() + GLStringConstants.NEWLINE);
}
}
}
writer.close();
return 0;
}
Aggregations