/** * Generates tab delimited string containing details about the passed SAMReadGroupRecord * * @param readGroupRecord record * @return tab delimited string containing details about the SAMReadGroupRecord */ private String getReadGroupDetails(final SAMReadGroupRecord readGroupRecord) { final List<String> elements = new ArrayList<>(5); final String tmp[] = readGroupRecord .getPlatformUnit() .split("\\."); // Expect to look like: D047KACXX110901.1.ACCAACTG String runBarcode = "?"; String lane = "?"; String molBarcode = "?"; if ((tmp.length == 3) || (tmp.length == 2)) { runBarcode = tmp[0]; lane = tmp[1]; molBarcode = (tmp.length == 3) ? tmp[2] : ""; // In older BAMS there may be no molecular barcode sequence } else { log.error("Unexpected format " + readGroupRecord.getPlatformUnit() + " for PU attribute"); } elements.add(runBarcode); elements.add(lane); elements.add(molBarcode); elements.add(readGroupRecord.getLibrary()); elements.add(readGroupRecord.getSample()); return String.join("\t", elements); }
/** Get the ID of the readgroup. */ public static String getID(final SAMReadGroupRecord rg) { final String pu = rg.getPlatformUnit(); return pu == null ? rg.getId() : pu; }
/** * Returns the platform unit associated with the provided read's read group. * * @param read read whose platform unit to retrieve * @param header SAM header containing read groups * @return the platform unit for the provided read's read group as a String, or null if the read * has no read group. */ public static String getPlatformUnit(final GATKRead read, final SAMFileHeader header) { final SAMReadGroupRecord readGroup = getSAMReadGroupRecord(read, header); return readGroup != null ? readGroup.getPlatformUnit() : null; }