Search in sources :

Example 1 with IdsvSamFileMetrics

use of au.edu.wehi.idsv.metrics.IdsvSamFileMetrics in project gridss by PapenfussLab.

the class CollectIdsvMetricsTest method should_calc_max_read_length.

@Test
public void should_calc_max_read_length() {
    File metricFiles = new File(testFolder.getRoot(), "metrics.txt");
    CollectIdsvMetrics c = new CollectIdsvMetrics();
    c.OUTPUT = metricFiles;
    c.setup(null, null);
    c.acceptRead(RP(0, 1, 2, 1)[0], null);
    c.acceptRead(RP(0, 1, 2, 1)[1], null);
    c.acceptRead(RP(0, 1, 7, 5)[0], null);
    c.acceptRead(RP(0, 1, 7, 5)[1], null);
    c.acceptRead(Read(0, 1, "100M"), null);
    c.finish();
    IdsvMetrics metrics = new IdsvSamFileMetrics(null, metricFiles, null, null, false).getIdsvMetrics();
    assertEquals(100, metrics.MAX_READ_LENGTH);
}
Also used : IdsvSamFileMetrics(au.edu.wehi.idsv.metrics.IdsvSamFileMetrics) File(java.io.File) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Test(org.junit.Test)

Example 2 with IdsvSamFileMetrics

use of au.edu.wehi.idsv.metrics.IdsvSamFileMetrics in project gridss by PapenfussLab.

the class CollectIdsvMetricsTest method should_calc_alternate_mappings.

@Test
public void should_calc_alternate_mappings() {
    File metricFiles = new File(testFolder.getRoot(), "metrics.txt");
    CollectIdsvMetrics c = new CollectIdsvMetrics();
    c.OUTPUT = metricFiles;
    c.setup(null, null);
    c.acceptRead(Read(0, 1, "1M"), null);
    SAMRecord r2 = Read(0, 1, "1M");
    r2.setSupplementaryAlignmentFlag(true);
    c.acceptRead(r2, null);
    SAMRecord r3 = Read(0, 1, "1M");
    r3.setNotPrimaryAlignmentFlag(true);
    c.acceptRead(r3, null);
    SAMRecord r4 = Read(0, 1, "1M");
    r4.setNotPrimaryAlignmentFlag(true);
    r4.setAttribute("SA", "chr1,5,+,1M,0,0");
    c.acceptRead(r4, null);
    c.finish();
    IdsvMetrics metrics = new IdsvSamFileMetrics(null, metricFiles, null, null, false).getIdsvMetrics();
    assertEquals(1, metrics.SECONDARY_NOT_SPLIT);
}
Also used : SAMRecord(htsjdk.samtools.SAMRecord) IdsvSamFileMetrics(au.edu.wehi.idsv.metrics.IdsvSamFileMetrics) File(java.io.File) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Test(org.junit.Test)

Example 3 with IdsvSamFileMetrics

use of au.edu.wehi.idsv.metrics.IdsvSamFileMetrics in project gridss by PapenfussLab.

the class EmpiricalReferenceLikelihoodModelTest method should_score_read_pairs_correctly.

@Test
public void should_score_read_pairs_correctly() {
    IdsvSamFileMetrics metrics = new IdsvSamFileMetrics(new InsertSizeMetrics() {

        {
            MEAN_INSERT_SIZE = 2;
            MEDIAN_INSERT_SIZE = 2;
            MIN_INSERT_SIZE = 1;
            MAX_INSERT_SIZE = 3;
            MEDIAN_ABSOLUTE_DEVIATION = 1;
        }
    }, new IdsvMetrics() {

        {
            MAX_READ_LENGTH = 100;
            MAX_PROPER_PAIR_FRAGMENT_LENGTH = 2;
            MIN_PROPER_PAIR_FRAGMENT_LENGTH = 2;
            READ_PAIRS = 13;
            READ_PAIRS_ONE_MAPPED = 2;
            READ_PAIRS_ZERO_MAPPED = 1;
            READ_PAIRS_BOTH_MAPPED = READ_PAIRS - READ_PAIRS_ONE_MAPPED - READ_PAIRS_ZERO_MAPPED;
            READS = 2 * READ_PAIRS;
            MAPPED_READS = READS - READ_PAIRS_ONE_MAPPED - 2 * READ_PAIRS_ZERO_MAPPED;
        }
    }, new MapqMetrics() {

        {
        }
    }, new InsertSizeDistribution(new int[] { 1, 2, 3 }, new double[] { 1, 8, 1 }), new ArrayList<CigarDetailMetrics>());
    assertEquals(10, model.scoreReadPair(metrics, 3, 1000, 1000), 0.001);
}
Also used : IdsvMetrics(gridss.analysis.IdsvMetrics) IdsvSamFileMetrics(au.edu.wehi.idsv.metrics.IdsvSamFileMetrics) InsertSizeMetrics(picard.analysis.InsertSizeMetrics) InsertSizeDistribution(gridss.analysis.InsertSizeDistribution) MapqMetrics(gridss.analysis.MapqMetrics) CigarDetailMetrics(gridss.analysis.CigarDetailMetrics) Test(org.junit.Test)

Example 4 with IdsvSamFileMetrics

use of au.edu.wehi.idsv.metrics.IdsvSamFileMetrics in project gridss by PapenfussLab.

the class SAMEvidenceSource method ensureMetrics.

public void ensureMetrics() {
    if (metrics == null) {
        File idsvFile = getContext().getFileSystemContext().getIdsvMetrics(getFile());
        File cigarFile = getContext().getFileSystemContext().getCigarMetrics(getFile());
        File mapqFile = getContext().getFileSystemContext().getMapqMetrics(getFile());
        if (!idsvFile.exists() || !cigarFile.exists() || !mapqFile.exists()) {
            log.info("Calculating metrics for " + getFile().getAbsolutePath());
            List<String> args = Lists.newArrayList("INPUT=" + getFile().getAbsolutePath(), "OUTPUT=" + getContext().getFileSystemContext().getMetricsPrefix(getFile()).getAbsolutePath(), "THRESHOLD_COVERAGE=" + getContext().getConfig().maxCoverage, "FILE_EXTENSION=null", "GRIDSS_PROGRAM=null", "GRIDSS_PROGRAM=CollectCigarMetrics", "GRIDSS_PROGRAM=CollectMapqMetrics", "GRIDSS_PROGRAM=CollectTagMetrics", "GRIDSS_PROGRAM=CollectIdsvMetrics", "GRIDSS_PROGRAM=ReportThresholdCoverage", // use yet
            "PROGRAM=null", "PROGRAM=CollectAlignmentSummaryMetrics", "PROGRAM=QualityScoreDistribution");
            if (!knownSingleEnded()) {
                // Don't run CollectInsertSizeMetrics
                args.add("PROGRAM=CollectInsertSizeMetrics");
            }
            if (getContext().getCalculateMetricsRecordCount() < Integer.MAX_VALUE) {
                args.add("STOP_AFTER=" + getContext().getCalculateMetricsRecordCount());
            }
            execute(new CollectGridssMetrics(), args);
        }
        metrics = new IdsvSamFileMetrics(getContext(), getFile(), knownSingleEnded());
    }
}
Also used : IdsvSamFileMetrics(au.edu.wehi.idsv.metrics.IdsvSamFileMetrics) MetricsFile(htsjdk.samtools.metrics.MetricsFile) File(java.io.File) CollectGridssMetrics(gridss.analysis.CollectGridssMetrics)

Example 5 with IdsvSamFileMetrics

use of au.edu.wehi.idsv.metrics.IdsvSamFileMetrics in project gridss by PapenfussLab.

the class CollectIdsvMetricsTest method should_calc_read_statistics.

@Test
public void should_calc_read_statistics() {
    File metricFiles = new File(testFolder.getRoot(), "metrics.txt");
    CollectIdsvMetrics c = new CollectIdsvMetrics();
    c.OUTPUT = metricFiles;
    c.setup(null, null);
    c.acceptRead(RP(0, 1, 2, 1)[1], null);
    c.acceptRead(RP(0, 1, 2, 1)[0], null);
    c.acceptRead(RP(0, 1, 7, 5)[0], null);
    c.acceptRead(RP(0, 1, 7, 5)[1], null);
    c.acceptRead(Read(0, 1, "100M"), null);
    c.acceptRead(OEA(0, 1, "1M", true)[0], null);
    c.acceptRead(OEA(0, 1, "1M", true)[1], null);
    c.acceptRead(Unmapped(100), null);
    SAMRecord[] unmapped = RP(0, 1, 2, 1);
    unmapped[0].setReadUnmappedFlag(true);
    unmapped[1].setReadUnmappedFlag(true);
    SAMRecordUtil.pairReads(unmapped[0], unmapped[1]);
    c.acceptRead(unmapped[0], null);
    c.acceptRead(unmapped[1], null);
    c.finish();
    IdsvMetrics metrics = new IdsvSamFileMetrics(null, metricFiles, null, null, false).getIdsvMetrics();
    assertEquals(10, metrics.READS);
    assertEquals(6, metrics.MAPPED_READS);
}
Also used : SAMRecord(htsjdk.samtools.SAMRecord) IdsvSamFileMetrics(au.edu.wehi.idsv.metrics.IdsvSamFileMetrics) File(java.io.File) IntermediateFilesTest(au.edu.wehi.idsv.IntermediateFilesTest) Test(org.junit.Test)

Aggregations

IdsvSamFileMetrics (au.edu.wehi.idsv.metrics.IdsvSamFileMetrics)7 File (java.io.File)5 Test (org.junit.Test)5 IntermediateFilesTest (au.edu.wehi.idsv.IntermediateFilesTest)4 SAMRecord (htsjdk.samtools.SAMRecord)3 CigarDetailMetrics (gridss.analysis.CigarDetailMetrics)2 CollectGridssMetrics (gridss.analysis.CollectGridssMetrics)1 IdsvMetrics (gridss.analysis.IdsvMetrics)1 InsertSizeDistribution (gridss.analysis.InsertSizeDistribution)1 MapqMetrics (gridss.analysis.MapqMetrics)1 MetricsFile (htsjdk.samtools.metrics.MetricsFile)1 InsertSizeMetrics (picard.analysis.InsertSizeMetrics)1