libStatGen Software
1
|
00001 /* 00002 * Copyright (C) 2010 Regents of the University of Michigan 00003 * 00004 * This program is free software: you can redistribute it and/or modify 00005 * it under the terms of the GNU General Public License as published by 00006 * the Free Software Foundation, either version 3 of the License, or 00007 * (at your option) any later version. 00008 * 00009 * This program is distributed in the hope that it will be useful, 00010 * but WITHOUT ANY WARRANTY; without even the implied warranty of 00011 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 00012 * GNU General Public License for more details. 00013 * 00014 * You should have received a copy of the GNU General Public License 00015 * along with this program. If not, see <http://www.gnu.org/licenses/>. 00016 */ 00017 00018 #ifndef __SAM_REFERENCE_INFO_H__ 00019 #define __SAM_REFERENCE_INFO_H__ 00020 00021 #include "StringArray.h" 00022 #include "StringHash.h" 00023 #include "IntArray.h" 00024 00025 /// Class for tracking the reference information mapping between the 00026 /// reference ids and the reference names. 00027 class SamReferenceInfo 00028 { 00029 public: 00030 /// Constructor. 00031 SamReferenceInfo(); 00032 /// Destructor. 00033 ~SamReferenceInfo(); 00034 /// Add reference sequence name and reference sequence length. 00035 void add(const char* referenceSequenceName, 00036 int32_t referenceSequenceLength); 00037 00038 /// Get the reference ID for the specified name, if addID is set to true, 00039 /// a reference id will be created for the referenceName if one does not 00040 /// already exist, while if addID is set to false (default), it will return 00041 /// NO_REF_ID if the reference name does not exist. 00042 int getReferenceID(const String & referenceName, bool addID = false); 00043 /// Get the reference ID for the specified name, if addID is set to true, 00044 /// a reference id will be created for the referenceName if one does not 00045 /// already exist, while if addID is set to false (default), it will return 00046 /// NO_REF_ID if the reference name does not exist. 00047 int getReferenceID(const char* referenceName, bool addID = false); 00048 /// Get the reference name for the specified id, if the id is not found, 00049 /// return "*". 00050 const String & getReferenceLabel(int id) const; 00051 00052 /// Get the number of entries contained here. 00053 int32_t getNumEntries() const; 00054 00055 /// Return the reference name at the specified index, returning "" if the 00056 /// index is out of bounds. 00057 const char* getReferenceName(int index) const; 00058 00059 /// Return the reference length at the specified index, returning 0 if the 00060 /// index is out of bounds. 00061 int32_t getReferenceLength(int index) const; 00062 00063 /// Reset this reference info. 00064 void clear(); 00065 00066 /// Copy the reference information. 00067 SamReferenceInfo & operator = (const SamReferenceInfo & rhs); 00068 00069 bool operator== (const SamReferenceInfo& rhs) const; 00070 bool operator!= (const SamReferenceInfo& rhs) const 00071 { 00072 return(!operator==(rhs)); 00073 } 00074 00075 /// Constant for the value returned if a reference id does not exist 00076 /// for a queried reference name. 00077 static const int NO_REF_ID = -3; 00078 00079 private: 00080 // Reference Name information 00081 StringArray myReferenceContigs; 00082 StringIntHash myReferenceHash; 00083 IntArray myReferenceLengths; 00084 }; 00085 00086 #endif 00087