/** * Get the GATKSAMReadGroupRecord of this read * @return a non-null GATKSAMReadGroupRecord */ @Override public GATKSAMReadGroupRecord getReadGroup() { if ( ! retrievedReadGroup ) { final SAMReadGroupRecord rg = super.getReadGroup(); // three cases: rg may be null (no rg, rg may already be a GATKSAMReadGroupRecord, or it may be // a regular SAMReadGroupRecord in which case we have to make it a GATKSAMReadGroupRecord if ( rg == null ) mReadGroup = null; else if ( rg instanceof GATKSAMReadGroupRecord ) mReadGroup = (GATKSAMReadGroupRecord)rg; else mReadGroup = new GATKSAMReadGroupRecord(rg); retrievedReadGroup = true; } return mReadGroup; }
public static final GATKSAMRecord addReadGroup(GATKSAMRecord rec, String readGroupName) { GATKSAMReadGroupRecord rgRec = new GATKSAMReadGroupRecord(readGroupName); rgRec.setSample("sample"); rec.setReadGroup(rgRec); return rec; }
@Test(enabled = true) public void testMissingPlatformUnit() { final String expected = "MY.7"; GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(expected); runTest(rg, expected, covariate); }
@Test(enabled = true) public void testSingleRecord() { final String expected = "SAMPLE.1"; GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord("MY.ID"); rg.setPlatformUnit(expected); runTest(rg, expected, covariate); }
@BeforeTest public void setup() { header = ArtificialSAMUtils.createArtificialSamHeader(1,1,1000); rgForMerged = new GATKSAMReadGroupRecord("RG1"); }
public ArtificialBAMBuilder createAndSetHeader(final int nSamples) { createdReads = null; this.header = new SAMFileHeader(); header.setSortOrder(SAMFileHeader.SortOrder.coordinate); header.setSequenceDictionary(parser.getContigs()); samples.clear(); 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); } return this; }
private GATKSAMReadGroupRecord createRG(String name) { GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(name); rg.setPlatform("ILLUMINA"); rg.setSample(name); return rg; }
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; } }
@Test(enabled = true) public void testForceReadgroup() { final RecalibrationArgumentCollection forcedRAC = new RecalibrationArgumentCollection(); forcedRAC.FORCE_READGROUP = "FOO"; final ReadGroupCovariate forcedCovariate = new ReadGroupCovariate(); forcedCovariate.initialize(forcedRAC); final GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord("NOT_FOO"); runTest(rg, "FOO", forcedCovariate); }
/** * 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; }
@BeforeClass public void setUp() throws Exception { header = ArtificialSAMUtils.createArtificialSamHeader(1, 1, 1000); rg = new GATKSAMReadGroupRecord(RGID); rg.setSample(sample); header.addReadGroup(rg); parser = new GenomeLocParser(header.getSequenceDictionary()); }
@BeforeClass private void init() throws IOException { referenceFile = new File(b37KGReference); reference = new CachingIndexedFastaSequenceFile(referenceFile); dictionary = reference.getSequenceDictionary(); genomeLocParser = new GenomeLocParser(dictionary); header = ArtificialSAMUtils.createDefaultReadGroup(new SAMFileHeader(), "test", "test"); header.setSequenceDictionary(dictionary); header.setSortOrder(SAMFileHeader.SortOrder.coordinate); readGroup = new GATKSAMReadGroupRecord(header.getReadGroup("test")); final List<GATKSAMRecord> reads = new ArrayList<>(); for ( final String contig : contigs ) { for ( int i = 1; i <= numReadsPerContig; i++ ) { reads.add(buildSAMRecord("read" + contig + "_" + i, contig, i)); } } createBAM(reads); }
@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); }
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);
allI.setReadGroup(new GATKSAMReadGroupRecord(bamBuilder.getHeader().getReadGroups().get(0)));
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; }
emptyRead.clearAttributes(); 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; }