public abstract class AbstractAlignmentMerger
extends java.lang.Object
Modifier and Type | Class and Description |
---|---|
static class |
AbstractAlignmentMerger.UnmappingReadStrategy |
Modifier and Type | Field and Description |
---|---|
static int |
MAX_RECORDS_IN_RAM |
protected java.io.File |
referenceFasta |
Constructor and Description |
---|
AbstractAlignmentMerger(java.io.File unmappedBamFile,
java.io.File targetBamFile,
java.io.File referenceFasta,
boolean clipAdapters,
boolean bisulfiteSequence,
boolean alignedReadsOnly,
htsjdk.samtools.SAMProgramRecord programRecord,
java.util.List<java.lang.String> attributesToRetain,
java.util.List<java.lang.String> attributesToRemove,
java.lang.Integer read1BasesTrimmed,
java.lang.Integer read2BasesTrimmed,
java.util.List<htsjdk.samtools.SamPairUtil.PairOrientation> expectedOrientations,
htsjdk.samtools.SAMFileHeader.SortOrder sortOrder,
PrimaryAlignmentSelectionStrategy primaryAlignmentSelectionStrategy,
boolean addMateCigar,
boolean unmapContaminantReads)
constructor with a default setting for unmappingReadsStrategy.
|
AbstractAlignmentMerger(java.io.File unmappedBamFile,
java.io.File targetBamFile,
java.io.File referenceFasta,
boolean clipAdapters,
boolean bisulfiteSequence,
boolean alignedReadsOnly,
htsjdk.samtools.SAMProgramRecord programRecord,
java.util.List<java.lang.String> attributesToRetain,
java.util.List<java.lang.String> attributesToRemove,
java.lang.Integer read1BasesTrimmed,
java.lang.Integer read2BasesTrimmed,
java.util.List<htsjdk.samtools.SamPairUtil.PairOrientation> expectedOrientations,
htsjdk.samtools.SAMFileHeader.SortOrder sortOrder,
PrimaryAlignmentSelectionStrategy primaryAlignmentSelectionStrategy,
boolean addMateCigar,
boolean unmapContaminantReads,
AbstractAlignmentMerger.UnmappingReadStrategy unmappingReadsStrategy)
Constructor
|
Modifier and Type | Method and Description |
---|---|
protected static void |
clipForOverlappingReads(htsjdk.samtools.SAMRecord read1,
htsjdk.samtools.SAMRecord read2)
Checks to see whether the ends of the reads overlap and soft clips reads
them if necessary.
|
void |
close() |
static void |
createNewCigarsIfMapsOffEndOfReference(htsjdk.samtools.SAMRecord rec)
Soft-clip an alignment that hangs off the end of its reference sequence.
|
static void |
fixNmMdAndUq(htsjdk.samtools.SAMRecord record,
htsjdk.samtools.reference.ReferenceSequenceFileWalker refSeqWalker,
boolean isBisulfiteSequence)
Calculates and sets the NM, MD, and and UQ tags from the record and the reference
|
static void |
fixUq(htsjdk.samtools.SAMRecord record,
htsjdk.samtools.reference.ReferenceSequenceFileWalker refSeqWalker,
boolean isBisulfiteSequence)
Calculates and sets UQ tag from the record and the reference
|
java.util.Set<java.lang.String> |
getAttributesToReverse()
Gets the set of attributes to be reversed on reads marked as negative strand.
|
java.util.Set<java.lang.String> |
getAttributesToReverseComplement()
Gets the set of attributes to be reverse complemented on reads marked as negative strand.
|
protected abstract htsjdk.samtools.SAMSequenceDictionary |
getDictionaryForMergedBam() |
protected htsjdk.samtools.SAMFileHeader |
getHeader() |
protected htsjdk.samtools.SAMProgramRecord |
getProgramRecord() |
protected abstract htsjdk.samtools.util.CloseableIterator<htsjdk.samtools.SAMRecord> |
getQuerynameSortedAlignedRecords() |
protected boolean |
ignoreAlignment(htsjdk.samtools.SAMRecord sam) |
boolean |
isClipOverlappingReads() |
protected boolean |
isContaminant(picard.sam.HitsForInsert hits) |
boolean |
isKeepAlignerProperPairFlags() |
protected boolean |
isReservedTag(java.lang.String tag) |
void |
mergeAlignment(java.io.File referenceFasta)
Merges the alignment data with the non-aligned records from the source BAM file.
|
protected void |
resetRefSeqFileWalker() |
void |
setAddPGTagToReads(boolean addPGTagToReads)
Set addPGTagToReads.
|
void |
setAttributesToReverse(java.util.Set<java.lang.String> attributesToReverse)
Sets the set of attributes to be reversed on reads marked as negative strand.
|
void |
setAttributesToReverseComplement(java.util.Set<java.lang.String> attributesToReverseComplement)
Sets the set of attributes to be reverse complemented on reads marked as negative strand.
|
void |
setClipOverlappingReads(boolean clipOverlappingReads) |
void |
setIncludeSecondaryAlignments(boolean includeSecondaryAlignments) |
void |
setKeepAlignerProperPairFlags(boolean keepAlignerProperPairFlags)
If true, keep the aligner's idea of proper pairs rather than letting alignment merger decide.
|
void |
setMaxRecordsInRam(int maxRecordsInRam)
Allows the caller to override the maximum records in RAM.
|
protected void |
setProgramRecord(htsjdk.samtools.SAMProgramRecord pg) |
protected void |
setValuesFromAlignment(htsjdk.samtools.SAMRecord rec,
htsjdk.samtools.SAMRecord alignment,
boolean needsSafeReverseComplement)
Sets the values from the alignment record on the unaligned BAM record.
|
protected void |
updateCigarForTrimmedOrClippedBases(htsjdk.samtools.SAMRecord rec,
htsjdk.samtools.SAMRecord alignment) |
public static final int MAX_RECORDS_IN_RAM
protected final java.io.File referenceFasta
public AbstractAlignmentMerger(java.io.File unmappedBamFile, java.io.File targetBamFile, java.io.File referenceFasta, boolean clipAdapters, boolean bisulfiteSequence, boolean alignedReadsOnly, htsjdk.samtools.SAMProgramRecord programRecord, java.util.List<java.lang.String> attributesToRetain, java.util.List<java.lang.String> attributesToRemove, java.lang.Integer read1BasesTrimmed, java.lang.Integer read2BasesTrimmed, java.util.List<htsjdk.samtools.SamPairUtil.PairOrientation> expectedOrientations, htsjdk.samtools.SAMFileHeader.SortOrder sortOrder, PrimaryAlignmentSelectionStrategy primaryAlignmentSelectionStrategy, boolean addMateCigar, boolean unmapContaminantReads)
public AbstractAlignmentMerger(java.io.File unmappedBamFile, java.io.File targetBamFile, java.io.File referenceFasta, boolean clipAdapters, boolean bisulfiteSequence, boolean alignedReadsOnly, htsjdk.samtools.SAMProgramRecord programRecord, java.util.List<java.lang.String> attributesToRetain, java.util.List<java.lang.String> attributesToRemove, java.lang.Integer read1BasesTrimmed, java.lang.Integer read2BasesTrimmed, java.util.List<htsjdk.samtools.SamPairUtil.PairOrientation> expectedOrientations, htsjdk.samtools.SAMFileHeader.SortOrder sortOrder, PrimaryAlignmentSelectionStrategy primaryAlignmentSelectionStrategy, boolean addMateCigar, boolean unmapContaminantReads, AbstractAlignmentMerger.UnmappingReadStrategy unmappingReadsStrategy)
unmappedBamFile
- The BAM file that was used as the input to the aligner, which will
include info on all the reads that did not map. Required.targetBamFile
- The file to which to write the merged SAM records. Required.referenceFasta
- The reference sequence for the map files. Required.clipAdapters
- Whether adapters marked in unmapped BAM file should be marked as
soft clipped in the merged bam. Required.bisulfiteSequence
- Whether the reads are bisulfite sequence (used when calculating the
NM and UQ tags). Required.alignedReadsOnly
- Whether to output only those reads that have alignment dataprogramRecord
- Program record for target file SAMRecords created.attributesToRetain
- private attributes from the alignment record that should be
included when merging. This overrides the exclusion of
attributes whose tags start with the reserved characters
of X, Y, and ZattributesToRemove
- attributes from the alignment record that should be
removed when merging. This overrides attributesToRetain if they share
common tags.read1BasesTrimmed
- The number of bases trimmed from start of read 1 prior to alignment. Optional.read2BasesTrimmed
- The number of bases trimmed from start of read 2 prior to alignment. Optional.expectedOrientations
- A List of SamPairUtil.PairOrientations that are expected for
aligned pairs. Used to determine the properPair flag.sortOrder
- The order in which the merged records should be output. If null,
output will be coordinate-sortedprimaryAlignmentSelectionStrategy
- What to do when there are multiple primary alignments, or multiple
alignments but none primary, for a read or read pair.addMateCigar
- True if we are to add or maintain the mate CIGAR (MC) tag, false if we are to remove or not include.unmapContaminantReads
- If true, identify reads having the signature of cross-species contamination (i.e. mostly clipped bases),
and mark them as unmapped.unmappingReadsStrategy
- An enum describing how to deal with reads whose mapping information are being removed (currently this happens due to cross-species
contamination). Ignored unless unmapContaminantReads is true.protected abstract htsjdk.samtools.SAMSequenceDictionary getDictionaryForMergedBam()
protected abstract htsjdk.samtools.util.CloseableIterator<htsjdk.samtools.SAMRecord> getQuerynameSortedAlignedRecords()
protected boolean ignoreAlignment(htsjdk.samtools.SAMRecord sam)
protected boolean isContaminant(picard.sam.HitsForInsert hits)
public java.util.Set<java.lang.String> getAttributesToReverse()
public void setAttributesToReverse(java.util.Set<java.lang.String> attributesToReverse)
public java.util.Set<java.lang.String> getAttributesToReverseComplement()
public void setAttributesToReverseComplement(java.util.Set<java.lang.String> attributesToReverseComplement)
public void setMaxRecordsInRam(int maxRecordsInRam)
public void setAddPGTagToReads(boolean addPGTagToReads)
public void mergeAlignment(java.io.File referenceFasta)
public static void fixNmMdAndUq(htsjdk.samtools.SAMRecord record, htsjdk.samtools.reference.ReferenceSequenceFileWalker refSeqWalker, boolean isBisulfiteSequence)
record
- the record to be fixedrefSeqWalker
- a ReferenceSequenceWalker that will be used to traverse the referenceisBisulfiteSequence
- a flag indicating whether the sequence came from bisulfite-sequencing which would imply a different
calculation of the NM tag.
No return value, modifies the provided record.public static void fixUq(htsjdk.samtools.SAMRecord record, htsjdk.samtools.reference.ReferenceSequenceFileWalker refSeqWalker, boolean isBisulfiteSequence)
record
- the record to be fixedrefSeqWalker
- a ReferenceSequenceWalker that will be used to traverse the referenceisBisulfiteSequence
- a flag indicating whether the sequence came from bisulfite-sequencing.
No return value, modifies the provided record.protected static void clipForOverlappingReads(htsjdk.samtools.SAMRecord read1, htsjdk.samtools.SAMRecord read2)
protected void setValuesFromAlignment(htsjdk.samtools.SAMRecord rec, htsjdk.samtools.SAMRecord alignment, boolean needsSafeReverseComplement)
rec
- The unaligned read recordalignment
- The alignment recordpublic static void createNewCigarsIfMapsOffEndOfReference(htsjdk.samtools.SAMRecord rec)
rec
- protected void updateCigarForTrimmedOrClippedBases(htsjdk.samtools.SAMRecord rec, htsjdk.samtools.SAMRecord alignment)
protected htsjdk.samtools.SAMProgramRecord getProgramRecord()
protected void setProgramRecord(htsjdk.samtools.SAMProgramRecord pg)
protected boolean isReservedTag(java.lang.String tag)
protected htsjdk.samtools.SAMFileHeader getHeader()
protected void resetRefSeqFileWalker()
public boolean isClipOverlappingReads()
public void setClipOverlappingReads(boolean clipOverlappingReads)
public boolean isKeepAlignerProperPairFlags()
public void setKeepAlignerProperPairFlags(boolean keepAlignerProperPairFlags)
public void setIncludeSecondaryAlignments(boolean includeSecondaryAlignments)
public void close()