Class for tracking the reference information mapping between the reference ids and the reference names. More...
#include <SamReferenceInfo.h>
Public Member Functions | |
SamReferenceInfo () | |
Constructor. | |
~SamReferenceInfo () | |
Destructor. | |
void | add (const char *referenceSequenceName, int32_t referenceSequenceLength) |
Add reference sequence name and reference sequence length. | |
int | getReferenceID (const String &referenceName, bool addID=false) |
Get the reference ID for the specified name, if addID is set to true, a reference id will be created for the referenceName if one does not already exist, while if addID is set to false (default), it will return NO_REF_ID if the reference name does not exist. | |
int | getReferenceID (const char *referenceName, bool addID=false) |
Get the reference ID for the specified name, if addID is set to true, a reference id will be created for the referenceName if one does not already exist, while if addID is set to false (default), it will return NO_REF_ID if the reference name does not exist. | |
const String & | getReferenceLabel (int id) const |
Get the reference name for the specified id, if the id is not found, return "*". | |
int32_t | getNumEntries () const |
Get the number of entries contained here. | |
const char * | getReferenceName (int index) const |
Return the reference name at the specified index, returning "" if the index is out of bounds. | |
int32_t | getReferenceLength (int index) const |
Return the reference length at the specified index, returning 0 if the index is out of bounds. | |
void | clear () |
Reset this reference info. | |
SamReferenceInfo & | operator= (const SamReferenceInfo &rhs) |
Copy the reference information. | |
bool | operator== (const SamReferenceInfo &rhs) const |
bool | operator!= (const SamReferenceInfo &rhs) const |
Static Public Attributes | |
static const int | NO_REF_ID = -3 |
Constant for the value returned if a reference id does not exist for a queried reference name. |
Class for tracking the reference information mapping between the reference ids and the reference names.
Definition at line 27 of file SamReferenceInfo.h.
int SamReferenceInfo::getReferenceID | ( | const char * | referenceName, | |
bool | addID = false | |||
) |
Get the reference ID for the specified name, if addID is set to true, a reference id will be created for the referenceName if one does not already exist, while if addID is set to false (default), it will return NO_REF_ID if the reference name does not exist.
Definition at line 71 of file SamReferenceInfo.cpp.
References getReferenceID().
00073 { 00074 String referenceNameString = referenceName; 00075 00076 return(getReferenceID(referenceNameString, addID)); 00077 }
int SamReferenceInfo::getReferenceID | ( | const String & | referenceName, | |
bool | addID = false | |||
) |
Get the reference ID for the specified name, if addID is set to true, a reference id will be created for the referenceName if one does not already exist, while if addID is set to false (default), it will return NO_REF_ID if the reference name does not exist.
Definition at line 45 of file SamReferenceInfo.cpp.
References NO_REF_ID.
Referenced by getReferenceID(), and SamFileHeader::getReferenceID().
00047 { 00048 if (referenceName == "*") 00049 return -1; 00050 00051 int id = myReferenceHash.Find(referenceName); 00052 00053 if (id >= 0) 00054 return myReferenceHash.Integer(id); 00055 00056 if(!addID) 00057 { 00058 // Don't add the id, so return NO_REF_ID 00059 return(NO_REF_ID); 00060 } 00061 00062 id = myReferenceContigs.Length(); 00063 myReferenceContigs.Push(referenceName); 00064 myReferenceLengths.Push(0); 00065 myReferenceHash.Add(referenceName, id); 00066 00067 return id; 00068 }
const String & SamReferenceInfo::getReferenceLabel | ( | int | id | ) | const |
Get the reference name for the specified id, if the id is not found, return "*".
Definition at line 80 of file SamReferenceInfo.cpp.
Referenced by SamFileHeader::getReferenceLabel().
00081 { 00082 static String noname("*"); 00083 00084 if ((id < 0) || (id >= myReferenceContigs.Length())) 00085 { 00086 return noname; 00087 } 00088 00089 return myReferenceContigs[id]; 00090 }
int32_t SamReferenceInfo::getReferenceLength | ( | int | index | ) | const |
Return the reference length at the specified index, returning 0 if the index is out of bounds.
Definition at line 112 of file SamReferenceInfo.cpp.
References getNumEntries().
00113 { 00114 if((index >= 0) && (index < getNumEntries())) 00115 { 00116 return(myReferenceLengths[index]); 00117 } 00118 00119 // Out of bounds, return 0 00120 return(0); 00121 }
const char * SamReferenceInfo::getReferenceName | ( | int | index | ) | const |
Return the reference name at the specified index, returning "" if the index is out of bounds.
Definition at line 100 of file SamReferenceInfo.cpp.
References getNumEntries().
00101 { 00102 if((index >= 0) && (index < getNumEntries())) 00103 { 00104 return(myReferenceContigs[index].c_str()); 00105 } 00106 00107 // Out of range, return blank 00108 return(""); 00109 }
const int SamReferenceInfo::NO_REF_ID = -3 [static] |
Constant for the value returned if a reference id does not exist for a queried reference name.
Definition at line 77 of file SamReferenceInfo.h.
Referenced by getReferenceID().