use of org.dash.valid.Linkages in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class HLAFrequenciesLoader method init.
private void init(Set<File> frequencyFiles, File allelesFile) {
Set<Linkages> linkages = new HashSet<Linkages>();
try {
for (File frequencyFile : frequencyFiles) {
InputStream is = new FileInputStream(frequencyFile);
InputStreamReader isr = new InputStreamReader(is);
BufferedReader reader = new BufferedReader(isr);
List<DisequilibriumElement> elements = loadStandardReferenceData(reader);
EnumSet<Locus> loci = Locus.lookup(elements.iterator().next().getLoci());
linkages.addAll(Linkages.lookup(loci));
this.disequilibriumElementsMap.put(loci, elements);
}
LinkagesLoader.getInstance(linkages);
if (allelesFile != null) {
loadIndividualLocusFrequencies(allelesFile);
}
} catch (IOException e) {
LOGGER.severe("Couldn't load disequilibrium element reference file.");
e.printStackTrace();
System.exit(-1);
}
}
use of org.dash.valid.Linkages 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;
}
use of org.dash.valid.Linkages in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class DetectedFindingsWriter method reportDetectedFindings.
/**
* @param linkagesFound
* @throws IOException
* @throws SecurityException
*/
public synchronized void reportDetectedFindings(DetectedLinkageFindings findings) {
XSSFRow row = spreadsheet.createRow(rowId++);
int cellId = 0;
XSSFCell cell = row.createCell(cellId++);
cell.setCellValue(findings.getGLId());
cell = row.createCell(cellId++);
cell.setCellValue(findings.getAlleleCount(Locus.HLA_A));
cell = row.createCell(cellId++);
cell.setCellValue(findings.getAlleleCount(Locus.HLA_B));
cell = row.createCell(cellId++);
cell.setCellValue(findings.getAlleleCount(Locus.HLA_C));
cell = row.createCell(cellId++);
cell.setCellValue(findings.getAlleleCount(Locus.HLA_DRB1));
cell = row.createCell(cellId++);
cell.setCellValue(findings.getAlleleCount(Locus.HLA_DRB345));
cell = row.createCell(cellId++);
cell.setCellValue(findings.getAlleleCount(Locus.HLA_DQB1));
for (Linkages linkage : LinkagesLoader.getInstance().getLinkages()) {
cell = row.createCell(cellId++);
cell.setCellValue(findings.getLinkageCount(linkage.getLoci()));
cell = row.createCell(cellId++);
cell.setCellValue(findings.getMinimumDifference(linkage.getLoci()) + "");
}
String detectedFindings = formatDetectedFindings(findings);
printWriter.write(detectedFindings);
}
use of org.dash.valid.Linkages in project ImmunogeneticDataTools by nmdp-bioinformatics.
the class DetectedFindingsWriter method formatDetectedFindings.
public static String formatDetectedFindings(DetectedLinkageFindings findings) {
StringBuffer sb = new StringBuffer();
sb.append(findings.getGLId() + GLStringConstants.COMMA);
sb.append(findings.getAlleleCount(Locus.HLA_A) + GLStringConstants.COMMA);
sb.append(findings.getAlleleCount(Locus.HLA_B) + GLStringConstants.COMMA);
sb.append(findings.getAlleleCount(Locus.HLA_C) + GLStringConstants.COMMA);
sb.append(findings.getAlleleCount(Locus.HLA_DRB1) + GLStringConstants.COMMA);
sb.append(findings.getAlleleCount(Locus.HLA_DRB345) + GLStringConstants.COMMA);
sb.append(findings.getAlleleCount(Locus.HLA_DQB1) + GLStringConstants.COMMA);
for (Linkages linkage : LinkagesLoader.getInstance().getLinkages()) {
sb.append(findings.getLinkageCount(linkage.getLoci()) + GLStringConstants.COMMA);
sb.append(findings.getMinimumDifference(linkage.getLoci()) + GLStringConstants.COMMA);
}
sb.append(GLStringConstants.NEWLINE);
return sb.toString();
}
Aggregations