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(); }
/** * Creates fastq writers based on readgroup passed in and sequence tag groupings from command line */ private List<FastqWriter> makeTagWriters(final SAMReadGroupRecord readGroup, final FastqWriterFactory factory) { String baseFilename = null; if (readGroup != null) { if (RG_TAG.equalsIgnoreCase("PU")) { baseFilename = readGroup.getPlatformUnit() + "_"; } else if (RG_TAG.equalsIgnoreCase("ID")) { baseFilename = readGroup.getReadGroupId() + "_"; } if (baseFilename == null) { throw new PicardException("The selected RG_TAG: " + RG_TAG + " is not present in the bam header."); } } else { baseFilename = ""; } List<File> tagFiles = new ArrayList<>(); for (String tagSplit : SEQUENCE_TAG_GROUP) { String fileName = baseFilename + tagSplit.replace(",", "_"); fileName = IOUtil.makeFileNameSafe(fileName); fileName += COMPRESS_OUTPUTS_PER_TAG_GROUP ? ".fastq.gz" : ".fastq"; final File result = (OUTPUT_DIR != null) ? new File(OUTPUT_DIR, fileName) : new File(FASTQ.getParent(), fileName); IOUtil.assertFileIsWritable(result); tagFiles.add(result); } return tagFiles.stream().map(factory::newWriter).collect(Collectors.toList()); }
/** * Creates fastq writers based on readgroup passed in and sequence tag groupings from command line */ private List<FastqWriter> makeTagWriters(final SAMReadGroupRecord readGroup, final FastqWriterFactory factory) { String baseFilename = null; if (readGroup != null) { if (RG_TAG.equalsIgnoreCase("PU")) { baseFilename = readGroup.getPlatformUnit() + "_"; } else if (RG_TAG.equalsIgnoreCase("ID")) { baseFilename = readGroup.getReadGroupId() + "_"; } if (baseFilename == null) { throw new PicardException("The selected RG_TAG: " + RG_TAG + " is not present in the bam header."); } } else { baseFilename = ""; } List<File> tagFiles = new ArrayList<>(); for (String tagSplit : SEQUENCE_TAG_GROUP) { String fileName = baseFilename + tagSplit.replace(",", "_"); fileName = IOUtil.makeFileNameSafe(fileName); fileName += COMPRESS_OUTPUTS_PER_TAG_GROUP ? ".fastq.gz" : ".fastq"; final File result = (OUTPUT_DIR != null) ? new File(OUTPUT_DIR, fileName) : new File(FASTQ.getParent(), fileName); IOUtil.assertFileIsWritable(result); tagFiles.add(result); } return tagFiles.stream().map(factory::newWriter).collect(Collectors.toList()); }
private File makeReadGroupFile(final SAMReadGroupRecord readGroup, final String preExtSuffix) { String fileName = null; if (RG_TAG.equalsIgnoreCase("PU")) { fileName = readGroup.getPlatformUnit(); } else if (RG_TAG.equalsIgnoreCase("ID")) { fileName = readGroup.getReadGroupId(); } if (fileName == null) { throw new PicardException("The selected RG_TAG: " + RG_TAG + " is not present in the bam header."); } fileName = IOUtil.makeFileNameSafe(fileName); if (preExtSuffix != null) { fileName += preExtSuffix; } fileName += COMPRESS_OUTPUTS_PER_RG ? ".fastq.gz" : ".fastq"; final File result = (OUTPUT_DIR != null) ? new File(OUTPUT_DIR, fileName) : new File(fileName); IOUtil.assertFileIsWritable(result); return result; }
private File makeReadGroupFile(final SAMReadGroupRecord readGroup, final String preExtSuffix) { String fileName = null; if (RG_TAG.equalsIgnoreCase("PU")) { fileName = readGroup.getPlatformUnit(); } else if (RG_TAG.equalsIgnoreCase("ID")) { fileName = readGroup.getReadGroupId(); } if (fileName == null) { throw new PicardException("The selected RG_TAG: " + RG_TAG + " is not present in the bam header."); } fileName = IOUtil.makeFileNameSafe(fileName); if (preExtSuffix != null) { fileName += preExtSuffix; } fileName += COMPRESS_OUTPUTS_PER_RG ? ".fastq.gz" : ".fastq"; final File result = (OUTPUT_DIR != null) ? new File(OUTPUT_DIR, fileName) : new File(fileName); IOUtil.assertFileIsWritable(result); return result; }
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()); }
/** * Returns the platform unit for a read group given its index. * * @param group the index of the targeted read group in the range * [1,{@link #getReadGroupCount()}] * @return never <code>null</code>. */ protected final String getPlatformUnit(final int group) { checkReadGroupIndex(group); return getHeader().getReadGroups().get(group - 1).getPlatformUnit(); }
@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()); } }
String uniqueReadGroupId = readGroup.getSample() + "_" + readGroup.getReadGroupId() + "_" + readGroup.getLibrary() + "_" + readGroup.getPlatformUnit(); int[] counts = countsByRGName.get(uniqueReadGroupId); if (counts == null) {
protected static Map<String, Map<String, MatePair>> createPUPairsMap(final File samFile) throws IOException { IOUtil.assertFileIsReadable(samFile); final SamReader reader = SamReaderFactory.makeDefault().open(samFile); final Map<String, Map<String, MatePair>> map = new LinkedHashMap<>(); Map<String,MatePair> curFileMap; for (final SAMRecord record : reader ) { final String platformUnit = record.getReadGroup().getPlatformUnit(); curFileMap = map.get(platformUnit); if(curFileMap == null) { curFileMap = new LinkedHashMap<>(); map.put(platformUnit, curFileMap); } MatePair mpair = curFileMap.get(record.getReadName()); if (mpair == null) { mpair = new MatePair(); curFileMap.put(record.getReadName(), mpair); } mpair.add(record); } reader.close(); return map; }
final FingerprintIdDetails id = new FingerprintIdDetails(rg.getPlatformUnit(), samFile.toUri().toString()); id.library = rg.getLibrary(); id.sample = rg.getSample();
final FingerprintIdDetails id = new FingerprintIdDetails(rg.getPlatformUnit(), samFile.toUri().toString()); id.library = rg.getLibrary(); id.sample = rg.getSample();