Package htsjdk.samtools

Examples of htsjdk.samtools.SAMFileHeader


        genomeLocParser.parseGenomeLoc("Bad:0-1");
    }

    @Test
    public void testContigHasColon() {
        SAMFileHeader header = new SAMFileHeader();
        header.setSortOrder(htsjdk.samtools.SAMFileHeader.SortOrder.coordinate);
        SAMSequenceDictionary dict = new SAMSequenceDictionary();
        SAMSequenceRecord rec = new SAMSequenceRecord("c:h:r1", 10);
        rec.setSequenceLength(10);
        dict.addSequence(rec);
        header.setSequenceDictionary(dict);

        final GenomeLocParser myGenomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
        GenomeLoc loc = myGenomeLocParser.parseGenomeLoc("c:h:r1:4-5");
        assertEquals(0, loc.getContigIndex());
        assertEquals(loc.getStart(), 4);
        assertEquals(loc.getStop(), 5);
    }
View Full Code Here


    }

    @DataProvider(name = "flankingGenomeLocs")
    public Object[][] getFlankingGenomeLocs() {
        int contigLength = 10000;
        SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, contigLength);
        GenomeLocParser parser = new GenomeLocParser(header.getSequenceDictionary());

        new FlankingGenomeLocTestData("atStartBase1", parser, 1,
                "chr1:1", null, "chr1:2");

        new FlankingGenomeLocTestData("atStartBase50", parser, 50,
View Full Code Here

        return tests.toArray(new Object[][]{});
    }

    @Test( dataProvider = "parseGenomeLoc")
    public void testParsingPositions(final String string, final String contig, final int start) {
        SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 10000000);
        GenomeLocParser genomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
        final GenomeLoc loc = genomeLocParser.parseGenomeLoc(string);
        Assert.assertEquals(loc.getContig(), contig);
        Assert.assertEquals(loc.getStart(), start);
        Assert.assertEquals(loc.getStop(), start);
    }
View Full Code Here

            samplesToChoose.addAll(sampleNames);

        random = GenomeAnalysisEngine.getRandomGenerator();

        if (toolkit != null) {
            final SAMFileHeader outputHeader = toolkit.getSAMFileHeader().clone();
            readGroupsToKeep = determineReadGroupsOfInterest(outputHeader, samplesToChoose);

            //If some read groups are to be excluded, remove them from the output header
            pruneReadGroups(outputHeader);
View Full Code Here

        }

        liftOver.setLiftOverMinMatch(LiftOver.DEFAULT_LIFTOVER_MINMATCH);

        try {
            final SAMFileHeader toHeader = new SAMFileReader(NEW_SEQ_DICT).getFileHeader();
            liftOver.validateToSequences(toHeader.getSequenceDictionary());
        } catch (RuntimeException e) {
            throw new UserException.BadInput("the chain file you are using is not compatible with the reference you are trying to lift over to; please use the appropriate chain file for the given reference");   
        }

        String trackName = variantCollection.variants.getName();
View Full Code Here

//    @Test(enabled = true, dataProvider = "LIBS_NotHoldingTooManyReads", timeOut = 100000)
    public void testLIBS_NotHoldingTooManyReads(final int nReadsPerLocus, final int downsampleTo, final int payloadInBytes) {
        logger.warn(String.format("testLIBS_NotHoldingTooManyReads %d %d %d", nReadsPerLocus, downsampleTo, payloadInBytes));
        final int readLength = 10;

        final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 100000);
        final int nSamples = 1;
        final List<String> samples = new ArrayList<String>(nSamples);
        for ( int i = 0; i < nSamples; i++ ) {
            final GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord("rg" + i);
            final String sample = "sample" + i;
            samples.add(sample);
            rg.setSample(sample);
            rg.setPlatform(NGSPlatform.ILLUMINA.getDefaultPlatform());
            header.addReadGroup(rg);
        }

        final boolean downsample = downsampleTo != -1;
        final DownsamplingMethod downsampler = downsample
                ? new DownsamplingMethod(DownsampleType.BY_SAMPLE, downsampleTo, null)
View Full Code Here

    public Map<String, SAMFileWriter> reduceInit() {
        HashMap<String, SAMFileHeader> headers = new HashMap<>();
        for ( SAMReadGroupRecord readGroup : this.getToolkit().getSAMFileHeader().getReadGroups()) {
            final String sample = readGroup.getSample();
            if ( ! headers.containsKey(sample) ) {
                SAMFileHeader header = duplicateSAMFileHeader(this.getToolkit().getSAMFileHeader());
                logger.debug(String.format("Creating BAM header for sample %s", sample));
                ArrayList<SAMReadGroupRecord> readGroups = new ArrayList<>();
                header.setReadGroups(readGroups);
                headers.put(sample, header);
            }

            SAMFileHeader header = headers.get(sample);
            List<SAMReadGroupRecord> newReadGroups = new ArrayList<>(header.getReadGroups());
            newReadGroups.add(readGroup);
            header.setReadGroups(newReadGroups);
        }

        HashMap<String, SAMFileWriter> outputs = new HashMap<>();
        for ( Map.Entry<String, SAMFileHeader> elt : headers.entrySet() ) {
            final String sample = elt.getKey();
View Full Code Here

        return outputs;
    }

    public static SAMFileHeader duplicateSAMFileHeader(SAMFileHeader toCopy) {
        SAMFileHeader copy = new SAMFileHeader();

        copy.setSortOrder(toCopy.getSortOrder());
        copy.setGroupOrder(toCopy.getGroupOrder());
        copy.setProgramRecords(toCopy.getProgramRecords());
        copy.setReadGroups(toCopy.getReadGroups());
        copy.setSequenceDictionary(toCopy.getSequenceDictionary());

        for (Map.Entry<String, String> e : toCopy.getAttributes())
            copy.setAttribute(e.getKey(), e.getValue());

        return copy;
    }
View Full Code Here

    protected SAMDataSource readsDataSource;

    @BeforeClass
    public void setup() throws FileNotFoundException {
        // sequence
        final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(10, 0, 10000);
        genomeLocParser = new GenomeLocParser(header.getSequenceDictionary());
        readsDataSource = null;
    }
View Full Code Here

        List<GenomeLoc> flankingList = getFlankingIntervals(parser, originalList, basePairs);

        if (flankingList.isEmpty())
            throw new UserException.MalformedFile(inputIntervals, "Unable to produce any flanks for the intervals");

        SAMFileHeader samFileHeader = new SAMFileHeader();
        samFileHeader.setSequenceDictionary(referenceDataSource.getReference().getSequenceDictionary());
        IntervalList intervalList = new IntervalList(samFileHeader);
        int i = 0;
        for (GenomeLoc loc: flankingList)
            intervalList.add(toInterval(loc, ++i));
        intervalList.write(flankingIntervals);
View Full Code Here

TOP

Related Classes of htsjdk.samtools.SAMFileHeader

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.