Search in sources :

Example 1 with CachingIndexedFastaSequenceFile

use of org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile in project gatk by broadinstitute.

the class GenomeLocParserUnitTest method testcreateGenomeLocOnContig.

@Test
public void testcreateGenomeLocOnContig() throws FileNotFoundException {
    final CachingIndexedFastaSequenceFile seq = new CachingIndexedFastaSequenceFile(new File(exampleReference));
    final SAMSequenceDictionary dict = seq.getSequenceDictionary();
    final GenomeLocParser genomeLocParser = new GenomeLocParser(dict);
    for (final SAMSequenceRecord rec : dict.getSequences()) {
        final GenomeLoc loc = genomeLocParser.createOverEntireContig(rec.getSequenceName());
        Assert.assertEquals(loc.getContig(), rec.getSequenceName());
        Assert.assertEquals(loc.getStart(), 1);
        Assert.assertEquals(loc.getStop(), rec.getSequenceLength());
    }
}
Also used : CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) SAMSequenceRecord(htsjdk.samtools.SAMSequenceRecord) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) File(java.io.File) SAMSequenceDictionary(htsjdk.samtools.SAMSequenceDictionary) BaseTest(org.broadinstitute.hellbender.utils.test.BaseTest) Test(org.testng.annotations.Test)

Example 2 with CachingIndexedFastaSequenceFile

use of org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile in project gatk by broadinstitute.

the class GenomeLocSortedSetUnitTest method makeGetOverlappingTest.

// -----------------------------------------------------------------------------------------------
//
// Test getOverlapping
//
// -----------------------------------------------------------------------------------------------
@DataProvider(name = "GetOverlapping")
public Object[][] makeGetOverlappingTest() throws Exception {
    final GenomeLocParser genomeLocParser = new GenomeLocParser(new CachingIndexedFastaSequenceFile(new File(exampleReference)));
    List<Object[]> tests = new ArrayList<>();
    final GenomeLoc prev1 = genomeLocParser.createGenomeLoc("1", 1, 10);
    final GenomeLoc prev2 = genomeLocParser.createGenomeLoc("1", 20, 50);
    final GenomeLoc post1 = genomeLocParser.createGenomeLoc("3", 1, 10);
    final GenomeLoc post2 = genomeLocParser.createGenomeLoc("3", 20, 50);
    final int chr20Length = genomeLocParser.getSequenceDictionary().getSequence("2").getSequenceLength();
    for (final int regionStart : Arrays.asList(1, 10, chr20Length - 10, chr20Length)) {
        for (final int regionSize : Arrays.asList(1, 10, 100)) {
            final GenomeLoc region = genomeLocParser.createGenomeLocOnContig("2", regionStart, regionStart + regionSize);
            final GenomeLoc spanning = genomeLocParser.createGenomeLocOnContig("2", regionStart - 10, region.getStop() + 10);
            final GenomeLoc before_into = genomeLocParser.createGenomeLocOnContig("2", regionStart - 10, regionStart + 1);
            final GenomeLoc middle = genomeLocParser.createGenomeLocOnContig("2", regionStart + 1, regionStart + 2);
            final GenomeLoc middle_past = genomeLocParser.createGenomeLocOnContig("2", region.getStop() - 1, region.getStop() + 10);
            final List<GenomeLoc> potentials = new LinkedList<>();
            potentials.add(region);
            if (spanning != null)
                potentials.add(spanning);
            if (before_into != null)
                potentials.add(before_into);
            if (middle != null)
                potentials.add(middle);
            if (middle_past != null)
                potentials.add(middle_past);
            for (final int n : Arrays.asList(1, 2, 3)) {
                for (final List<GenomeLoc> regions : Utils.makePermutations(potentials, n, false)) {
                    tests.add(new Object[] { new GenomeLocSortedSet(genomeLocParser, regions), region });
                    tests.add(new Object[] { new GenomeLocSortedSet(genomeLocParser, Utils.append(regions, prev1)), region });
                    tests.add(new Object[] { new GenomeLocSortedSet(genomeLocParser, Utils.append(regions, prev1, prev2)), region });
                    tests.add(new Object[] { new GenomeLocSortedSet(genomeLocParser, Utils.append(regions, post1)), region });
                    tests.add(new Object[] { new GenomeLocSortedSet(genomeLocParser, Utils.append(regions, post1, post2)), region });
                    tests.add(new Object[] { new GenomeLocSortedSet(genomeLocParser, Utils.append(regions, prev1, post1)), region });
                    tests.add(new Object[] { new GenomeLocSortedSet(genomeLocParser, Utils.append(regions, prev1, prev2, post1, post2)), region });
                }
            }
        }
    }
    return tests.toArray(new Object[][] {});
}
Also used : CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) File(java.io.File) DataProvider(org.testng.annotations.DataProvider)

Example 3 with CachingIndexedFastaSequenceFile

use of org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile in project gatk by broadinstitute.

the class ReadThreadingAssemblerUnitTest method setup.

@BeforeClass
public void setup() throws FileNotFoundException {
    seq = new CachingIndexedFastaSequenceFile(new File(hg19_chr1_1M_Reference));
    header = ArtificialReadUtils.createArtificialSamHeader(seq.getSequenceDictionary());
}
Also used : CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) BeforeClass(org.testng.annotations.BeforeClass)

Example 4 with CachingIndexedFastaSequenceFile

use of org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile in project gatk by broadinstitute.

the class SplitNCigarReads method onTraversalStart.

@Override
public void onTraversalStart() {
    header = getHeaderForSAMWriter();
    rnaReadTransform = REFACTOR_NDN_CIGAR_READS ? new NDNCigarReadTransformer() : ReadTransformer.identity();
    try {
        referenceReader = new CachingIndexedFastaSequenceFile(referenceArguments.getReferenceFile());
        GenomeLocParser genomeLocParser = new GenomeLocParser(getBestAvailableSequenceDictionary());
        outputWriter = createSAMWriter(OUTPUT, false);
        overhangManager = new OverhangFixingManager(header, outputWriter, genomeLocParser, referenceReader, MAX_RECORDS_IN_MEMORY, MAX_MISMATCHES_IN_OVERHANG, MAX_BASES_TO_CLIP, doNotFixOverhangs, processSecondaryAlignments);
    } catch (FileNotFoundException ex) {
        throw new UserException.CouldNotReadInputFile(referenceArguments.getReferenceFile(), ex);
    }
}
Also used : NDNCigarReadTransformer(org.broadinstitute.hellbender.transformers.NDNCigarReadTransformer) FileNotFoundException(java.io.FileNotFoundException) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) UserException(org.broadinstitute.hellbender.exceptions.UserException) GenomeLocParser(org.broadinstitute.hellbender.utils.GenomeLocParser)

Example 5 with CachingIndexedFastaSequenceFile

use of org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile in project gatk-protected by broadinstitute.

the class ReadThreadingAssemblerUnitTest method setup.

@BeforeClass
public void setup() throws FileNotFoundException {
    seq = new CachingIndexedFastaSequenceFile(new File(hg19_chr1_1M_Reference));
    header = ArtificialReadUtils.createArtificialSamHeader(seq.getSequenceDictionary());
}
Also used : CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) CachingIndexedFastaSequenceFile(org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile) File(java.io.File) IndexedFastaSequenceFile(htsjdk.samtools.reference.IndexedFastaSequenceFile) BeforeClass(org.testng.annotations.BeforeClass)

Aggregations

CachingIndexedFastaSequenceFile (org.broadinstitute.hellbender.utils.fasta.CachingIndexedFastaSequenceFile)15 File (java.io.File)14 BeforeClass (org.testng.annotations.BeforeClass)6 SAMFileHeader (htsjdk.samtools.SAMFileHeader)5 IndexedFastaSequenceFile (htsjdk.samtools.reference.IndexedFastaSequenceFile)5 BaseTest (org.broadinstitute.hellbender.utils.test.BaseTest)5 Test (org.testng.annotations.Test)5 ReferenceSequenceFile (htsjdk.samtools.reference.ReferenceSequenceFile)4 FileNotFoundException (java.io.FileNotFoundException)3 UserException (org.broadinstitute.hellbender.exceptions.UserException)3 GenomeLocParser (org.broadinstitute.hellbender.utils.GenomeLocParser)3 ReadFilter (org.broadinstitute.hellbender.engine.filters.ReadFilter)2 SimpleInterval (org.broadinstitute.hellbender.utils.SimpleInterval)2 ActivityProfileState (org.broadinstitute.hellbender.utils.activityprofile.ActivityProfileState)2 ReadFilteringIterator (org.broadinstitute.hellbender.utils.iterators.ReadFilteringIterator)2 LocusIteratorByState (org.broadinstitute.hellbender.utils.locusiterator.LocusIteratorByState)2 GATKRead (org.broadinstitute.hellbender.utils.read.GATKRead)2 SAMSequenceDictionary (htsjdk.samtools.SAMSequenceDictionary)1 SAMSequenceRecord (htsjdk.samtools.SAMSequenceRecord)1 NDNCigarReadTransformer (org.broadinstitute.hellbender.transformers.NDNCigarReadTransformer)1