use of gridss.analysis.MapqMetrics in project gridss by PapenfussLab.
the class IdsvSamFileMetricsCollectorTest method should_calc_max_fragment_size.
@Test
public void should_calc_max_fragment_size() {
IdsvSamFileMetricsCollector c = new IdsvSamFileMetricsCollector(null);
c.acceptRecord(Read(0, 1, "100M"), null);
c.acceptRecord(RP(0, 1, 2, 1)[0], null);
c.acceptRecord(RP(0, 1, 7, 5)[0], null);
// should ignore this as it's not a proper pair
SAMRecord r = RP(0, 1, 100, 5)[0];
r.setProperPairFlag(false);
c.acceptRecord(r, null);
// 12345678901234567890
// ----> <----
c.acceptRecord(Read(0, 1, "100M"), null);
MetricsFile<IdsvMetrics, Integer> idsv = new MetricsFile<IdsvMetrics, Integer>();
MetricsFile<InsertSizeMetrics, Integer> is = new MetricsFile<InsertSizeMetrics, Integer>();
MetricsFile<CigarDetailMetrics, Integer> sc = new MetricsFile<CigarDetailMetrics, Integer>();
MetricsFile<MapqMetrics, Integer> mq = new MetricsFile<MapqMetrics, Integer>();
c.finish(is, idsv, mq, sc);
assertEquals(11, (int) ((IdsvMetrics) idsv.getMetrics().get(0)).MAX_PROPER_PAIR_FRAGMENT_LENGTH);
c = new IdsvSamFileMetricsCollector(null);
// mate before
r = RP(0, 1, 100, 5)[1];
c.acceptRecord(r, null);
c.finish(is, idsv, mq, sc);
assertEquals(11, (int) ((IdsvMetrics) idsv.getMetrics().get(0)).MAX_PROPER_PAIR_FRAGMENT_LENGTH);
}
use of gridss.analysis.MapqMetrics 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);
}
use of gridss.analysis.MapqMetrics in project gridss by PapenfussLab.
the class TestHelper method IDSV.
public IdsvMetrics IDSV(Collection<SAMRecord> input) {
IdsvSamFileMetricsCollector c = new IdsvSamFileMetricsCollector(null);
for (SAMRecord r : input) {
c.acceptRecord(r, null);
}
MetricsFile<IdsvMetrics, Integer> idsv = new MetricsFile<IdsvMetrics, Integer>();
MetricsFile<InsertSizeMetrics, Integer> is = new MetricsFile<InsertSizeMetrics, Integer>();
MetricsFile<CigarDetailMetrics, Integer> sc = new MetricsFile<CigarDetailMetrics, Integer>();
MetricsFile<MapqMetrics, Integer> mqm = new MetricsFile<MapqMetrics, Integer>();
c.finish(is, idsv, mqm, sc);
IdsvMetrics metrics = idsv.getMetrics().get(0);
return metrics;
}
use of gridss.analysis.MapqMetrics in project gridss by PapenfussLab.
the class IdsvSamFileMetrics method getMapqMetrics.
public static MapqMetrics getMapqMetrics(File mapqMetricsFile) {
if (mapqMetricsFile == null)
return null;
MapqMetrics bestMetrics = null;
for (MapqMetrics metric : Iterables.filter(MetricsFile.readBeans(mapqMetricsFile), MapqMetrics.class)) {
if (metric.SAMPLE == null && metric.LIBRARY == null && metric.READ_GROUP == null) {
if (bestMetrics == null || bestMetrics.MAPPED_READS < metric.MAPPED_READS) {
bestMetrics = metric;
}
}
}
if (bestMetrics == null) {
bestMetrics = new MapqMetrics();
log.error(String.format("No mapq metrics found in %s.", mapqMetricsFile));
}
return bestMetrics;
}
use of gridss.analysis.MapqMetrics in project gridss by PapenfussLab.
the class IdsvSamFileMetricsTest method wrapper_inner_metrics.
@Test
public void wrapper_inner_metrics() {
IdsvMetrics im = new IdsvMetrics();
InsertSizeMetrics ism = new InsertSizeMetrics();
MapqMetrics mqm = new MapqMetrics();
List<CigarDetailMetrics> sc = new ArrayList<CigarDetailMetrics>();
InsertSizeDistribution isd = new InsertSizeDistribution(new int[] { 1 }, new double[] { 1 });
IdsvSamFileMetrics metrics = new IdsvSamFileMetrics(ism, im, mqm, isd, sc);
assertEquals(im, metrics.getIdsvMetrics());
assertEquals(isd, metrics.getInsertSizeDistribution());
assertEquals(ism, metrics.getInsertSizeMetrics());
assertEquals(sc, metrics.getCigarDetailMetrics());
assertEquals(mqm, metrics.getMapqMetrics());
}
Aggregations