public class SAMRecordSetBuilder extends java.lang.Object implements java.lang.Iterable<SAMRecord>
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_CHROMOSOME_LENGTH |
static DuplicateScoringStrategy.ScoringStrategy |
DEFAULT_DUPLICATE_SCORING_STRATEGY |
Constructor and Description |
---|
SAMRecordSetBuilder()
Constructs a new SAMRecordSetBuilder with all the data needed to keep the records
sorted in coordinate order.
|
SAMRecordSetBuilder(boolean sortForMe,
SAMFileHeader.SortOrder sortOrder)
Construct a new SAMRecordSetBuilder.
|
SAMRecordSetBuilder(boolean sortForMe,
SAMFileHeader.SortOrder sortOrder,
boolean addReadGroup) |
SAMRecordSetBuilder(boolean sortForMe,
SAMFileHeader.SortOrder sortOrder,
boolean addReadGroup,
int defaultChromosomeLength) |
SAMRecordSetBuilder(boolean sortForMe,
SAMFileHeader.SortOrder sortOrder,
boolean addReadGroup,
int defaultChromosomeLength,
DuplicateScoringStrategy.ScoringStrategy duplicateScoringStrategy) |
Modifier and Type | Method and Description |
---|---|
SAMRecord |
addFrag(java.lang.String name,
int contig,
int start,
boolean negativeStrand)
Adds a skeletal fragment (non-PE) record to the set using the provided
contig start and strand information.
|
SAMRecord |
addFrag(java.lang.String name,
int contig,
int start,
boolean negativeStrand,
boolean recordUnmapped,
java.lang.String cigar,
java.lang.String qualityString,
int defaultQuality)
Adds a fragment record (mapped or unmapped) to the set using the provided contig start and optionally the strand,
cigar string, quality string or default quality score.
|
SAMRecord |
addFrag(java.lang.String name,
int contig,
int start,
boolean negativeStrand,
boolean recordUnmapped,
java.lang.String cigar,
java.lang.String qualityString,
int defaultQuality,
boolean isSecondary)
Adds a fragment record (mapped or unmapped) to the set using the provided contig start and optionally the strand,
cigar string, quality string or default quality score.
|
SAMRecord |
addFrag(java.lang.String name,
int contig,
int start,
boolean negativeStrand,
boolean recordUnmapped,
java.lang.String cigar,
java.lang.String qualityString,
int defaultQuality,
boolean isSecondary,
boolean isSupplementary)
Adds a fragment record (mapped or unmapped) to the set using the provided contig start and optionally the strand,
cigar string, quality string or default quality score.
|
void |
addPair(java.lang.String name,
int contig,
int start1,
int start2)
Adds a skeletal pair of records to the set using the provided
contig starts.
|
java.util.List<SAMRecord> |
addPair(java.lang.String name,
int contig,
int start1,
int start2,
boolean record1Unmapped,
boolean record2Unmapped,
java.lang.String cigar1,
java.lang.String cigar2,
boolean strand1,
boolean strand2,
boolean record1NonPrimary,
boolean record2NonPrimary,
int defaultQuality)
Adds a pair of records (mapped or unmmapped) to the set using the provided contig starts.
|
java.util.List<SAMRecord> |
addPair(java.lang.String name,
int contig,
int start1,
int start2,
boolean record1Unmapped,
boolean record2Unmapped,
java.lang.String cigar1,
java.lang.String cigar2,
boolean strand1,
boolean strand2,
int defaultQuality)
Adds a pair of records (mapped or unmmapped) to the set using the provided contig starts.
|
java.util.List<SAMRecord> |
addPair(java.lang.String name,
int contig1,
int contig2,
int start1,
int start2,
boolean record1Unmapped,
boolean record2Unmapped,
java.lang.String cigar1,
java.lang.String cigar2,
boolean strand1,
boolean strand2,
boolean record1NonPrimary,
boolean record2NonPrimary,
int defaultQuality)
Adds a pair of records (mapped or unmmapped) to the set using the provided contig starts.
|
void |
addRecord(SAMRecord record)
The record should already have the DS and MC tags computed
|
void |
addUnmappedFragment(java.lang.String name)
Adds an unmapped fragment read to the builder.
|
void |
addUnmappedPair(java.lang.String name)
Adds a pair with both ends unmapped to the builder.
|
SAMFileHeader |
getHeader() |
java.util.Collection<SAMRecord> |
getRecords()
Returns the accumulated list of sam records.
|
SamReader |
getSamReader()
Creates samFileReader from the data in instance of this class
|
CloseableIterator<SAMRecord> |
iterator()
Returns a CloseableIterator over the collection of SAMRecords.
|
static SAMFileHeader |
makeDefaultHeader(SAMFileHeader.SortOrder sortOrder,
int contigLength,
boolean addReadGroup)
creates a simple header
|
void |
setHeader(SAMFileHeader header) |
void |
setProgramRecord(SAMProgramRecord programRecord)
Adds the given program record to the header, and assigns the PG tag to any SAMRecords
created after it has been added.
|
void |
setRandomSeed(long seed)
Set the seed of the random number generator for cases in which repeatable result is desired.
|
void |
setReadGroup(SAMReadGroupRecord readGroup) |
void |
setReadLength(int readLength) |
void |
setUnmappedHasBasesAndQualities(boolean value) |
void |
setUseBamFile(boolean useBamFile)
Determine whether the class will use a bam (default) or a sam file to hold the
records when providing a reader to them.
|
void |
setUseNmFlag(boolean useNmFlag) |
int |
size() |
void |
writeRandomReference(java.nio.file.Path fasta)
Writes a random (but deterministic) reference file given a
SAMFileHeader
output file is expected to have a non-compressed fasta suffix. |
static void |
writeRandomReference(SAMFileHeader header,
java.nio.file.Path fasta)
Writes a random (but deterministic) reference file given a
SAMFileHeader
output file is expected to have a non-compressed fasta suffix. |
public static final int DEFAULT_CHROMOSOME_LENGTH
public static final DuplicateScoringStrategy.ScoringStrategy DEFAULT_DUPLICATE_SCORING_STRATEGY
public SAMRecordSetBuilder()
public SAMRecordSetBuilder(boolean sortForMe, SAMFileHeader.SortOrder sortOrder)
sortOrder
- If sortForMe, defines the sort order.sortForMe
- If true, keep the records created in sorted order.public SAMRecordSetBuilder(boolean sortForMe, SAMFileHeader.SortOrder sortOrder, boolean addReadGroup)
public SAMRecordSetBuilder(boolean sortForMe, SAMFileHeader.SortOrder sortOrder, boolean addReadGroup, int defaultChromosomeLength)
public SAMRecordSetBuilder(boolean sortForMe, SAMFileHeader.SortOrder sortOrder, boolean addReadGroup, int defaultChromosomeLength, DuplicateScoringStrategy.ScoringStrategy duplicateScoringStrategy)
public void setUseBamFile(boolean useBamFile)
useBamFile
- if true will use a BAM file, otherwise it will use a SAM file to hold the records.public void setUnmappedHasBasesAndQualities(boolean value)
public int size()
public void setRandomSeed(long seed)
public void setProgramRecord(SAMProgramRecord programRecord)
public void setUseNmFlag(boolean useNmFlag)
public void setReadGroup(SAMReadGroupRecord readGroup)
public java.util.Collection<SAMRecord> getRecords()
public void setHeader(SAMFileHeader header)
public void addRecord(SAMRecord record)
public CloseableIterator<SAMRecord> iterator()
iterator
in interface java.lang.Iterable<SAMRecord>
public SAMRecord addFrag(java.lang.String name, int contig, int start, boolean negativeStrand)
public SAMRecord addFrag(java.lang.String name, int contig, int start, boolean negativeStrand, boolean recordUnmapped, java.lang.String cigar, java.lang.String qualityString, int defaultQuality) throws SAMException
SAMException
public SAMRecord addFrag(java.lang.String name, int contig, int start, boolean negativeStrand, boolean recordUnmapped, java.lang.String cigar, java.lang.String qualityString, int defaultQuality, boolean isSecondary) throws SAMException
SAMException
public SAMRecord addFrag(java.lang.String name, int contig, int start, boolean negativeStrand, boolean recordUnmapped, java.lang.String cigar, java.lang.String qualityString, int defaultQuality, boolean isSecondary, boolean isSupplementary) throws SAMException
SAMException
public void addUnmappedFragment(java.lang.String name)
public void addPair(java.lang.String name, int contig, int start1, int start2)
public java.util.List<SAMRecord> addPair(java.lang.String name, int contig, int start1, int start2, boolean record1Unmapped, boolean record2Unmapped, java.lang.String cigar1, java.lang.String cigar2, boolean strand1, boolean strand2, int defaultQuality)
public java.util.List<SAMRecord> addPair(java.lang.String name, int contig1, int contig2, int start1, int start2, boolean record1Unmapped, boolean record2Unmapped, java.lang.String cigar1, java.lang.String cigar2, boolean strand1, boolean strand2, boolean record1NonPrimary, boolean record2NonPrimary, int defaultQuality)
public java.util.List<SAMRecord> addPair(java.lang.String name, int contig, int start1, int start2, boolean record1Unmapped, boolean record2Unmapped, java.lang.String cigar1, java.lang.String cigar2, boolean strand1, boolean strand2, boolean record1NonPrimary, boolean record2NonPrimary, int defaultQuality)
public void addUnmappedPair(java.lang.String name)
public SamReader getSamReader()
public SAMFileHeader getHeader()
public void setReadLength(int readLength)
public static SAMFileHeader makeDefaultHeader(SAMFileHeader.SortOrder sortOrder, int contigLength, boolean addReadGroup)
sortOrder
- Use this sort order in the headercontigLength
- length of the other contigspublic void writeRandomReference(java.nio.file.Path fasta) throws java.io.IOException
SAMFileHeader
output file is expected to have a non-compressed fasta suffix.
Method will also write .dict and .fai files next to the reference file.
files next to the provided. Will use the current SAMFileHeader
to model
the reference on.fasta
- Path to output reference where it will be written. No checks will be
performed regarding the writability, or existence of the files prior to writing.java.io.IOException
- In case of problem during writing the files.public static void writeRandomReference(SAMFileHeader header, java.nio.file.Path fasta) throws java.io.IOException
SAMFileHeader
output file is expected to have a non-compressed fasta suffix.
Method will also write .dict and .fai files next to the reference file.
files next to the providedheader
- Header file to base the reference on. Length and names of sequences will be
taken from here, as will the order of the contigs in the reference.fasta
- Path to output reference where it will be written. No checks will be performed
regarding the writability, or existence of the files prior to writing.java.io.IOException
- In case of problem during writing the files.