Search in sources :

Example 6 with Sample

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

the class AnalyzeGLStrings method writeOutput.

private void writeOutput(List<Sample> samplesList) throws IOException {
    PrintWriter writer = null;
    PrintWriter summaryWriter = null;
    PrintWriter pairWriter = null;
    PrintWriter pairWarningsWriter = null;
    PrintWriter linkageWriter = null;
    PrintWriter linkageWarningsWriter = null;
    PrintWriter nonCwdWriter = null;
    PrintWriter detectedFindingsWriter = null;
    boolean writeToDir = false;
    if (outputFile != null && outputFile.isDirectory()) {
        writeToDir = true;
        summaryWriter = writer(new File(outputFile + "/" + SummaryWriter.SUMMARY_XML_FILE), true);
        pairWriter = writer(new File(outputFile + "/" + HaplotypePairFileHandler.HAPLOTYPE_PAIRS_LOG), true);
        pairWarningsWriter = writer(new File(outputFile + "/" + HaplotypePairWarningFileHandler.HAPLOTYPE_PAIRS_WARNING_LOG), true);
        linkageWriter = writer(new File(outputFile + "/" + LinkageDisequilibriumFileHandler.LINKAGES_LOG), true);
        linkageWarningsWriter = writer(new File(outputFile + "/" + LinkageWarningFileHandler.LINKAGE_WARNINGS_LOG), true);
        nonCwdWriter = writer(new File(outputFile + "/" + CommonWellDocumentedFileHandler.NON_CWD_WARNINGS_LOG), true);
        detectedFindingsWriter = writer(new File(outputFile + "/" + DetectedFindingsWriter.DETECTED_FINDINGS_CSV), true);
    } else {
        writer = writer(outputFile, true);
    }
    SamplesList allSamples = new SamplesList();
    allSamples.setSamples(samplesList);
    String summaryFindings = SummaryWriter.formatDetectedLinkages(allSamples);
    for (Sample sample : samplesList) {
        DetectedLinkageFindings findings = sample.getFindings();
        if (warnings != null && warnings == Boolean.TRUE && !findings.hasAnomalies()) {
            continue;
        }
        if (writeToDir) {
            if (sample.getFindings().hasAnomalies()) {
                pairWarningsWriter.write(HaplotypePairWriter.formatDetectedLinkages(findings));
                linkageWarningsWriter.write(LinkageDisequilibriumWriter.formatDetectedLinkages(findings));
            } else {
                pairWriter.write(HaplotypePairWriter.formatDetectedLinkages(findings));
                linkageWriter.write(LinkageDisequilibriumWriter.formatDetectedLinkages(findings));
                nonCwdWriter.write(CommonWellDocumentedWriter.formatCommonWellDocumented(findings));
                detectedFindingsWriter.write(DetectedFindingsWriter.formatDetectedFindings(findings));
            }
        }
    }
    if (writeToDir) {
        summaryWriter.write(summaryFindings);
        summaryWriter.close();
        pairWriter.close();
        pairWarningsWriter.close();
        linkageWriter.close();
        linkageWarningsWriter.close();
        nonCwdWriter.close();
        detectedFindingsWriter.close();
    } else {
        writer.write(summaryFindings);
        writer.close();
    }
}
Also used : SamplesList(org.dash.valid.report.SamplesList) Sample(org.dash.valid.Sample) DetectedLinkageFindings(org.dash.valid.report.DetectedLinkageFindings) File(java.io.File) PrintWriter(java.io.PrintWriter)

Example 7 with Sample

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

the class AnalyzeGLStringsTest method testAnalyzeGLString.

@Test
public void testAnalyzeGLString() throws Exception {
    InputStream is = AnalyzeGLStringsTest.class.getClassLoader().getResourceAsStream("fullyQualifiedExample.txt");
    BufferedReader reader = new BufferedReader(new InputStreamReader(is));
    File inputFile = null;
    File outputFile = null;
    String hladb = "3.20.0";
    String freq = null;
    Boolean warnings = null;
    Set<File> frequencyFiles = null;
    File allelesFile = null;
    AnalyzeGLStrings analyzer = new AnalyzeGLStrings(inputFile, outputFile, hladb, freq, warnings, frequencyFiles, allelesFile);
    List<Sample> samplesList = analyzer.performAnalysis(reader);
    assertNotNull(samplesList);
    assertTrue(samplesList.size() > 0);
}
Also used : InputStreamReader(java.io.InputStreamReader) InputStream(java.io.InputStream) Sample(org.dash.valid.Sample) BufferedReader(java.io.BufferedReader) File(java.io.File) Test(org.junit.Test)

Aggregations

Sample (org.dash.valid.Sample)7 Test (org.junit.Test)4 LinkageDisequilibriumGenotypeList (org.dash.valid.gl.LinkageDisequilibriumGenotypeList)3 MultilocusUnphasedGenotype (org.nmdp.gl.MultilocusUnphasedGenotype)3 BufferedReader (java.io.BufferedReader)2 File (java.io.File)2 DetectedLinkageFindings (org.dash.valid.report.DetectedLinkageFindings)2 Genotype (io.swagger.model.Genotype)1 SampleData (io.swagger.model.SampleData)1 Samples (io.swagger.model.Samples)1 IOException (java.io.IOException)1 InputStream (java.io.InputStream)1 InputStreamReader (java.io.InputStreamReader)1 PrintWriter (java.io.PrintWriter)1 Haplotype (org.dash.valid.gl.haplo.Haplotype)1 SamplesList (org.dash.valid.report.SamplesList)1 CommandLineParseException (org.dishevelled.commandline.CommandLineParseException)1