18 #ifndef __SAM_RECORD_H__ 19 #define __SAM_RECORD_H__ 23 #include "GenomeSequence.h" 24 #include "SamStatus.h" 26 #include "MathVector.h" 27 #include "StringArray.h" 29 #include "SamFileHeader.h" 30 #include "CigarRoller.h" 37 int32_t myReferenceID;
39 uint32_t myReadNameLength : 8, myMapQuality : 8, myBin : 16;
40 uint32_t myCigarLength : 16, myFlag : 16;
42 int32_t myMateReferenceID;
43 int32_t myMatePosition;
107 bool setReadName(
const char* readName);
112 bool setFlag(uint16_t flag);
120 const char* referenceName);
128 bool set1BasedPosition(int32_t position);
136 bool set0BasedPosition(int32_t position);
141 bool setMapQuality(uint8_t mapQuality);
148 bool setCigar(
const char* cigar);
155 bool setCigar(
const Cigar& cigar);
164 const char* mateReferenceName);
172 bool set1BasedMatePosition(int32_t matePosition);
180 bool set0BasedMatePosition(int32_t matePosition);
185 bool setInsertSize(int32_t insertSize);
192 bool setSequence(
const char* seq);
199 bool setQuality(
const char* quality);
203 bool shiftIndelsLeft();
234 bool addIntTag(
const char* tag, int32_t value);
244 bool addTag(
const char* tag,
char vtype,
const char* value);
254 bool rmTag(
const char* tag,
char type);
264 bool rmTags(
const char* tags);
278 const void* getRecordBuffer();
302 int32_t getBlockSize();
306 const char* getReferenceName();
310 int32_t getReferenceID();
314 int32_t get1BasedPosition();
318 int32_t get0BasedPosition();
322 uint8_t getReadNameLength();
326 uint8_t getMapQuality();
334 uint16_t getCigarLength();
342 int32_t getReadLength();
347 const char* getMateReferenceName();
353 const char* getMateReferenceNameOrEqual();
358 int32_t getMateReferenceID();
362 int32_t get1BasedMatePosition();
366 int32_t get0BasedMatePosition();
371 int32_t getInsertSize();
376 int32_t get0BasedAlignmentEnd();
381 int32_t get1BasedAlignmentEnd();
386 int32_t getAlignmentLength();
391 int32_t get0BasedUnclippedStart();
396 int32_t get1BasedUnclippedStart();
401 int32_t get0BasedUnclippedEnd();
406 int32_t get1BasedUnclippedEnd();
410 const char* getReadName();
414 const char* getCigar();
419 const char* getSequence();
429 const char* getQuality();
436 char getSequence(
int index);
450 char getQuality(
int index);
456 Cigar* getCigarInfo();
469 uint32_t getNumOverlaps(int32_t start, int32_t end);
510 uint32_t getTagLength();
521 bool getNextSamTag(
char* tag,
char& vtype,
void** value);
531 static bool isIntegerType(
char vtype);
537 static bool isFloatType(
char vtype);
543 static bool isCharType(
char vtype);
549 static bool isStringType(
char vtype);
564 bool getTagsString(
const char* tags,
String& returnString,
char delim =
'\t');
569 const String* getStringTag(
const char * tag);
574 int* getIntegerTag(
const char * tag);
581 bool getIntegerTag(
const char * tag,
int& tagVal);
588 bool getFloatTag(
const char * tag,
float& tagVal);
591 const String & getString(
const char * tag);
594 int & getInteger(
const char * tag);
601 {
return(checkTag(tag,
'Z') || checkTag(tag,
'B')); }
613 bool checkFloat(
const char * tag) {
return checkTag(tag,
'f'); }
620 bool checkTag(
const char * tag,
char type);
629 static int MAKEKEY(
char ch1,
char ch2,
char type)
630 {
return (getKeyType(type) << 16) + (ch2 << 8) + ch1; }
632 static char getKeyType(
char type)
652 static inline int getNumericTagTypeSize(
char type)
679 bool allocateRecordStructure(
int size);
681 void* getStringPtr(
int offset);
682 void* getIntegerPtr(
int offset,
char& vtype);
683 void* getFloatPtr(
int offset);
693 void setSequenceAndQualityFromBuffer();
702 bool parseCigarBinary();
706 bool parseCigarString();
710 bool setTagsFromBuffer();
714 bool setTagsInBuffer();
718 void getTypeFromKey(
int key,
char& type)
const;
719 void getTag(
int key,
char* tag)
const;
721 String & getString(
int offset);
722 int & getInteger(
int offset);
723 const char & getIntegerType(
int offset)
const;
724 float & getFloat(
int offset);
728 inline void appendIntArrayValue(
int index,
String& strVal)
const 730 appendIntArrayValue(intType[index], integers[index], strVal);
733 void appendIntArrayValue(
char type,
int value,
String& strVal)
const;
735 int getBtagBufferSize(
String& tagStr);
736 int setBtagBuffer(
String& tagStr,
char* extraPtr);
737 int getStringFromBtagBuffer(
unsigned char* buffer,
String& tagStr);
739 static const int DEFAULT_BLOCK_SIZE = 40;
740 static const int DEFAULT_BIN = 4680;
741 static const int DEFAULT_READ_NAME_LENGTH = 8;
742 static const char* DEFAULT_READ_NAME;
743 static const char* FIELD_ABSENT_STRING;
750 uint32_t* myCigarTempBuffer;
753 int myCigarTempBufferAllocatedSize;
756 int myCigarTempBufferLength;
762 bool myIsBufferSynced;
765 bool myNeedToSetTagsFromBuffer;
770 bool myNeedToSetTagsInBuffer;
777 String myMateReferenceName;
782 std::string mySeqWithEq;
783 std::string mySeqWithoutEq;
786 int32_t myAlignmentLength;
788 int32_t myUnclippedStartOffset;
789 int32_t myUnclippedEndOffset;
801 std::vector<char> intType;
802 std::vector<float> floats;
807 bool myIsReadNameBufferValid;
808 bool myIsCigarBufferValid;
809 bool myIsSequenceBufferValid;
810 bool myIsQualityBufferValid;
811 bool myIsTagsBufferValid;
814 unsigned char* myPackedSequence;
815 unsigned char* myPackedQuality;
831 String NOT_FOUND_TAG_STRING;
832 int NOT_FOUND_TAG_INT;
834 static const int myMaxWarns = 5;
835 static int myNumWarns;
SequenceTranslation
Enum containing the settings on how to translate the sequence if a reference is available.
This class is used to track the status results of some methods in the BAM classes.
Translate '=' to the actual base.
bool checkInteger(const char *tag)
Check if the specified tag contains an integer.
bool checkString(const char *tag)
Check if the specified tag contains a string.
bool checkFloat(const char *tag)
Check if the specified tag contains a string.
Structure of a BAM record.
This class represents the CIGAR without any methods to set the cigar (see CigarRoller for that)...
Leave the sequence as is.
HandlingType
This specifies how this class should respond to errors.
Create/Access/Modify/Load Genome Sequences stored as binary mapped files.
Translate bases that match the reference to '='.
Class providing an easy to use interface to get/set/operate on the fields in a SAM/BAM record...
The purpose of this class is to provide accessors for setting, updating, modifying the CIGAR object...
Status
Return value enum for StatGenFile methods.