BamTools  2.5.1
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 <string>
14 #include <vector>
15 #include "api/BamAux.h"
16 #include "api/api_global.h"
17 
18 namespace BamTools {
19 
21 {
22 
23  // ctor & dtor
24  SamSequence();
25  SamSequence(const std::string& name, const int& length);
26  SamSequence(const std::string& name, const std::string& length);
27  SamSequence(const SamSequence& other);
28  ~SamSequence();
29 
30  // query/modify entire sequence
31  void Clear(); // clears all contents
32 
33  // convenience query methods
34  bool HasAssemblyID() const; // returns true if sequence has an assembly ID
35  bool HasChecksum() const; // returns true if sequence has an MD5 checksum
36  bool HasLength() const; // returns true if sequence has a length
37  bool HasName() const; // returns true if sequence has a name
38  bool HasSpecies() const; // returns true if sequence has a species ID
39  bool HasURI() const; // returns true if sequence has a URI
40 
41  // data members
42  std::string AssemblyID; // AS:<AssemblyID>
43  std::string Checksum; // M5:<Checksum>
44  std::string Length; // LN:<Length> *Required for valid SAM header*
45  std::string Name; // SN:<Name> *Required for valid SAM header*
46  std::string Species; // SP:<Species>
47  std::string URI; // UR:<URI>
48  std::vector<CustomHeaderTag> CustomTags; // optional custom tags
49 };
50 
54 API_EXPORT inline bool operator==(const SamSequence& lhs, const SamSequence& rhs)
55 {
56  if (lhs.Name != rhs.Name) return false;
57  if (lhs.Length != rhs.Length) return false;
58  if (lhs.HasChecksum() && rhs.HasChecksum())
59  return (lhs.Checksum == rhs.Checksum);
60  else
61  return true;
62 }
63 
64 } // namespace BamTools
65 
66 #endif // SAM_SEQUENCE_H
#define API_EXPORT
Definition: api_global.h:18
Contains all BamTools classes & methods.
Definition: Sort.h:24
API_EXPORT bool operator==(const SamProgram &lhs, const SamProgram &rhs)
tests equality by comparing program IDs
Definition: SamProgram.h:59
Represents a SAM sequence entry.
Definition: SamSequence.h:21
std::string Species
corresponds to @SQ SP:<Species>
Definition: SamSequence.h:46
std::string Checksum
corresponds to @SQ M5:<Checksum>
Definition: SamSequence.h:43
std::string Length
corresponds to @SQ LN:<Length>
Definition: SamSequence.h:44
std::string Name
corresponds to @SQ SN:<Name>
Definition: SamSequence.h:45
std::vector< CustomHeaderTag > CustomTags
Definition: SamSequence.h:48
bool HasChecksum() const
Returns true if sequence contains @SQ M5:<Checksum>
Definition: SamSequence.cpp:117
std::string AssemblyID
corresponds to @SQ AS:<AssemblyID>
Definition: SamSequence.h:42
std::string URI
corresponds to @SQ UR:<URI>
Definition: SamSequence.h:47