public static final GATKSAMRecord addReadGroup(GATKSAMRecord rec, String readGroupName) { GATKSAMReadGroupRecord rgRec = new GATKSAMReadGroupRecord(readGroupName); rgRec.setSample("sample"); rec.setReadGroup(rgRec); return rec; }
final String readName = String.format("%s.%d.%d.%s", baseName, locus, readI, rg.getId()); final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, readName, 0, alignmentStart + locus, readLength); read.setReadGroup(rg); reads.add(read);
public GATKSAMRecord makeRead(final int start, final int length) { final byte[] quals = Utils.dupBytes((byte)30, length); final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "read " + readCounter++, 0, start + getStart(), ref.substring(start, start + length).getBytes(), quals, length + "M"); read.setReadGroup(rg); return read; } }
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]); return read; } }
/** * Create an artificial read based on the parameters. The cigar string will be *M, where * is the length of the read * * @param header the SAM header to associate the read with * @param name the name of the read * @param refIndex the reference index, i.e. what chromosome to associate it with * @param alignmentStart where to start the alignment * @param bases the sequence of the read * @param qual the qualities of the read * @return the artificial read */ public static GATKSAMRecord createArtificialRead(SAMFileHeader header, String name, int refIndex, int alignmentStart, byte[] bases, byte[] qual) { if (bases.length != qual.length) { throw new ReviewedGATKException("Passed in read string is different length then the quality array"); } GATKSAMRecord rec = createArtificialRead(header, name, refIndex, alignmentStart, bases.length); rec.setReadBases(bases); rec.setBaseQualities(qual); rec.setReadGroup(new GATKSAMReadGroupRecord("x")); if (refIndex == -1) { rec.setReadUnmappedFlag(true); } return rec; }
/** * Clears all attributes except ReadGroup of the read. */ public GATKSAMRecord simplify () { GATKSAMReadGroupRecord rg = getReadGroup(); // save the read group information byte[] insQuals = (this.getAttribute(BQSR_BASE_INSERTION_QUALITIES) == null) ? null : getBaseInsertionQualities(); byte[] delQuals = (this.getAttribute(BQSR_BASE_DELETION_QUALITIES) == null) ? null : getBaseDeletionQualities(); this.clearAttributes(); // clear all attributes from the read this.setReadGroup(rg); // restore read group if (insQuals != null) this.setBaseQualities(insQuals, EventType.BASE_INSERTION); // restore base insertion if we had any if (delQuals != null) this.setBaseQualities(delQuals, EventType.BASE_DELETION); // restore base deletion if we had any return this; }
private GATKSAMRecord makeOverlappingRead(final String leftFlank, final int leftQual, final String overlapBases, final byte[] overlapQuals, final String rightFlank, final int rightQual, final int alignmentStart) { final String bases = leftFlank + overlapBases + rightFlank; final int readLength = bases.length(); final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "myRead", 0, alignmentStart, readLength); final byte[] leftQuals = Utils.dupBytes((byte) leftQual, leftFlank.length()); final byte[] rightQuals = Utils.dupBytes((byte) rightQual, rightFlank.length()); final byte[] quals = Utils.concat(leftQuals, overlapQuals, rightQuals); read.setCigarString(readLength + "M"); read.setReadBases(bases.getBytes()); for ( final EventType type : EventType.values() ) read.setBaseQualities(quals, type); read.setReadGroup(rgForMerged); read.setMappingQuality(60); return read; }
@Test(enabled = true) public void testMaxCyclePasses() { int readLength = RAC.MAXIMUM_CYCLE_VALUE; GATKSAMRecord read = ReadUtils.createRandomRead(readLength); read.setReadPairedFlag(true); read.setReadGroup(new GATKSAMReadGroupRecord("MY.ID")); read.getReadGroup().setPlatform("illumina"); ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1); covariate.recordValues(read, readCovariates); } }
@Test(enabled = true, expectedExceptions={UserException.class}) public void testMoreThanMaxCycleFails() { int readLength = RAC.MAXIMUM_CYCLE_VALUE + 1; GATKSAMRecord read = ReadUtils.createRandomRead(readLength); read.setReadPairedFlag(true); read.setReadGroup(new GATKSAMReadGroupRecord("MY.ID")); read.getReadGroup().setPlatform("illumina"); ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1); covariate.recordValues(read, readCovariates); }
private static void runTest(final GATKSAMReadGroupRecord rg, final String expected, final ReadGroupCovariate covariate) { GATKSAMRecord read = ReadUtils.createRandomRead(10); read.setReadGroup(rg); ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1); covariate.recordValues(read, readCovariates); verifyCovariateArray(readCovariates.getMismatchesKeySet(), expected, covariate); }
protected GATKSAMRecord buildSAMRecord(final String readName, final String contig, final int alignmentStart) { GATKSAMRecord record = new GATKSAMRecord(header); record.setReadName(readName); record.setReferenceIndex(dictionary.getSequenceIndex(contig)); record.setAlignmentStart(alignmentStart); record.setCigarString("1M"); record.setReadString("A"); record.setBaseQualityString("A"); record.setReadGroup(readGroup); return record; }
allI.setReadGroup(new GATKSAMReadGroupRecord(bamBuilder.getHeader().getReadGroups().get(0)));
read.setReferenceName(loc.getContig()); read.setReadNegativeStrandFlag(false); read.setReadGroup(sampleRG(sample));
final GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(rgs); rg.setPlatform("illumina"); read.setReadGroup(rg); read.setReadNegativeStrandFlag(rnd.nextBoolean()); final byte[] mQuals = read.getBaseQualities(EventType.BASE_SUBSTITUTION);
protected GATKSAMRecord buildSAMRecord(String readName, String contig, int alignmentStart, int alignmentEnd) { SAMFileHeader header = ArtificialSAMUtils.createDefaultReadGroup(new SAMFileHeader(), "test", "test"); header.setSequenceDictionary(dictionary); header.setSortOrder(SAMFileHeader.SortOrder.coordinate); GATKSAMRecord record = new GATKSAMRecord(header); record.setReadName(readName); record.setReferenceIndex(dictionary.getSequenceIndex(contig)); record.setAlignmentStart(alignmentStart); Cigar cigar = new Cigar(); int len = alignmentEnd - alignmentStart + 1; cigar.add(new CigarElement(len, CigarOperator.M)); record.setCigar(cigar); record.setReadString(new String(new char[len]).replace("\0", "A")); record.setBaseQualities(new byte[len]); record.setReadGroup(new GATKSAMReadGroupRecord(header.getReadGroup("test"))); return record; }
correctedRead.setReadBases(inputRead.getReadBases()); correctedRead.setReadString(inputRead.getReadString()); correctedRead.setReadGroup(inputRead.getReadGroup()); return correctedRead;
if (samRG != null) { GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(samRG); emptyRead.setReadGroup(rg);
@Test(enabled = true) public void testSimpleCycles() { short readLength = 10; GATKSAMRecord read = ReadUtils.createRandomRead(readLength); read.setReadPairedFlag(true); read.setReadGroup(new GATKSAMReadGroupRecord("MY.ID")); read.getReadGroup().setPlatform("illumina"); ReadCovariates readCovariates = new ReadCovariates(read.getReadLength(), 1); covariate.recordValues(read, readCovariates); verifyCovariateArray(readCovariates.getMismatchesKeySet(), 1, (short) 1); read.setReadNegativeStrandFlag(true); covariate.recordValues(read, readCovariates); verifyCovariateArray(readCovariates.getMismatchesKeySet(), readLength, -1); read.setSecondOfPairFlag(true); covariate.recordValues(read, readCovariates); verifyCovariateArray(readCovariates.getMismatchesKeySet(), -readLength, 1); read.setReadNegativeStrandFlag(false); covariate.recordValues(read, readCovariates); verifyCovariateArray(readCovariates.getMismatchesKeySet(), -1, -1); }
private GATKSAMRecord createReadOffContig(final SAMFileHeader header, final boolean negStrand, final int pre, final int post) { final int contigLen = header.getSequence(0).getSequenceLength(); final int readLen = pre + contigLen + post; final GATKSAMRecord read = ArtificialSAMUtils.createArtificialRead(header, "read1", 0, 1, readLen); read.setAlignmentStart(1); read.setCigar(TextCigarCodec.decode(pre + "S" + contigLen + "M" + post + "S")); read.setBaseQualities(Utils.dupBytes((byte) 30, readLen)); read.setReadBases(Utils.dupBytes((byte)'A', readLen)); read.setMappingQuality(60); read.setMateAlignmentStart(1); read.setProperPairFlag(true); read.setReadPairedFlag(true); read.setInferredInsertSize(30); read.setReadNegativeStrandFlag(negStrand); read.setMateNegativeStrandFlag(! negStrand); read.setReadGroup(new GATKSAMReadGroupRecord("foo")); return read; }