Search in sources :

Example 11 with AssemblyRegion

use of org.broadinstitute.hellbender.engine.AssemblyRegion in project gatk by broadinstitute.

the class AssemblyResultSetUnitTest method testTrimTo.

@Test(dataProvider = "trimmingData")
public void testTrimTo(final Map<Haplotype, AssemblyResult> haplotypesAndResultSets, final AssemblyRegion original) {
    final AssemblyResultSet subject = new AssemblyResultSet();
    for (final Map.Entry<Haplotype, AssemblyResult> entry : haplotypesAndResultSets.entrySet()) subject.add(entry.getKey(), entry.getValue());
    subject.setRegionForGenotyping(original);
    final SimpleInterval originalLocation = original.getExtendedSpan();
    final int length = originalLocation.size();
    final SimpleInterval newLocation = new SimpleInterval(originalLocation.getContig(), originalLocation.getStart() + length / 2, originalLocation.getEnd() - length / 2);
    final AssemblyRegion newRegion = original.trim(newLocation);
    final Map<Haplotype, Haplotype> originalHaplotypesByTrimmed = new HashMap<>(haplotypesAndResultSets.size());
    for (final Haplotype h : haplotypesAndResultSets.keySet()) originalHaplotypesByTrimmed.put(h.trim(newRegion.getExtendedSpan()), h);
    final AssemblyResultSet trimmed = subject.trimTo(newRegion);
    Assert.assertFalse(subject.wasTrimmed());
    Assert.assertTrue(trimmed.wasTrimmed());
    for (final Haplotype h : trimmed.getHaplotypeList()) {
        Assert.assertEquals(h.getGenomeLocation(), newLocation);
        Assert.assertEquals(h.getBases().length, newLocation.size());
    }
}
Also used : AssemblyRegion(org.broadinstitute.hellbender.engine.AssemblyRegion) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 12 with AssemblyRegion

use of org.broadinstitute.hellbender.engine.AssemblyRegion in project gatk by broadinstitute.

the class ReadThreadingAssemblerUnitTest method assemble.

private List<Haplotype> assemble(final ReadThreadingAssembler assembler, final byte[] refBases, final SimpleInterval loc, final List<GATKRead> reads) {
    final Haplotype refHaplotype = new Haplotype(refBases, true);
    final Cigar c = new Cigar();
    c.add(new CigarElement(refHaplotype.getBases().length, CigarOperator.M));
    refHaplotype.setCigar(c);
    final AssemblyRegion activeRegion = new AssemblyRegion(loc, null, true, 0, header);
    activeRegion.addAll(reads);
    //        logger.warn("Assembling " + activeRegion + " with " + engine);
    final AssemblyResultSet assemblyResultSet = assembler.runLocalAssembly(activeRegion, refHaplotype, refBases, loc, Collections.<VariantContext>emptyList(), null, header);
    return assemblyResultSet.getHaplotypeList();
}
Also used : Cigar(htsjdk.samtools.Cigar) AssemblyRegion(org.broadinstitute.hellbender.engine.AssemblyRegion) AssemblyResultSet(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.AssemblyResultSet) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) KBestHaplotype(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.graphs.KBestHaplotype) CigarElement(htsjdk.samtools.CigarElement)

Example 13 with AssemblyRegion

use of org.broadinstitute.hellbender.engine.AssemblyRegion in project gatk-protected by broadinstitute.

the class AssemblyBasedCallerUtils method assemblyRegionWithWellMappedReads.

// create the assembly using just high quality reads (eg Q20 or higher).  We may want to use lower
// quality reads in the PairHMM downstream, so we can't use a ReadFilter
public static AssemblyRegion assemblyRegionWithWellMappedReads(final AssemblyRegion originalAssemblyRegion, final int minMappingQuality, final SAMFileHeader readsHeader) {
    final AssemblyRegion result = new AssemblyRegion(originalAssemblyRegion.getSpan(), originalAssemblyRegion.getSupportingStates(), originalAssemblyRegion.isActive(), originalAssemblyRegion.getExtension(), readsHeader);
    originalAssemblyRegion.getReads().stream().filter(rec -> rec.getMappingQuality() >= minMappingQuality).forEach(result::add);
    return result;
}
Also used : java.util(java.util) AssemblyRegion(org.broadinstitute.hellbender.engine.AssemblyRegion) ReadClipper(org.broadinstitute.hellbender.utils.clipping.ReadClipper) GATKRead(org.broadinstitute.hellbender.utils.read.GATKRead) SAMFileHeader(htsjdk.samtools.SAMFileHeader) FragmentCollection(org.broadinstitute.hellbender.utils.fragments.FragmentCollection) HaplotypeBAMWriter(org.broadinstitute.hellbender.utils.haplotype.HaplotypeBAMWriter) ReferenceSequenceFile(htsjdk.samtools.reference.ReferenceSequenceFile) ReadUtils(org.broadinstitute.hellbender.utils.read.ReadUtils) AlignmentUtils(org.broadinstitute.hellbender.utils.read.AlignmentUtils) Locatable(htsjdk.samtools.util.Locatable) GATKVariantContextUtils(org.broadinstitute.hellbender.utils.variant.GATKVariantContextUtils) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) ReadCoordinateComparator(org.broadinstitute.hellbender.utils.read.ReadCoordinateComparator) SAMFileWriter(htsjdk.samtools.SAMFileWriter) QualityUtils(org.broadinstitute.hellbender.utils.QualityUtils) SampleList(org.broadinstitute.hellbender.utils.genotyper.SampleList) SimpleInterval(org.broadinstitute.hellbender.utils.SimpleInterval) Collectors(java.util.stream.Collectors) File(java.io.File) FileNotFoundException(java.io.FileNotFoundException) FragmentUtils(org.broadinstitute.hellbender.utils.fragments.FragmentUtils) ReadLikelihoods(org.broadinstitute.hellbender.utils.genotyper.ReadLikelihoods) Logger(org.apache.logging.log4j.Logger) ReadThreadingAssembler(org.broadinstitute.hellbender.tools.walkers.haplotypecaller.readthreading.ReadThreadingAssembler) UserException(org.broadinstitute.hellbender.exceptions.UserException) VariantContext(htsjdk.variant.variantcontext.VariantContext) Haplotype(org.broadinstitute.hellbender.utils.haplotype.Haplotype) AssemblyRegion(org.broadinstitute.hellbender.engine.AssemblyRegion)

Aggregations

AssemblyRegion (org.broadinstitute.hellbender.engine.AssemblyRegion)13 Haplotype (org.broadinstitute.hellbender.utils.haplotype.Haplotype)8 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)7 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)4 Test (org.testng.annotations.Test)4 Cigar (htsjdk.samtools.Cigar)2 CigarElement (htsjdk.samtools.CigarElement)2 SAMFileHeader (htsjdk.samtools.SAMFileHeader)2 SAMFileWriter (htsjdk.samtools.SAMFileWriter)2 ReferenceSequenceFile (htsjdk.samtools.reference.ReferenceSequenceFile)2 Locatable (htsjdk.samtools.util.Locatable)2 VariantContext (htsjdk.variant.variantcontext.VariantContext)2 File (java.io.File)2 FileNotFoundException (java.io.FileNotFoundException)2 java.util (java.util)2 Collectors (java.util.stream.Collectors)2 Logger (org.apache.logging.log4j.Logger)2 UserException (org.broadinstitute.hellbender.exceptions.UserException)2 AssemblyResultSet (org.broadinstitute.hellbender.tools.walkers.haplotypecaller.AssemblyResultSet)2 KBestHaplotype (org.broadinstitute.hellbender.tools.walkers.haplotypecaller.graphs.KBestHaplotype)2