public abstract class AbstractAlignmentMerger
extends java.lang.Object
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
|
Modifier and Type | Method and Description |
---|---|
protected 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 |
fixNMandUQ(htsjdk.samtools.SAMRecord record,
htsjdk.samtools.reference.ReferenceSequenceFileWalker refSeqWalker,
boolean isBisulfiteSequence)
Calculates and sets the NM and UQ tags from the record and the reference
|
protected htsjdk.samtools.SAMFileHeader |
getHeader() |
protected htsjdk.samtools.SAMProgramRecord |
getProgramRecord() |
protected abstract htsjdk.samtools.util.CloseableIterator<htsjdk.samtools.SAMRecord> |
getQuerynameSortedAlignedRecords() |
protected htsjdk.samtools.SAMSequenceDictionary |
getSequenceDictionary() |
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 |
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)
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)
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 contamination from a foreign organism (i.e. mostly clipped bases),
and mark them as unmapped.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 void setMaxRecordsInRam(int maxRecordsInRam)
public void mergeAlignment(java.io.File referenceFasta)
public static void fixNMandUQ(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.protected void clipForOverlappingReads(htsjdk.samtools.SAMRecord read1, htsjdk.samtools.SAMRecord read2)
protected void setValuesFromAlignment(htsjdk.samtools.SAMRecord rec, htsjdk.samtools.SAMRecord alignment)
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.SAMSequenceDictionary getSequenceDictionary()
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()