BamTools  2.4.0
SamSequence.h
Go to the documentation of this file.
1 // ***************************************************************************
2 // SamSequence.h (c) 2010 Derek Barnett
3 // Marth Lab, Department of Biology, Boston College
4 // ---------------------------------------------------------------------------
5 // Last modified: 10 October 2011 (DB)
6 // ---------------------------------------------------------------------------
7 // Provides direct read/write access to the SAM sequence data fields.
8 // ***************************************************************************
9 
10 #ifndef SAM_SEQUENCE_H
11 #define SAM_SEQUENCE_H
12 
13 #include "api/api_global.h"
14 #include "api/BamAux.h"
15 #include <string>
16 #include <vector>
17 
18 namespace BamTools {
19 
21 
22  // ctor & dtor
23  SamSequence(void);
24  SamSequence(const std::string& name, const int& length);
25  SamSequence(const std::string& name, const std::string& length);
26  SamSequence(const SamSequence& other);
27  ~SamSequence(void);
28 
29  // query/modify entire sequence
30  void Clear(void); // clears all contents
31 
32  // convenience query methods
33  bool HasAssemblyID(void) const; // returns true if sequence has an assembly ID
34  bool HasChecksum(void) const; // returns true if sequence has an MD5 checksum
35  bool HasLength(void) const; // returns true if sequence has a length
36  bool HasName(void) const; // returns true if sequence has a name
37  bool HasSpecies(void) const; // returns true if sequence has a species ID
38  bool HasURI(void) const; // returns true if sequence has a URI
39 
40  // data members
41  std::string AssemblyID; // AS:<AssemblyID>
42  std::string Checksum; // M5:<Checksum>
43  std::string Length; // LN:<Length> *Required for valid SAM header*
44  std::string Name; // SN:<Name> *Required for valid SAM header*
45  std::string Species; // SP:<Species>
46  std::string URI; // UR:<URI>
47  std::vector<CustomHeaderTag> CustomTags; // optional custom tags
48 };
49 
53 API_EXPORT inline bool operator==(const SamSequence& lhs, const SamSequence& rhs) {
54  if ( lhs.Name != rhs.Name ) return false;
55  if ( lhs.Length != rhs.Length ) return false;
56  if ( lhs.HasChecksum() && rhs.HasChecksum() )
57  return (lhs.Checksum == rhs.Checksum);
58  else return true;
59 }
60 
61 } // namespace BamTools
62 
63 #endif // SAM_SEQUENCE_H
std::string Checksum
corresponds to @SQ M5:<Checksum>
Definition: SamSequence.h:42
API_EXPORT bool operator==(const SamProgram &lhs, const SamProgram &rhs)
tests equality by comparing program IDs
Definition: SamProgram.h:57
std::vector< CustomHeaderTag > CustomTags
Definition: SamSequence.h:47
std::string AssemblyID
corresponds to @SQ AS:<AssemblyID>
Definition: SamSequence.h:41
#define API_EXPORT
Definition: api_global.h:18
bool HasChecksum(void) const
Returns true if sequence contains @SQ M5:<Checksum>
Definition: SamSequence.cpp:133
std::string URI
corresponds to @SQ UR:<URI>
Definition: SamSequence.h:46
std::string Length
corresponds to @SQ LN:<Length>
Definition: SamSequence.h:43
std::string Species
corresponds to @SQ SP:<Species>
Definition: SamSequence.h:45
Represents a SAM sequence entry.
Definition: SamSequence.h:20
std::string Name
corresponds to @SQ SN:<Name>
Definition: SamSequence.h:44
Contains all BamTools classes & methods.
Definition: Sort.h:24