/** * Checks whether the provided SAM header if from a reduced bam file. * @param header the SAM header for a given file * @throws UserException if the header is from a reduced bam */ private void checkForUnsupportedBamFile(final SAMFileHeader header) { for ( final SAMProgramRecord PGrecord : header.getProgramRecords() ) { if ( unsupportedPGs.containsKey(PGrecord.getId()) ) throw new UserException("The GATK no longer supports running off of BAMs produced by " + unsupportedPGs.get(PGrecord.getId())); } }
/** * Creates a program record for the program, adds it to the list of program records (@PG tags) in the bam file and sets * up the writer with the header and presorted status. * * @param originalHeader original header * @param programRecord the program record for this program */ public static SAMFileHeader setupWriter(final SAMFileHeader originalHeader, final SAMProgramRecord programRecord) { final SAMFileHeader header = originalHeader.clone(); final List<SAMProgramRecord> oldRecords = header.getProgramRecords(); final List<SAMProgramRecord> newRecords = new ArrayList<SAMProgramRecord>(oldRecords.size()+1); for ( SAMProgramRecord record : oldRecords ) if ( (programRecord != null && !record.getId().startsWith(programRecord.getId()))) newRecords.add(record); if (programRecord != null) { newRecords.add(programRecord); header.setProgramRecords(newRecords); } return header; }
private boolean compareProgramRecords(final SAMFileHeader h1, final SAMFileHeader h2) throws Exception { final List<SAMProgramRecord> l1 = h1.getProgramRecords(); final List<SAMProgramRecord> l2 = h2.getProgramRecords(); if (!compareValues(l1.size(), l2.size(), "Number of program records")) { return false; } boolean ret = true; for (SAMProgramRecord pr1 : l1) { for (SAMProgramRecord pr2 : l2) { if (pr1.getId().equals(pr2.getId())) { ret = compareProgramRecord(pr1, pr2) && ret; } } } return ret; }
/** * Generate the list of program records seen in the SAM file, approximating this with those in the header that were not * themselves mentioned elsewhere. */ private void setPGIdsSeen(final SAMFileHeader header) { final Set<String> pgIdsSeenAsPrevious = new HashSet<String>(); // get all program record ids that are mentioned as previously seen for (final SAMProgramRecord samProgramRecord : header.getProgramRecords()) { final String previousProgramGroupID = samProgramRecord.getPreviousProgramGroupId(); if (null != previousProgramGroupID) pgIdsSeenAsPrevious.add(previousProgramGroupID); } // ignore those that were previously seen for (final SAMProgramRecord samProgramRecord : header.getProgramRecords()) { final String pgId = samProgramRecord.getId(); if (!pgIdsSeenAsPrevious.contains(pgId)) this.pgIdsSeen.add(pgId); } } }
private boolean compareProgramRecords(final SAMFileHeader h1, final SAMFileHeader h2) throws Exception { final List<SAMProgramRecord> l1 = h1.getProgramRecords(); final List<SAMProgramRecord> l2 = h2.getProgramRecords(); if (!compareValues(l1.size(), l2.size(), "Number of program records")) { return false; } boolean ret = true; for (SAMProgramRecord pr1 : l1) { for (SAMProgramRecord pr2 : l2) { if (pr1.getId().equals(pr2.getId())) { ret = compareProgramRecord(pr1, pr2) && ret; } } } return ret; }
/** * Generate the list of program records seen in the SAM file, approximating this with those in the header that were not * themselves mentioned elsewhere. */ private void setPGIdsSeen(final SAMFileHeader header) { final Set<String> pgIdsSeenAsPrevious = new HashSet<String>(); // get all program record ids that are mentioned as previously seen for (final SAMProgramRecord samProgramRecord : header.getProgramRecords()) { final String previousProgramGroupID = samProgramRecord.getPreviousProgramGroupId(); if (null != previousProgramGroupID) pgIdsSeenAsPrevious.add(previousProgramGroupID); } // ignore those that were previously seen for (final SAMProgramRecord samProgramRecord : header.getProgramRecords()) { final String pgId = samProgramRecord.getId(); if (!pgIdsSeenAsPrevious.contains(pgId)) this.pgIdsSeen.add(pgId); } } }
private void setupWriter(SAMFileHeader header) { if ( !NO_PG_TAG ) { final SAMProgramRecord programRecord = createProgramRecord(); List<SAMProgramRecord> oldRecords = header.getProgramRecords(); List<SAMProgramRecord> newRecords = new ArrayList<SAMProgramRecord>(oldRecords.size()+1); for ( SAMProgramRecord record : oldRecords ) { if ( !record.getId().startsWith(PROGRAM_RECORD_NAME) || KEEP_ALL_PG_RECORDS ) newRecords.add(record); } newRecords.add(programRecord); header.setProgramRecords(newRecords); } writer.writeHeader(header); writer.setPresorted(true); }
for (final SAMProgramRecord programGroup : header.getProgramRecords()) { if (!idsThatAreAlreadyTaken.add(programGroup.getId())) throw new SAMException("Input file: " + header + " contains more than one PG with the same id (" + programGroup.getId() + ")"); final String idJustProcessed = justProcessedPair.getHeaderRecord().getId(); if (pairLeftToProcess.getFileHeader() == justProcessedPair.getFileHeader() && ppIdOfRecordLeftToProcess.equals(idJustProcessed)) { programGroupsLeftToProcessIterator.remove();
for (final SAMProgramRecord programGroup : header.getProgramRecords()) { if(!idsThatAreAlreadyTaken.add(programGroup.getId())) throw new SAMException("Input file: " + header + " contains more than one PG with the same id (" + programGroup.getId() + ")"); final String idJustProcessed = justProcessedPair.getHeaderRecord().getId(); if(pairLeftToProcess.getFileHeader() == justProcessedPair.getFileHeader() && ppIdOfRecordLeftToProcess.equals(idJustProcessed)) { programGroupsLeftToProcessIterator.remove();
for (final SAMProgramRecord programGroup : header.getProgramRecords()) { if (!idsThatAreAlreadyTaken.add(programGroup.getId())) throw new SAMException("Input file: " + header + " contains more than one PG with the same id (" + programGroup.getId() + ")"); final String idJustProcessed = justProcessedPair.getHeaderRecord().getId(); if (pairLeftToProcess.getFileHeader() == justProcessedPair.getFileHeader() && ppIdOfRecordLeftToProcess.equals(idJustProcessed)) { programGroupsLeftToProcessIterator.remove();
attr.put(entry.getKey(), entry.getValue()); alignmentHeader.addProgramRecords(pg.getId(), attr);
for (final SAMProgramRecord pg : header.getProgramRecords()) pgs.add(pg.getId()); for (int i = 1; i < Integer.MAX_VALUE; ++i) { if (!pgs.contains(String.valueOf(i))) {
for (final SAMProgramRecord pg : header.getProgramRecords()) pgs.add(pg.getId()); for (int i = 1; i < Integer.MAX_VALUE; ++i) { if (!pgs.contains(String.valueOf(i))) {