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