18 #ifndef __SAM_FILE_H__ 19 #define __SAM_FILE_H__ 21 #include "SamStatus.h" 23 #include "SamFileHeader.h" 24 #include "SamRecord.h" 25 #include "GenericSamInterface.h" 27 #include "SamStatistics.h" 258 bool overlap =
true);
273 bool SetReadSection(
const char* refName, int32_t start, int32_t end,
274 bool overlap =
true);
286 void SetReadFlags(uint16_t requiredFlags, uint16_t excludedFlags);
338 return(
iftell(myFilePtr));
344 if(myFilePtr != NULL)
380 bool ensureIndexedReadPosition();
388 bool checkRecordInSection(
SamRecord& record);
422 bool myOverlapSection;
426 uint64_t myCurrentChunkEnd;
434 std::string myRefName;
437 bool myAttemptRecovery;
439 uint16_t myRequiredFlags;
440 uint16_t myExcludedFlags;
444 bool attemptRecoverySync(
bool (*checkSignature)(
void *data) ,
int length);
446 void setAttemptRecovery(
bool flag =
false)
448 myAttemptRecovery = flag;
void DisableBuffering()
Turn off file read buffering.
Child class of SamFile for writing files.
void SetWriteSequenceTranslation(SamRecord::SequenceTranslation translation)
Set the type of sequence translation to use when writing the sequence.
uint32_t GetNumOverlaps(SamRecord &samRecord)
Returns the number of bases in the passed in read that overlap the region that is currently set...
SamStatistics * myStatistics
Pointer to the statistics for this file.
bool ReadHeader(SamFileHeader &header)
Reads the header section from the file and stores it in the passed in header.
SequenceTranslation
Enum containing the settings on how to translate the sequence if a reference is available.
void SetReadSequenceTranslation(SamRecord::SequenceTranslation translation)
Set the type of sequence translation to use when reading the sequence.
bool validateSortOrder(SamRecord &record, SamFileHeader &header)
Validate that the record is sorted compared to the previously read record if there is one...
This class is used to track the status results of some methods in the BAM classes.
const BamIndex * GetBamIndex()
Return the bam index if one has been opened.
void Close()
Close the file if there is one open.
void SetReference(GenomeSequence *reference)
Sets the reference to the specified genome sequence object.
OpenType
Enum for indicating whether to open the file for read or write.
SamFile()
Default Constructor, initializes the variables, but does not open any files.
int32_t getNumMappedReadsFromIndex(int32_t refID)
Get the number of mapped reads in the specified reference id.
Status getStatus() const
Return the enum for this status object.
uint32_t GetCurrentRecordCount()
Return the number of records that have been read/written so far.
int64_t GetCurrentPosition()
Get the current file position.
bool SetReadSection(int32_t refID)
Sets which reference id (index into the BAM list of reference information) of the BAM file should be ...
void setSortedValidation(SortedType sortType)
Set the flag to validate that the file is sorted as it is read/written.
int32_t getNumUnMappedReadsFromIndex(int32_t refID)
Get the number of unmapped reads in the specified reference id.
virtual ~SamFile()
Destructor.
bool ReadBamIndex()
Read the bam index file using the BAM filename as a base.
Child class of SamFile for reading files.
file is sorted by coordinate.
bool myIsOpenForWrite
Flag to indicate if a file is open for writing.
Allows the user to easily read/write a SAM/BAM file.
SamStatus::Status GetStatus()
Get the Status of the last call that sets status.
void PrintStatistics()
Print the statistics that have been recorded due to a call to GenerateStatistics. ...
bool IsOpen()
Returns whether or not the file has been opened successfully.
bool WriteHeader(SamFileHeader &header)
Writes the specified header into the file.
SO flag from the header indicates the sort type.
HandlingType
This specifies how this class should respond to errors.
int32_t myPrevCoord
Previous values used for checking if the file is sorted.
SamStatus myStatus
The status of the last SamFile command.
bool WriteRecord(SamFileHeader &header, SamRecord &record)
Writes the specified record into the file.
uint32_t myRecordCount
Keep a count of the number of records that have been read/written so far.
const char * GetStatusMessage()
Get the Status Message of the last call that sets status.
void resetFile()
Resets the file prepping for a new file.
SamStatus::Status GetFailure()
Deprecated, get the Status of the last call that sets status.
bool IsEOF()
Returns whether or not the end of the file has been reached.
file is sorted by queryname.
bool ReadRecord(SamFileHeader &header, SamRecord &record)
Reads the next record from the file & stores it in the passed in record.
Create/Access/Modify/Load Genome Sequences stored as binary mapped files.
bool OpenForWrite(const char *filename, SamFileHeader *header=NULL)
Open a sam/bam file for writing with the specified filename, determining SAM/BAM from the extension (...
Class providing an easy to use interface to get/set/operate on the fields in a SAM/BAM record...
void GenerateStatistics(bool genStats)
Whether or not statistics should be generated for this file.
bool OpenForRead(const char *filename, SamFileHeader *header=NULL)
Open a sam/bam file for reading with the specified filename, determing the type of file and SAM/BAM b...
const char * getStatusMessage() const
Return the status message for this object.
SortedType
Enum for indicating the type of sort expected in the file.
bool myIsOpenForRead
Flag to indicate if a file is open for reading.
Status
Return value enum for StatGenFile methods.
bool myIsBamOpenForRead
Values for reading Sorted BAM files via the index.
void SetReadFlags(uint16_t requiredFlags, uint16_t excludedFlags)
Specify which reads should be returned by ReadRecord.
bool myHasHeader
Flag to indicate if a header has been read/written - required before being able to read/write a recor...