public void setReadGroup( final GATKSAMReadGroupRecord readGroup ) { mReadGroup = readGroup; retrievedReadGroup = true; setAttribute("RG", mReadGroup.getId()); // todo -- this should be standardized, but we don't have access to SAMTagUtils! }
/** * Given a read, outputs the base qualities in a string format * * @param read the read * @return a string representation of the base qualities */ public static String convertReadQualToString(GATKSAMRecord read) { return convertReadQualToString(read.getBaseQualities()); }
public static GATKSAMRecord createRandomRead(int length, boolean allowNs) { byte[] quals = ReadUtils.createRandomReadQuals(length); byte[] bbases = ReadUtils.createRandomReadBases(length, allowNs); return ArtificialSAMUtils.createArtificialRead(bbases, quals, bbases.length + "M"); }
private Cigar makeExpectedCigar1(final Cigar originalCigar, final char indelOp, final int indelStart, final int indelSize, final int readLength) { if ( indelSize == 0 || indelStart < 17 || indelStart > (26 - (indelOp == 'D' ? indelSize : 0)) ) return originalCigar; final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 1, readLength); read.setCigarString(buildTestCigarString(indelOp, 0, 16, indelSize, readLength)); return read.getCigar(); }
private GATKSAMRecord makeRead(final int fragmentSize, final int mateStart) { final byte[] bases = {'A', 'C', 'G', 'T', 'A', 'C', 'G', 'T'}; final byte[] quals = {30, 30, 30, 30, 30, 30, 30, 30}; final String cigar = "8M"; GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(bases, quals, cigar); read.setProperPairFlag(true); read.setReadPairedFlag(true); read.setMateAlignmentStart(mateStart); read.setInferredInsertSize(fragmentSize); return read; }
public static final GATKSAMRecord addReadGroup(GATKSAMRecord rec, String readGroupName) { GATKSAMReadGroupRecord rgRec = new GATKSAMReadGroupRecord(readGroupName); rgRec.setSample("sample"); rec.setReadGroup(rgRec); return rec; }
/** * @see #getMismatchCount(GATKSAMRecord, byte[], int, int, int) with startOnRead == 0 and nReadBases == read.getReadLength() */ public static MismatchCount getMismatchCount(GATKSAMRecord r, byte[] refSeq, int refIndex) { return getMismatchCount(r, refSeq, refIndex, 0, r.getReadLength()); }
/** * Returns the reverse complement of the read bases * * @param read the read * @return the reverse complement of the read bases */ public static String getBasesReverseComplement(GATKSAMRecord read) { return getBasesReverseComplement(read.getReadBases()); }
/** * create an iterator containing the specified read piles * * @param startingChr the chromosome (reference ID) to start from * @param endingChr the id to end with * @param readCount the number of reads per chromosome * @return GATKSAMIterator representing the specified amount of fake data */ public static GATKSAMIterator mappedReadIterator(int startingChr, int endingChr, int readCount) { SAMFileHeader header = createArtificialSamHeader((endingChr - startingChr) + 1, startingChr, readCount + DEFAULT_READ_LENGTH); return new ArtificialSAMQueryIterator(startingChr, endingChr, readCount, 0, header); }
/** * Get the element for the given read at the given reference position * * @param read the read * @param refLoc the reference position * @return a Double representing the element to be used in the rank sum test, or null if it should not be used */ @Override protected Double getElementForRead(final GATKSAMRecord read, final int refLoc) { return (double) read.getBaseQualities()[ReadUtils.getReadCoordinateForReferenceCoordinateUpToEndOfRead(read, refLoc, ReadUtils.ClippingTail.RIGHT_TAIL)]; }
/** * Efficient caching accessor that returns the GATK NGSPlatform of this read * @return */ public NGSPlatform getNGSPlatform() { return getReadGroup().getNGSPlatform(); }
/** * Determines whether the read aligns off the end of the contig. * Pulled out to make it testable. * * @param read the read to check * @return true if it aligns off the end */ protected static boolean realignmentProducesBadAlignment(final GATKSAMRecord read, final int contigLength) { return read.getAlignmentEnd() > contigLength; }
/** * query containing - get reads contained by the specified interval * * @param contig the contig index string * @param start the start position * @param stop the stop position */ public void queryContained( String contig, int start, int stop ) { this.overlapping = false; initialize(contig, start, stop); }
/** * Construct a new read stream analyzer, providing an ArtificialSingleSampleReadStream that will * serve as the basis for comparison after the analysis is complete. * * @param originalStream the original ArtificialSingleSampleReadStream upon which the stream * that will be fed to the analyzer is based */ public ArtificialSingleSampleReadStreamAnalyzer( ArtificialSingleSampleReadStream originalStream ) { this.originalStream = originalStream; reset(); }
/** * Gets the SAM file associated with a given reader ID. * @param id The reader for which to retrieve the source file. * @return the file actually associated with the id. */ public File getSAMFile(SAMReaderID id) { return id.getSamFile(); }
private Cigar makeExpectedCigar2(final Cigar originalCigar, final char indelOp, final int indelStart, final int indelSize, final int readLength) { if ( indelStart < 17 || indelStart > (26 - (indelOp == 'D' ? indelSize : 0)) ) return originalCigar; final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, 1, readLength); if ( indelOp == 'I' && (indelSize == 1 || indelSize == 3) && indelStart % 2 == 1 ) read.setCigarString(buildTestCigarString(indelOp, 0, Math.max(indelStart - indelSize, 16), indelSize, readLength)); else if ( (indelSize == 2 || indelSize == 4) && (indelOp == 'D' || indelStart % 2 == 0) ) read.setCigarString(buildTestCigarString(indelOp, 0, 16, indelSize, readLength)); else return originalCigar; return read.getCigar(); }
/** * create an ArtificialSAMQueryIterator containing the specified read piles * * @param startingChr the chromosome (reference ID) to start from * @param endingChr the id to end with * @param readCount the number of reads per chromosome * @return GATKSAMIterator representing the specified amount of fake data */ public static ArtificialSAMQueryIterator queryReadIterator(int startingChr, int endingChr, int readCount) { SAMFileHeader header = createArtificialSamHeader((endingChr - startingChr) + 1, startingChr, readCount + DEFAULT_READ_LENGTH); return new ArtificialSAMQueryIterator(startingChr, endingChr, readCount, 0, header); }
@Override protected Double getElementForRead(final GATKSAMRecord read, final int refLoc) { return (double)read.getBaseQualities()[ReadUtils.getReadCoordinateForReferenceCoordinateUpToEndOfRead(read, refLoc, ReadUtils.ClippingTail.RIGHT_TAIL)]; }
/** * create an ArtificialSAMQueryIterator containing the specified read piles * * @param startingChr the chromosome (reference ID) to start from * @param endingChr the id to end with * @param readCount the number of reads per chromosome * @param unmappedReadCount the count of unmapped reads to place at the end of the iterator, like in a sorted bam file * @return GATKSAMIterator representing the specified amount of fake data */ public static GATKSAMIterator queryReadIterator(int startingChr, int endingChr, int readCount, int unmappedReadCount) { SAMFileHeader header = createArtificialSamHeader((endingChr - startingChr) + 1, startingChr, readCount + DEFAULT_READ_LENGTH); return new ArtificialSAMQueryIterator(startingChr, endingChr, readCount, unmappedReadCount, header); }
/** * create an iterator containing the specified read piles * * @param startingChr the chromosome (reference ID) to start from * @param endingChr the id to end with * @param readCount the number of reads per chromosome * @param unmappedReadCount the count of unmapped reads to place at the end of the iterator, like in a sorted bam file * @return GATKSAMIterator representing the specified amount of fake data */ public static GATKSAMIterator mappedAndUnmappedReadIterator(int startingChr, int endingChr, int readCount, int unmappedReadCount) { SAMFileHeader header = createArtificialSamHeader((endingChr - startingChr) + 1, startingChr, readCount + DEFAULT_READ_LENGTH); return new ArtificialSAMQueryIterator(startingChr, endingChr, readCount, unmappedReadCount, header); }