libStatGen Software 1
Loading...
Searching...
No Matches
SamFile.h
1/*
2 * Copyright (C) 2010 Regents of the University of Michigan
3 *
4 * This program is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
8 *
9 * This program is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with this program. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef __SAM_FILE_H__
19#define __SAM_FILE_H__
20
21#include "SamStatus.h"
22#include "InputFile.h"
23#include "SamFileHeader.h"
24#include "SamRecord.h"
25#include "GenericSamInterface.h"
26#include "BamIndex.h"
27#include "SamStatistics.h"
28
29/// Allows the user to easily read/write a SAM/BAM file.
30/// The SamFile class contains additional functionality that allows a user
31/// to read specific sections of sorted & indexed BAM files. In order to
32/// take advantage of this capability, the index file must be read prior to
33/// setting the read section. This logic saves the time of having to read
34/// the entire file and takes advantage of the seeking capability of BGZF.
36{
37public:
38 /// Enum for indicating whether to open the file for read or write.
39 enum OpenType {
40 READ, ///< open for reading.
41 WRITE ///< open for writing.
42 };
43
44
45 /// Enum for indicating the type of sort expected in the file.
47 UNSORTED = 0, ///< file is not sorted.
48 FLAG, ///< SO flag from the header indicates the sort type.
49 COORDINATE, ///< file is sorted by coordinate.
50 QUERY_NAME ///< file is sorted by queryname.
51 };
52
53 /// Default Constructor, initializes the variables, but does not open
54 /// any files.
55 SamFile();
56
57 /// Constructor that sets the error handling type.
58 /// \param errorHandlingType how to handle errors.
59 SamFile(ErrorHandler::HandlingType errorHandlingType);
60
61 /// Constructor that opens the specified file based on the specified mode
62 /// (READ/WRITE), aborts if the file could not be opened.
63 /// \param filename name of the file to open.
64 /// \param mode mode to use for opening the file.
65 SamFile(const char* filename, OpenType mode);
66
67 /// Constructor that opens the specified file based on the specified mode
68 /// (READ/WRITE) and handles errors per the specified handleType.
69 /// \param filename name of the file to open.
70 /// \param mode mode to use for opening the file.
71 /// \param errorHandlingType how to handle errors.
72 SamFile(const char* filename, OpenType mode,
73 ErrorHandler::HandlingType errorHandlingType);
74
75 /// Constructor that opens the specified file based on the specified mode
76 /// (READ/WRITE) and reads the header, aborts if the file could not be
77 /// opened or the header not read.
78 /// \param filename name of the file to open.
79 /// \param mode mode to use for opening the file.
80 /// \param header to read into or write from
81 SamFile(const char* filename, OpenType mode, SamFileHeader* header);
82
83 /// Constructor that opens the specified file based on the specified mode
84 /// (READ/WRITE) and reads the header, handling errors per the specified
85 /// handleType.
86 /// \param filename name of the file to open.
87 /// \param mode mode to use for opening the file.
88 /// \param errorHandlingType how to handle errors.
89 /// \param header to read into or write from
90 SamFile(const char* filename, OpenType mode,
91 ErrorHandler::HandlingType errorHandlingType,
92 SamFileHeader* header);
93
94 /// Destructor
95 virtual ~SamFile();
96
97 /// Open a sam/bam file for reading with the specified filename,
98 /// determing the type of file and SAM/BAM by reading the file
99 /// (if not stdin).
100 /// \param filename the sam/bam file to open for reading.
101 /// \param header to read into or write from (optional)
102 /// \return true = success; false = failure.
103 bool OpenForRead(const char * filename, SamFileHeader* header = NULL);
104
105 /// Open a sam/bam file for writing with the specified filename,
106 /// determining SAM/BAM from the extension (.bam = BAM).
107 /// \param filename the sam/bam file to open for writing.
108 /// \param header to read into or write from (optional)
109 /// \return true = success; false = failure.
110 bool OpenForWrite(const char * filename, SamFileHeader* header = NULL);
111
112 /// Read the specified bam index file. It must be read prior to setting a
113 /// read section, for seeking and reading portions of a bam file.
114 /// \param filename the name of the bam index file to be read.
115 /// \return true = success; false = failure.
116 bool ReadBamIndex(const char * filename);
117
118 /// Read the bam index file using the BAM filename as a base.
119 /// It must be read prior to setting a read section, for seeking
120 /// and reading portions of a bam file.
121 /// Must be read after opening the BAM file since it uses the
122 /// BAM filename as a base name for the index file.
123 /// First it tries filename.bam.bai. If that fails, it tries
124 /// it without the .bam extension, filename.bai.
125 /// \return true = success; false = failure.
126 bool ReadBamIndex();
127
128 /// Sets the reference to the specified genome sequence object.
129 /// \param reference pointer to the GenomeSequence object.
130 void SetReference(GenomeSequence* reference);
131
132 /// Set the type of sequence translation to use when reading
133 /// the sequence. Passed down to the SamRecord when it is read.
134 /// The default type (if this method is never called) is
135 /// NONE (the sequence is left as-is).
136 /// \param translation type of sequence translation to use.
138
139 /// Set the type of sequence translation to use when writing
140 /// the sequence. Passed down to the SamRecord when it is written.
141 /// The default type (if this method is never called) is
142 /// NONE (the sequence is left as-is).
143 /// \param translation type of sequence translation to use.
145
146 /// Close the file if there is one open.
147 void Close();
148
149 /// Returns whether or not the file has been opened successfully.
150 /// \return true = open; false = not open.
151 bool IsOpen();
152
153 /// Returns whether or not the end of the file has been reached.
154 /// \return true = EOF; false = not eof.
155 /// If the file is not open, true is returned.
156 bool IsEOF();
157
158 /// Returns whether or not the file has been opened for streaming
159 /// input/output.
160 /// \return true = stream; false = not a stream.
161 bool IsStream();
162
163 /// Reads the header section from the file and stores it in
164 /// the passed in header.
165 /// \return true = success; false = failure.
166 bool ReadHeader(SamFileHeader& header);
167
168 /// Writes the specified header into the file.
169 /// \return true = success; false = failure.
170 bool WriteHeader(SamFileHeader& header);
171
172 /// Reads the next record from the file & stores it in the passed in record.
173 ///
174 /// If it is an indexed BAM file and SetReadSection was called,
175 /// only alignments in the section specified by SetReadSection are read.
176 /// If they all have already been read, this method returns false.
177 ///
178 /// Validates that the record is sorted according to the value set by
179 /// setSortedValidation. No sorting validation is done if specified to be
180 /// unsorted, or setSortedValidation was never called.
181 /// \return true = record was successfully set (and sorted if applicable),
182 /// false = record was not successfully set
183 /// (or not sorted as expected).
184 bool ReadRecord(SamFileHeader& header, SamRecord& record);
185
186 /// Writes the specified record into the file.
187 /// Validates that the record is sorted according to the value set by
188 /// setSortedValidation. No sorting validation is done if specified to
189 /// be unsorted, or setSortedValidation was never called. Returns false
190 /// and does not write the record if the record was not properly sorted.
191 /// \return true = success; false = failure.
192 bool WriteRecord(SamFileHeader& header, SamRecord& record);
193
194 /// Set the flag to validate that the file is sorted as it is read/written.
195 /// Must be called after the file has been opened.
196 /// Sorting validation is reset everytime SetReadPosition is called since
197 /// it can jump around in the file.
198 /// \param sortType specifies the type of sort to be checked for.
199 void setSortedValidation(SortedType sortType);
200
201 /// Return the number of records that have been read/written so far.
202 uint32_t GetCurrentRecordCount();
203
204 /// Deprecated, get the Status of the last call that sets status.
205 /// To remain backwards compatable - will be removed later.
207 {
208 return(GetStatus());
209 }
210
211 /// Get the Status of the last call that sets status.
213 {
214 return(myStatus.getStatus());
215 }
216
217 /// Get the Status Message of the last call that sets status.
218 inline const char* GetStatusMessage()
219 {
220 return(myStatus.getStatusMessage());
221 }
222
223 /// Sets which reference id (index into the BAM list of reference
224 /// information) of the BAM file should be read. The records
225 /// for that reference id will be retrieved on each ReadRecord call.
226 /// Reference ids start at 0, and -1 indicates reads with no reference.
227 /// When all records have been retrieved for the specified reference id,
228 /// ReadRecord will return failure until a new read section is set.
229 /// Must be called only after the file has been opened for reading.
230 /// Sorting validation is reset everytime SetReadPosition is called since
231 /// it can jump around in the file.
232 /// \param refID the reference ID of the records to read from the file.
233 /// \return true = success; false = failure.
234 bool SetReadSection(int32_t refID);
235
236 /// Sets which reference name of the BAM file should be read. The records
237 /// for that reference name will be retrieved on each ReadRecord call.
238 /// Specify "" or "*" to read records not associated with a reference.
239 /// When all records have been retrieved for the specified reference name,
240 /// ReadRecord will return failure until a new read section is set.
241 /// Must be called only after the file has been opened for reading.
242 /// Sorting validation is reset everytime SetReadPosition is called since
243 /// it can jump around in the file.
244 /// \param refName the reference name of the records to read from the file.
245 /// \return true = success; false = failure.
246 bool SetReadSection(const char* refName);
247
248 /// Sets which reference id (index into the BAM list of reference
249 /// information) & start/end positions of the BAM file should be read.
250 /// The records for that reference id and positions will be retrieved on
251 /// each ReadRecord call. Reference ids start at 0, and -1 indicates
252 /// reads with no reference. When all records have been retrieved for the
253 /// specified reference id, ReadRecord will return failure until a new read
254 /// section is set. Must be called only after the file has been opened
255 /// for reading. Sorting validation is reset everytime SetReadPosition is
256 /// called since it can jump around in the file.
257 /// \param refID the reference ID of the records to read from the file.
258 /// \param start inclusive 0-based start position of records that should be read for this refID.
259 /// \param end exclusive 0-based end position of records that should be read for this refID.
260 /// \param overlap When true (default), return reads that just overlap the region; when false, only return reads that fall completely within the region
261 /// \return true = success; false = failure.
262 bool SetReadSection(int32_t refID, int32_t start, int32_t end,
263 bool overlap = true);
264
265 /// Sets which reference name & start/end positions of the BAM file should
266 /// be read. The records for this reference name & positions will be
267 /// retrieved on each ReadRecord call. Specify "" or "*" to indicate
268 /// reads with no reference. When all records have been retrieved for
269 /// the specified section, ReadRecord will return failure until a new read
270 /// section is set. Must be called only after the file has been opened for
271 /// reading. Sorting validation is reset everytime SetReadSection is
272 /// called since it can jump around in the file.
273 /// \param refName the reference name of the records to read from the file.
274 /// \param start inclusive 0-based start position of records that should be read for this refID.
275 /// \param end exclusive 0-based end position of records that should be read for this refID.
276 /// \param overlap When true (default), return reads that just overlap the region; when false, only return reads that fall completely within the region
277 /// \return true = success; false = failure.
278 bool SetReadSection(const char* refName, int32_t start, int32_t end,
279 bool overlap = true);
280
281 /// Specify which reads should be returned by ReadRecord.
282 /// Reads will only be returned by ReadRecord that contain the specified
283 /// required flags and that do not contain any of the specified excluded
284 /// flags. ReadRecord will continue to read from the file until a record
285 /// that complies with these flag settings is found or until the end of the
286 /// file/region.
287 /// \param requiredFlags flags that are required to be in records
288 /// returned by ReadRecord (set to 0x0 if there are no required flags).
289 /// \param excludedFlags flags that are required to not be in records
290 /// returned by ReadRecord (set to 0x0 if there are no excluded flags).
291 void SetReadFlags(uint16_t requiredFlags, uint16_t excludedFlags);
292
293 /// Get the number of mapped reads in the specified reference id.
294 /// Returns -1 for out of range refIDs.
295 /// \param refID reference ID for which to extract the number of mapped reads.
296 /// \return number of mapped reads for the specified reference id.
297 int32_t getNumMappedReadsFromIndex(int32_t refID);
298
299 /// Get the number of unmapped reads in the specified reference id.
300 /// Returns -1 for out of range refIDs.
301 /// \param refID reference ID for which to extract the number of unmapped reads.
302 /// \return number of unmapped reads for the specified reference id.
303 int32_t getNumUnMappedReadsFromIndex(int32_t refID);
304
305 /// Get the number of mapped reads in the specified reference name.
306 /// Returns -1 for unknown reference names.
307 /// \param refName reference name for which to extract the number of mapped reads.
308 /// \param header header object containing the map from refName to refID
309 /// \return number of mapped reads for the specified reference name.
310 int32_t getNumMappedReadsFromIndex(const char* refName,
311 SamFileHeader& header);
312
313 /// Get the number of unmapped reads in the specified reference name.
314 /// Returns -1 for unknown reference names.
315 /// \param refName reference name for which to extract the number of unmapped reads.
316 /// \param header header object containing the map from refName to refID
317 /// \return number of unmapped reads for the specified reference name.
318 int32_t getNumUnMappedReadsFromIndex(const char* refName,
319 SamFileHeader& header);
320
321 /// Returns the number of bases in the passed in read that overlap the
322 /// region that is currently set. Overlapping means that the bases occur
323 /// in both the read and the reference as either matches or mismatches.
324 /// This does not count insertions, deletions, clips, pads, or skips.
325 /// \param samRecord to check for overlapping bases.
326 /// \return number of bases that overlap region that is currently set.
327 uint32_t GetNumOverlaps(SamRecord& samRecord);
328
329 /// Whether or not statistics should be generated for this file.
330 /// The value is carried over between files and is not reset, but
331 /// the statistics themselves are reset between files.
332 /// \param genStats set to true if statistics should be generated, false if not.
333 void GenerateStatistics(bool genStats);
334
335 /// Return the bam index if one has been opened.
336 /// \return const pointer to the bam index, or null if one has not been opened.
337 const BamIndex* GetBamIndex();
338
339 /// Get the current file position.
340 /// \return current position in the file.
341 inline int64_t GetCurrentPosition()
342 {
343 return(iftell(myFilePtr));
344 }
345
346 /// Turn off file read buffering.
347 inline void DisableBuffering()
348 {
349 if(myFilePtr != NULL)
350 {
351 myFilePtr->disableBuffering();
352 }
353 }
354
355 /// Print the statistics that have been recorded due to a call to
356 /// GenerateStatistics.
357 inline void PrintStatistics() {if(myStatistics != NULL) myStatistics->print();}
358
359protected:
360 void init();
361 void init(const char* filename, OpenType mode, SamFileHeader* header);
362
363 /// Resets the file prepping for a new file.
364 void resetFile();
365
366 /// Validate that the record is sorted compared to the previously read
367 /// record if there is one, according to the specified sort order.
368 /// If the sort order is UNSORTED, true is returned.
369 /// Sorting validation is reset everytime SetReadPosition is called since
370 /// it can jump around in the file.
371 bool validateSortOrder(SamRecord& record, SamFileHeader& header);
372
373 // Return the sort order as defined by the header. If it is undefined
374 // or set to an unknown value, UNSORTED is returned.
375 SortedType getSortOrderFromHeader(SamFileHeader& header);
376
377 bool processNewSection(SamFileHeader &header);
378
379 // Check if there is more to read in the current chunk, if not,
380 // move to the next chunk.
381 // If no sections are specified or it successfully found a chunk to read,
382 // return true.
383 // Sets the status and returns false if it was unable to move to a new chunk
384 // or there are no more chunks to read, otherwise returns true.
385 bool ensureIndexedReadPosition();
386
387 // Check whether or not the record falls within the specified section.
388 // If no sections are specified or this read falls within the
389 // specified sections, return true.
390 // If it does not, return false.
391 // If the record position indicates there will be no more records within the
392 // region, return false AND set the sam status to indicate NO_MORE_RECS.
393 bool checkRecordInSection(SamRecord& record);
394
395 IFILE myFilePtr;
396 GenericSamInterface* myInterfacePtr;
397
398 /// Flag to indicate if a file is open for reading.
400 /// Flag to indicate if a file is open for writing.
402 /// Flag to indicate if a header has been read/written - required before
403 /// being able to read/write a record.
405
406 SortedType mySortedType;
407
408 /// Previous values used for checking if the file is sorted.
409 int32_t myPrevCoord;
410 int32_t myPrevRefID;
411 String myPrevReadName;
412
413 /// Keep a count of the number of records that have been read/written so far.
415
416 /// Pointer to the statistics for this file.
418
419 /// The status of the last SamFile command.
421
422 /// Values for reading Sorted BAM files via the index.
424 bool myNewSection;
425 // whether to return reads that overlap (true) the section or
426 // are fully enclosed (false) in the section.
427 bool myOverlapSection;
428 int32_t myRefID;
429 int32_t myStartPos;
430 int32_t myEndPos;
431 uint64_t myCurrentChunkEnd;
432 SortedChunkList myChunksToRead;
433 BamIndex* myBamIndex;
434
435 GenomeSequence* myRefPtr;
436 SamRecord::SequenceTranslation myReadTranslation;
437 SamRecord::SequenceTranslation myWriteTranslation;
438
439 std::string myRefName;
440
441private:
442 bool myAttemptRecovery;
443
444 uint16_t myRequiredFlags;
445 uint16_t myExcludedFlags;
446
447public:
448
449 bool attemptRecoverySync(bool (*checkSignature)(void *data) , int length);
450
451 void setAttemptRecovery(bool flag = false)
452 {
453 myAttemptRecovery = flag;
454 }
455
456};
457
458
459/// Child class of SamFile for reading files.
460class SamFileReader : public SamFile
461{
462public:
463
464 /// Default Constructor.
466
467 /// Constructor that opens the specified file for read.
468 SamFileReader(const char* filename);
469
470 /// Constructor that opens the specified file for read.
471 SamFileReader(const char* filename,
472 ErrorHandler::HandlingType errorHandlingType);
473
474 /// Constructor that opens the specified file for read and reads
475 /// the header from the file.
476 SamFileReader(const char* filename,
477 SamFileHeader* header);
478
479 /// Constructor that opens the specified file for read and reads
480 /// the header from the file.
481 SamFileReader(const char* filename,
482 ErrorHandler::HandlingType errorHandlingType,
483 SamFileHeader* header);
484
485 virtual ~SamFileReader();
486};
487
488
489/// Child class of SamFile for writing files.
490class SamFileWriter : public SamFile
491{
492public:
493 /// Default Constructor.
495
496 /// Constructor that opens the specified file for write.
497 SamFileWriter(const char* filename);
498
499 /// Constructor that opens the specified file for write.
500 SamFileWriter(const char* filename,
501 ErrorHandler::HandlingType errorHandlingType);
502
503 /// Constructor that opens the specified file for write and write
504 /// the specified header into the file.
505 SamFileWriter(const char* filename,
506 SamFileHeader* header);
507
508 /// Constructor that opens the specified file for write and write
509 /// the specified header into the file.
510 SamFileWriter(const char* filename,
511 ErrorHandler::HandlingType errorHandlingType,
512 SamFileHeader* header);
513
514 virtual ~SamFileWriter();
515};
516
517#endif
int64_t iftell(IFILE file)
Get current position in the file.
Definition InputFile.h:682
HandlingType
This specifies how this class should respond to errors.
Create/Access/Modify/Load Genome Sequences stored as binary mapped files.
Class for easily reading/writing files without having to worry about file type (uncompressed,...
Definition InputFile.h:37
void disableBuffering()
Disable read buffering.
Definition InputFile.h:121
This class allows a user to get/set the fields in a SAM/BAM Header.
Child class of SamFile for reading files.
Definition SamFile.h:461
SamFileReader()
Default Constructor.
Definition SamFile.cpp:1373
Child class of SamFile for writing files.
Definition SamFile.h:491
SamFileWriter()
Default Constructor.
Definition SamFile.cpp:1419
Allows the user to easily read/write a SAM/BAM file.
Definition SamFile.h:36
bool ReadHeader(SamFileHeader &header)
Reads the header section from the file and stores it in the passed in header.
Definition SamFile.cpp:450
bool IsOpen()
Returns whether or not the file has been opened successfully.
Definition SamFile.cpp:410
int32_t getNumUnMappedReadsFromIndex(int32_t refID)
Get the number of unmapped reads in the specified reference id.
Definition SamFile.cpp:818
void Close()
Close the file if there is one open.
Definition SamFile.cpp:400
void resetFile()
Resets the file prepping for a new file.
Definition SamFile.cpp:966
int32_t myPrevCoord
Previous values used for checking if the file is sorted.
Definition SamFile.h:409
bool myIsOpenForRead
Flag to indicate if a file is open for reading.
Definition SamFile.h:399
bool ReadBamIndex()
Read the bam index file using the BAM filename as a base.
Definition SamFile.cpp:328
bool SetReadSection(int32_t refID)
Sets which reference id (index into the BAM list of reference information) of the BAM file should be ...
Definition SamFile.cpp:696
SortedType
Enum for indicating the type of sort expected in the file.
Definition SamFile.h:46
@ UNSORTED
file is not sorted.
Definition SamFile.h:47
@ FLAG
SO flag from the header indicates the sort type.
Definition SamFile.h:48
@ QUERY_NAME
file is sorted by queryname.
Definition SamFile.h:50
@ COORDINATE
file is sorted by coordinate.
Definition SamFile.h:49
bool ReadRecord(SamFileHeader &header, SamRecord &record)
Reads the next record from the file & stores it in the passed in record.
Definition SamFile.cpp:514
bool IsStream()
Returns whether or not the file has been opened for streaming input/output.
Definition SamFile.cpp:437
void SetReadFlags(uint16_t requiredFlags, uint16_t excludedFlags)
Specify which reads should be returned by ReadRecord.
Definition SamFile.cpp:794
void SetReference(GenomeSequence *reference)
Sets the reference to the specified genome sequence object.
Definition SamFile.cpp:380
OpenType
Enum for indicating whether to open the file for read or write.
Definition SamFile.h:39
@ READ
open for reading.
Definition SamFile.h:40
@ WRITE
open for writing.
Definition SamFile.h:41
void GenerateStatistics(bool genStats)
Whether or not statistics should be generated for this file.
Definition SamFile.cpp:891
const BamIndex * GetBamIndex()
Return the bam index if one has been opened.
Definition SamFile.cpp:916
void PrintStatistics()
Print the statistics that have been recorded due to a call to GenerateStatistics.
Definition SamFile.h:357
uint32_t GetNumOverlaps(SamRecord &samRecord)
Returns the number of bases in the passed in read that overlap the region that is currently set.
Definition SamFile.cpp:877
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...
Definition SamFile.cpp:93
bool IsEOF()
Returns whether or not the end of the file has been reached.
Definition SamFile.cpp:424
int32_t getNumMappedReadsFromIndex(int32_t refID)
Get the number of mapped reads in the specified reference id.
Definition SamFile.cpp:803
SamStatus::Status GetStatus()
Get the Status of the last call that sets status.
Definition SamFile.h:212
int64_t GetCurrentPosition()
Get the current file position.
Definition SamFile.h:341
SamStatus::Status GetFailure()
Deprecated, get the Status of the last call that sets status.
Definition SamFile.h:206
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 (...
Definition SamFile.cpp:223
bool WriteHeader(SamFileHeader &header)
Writes the specified header into the file.
Definition SamFile.cpp:480
bool myIsOpenForWrite
Flag to indicate if a file is open for writing.
Definition SamFile.h:401
void DisableBuffering()
Turn off file read buffering.
Definition SamFile.h:347
bool myIsBamOpenForRead
Values for reading Sorted BAM files via the index.
Definition SamFile.h:423
bool myHasHeader
Flag to indicate if a header has been read/written - required before being able to read/write a recor...
Definition SamFile.h:404
virtual ~SamFile()
Destructor.
Definition SamFile.cpp:82
SamFile()
Default Constructor, initializes the variables, but does not open any files.
Definition SamFile.cpp:26
void SetWriteSequenceTranslation(SamRecord::SequenceTranslation translation)
Set the type of sequence translation to use when writing the sequence.
Definition SamFile.cpp:394
void SetReadSequenceTranslation(SamRecord::SequenceTranslation translation)
Set the type of sequence translation to use when reading the sequence.
Definition SamFile.cpp:387
bool validateSortOrder(SamRecord &record, SamFileHeader &header)
Validate that the record is sorted compared to the previously read record if there is one,...
Definition SamFile.cpp:1019
bool WriteRecord(SamFileHeader &header, SamRecord &record)
Writes the specified record into the file.
Definition SamFile.cpp:632
uint32_t myRecordCount
Keep a count of the number of records that have been read/written so far.
Definition SamFile.h:414
SamStatus myStatus
The status of the last SamFile command.
Definition SamFile.h:420
const char * GetStatusMessage()
Get the Status Message of the last call that sets status.
Definition SamFile.h:218
uint32_t GetCurrentRecordCount()
Return the number of records that have been read/written so far.
Definition SamFile.cpp:689
void setSortedValidation(SortedType sortType)
Set the flag to validate that the file is sorted as it is read/written.
Definition SamFile.cpp:682
SamStatistics * myStatistics
Pointer to the statistics for this file.
Definition SamFile.h:417
Class providing an easy to use interface to get/set/operate on the fields in a SAM/BAM record.
Definition SamRecord.h:52
SequenceTranslation
Enum containing the settings on how to translate the sequence if a reference is available.
Definition SamRecord.h:57
This class is used to track the status results of some methods in the BAM classes.
const char * getStatusMessage() const
Return the status message for this object.
Status
Return value enum for StatGenFile methods.
Status getStatus() const
Return the enum for this status object.