Package htsjdk.samtools
Class SamFileHeaderMerger
- java.lang.Object
-
- htsjdk.samtools.SamFileHeaderMerger
-
public class SamFileHeaderMerger extends Object
Merges SAMFileHeaders that have the same sequences into a single merged header object while providing read group translation for cases where read groups clash across input headers.
-
-
Constructor Summary
Constructors Constructor Description SamFileHeaderMerger(SAMFileHeader.SortOrder sortOrder, Collection<SAMFileHeader> headers, boolean mergeDictionaries)
Create SAMFileHeader with additional information..SamFileHeaderMerger(Collection<SamReader> readers, SAMFileHeader.SortOrder sortOrder)
Deprecated.SamFileHeaderMerger(Collection<SamReader> readers, SAMFileHeader.SortOrder sortOrder, boolean mergeDictionaries)
Deprecated.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Deprecated Methods Modifier and Type Method Description Collection<SAMFileHeader>
getHeaders()
Returns the collection of readers that this header merger is working with.SAMFileHeader
getMergedHeader()
Returns the merged header that should be written to any output merged file.Integer
getMergedSequenceIndex(SAMFileHeader header, Integer oldReferenceSequenceIndex)
Another mechanism for getting the new sequence index, for situations in which the reader is not available.Integer
getMergedSequenceIndex(SamReader reader, Integer oldReferenceSequenceIndex)
Deprecated.replaced bygetMergedSequenceIndex(SAMFileHeader, Integer)
String
getProgramGroupId(SAMFileHeader header, String originalProgramGroupId)
String
getProgramGroupId(SamReader reader, String originalProgramGroupId)
Deprecated.replaced bygetProgramGroupId(SAMFileHeader, String)
Collection<SamReader>
getReaders()
Deprecated.replaced bygetHeaders()
String
getReadGroupId(SAMFileHeader header, String originalReadGroupId)
Returns the read group id that should be used for the input read and RG id.String
getReadGroupId(SamReader reader, String originalReadGroupId)
Deprecated.replaced bygetReadGroupId(SAMFileHeader, String)
boolean
hasMergedSequenceDictionary()
boolean
hasProgramGroupCollisions()
Returns true if there are program group duplicates within the merged headers.boolean
hasReadGroupCollisions()
Returns true if there are read group duplicates within the merged headers.static String
positiveFourDigitBase36Str(int leftOver)
Convert an integer to base36, protected solely for testing
-
-
-
Constructor Detail
-
SamFileHeaderMerger
@Deprecated public SamFileHeaderMerger(Collection<SamReader> readers, SAMFileHeader.SortOrder sortOrder)
Deprecated.Create SAMFileHeader with additional information. Required that sequence dictionaries agree.- Parameters:
readers
- sam file readers to combinesortOrder
- sort order new header should have
-
SamFileHeaderMerger
@Deprecated public SamFileHeaderMerger(Collection<SamReader> readers, SAMFileHeader.SortOrder sortOrder, boolean mergeDictionaries)
Deprecated.Create SAMFileHeader with additional information.- Parameters:
readers
- sam file readers to combinesortOrder
- sort order new header should havemergeDictionaries
- If true, merge sequence dictionaries in new header. If false, require that all input sequence dictionaries be identical.
-
SamFileHeaderMerger
public SamFileHeaderMerger(SAMFileHeader.SortOrder sortOrder, Collection<SAMFileHeader> headers, boolean mergeDictionaries)
Create SAMFileHeader with additional information.. This is the preferred constructor.- Parameters:
sortOrder
- sort order new header should haveheaders
- sam file headers to combinemergeDictionaries
- If true, merge sequence dictionaries in new header. If false, require that all input sequence dictionaries be identical.
-
-
Method Detail
-
positiveFourDigitBase36Str
public static String positiveFourDigitBase36Str(int leftOver)
Convert an integer to base36, protected solely for testing- Parameters:
leftOver
- Both the initial value and the running quotient- Returns:
- A four digit string composed of base 36 symbols
-
getReadGroupId
@Deprecated public String getReadGroupId(SamReader reader, String originalReadGroupId)
Deprecated.replaced bygetReadGroupId(SAMFileHeader, String)
Returns the read group id that should be used for the input read and RG id.
-
getReadGroupId
public String getReadGroupId(SAMFileHeader header, String originalReadGroupId)
Returns the read group id that should be used for the input read and RG id.
-
getProgramGroupId
@Deprecated public String getProgramGroupId(SamReader reader, String originalProgramGroupId)
Deprecated.replaced bygetProgramGroupId(SAMFileHeader, String)
- Parameters:
reader
- one of the input filesoriginalProgramGroupId
- a program group ID from the above input file- Returns:
- new ID from the merged list of program groups in the output file
-
getProgramGroupId
public String getProgramGroupId(SAMFileHeader header, String originalProgramGroupId)
- Parameters:
header
- one of the input headersoriginalProgramGroupId
- a program group ID from the above input file- Returns:
- new ID from the merged list of program groups in the output file
-
hasReadGroupCollisions
public boolean hasReadGroupCollisions()
Returns true if there are read group duplicates within the merged headers.
-
hasProgramGroupCollisions
public boolean hasProgramGroupCollisions()
Returns true if there are program group duplicates within the merged headers.
-
hasMergedSequenceDictionary
public boolean hasMergedSequenceDictionary()
- Returns:
- if we've merged the sequence dictionaries, return true
-
getMergedHeader
public SAMFileHeader getMergedHeader()
Returns the merged header that should be written to any output merged file.
-
getReaders
@Deprecated public Collection<SamReader> getReaders()
Deprecated.replaced bygetHeaders()
Returns the collection of readers that this header merger is working with. May return null.
-
getHeaders
public Collection<SAMFileHeader> getHeaders()
Returns the collection of readers that this header merger is working with.
-
getMergedSequenceIndex
@Deprecated public Integer getMergedSequenceIndex(SamReader reader, Integer oldReferenceSequenceIndex)
Deprecated.replaced bygetMergedSequenceIndex(SAMFileHeader, Integer)
returns the new mapping for a specified reader, given it's old sequence index- Parameters:
reader
- the readeroldReferenceSequenceIndex
- the old sequence (also called reference) index- Returns:
- the new index value
-
getMergedSequenceIndex
public Integer getMergedSequenceIndex(SAMFileHeader header, Integer oldReferenceSequenceIndex)
Another mechanism for getting the new sequence index, for situations in which the reader is not available. Note that if the SAMRecord has already had its header replaced with the merged header, this won't work.- Parameters:
header
- The original header for the input record in question.oldReferenceSequenceIndex
- The original sequence index.- Returns:
- the new index value that is compatible with the merged sequence index.
-
-