@Override public String getSample() { if ( !retrievedSample ) { mSample = super.getSample(); retrievedSample = true; } return mSample; }
public String getSample() { return readGroupRecord == null ? null : readGroupRecord.getSample(); }
/** * * @param rg * @return sample Object with this ID, or null if this does not exist */ public Sample getSample(final SAMReadGroupRecord rg) { return getSample(rg.getSample()); }
public boolean filterOut( final SAMRecord read ) { final SAMReadGroupRecord readGroup = read.getReadGroup(); return !( readGroup != null && SAMPLES_TO_KEEP.contains(readGroup.getSample()) ); } }
protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeSampleCollector(final SAMReadGroupRecord rg) { return makeChildCollector(rg.getSample(), null, null); } protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeLibraryCollector(final SAMReadGroupRecord rg) {
protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeSampleCollector(final SAMReadGroupRecord rg) { return makeChildCollector(rg.getSample(), null, null); } protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeLibraryCollector(final SAMReadGroupRecord rg) {
@Override public void addAlignment(SAMRecord samRecord) { super.addAlignment(samRecord, sampleToWriterMap.get(samRecord.getReadGroup().getSample())); } }
public FingerprintIdDetails(final SAMReadGroupRecord rg, final String file) { this(rg.getPlatformUnit(), file); this.sample = rg.getSample(); this.library = rg.getLibrary(); }
public FingerprintIdDetails(final SAMReadGroupRecord rg, final String file) { this(rg.getPlatformUnit(), file); this.sample = rg.getSample(); this.library = rg.getLibrary(); }
protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeLibraryCollector(final SAMReadGroupRecord rg) { return makeChildCollector(rg.getSample(), rg.getLibrary(), null); } protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeReadGroupCollector(final SAMReadGroupRecord rg) {
protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeLibraryCollector(final SAMReadGroupRecord rg) { return makeChildCollector(rg.getSample(), rg.getLibrary(), null); } protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeReadGroupCollector(final SAMReadGroupRecord rg) {
/** * Write out the read */ @Override public Map<String, SAMFileWriter> reduce(SAMRecord read, Map<String, SAMFileWriter> outputs) { final String sample = read.getReadGroup().getSample(); SAMFileWriter output = outputs.get(sample); if ( output != null ) { output.addAlignment(read); } else { throw new RuntimeException(String.format("Read group %s not present in header but found in read %s", read.getReadGroup().getReadGroupId(), read.getReadName())); } return outputs; }
protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeReadGroupCollector(final SAMReadGroupRecord rg) { return makeChildCollector(rg.getSample(), rg.getLibrary(), rg.getPlatformUnit()); }
protected PerUnitMetricCollector<METRIC_TYPE, Histogram_KEY, ARGTYPE> makeReadGroupCollector(final SAMReadGroupRecord rg) { return makeChildCollector(rg.getSample(), rg.getLibrary(), rg.getPlatformUnit()); }
public BySampleSAMFileWriter(GenomeAnalysisEngine toolkit, String ext, SAMFileHeader.SortOrder order, boolean presorted, boolean indexOnTheFly, boolean generateMD5, SAMProgramRecord pRecord, boolean keep_records) { super(toolkit, ext, order, presorted, indexOnTheFly, generateMD5, pRecord, keep_records); sampleToWriterMap = new HashMap<String, SAMReaderID>(toolkit.getSAMFileHeader().getReadGroups().size() * 2); for (SAMReaderID readerID : toolkit.getReadsDataSource().getReaderIDs()) { for (SAMReadGroupRecord rg : toolkit.getReadsDataSource().getHeader(readerID).getReadGroups()) { String sample = rg.getSample(); if (sampleToWriterMap.containsKey(sample) && sampleToWriterMap.get(sample) != readerID) { throw new ReviewedGATKException("The same sample appears in multiple files, this input cannot be multiplexed using the BySampleSAMFileWriter, try NWaySAMFileWriter instead."); } else { sampleToWriterMap.put(sample, readerID); } } } }
private String getCategoryLabelFor(File file) { String label = file.getName(); if (file.exists() && getContext().getConfig().useReadGroupSampleNameCategoryLabel) { try (SamReader reader = SamReaderFactory.makeDefault().referenceSequence(REFERENCE_SEQUENCE).open(file)) { SAMFileHeader header = reader.getFileHeader(); if (header.getReadGroups().size() == 1) { String sampleName = header.getReadGroups().get(0).getSample(); if (sampleName != null && sampleName.length() > 0) { label = sampleName; log.info(String.format("Using Read Group sample name %s for file %s", label, file)); } } } catch (IOException e) { log.debug(e, "Unable to load read group headers for ", file); } } return label; } public List<SAMEvidenceSource> getSamEvidenceSources() {
@Override public void acceptRecord(final TestArg args) { numProcessed += 1; metric.TALLY += 1; if(metric.SAMPLE != null) { Assert.assertEquals(metric.SAMPLE, args.samRecord.getReadGroup().getSample()); } if(metric.LIBRARY != null) { Assert.assertEquals(metric.LIBRARY, args.samRecord.getReadGroup().getLibrary()); } if(metric.READ_GROUP != null) { Assert.assertEquals(metric.READ_GROUP, args.samRecord.getReadGroup().getPlatformUnit()); } }
private boolean compareReadGroup(final SAMReadGroupRecord samReadGroupRecord1, final SAMReadGroupRecord samReadGroupRecord2) { boolean ret = compareValues(samReadGroupRecord1.getReadGroupId(), samReadGroupRecord2.getReadGroupId(), "Read Group ID"); ret = compareValues(samReadGroupRecord1.getSample(), samReadGroupRecord2.getSample(), "Sample for read group " + samReadGroupRecord1.getReadGroupId()) && ret; ret = compareValues(samReadGroupRecord1.getLibrary(), samReadGroupRecord2.getLibrary(), "Library for read group " + samReadGroupRecord1.getReadGroupId()) && ret; final String[] attributes = {"DS", "PU", "PI", "CN", "DT", "PL"}; for (final String attribute : attributes) { ret = compareValues(samReadGroupRecord1.getAttribute(attribute), samReadGroupRecord2.getAttribute(attribute), attribute + " for read group " + samReadGroupRecord1.getReadGroupId()) && ret; } return ret; }
private boolean compareReadGroup(final SAMReadGroupRecord samReadGroupRecord1, final SAMReadGroupRecord samReadGroupRecord2) { boolean ret = compareValues(samReadGroupRecord1.getReadGroupId(), samReadGroupRecord2.getReadGroupId(), "Read Group ID"); ret = compareValues(samReadGroupRecord1.getSample(), samReadGroupRecord2.getSample(), "Sample for read group " + samReadGroupRecord1.getReadGroupId()) && ret; ret = compareValues(samReadGroupRecord1.getLibrary(), samReadGroupRecord2.getLibrary(), "Library for read group " + samReadGroupRecord1.getReadGroupId()) && ret; final String[] attributes = {"DS", "PU", "PI", "CN", "DT", "PL"}; for (final String attribute : attributes) { ret = compareValues(samReadGroupRecord1.getAttribute(attribute), samReadGroupRecord2.getAttribute(attribute), attribute + " for read group " + samReadGroupRecord1.getReadGroupId()) && ret; } return ret; }
@Test public void testOnTheFlySampleRenamingWithSingleBamFile() throws IOException { final File sampleRenameMapFile = createTestSampleRenameMapFile( Arrays.asList(privateTestDir + "CEUTrio.HiSeq.WGS.b37.NA12878.HEADERONLY.bam myNewSampleName")); final WalkerTestSpec spec = new WalkerTestSpec(" -T TestPrintReadsWalker" + " -R " + b37KGReference + " -I " + privateTestDir + "CEUTrio.HiSeq.WGS.b37.NA12878.HEADERONLY.bam" + " --sample_rename_mapping_file " + sampleRenameMapFile.getAbsolutePath() + " -o %s", 1, Arrays.asList("")); // No MD5s; we only want to check the read groups final File outputBam = executeTest("testOnTheFlySampleRenamingWithSingleBamFile", spec).first.get(0); final SamReader reader = SamReaderFactory.makeDefault().open(outputBam); for ( final SAMReadGroupRecord readGroup : reader.getFileHeader().getReadGroups() ) { Assert.assertEquals(readGroup.getSample(), "myNewSampleName", String.format("Sample for read group %s not renamed correctly", readGroup.getId())); } reader.close(); }