private GATKSAMReadGroupRecord createRG(String name) { GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(name); rg.setPlatform("ILLUMINA"); rg.setSample(name); return rg; }
final LinkedList<GATKSAMReadGroupRecord> readGroups = new LinkedList<GATKSAMReadGroupRecord>(); for ( final SAMReadGroupRecord rg : header.getReadGroups()) readGroups.add(new GATKSAMReadGroupRecord(rg)); for ( int readI = 0; readI < nReadsPerLocus; readI++ ) { for ( final GATKSAMReadGroupRecord rg : readGroups ) { 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);
private boolean isReadFromNormal(final GATKSAMRecord rec) { return normalSampleName != null && normalSampleName.equals(rec.getReadGroup().getSample()); }
/** * If the sample has a PU tag annotation, return that. If not, return the read group id. * * @param rg the read group record * @return platform unit or readgroup id */ private String readGroupValueFromRG(final GATKSAMReadGroupRecord rg) { if ( forceReadGroup != null ) return forceReadGroup; final String platformUnit = rg.getPlatformUnit(); return platformUnit == null ? rg.getId() : platformUnit; }
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 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); } }
/** * 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; }
/** * Section of code shared between the two recalibration walkers which uses the command line arguments to adjust attributes of the read such as quals or platform string * * @param read The read to adjust * @param RAC The list of shared command line arguments */ public static void parsePlatformForRead(final GATKSAMRecord read, final RecalibrationArgumentCollection RAC) { GATKSAMReadGroupRecord readGroup = read.getReadGroup(); if (RAC.FORCE_PLATFORM != null && (readGroup.getPlatform() == null || !readGroup.getPlatform().equals(RAC.FORCE_PLATFORM))) { readGroup.setPlatform(RAC.FORCE_PLATFORM); } if (readGroup.getPlatform() == null) { if (RAC.DEFAULT_PLATFORM != null) { if (!warnUserNullPlatform) { Utils.warnUser("The input .bam file contains reads with no platform information. " + "Defaulting to platform = " + RAC.DEFAULT_PLATFORM + ". " + "First observed at read with name = " + read.getReadName()); warnUserNullPlatform = true; } readGroup.setPlatform(RAC.DEFAULT_PLATFORM); } else { throw new UserException.MalformedBAM(read, "The input .bam file contains reads with no platform information. First observed at read with name = " + read.getReadName()); } } }
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! }
@Test(enabled = true) public void testSingleRecord() { final String expected = "SAMPLE.1"; GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord("MY.ID"); rg.setPlatformUnit(expected); runTest(rg, expected, covariate); }
@Override public String toString() { return "GATKSAMReadGroupRecord @RG:" + getReadGroupId(); }
/** * Get the NGSPlatform enum telling us the platform of this read group * * This function call is caching, so subsequent calls to it are free, while * the first time it's called there's a bit of work to resolve the enum * * @return an NGSPlatform enum value */ public NGSPlatform getNGSPlatform() { if ( ! retrievedNGSPlatform ) { mNGSPlatform = NGSPlatform.fromReadGroupPL(getPlatform()); retrievedNGSPlatform = true; } return mNGSPlatform; }
@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); }
@Test(enabled = true) public void testMissingPlatformUnit() { final String expected = "MY.7"; GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord(expected); runTest(rg, expected, covariate); }
@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()); }
private Set<GATKSAMRecord> filterNonPassingReads( final ActiveRegion activeRegion ) { final Set<GATKSAMRecord> readsToRemove = new LinkedHashSet<>(); for( final GATKSAMRecord rec : activeRegion.getReads() ) { if( rec.getReadLength() < READ_LENGTH_FILTER_THRESHOLD || rec.getMappingQuality() < READ_QUALITY_FILTER_THRESHOLD || (!isBadMateFilterDisabled && BadMateFilter.hasBadMate(rec)) || (keepRG != null && !rec.getReadGroup().getId().equals(keepRG)) ) { readsToRemove.add(rec); } } activeRegion.removeAll( readsToRemove ); return readsToRemove; }
/** * Gets a list of the read groups represented in this pileup. * * @return */ @Override public Collection<String> getReadGroups() { Set<String> readGroups = new HashSet<String>(); for (PileupElement pileupElement : this) readGroups.add(pileupElement.getRead().getReadGroup().getReadGroupId()); return readGroups; }
throw new UserException("The platform (" + read.getReadGroup().getPlatform() + ") associated with read group " + read.getReadGroup() + " is not a recognized platform. Allowable options are " + NGSPlatform.knownPlatformsString());
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; }
requestedCovariates[covariateIndex++] = cov; final GATKSAMReadGroupRecord rg = new GATKSAMReadGroupRecord("id"); rg.setPlatform("illumina"); final GATKSAMRecord read = ReadUtils.createRandomRead(length, false); read.setReadGroup(rg);