Search in sources :

Example 1 with Linkages

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);
    }
}
Also used : Linkages(org.dash.valid.Linkages) InputStreamReader(java.io.InputStreamReader) FileInputStream(java.io.FileInputStream) InputStream(java.io.InputStream) IOException(java.io.IOException) FileInputStream(java.io.FileInputStream) BaseDisequilibriumElement(org.dash.valid.base.BaseDisequilibriumElement) DisequilibriumElement(org.dash.valid.DisequilibriumElement) BufferedReader(java.io.BufferedReader) Locus(org.dash.valid.Locus) File(java.io.File) HashSet(java.util.HashSet)

Example 2 with Linkages

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;
}
Also used : Linkages(org.dash.valid.Linkages) FileInputStream(java.io.FileInputStream) DisequilibriumElementByRace(org.dash.valid.race.DisequilibriumElementByRace) DisequilibriumElement(org.dash.valid.DisequilibriumElement) Locus(org.dash.valid.Locus) PrintWriter(java.io.PrintWriter) HashSet(java.util.HashSet) FrequencyByRace(org.dash.valid.race.FrequencyByRace)

Example 3 with Linkages

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);
}
Also used : Linkages(org.dash.valid.Linkages) XSSFRow(org.apache.poi.xssf.usermodel.XSSFRow) XSSFCell(org.apache.poi.xssf.usermodel.XSSFCell)

Example 4 with Linkages

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();
}
Also used : Linkages(org.dash.valid.Linkages)

Aggregations

Linkages (org.dash.valid.Linkages)4 FileInputStream (java.io.FileInputStream)2 HashSet (java.util.HashSet)2 DisequilibriumElement (org.dash.valid.DisequilibriumElement)2 Locus (org.dash.valid.Locus)2 BufferedReader (java.io.BufferedReader)1 File (java.io.File)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 XSSFCell (org.apache.poi.xssf.usermodel.XSSFCell)1 XSSFRow (org.apache.poi.xssf.usermodel.XSSFRow)1 BaseDisequilibriumElement (org.dash.valid.base.BaseDisequilibriumElement)1 DisequilibriumElementByRace (org.dash.valid.race.DisequilibriumElementByRace)1 FrequencyByRace (org.dash.valid.race.FrequencyByRace)1