Examples of SAMReadGroupRecord


Examples of htsjdk.samtools.SAMReadGroupRecord

        Object pu_attr = samRecord.getAttribute("PU");

        if ( pu_attr == null ) {
            // no platform unit in the record, go get from read group
            SAMReadGroupRecord rgr = samRecord.getReadGroup();
            if ( rgr == null ) throw new UserException.MalformedBAM(samRecord, "Read " + samRecord.getReadName() +" has NO associated read group record");
            pu_attr = rgr.getAttribute("PU") ;
        }
        if ( pu_attr == null ) return false; // could not get PU, forget about the filtering...
        return blackListedLanes.contains((String)pu_attr);
    }
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

    public boolean filterOut(SAMRecord samRecord) {
        for (Entry<String, Collection<String>> filterEntry : filterEntries) {
            String attributeType = filterEntry.getKey();

            SAMReadGroupRecord samReadGroupRecord = samRecord.getReadGroup();
            if (samReadGroupRecord != null) {
                Object attribute;
                if ("ID".equals(attributeType) || "RG".equals(attributeType))
                    attribute = samReadGroupRecord.getId();
                else
                    attribute = samReadGroupRecord.getAttribute(attributeType);
                if (attribute != null && filterEntry.getValue().contains(attribute))
                    return true;
            }
        }
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

public class LibraryReadFilter extends ReadFilter {
    @Argument(fullName = "library", shortName = "library", doc="The name of the library to keep, filtering out all others", required=true)
    private String LIBRARY_TO_KEEP = null;

    public boolean filterOut( final SAMRecord read ) {
        final SAMReadGroupRecord readGroup = read.getReadGroup();
        return ( readGroup == null || readGroup.getLibrary() == null || !readGroup.getLibrary().equals( LIBRARY_TO_KEEP ) );
    }
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

public class SampleFilter extends ReadFilter {
    @Argument(fullName = "sample_to_keep", shortName = "goodSM", doc="The name of the sample(s) to keep, filtering out all others", required=true)
    private Set SAMPLES_TO_KEEP = null;

    public boolean filterOut( final SAMRecord read ) {
        final SAMReadGroupRecord readGroup = read.getReadGroup();
        return !( readGroup != null && SAMPLES_TO_KEEP.contains(readGroup.getSample()) );
    }
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

    /**
     * Ensure that basic read group splitting works.
     */
    @Test
    public void testSplitByReadGroup() {
        SAMReadGroupRecord readGroupOne = new SAMReadGroupRecord("rg1");
        SAMReadGroupRecord readGroupTwo = new SAMReadGroupRecord("rg2");

        SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1,1,1000);
        header.addReadGroup(readGroupOne);
        header.addReadGroup(readGroupTwo);

        GATKSAMRecord read1 = ArtificialSAMUtils.createArtificialRead(header,"read1",0,1,10);
        read1.setAttribute("RG",readGroupOne.getId());
        GATKSAMRecord read2 = ArtificialSAMUtils.createArtificialRead(header,"read2",0,1,10);
        read2.setAttribute("RG",readGroupTwo.getId());
        GATKSAMRecord read3 = ArtificialSAMUtils.createArtificialRead(header,"read3",0,1,10);
        read3.setAttribute("RG",readGroupOne.getId());
        GATKSAMRecord read4 = ArtificialSAMUtils.createArtificialRead(header,"read4",0,1,10);
        read4.setAttribute("RG",readGroupTwo.getId());
        GATKSAMRecord read5 = ArtificialSAMUtils.createArtificialRead(header,"read5",0,1,10);
        read5.setAttribute("RG",readGroupTwo.getId());
        GATKSAMRecord read6 = ArtificialSAMUtils.createArtificialRead(header,"read6",0,1,10);
        read6.setAttribute("RG",readGroupOne.getId());
        GATKSAMRecord read7 = ArtificialSAMUtils.createArtificialRead(header,"read7",0,1,10);
        read7.setAttribute("RG",readGroupOne.getId());

View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

    /**
     * Ensure that splitting read groups still works when dealing with a sample-split pileup.
     */
    @Test
    public void testSplitBySample() {
        SAMReadGroupRecord readGroupOne = new SAMReadGroupRecord("rg1");
        readGroupOne.setSample("sample1");
        SAMReadGroupRecord readGroupTwo = new SAMReadGroupRecord("rg2");
        readGroupTwo.setSample("sample2");

        SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1,1,1000);
        header.addReadGroup(readGroupOne);
        header.addReadGroup(readGroupTwo);

        GATKSAMRecord read1 = ArtificialSAMUtils.createArtificialRead(header,"read1",0,1,10);
        read1.setAttribute("RG",readGroupOne.getId());
        GATKSAMRecord read2 = ArtificialSAMUtils.createArtificialRead(header,"read2",0,1,10);
        read2.setAttribute("RG",readGroupTwo.getId());
        GATKSAMRecord read3 = ArtificialSAMUtils.createArtificialRead(header,"read3",0,1,10);
        read3.setAttribute("RG",readGroupOne.getId());
        GATKSAMRecord read4 = ArtificialSAMUtils.createArtificialRead(header,"read4",0,1,10);
        read4.setAttribute("RG",readGroupTwo.getId());

        ReadBackedPileupImpl sample1Pileup = new ReadBackedPileupImpl(null,
                                                                      Arrays.asList(read1,read3),
                                                                      Arrays.asList(1,1));
        ReadBackedPileupImpl sample2Pileup = new ReadBackedPileupImpl(null,
                                                                      Arrays.asList(read2,read4),
                                                                      Arrays.asList(1,1));
        Map<String,ReadBackedPileupImpl> sampleToPileupMap = new HashMap<String,ReadBackedPileupImpl>();
        sampleToPileupMap.put(readGroupOne.getSample(),sample1Pileup);
        sampleToPileupMap.put(readGroupTwo.getSample(),sample2Pileup);

        ReadBackedPileup compositePileup = new ReadBackedPileupImpl(null,sampleToPileupMap);

        ReadBackedPileup rg1Pileup = compositePileup.getPileupForReadGroup("rg1");
        List<GATKSAMRecord> rg1Reads = rg1Pileup.getReads();
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

    @Test
    public void testGetPileupForSample() {
        String sample1 = "sample1";
        String sample2 = "sample2";

        SAMReadGroupRecord readGroupOne = new SAMReadGroupRecord("rg1");
        readGroupOne.setSample(sample1);
        SAMReadGroupRecord readGroupTwo = new SAMReadGroupRecord("rg2");
        readGroupTwo.setSample(sample2);

        SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(1,1,1000);
        header.addReadGroup(readGroupOne);
        header.addReadGroup(readGroupTwo);

        GATKSAMRecord read1 = ArtificialSAMUtils.createArtificialRead(header,"read1",0,1,10);
        read1.setAttribute("RG",readGroupOne.getId());
        GATKSAMRecord read2 = ArtificialSAMUtils.createArtificialRead(header,"read2",0,1,10);
        read2.setAttribute("RG",readGroupTwo.getId());

        Map<String,ReadBackedPileupImpl> sampleToPileupMap = new HashMap<String,ReadBackedPileupImpl>();
        sampleToPileupMap.put(sample1,new ReadBackedPileupImpl(null,Collections.singletonList(read1),0));
        sampleToPileupMap.put(sample2,new ReadBackedPileupImpl(null,Collections.singletonList(read2),0));
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

    @DataProvider(name = "ArtificialSingleSampleReadStreamTestDataProvider")
    public Object[][] createArtificialSingleSampleReadStreamTests() {
        SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(3, 1, 10000);
        String readGroupID = "testReadGroup";
        SAMReadGroupRecord readGroup = new SAMReadGroupRecord(readGroupID);
        readGroup.setSample("testSample");
        header.addReadGroup(readGroup);

        GenomeAnalysisEngine.resetRandomGenerator();

        // brute force testing!
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

    @DataProvider(name = "ArtificialSingleSampleReadStreamInvalidArgumentsTestDataProvider")
    public Object[][] createInvalidArgumentsTests() {
        SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(3, 1, 10000);
        String readGroupID = "testReadGroup";
        header.addReadGroup(new SAMReadGroupRecord(readGroupID));

        return new Object[][] {
            {"testNullHeader", null, readGroupID, 1, 1, 1, 2, 1, 2, 1, 2, 0},
            {"testNullReadGroup", header, null, 1, 1, 1, 2, 1, 2, 1, 2, 0},
            {"testInvalidReadGroup", header, "foo", 1, 1, 1, 2, 1, 2, 1, 2, 0},
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

     */
    @Test(dataProvider = "TestMappings")
    public void testPLFromReadWithRG(final String plField, final NGSPlatform expected) {
        final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
        final String rgID = "ID";
        final SAMReadGroupRecord rg = new SAMReadGroupRecord(rgID);
        if ( plField != null )
            rg.setPlatform(plField);
        header.addReadGroup(rg);
        final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 1, 10);
        read.setAttribute("RG", rgID);
        Assert.assertEquals(NGSPlatform.fromRead(read), expected);
    }
View Full Code Here
TOP
Copyright © 2018 www.massapi.com. 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.