Java Code Examples for htsjdk.samtools.SAMProgramRecord#setProgramName()

The following examples show how to use htsjdk.samtools.SAMProgramRecord#setProgramName() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: AbstractMarkDuplicatesCommandLineProgram.java    From picard with MIT License 5 votes vote down vote up
/**
 * We have to re-chain the program groups based on this algorithm.  This returns the map from existing program group ID
 * to new program group ID.
 */
protected Map<String, String> getChainedPgIds(final SAMFileHeader outputHeader) {
    final Map<String, String> chainedPgIds;
    // Generate new PG record(s)
    if (PROGRAM_RECORD_ID != null) {
        final SAMFileHeader.PgIdGenerator pgIdGenerator = new SAMFileHeader.PgIdGenerator(outputHeader);
        if (PROGRAM_GROUP_VERSION == null) {
            PROGRAM_GROUP_VERSION = this.getVersion();
        }
        if (PROGRAM_GROUP_COMMAND_LINE == null) {
            PROGRAM_GROUP_COMMAND_LINE = this.getCommandLine();
        }
        chainedPgIds = new HashMap<>();
        for (final String existingId : this.pgIdsSeen) {
            final String newPgId = pgIdGenerator.getNonCollidingId(PROGRAM_RECORD_ID);
            chainedPgIds.put(existingId, newPgId);
            final SAMProgramRecord programRecord = new SAMProgramRecord(newPgId);
            programRecord.setProgramVersion(PROGRAM_GROUP_VERSION);
            programRecord.setCommandLine(PROGRAM_GROUP_COMMAND_LINE);
            programRecord.setProgramName(PROGRAM_GROUP_NAME);
            programRecord.setPreviousProgramGroupId(existingId);
            outputHeader.addProgramRecord(programRecord);
        }
    } else {
        chainedPgIds = null;
    }
    return chainedPgIds;
}
 
Example 2
Source File: GATKTool.java    From gatk with BSD 3-Clause "New" or "Revised" License 5 votes vote down vote up
/**
 * Returns the SAM header suitable for writing SAM/BAM/CRAM files produced by this tool.
 *
 * The default implementation calls {@link #getHeaderForReads} (and makes an empty header if that call returns null)
 * and optionally adds program tag to the header with a program version {@link #getVersion()}, program name {@link #getToolName()}
 * and command line {@link #getCommandLine()}.
 *
 * Subclasses may override.
 *
 * @return SAM header for the SAM writer with (optionally, if {@link #addOutputSAMProgramRecord} is true) program record appropriately.
 */
protected SAMFileHeader getHeaderForSAMWriter(){
    final SAMFileHeader header = getHeaderForReads() == null ? new SAMFileHeader(): getHeaderForReads();
    if (addOutputSAMProgramRecord) {
        final SAMProgramRecord programRecord = new SAMProgramRecord(createProgramGroupID(header));
        programRecord.setProgramVersion(getVersion());
        programRecord.setCommandLine(getCommandLine());
        programRecord.setProgramName(getToolName());
        header.addProgramRecord(programRecord);
    }
    return header;
}
 
Example 3
Source File: FixBAMFileHeader.java    From cramtools with Apache License 2.0 4 votes vote down vote up
public void addPG(SAMFileHeader header, String program, String cmd, String version) {
	SAMProgramRecord programRecord = header.createProgramRecord();
	programRecord.setCommandLine(cmd);
	programRecord.setProgramName(program);
	programRecord.setProgramVersion(version);
}