Examples of SAMReadGroupRecord


Examples of htsjdk.samtools.SAMReadGroupRecord

    @Test()
    public void testPLFromReadWithRGButNoPL() {
        final SAMFileHeader header = ArtificialSAMUtils.createArtificialSamHeader(seq.getSequenceDictionary());
        final String rgID = "ID";
        final SAMReadGroupRecord rg = new SAMReadGroupRecord(rgID);
        header.addReadGroup(rg);
        final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 1, 10);
        read.setAttribute("RG", rgID);
        Assert.assertEquals(NGSPlatform.fromRead(read), NGSPlatform.UNKNOWN);
    }
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

            default:
                throw new UserException("Must use valid CountPileupType");
        }

        for (PileupElement e : countPileup) {
            SAMReadGroupRecord readGroup = getReadGroup(e.getRead());
            if (!countsByRG.keySet().contains(readGroup))
                countsByRG.put(readGroup, new int[6]);

            updateCounts(countsByRG.get(readGroup), e);
        }
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

            }
        }
    }

    private static SAMReadGroupRecord getReadGroup(SAMRecord r) {
        SAMReadGroupRecord rg = r.getReadGroup();
        if ( rg == null ) {
            String msg = "Read "+r.getReadName()+" lacks read group information; Please associate all reads with read groups";
            throw new UserException.MalformedBAM(r, msg);
        }
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

     * @return true if the read passes the filter, false if it doesn't
     */
    public boolean filter(ReferenceContext ref, GATKSAMRecord read) {
        // check that the read belongs to an RG that we need to keep
        if (!readGroupsToKeep.isEmpty()) {
            final SAMReadGroupRecord readGroup = read.getReadGroup();
            if (!readGroupsToKeep.contains(readGroup.getReadGroupId()))
                return false;
        }

        // check if we've reached the output limit
        if ( nReadsToPrint == 0 ) {
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

    @Override
    public Integer map(final ReferenceContext referenceContext,final GATKSAMRecord samRecord,final RefMetaDataTracker RefMetaDataTracker) {

        final int length = Math.abs(samRecord.getReadLength());
        final SAMReadGroupRecord rg = samRecord.getReadGroup();

        increment(table,length, rg);

        return null;
    }
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

            readI++;
            return makeRead();
        }

        private GATKSAMRecord makeRead() {
            final SAMReadGroupRecord rg = header.getReadGroups().get(0);
            final String readName = String.format("%s.%d.%s", "read", readI, rg.getId());
            final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, readName, 0, 1, readLength);
            read.setReadGroup(new GATKSAMReadGroupRecord(rg));
            if ( payloadInBytes > 0 )
                // add a payload byte array to push memory use per read even higher
                read.setAttribute("PL", new byte[payloadInBytes]);
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

                PairedReadSequence prs = pendingByName.remove(rec.getReadName());
                if (prs == null) {
                    // Make a new paired read object and add RG and physical location information to it
                    prs = new PairedReadSequence();
                    if (opticalDuplicateFinder.addLocationInformation(rec.getReadName(), prs)) {
                        final SAMReadGroupRecord rg = rec.getReadGroup();
                        if (rg != null) prs.setReadGroup((short) readGroups.indexOf(rg));
                    }

                    pendingByName.put(rec.getReadName(), prs);
                }
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

        return srec ;
    }

    /** Creates a simple header with the values provided on the command line. */
    private SAMFileHeader createFileHeader() {
        final SAMReadGroupRecord rgroup = new SAMReadGroupRecord(this.READ_GROUP_NAME);
        rgroup.setSample(this.SAMPLE_NAME);
        if (this.LIBRARY_NAME != null) rgroup.setLibrary(this.LIBRARY_NAME);
        if (this.PLATFORM != null) rgroup.setPlatform(this.PLATFORM);
        if (this.PLATFORM_UNIT != null) rgroup.setPlatformUnit(this.PLATFORM_UNIT);
        if (this.SEQUENCING_CENTER != null) rgroup.setSequencingCenter(SEQUENCING_CENTER);
        if (this.PREDICTED_INSERT_SIZE != null) rgroup.setPredictedMedianInsertSize(PREDICTED_INSERT_SIZE);
        if (this.DESCRIPTION != null) rgroup.setDescription(this.DESCRIPTION);
        if (this.RUN_DATE != null) rgroup.setRunDate(this.RUN_DATE);

        final SAMFileHeader header = new SAMFileHeader();
        header.addReadGroup(rgroup);

        for (final String comment : COMMENT) {
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

     * @return A SAMFileWriter
     */
    private SAMFileWriterWrapper buildSamFileWriter(final File output, final String sampleAlias,
                                                    final String libraryName, final Map<String, String> headerParameters) {
        IOUtil.assertFileIsWritable(output);
        final SAMReadGroupRecord rg = new SAMReadGroupRecord(READ_GROUP_ID);
        rg.setSample(sampleAlias);

        if (libraryName != null) rg.setLibrary(libraryName);
        for (final Map.Entry<String, String> tagNameToValue : headerParameters.entrySet()) {
            if (tagNameToValue.getValue() != null) {
                rg.setAttribute(tagNameToValue.getKey(), tagNameToValue.getValue());
            }
        }

        final SAMFileHeader header = new SAMFileHeader();
        header.setSortOrder(SAMFileHeader.SortOrder.queryname);
View Full Code Here

Examples of htsjdk.samtools.SAMReadGroupRecord

        IOUtil.assertFileIsWritable(OUTPUT);

        final SAMFileReader in = new SAMFileReader(INPUT);

        // create the read group we'll be using
        final SAMReadGroupRecord rg = new SAMReadGroupRecord(RGID);
        rg.setLibrary(RGLB);
        rg.setPlatform(RGPL);
        rg.setSample(RGSM);
        rg.setPlatformUnit(RGPU);
        if (RGCN != null) rg.setSequencingCenter(RGCN);
        if (RGDS != null) rg.setDescription(RGDS);
        if (RGDT != null) rg.setRunDate(RGDT);
        if (RGPI != null) rg.setPredictedMedianInsertSize(RGPI);

        log.info(String.format("Created read group ID=%s PL=%s LB=%s SM=%s%n", rg.getId(), rg.getPlatform(), rg.getLibrary(), rg.getSample()));

        // create the new header and output file
        final SAMFileHeader inHeader = in.getFileHeader();
        final SAMFileHeader outHeader = inHeader.clone();
        outHeader.setReadGroups(Arrays.asList(rg));
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.