Skip to content

Commit

Permalink
feat: barcode support to the string graph
Browse files Browse the repository at this point in the history
  • Loading branch information
chungongyu committed Nov 9, 2020
1 parent 418d727 commit 1d34045
Show file tree
Hide file tree
Showing 3 changed files with 7 additions and 3 deletions.
2 changes: 1 addition & 1 deletion src/bigraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -503,7 +503,7 @@ bool Bigraph::load(std::istream& stream, size_t minOverlap, bool allowContainmen
LOG4CXX_ERROR(logger, boost::format("Error: Unexpected vertex record found at line %s") % line);
return false;
}
Vertex* vertex = new Vertex(record.id, record.seq, record.substring ? (int)record.substring : false);
Vertex* vertex = new Vertex(record.id, record.seq, record.substring ? (int)record.substring : false, record.barcode ? (std::string)record.barcode : "");
if (!g->addVertex(vertex)) {
LOG4CXX_ERROR(logger, boost::format("Error: Attempted to insert vertex into graph with a duplicate id: %s") % vertex->id());
LOG4CXX_ERROR(logger, "All reads must have a unique identifier");
Expand Down
6 changes: 5 additions & 1 deletion src/bigraph.h
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ class Vertex {
public:
typedef std::string Id;

Vertex(const Id& id, const std::string& seq, bool contained = false) : _id(id), _seq(seq), _contained(contained), _color(GC_NONE), _coverage(1) {
Vertex(const Id& id, const std::string& seq, bool contained=false, const std::string& index="") : _id(id), _seq(seq), _contained(contained), _index(index), _color(GC_NONE), _coverage(1) {
}
~Vertex();

Expand All @@ -121,6 +121,9 @@ class Vertex {
const std::string& seq() const {
return _seq;
}
const std::string& index() const {
return _index;
}
size_t coverage() const {
return _coverage;
}
Expand Down Expand Up @@ -173,6 +176,7 @@ class Vertex {
Id _id;
GraphColor _color;
std::string _seq;
std::string _index;
size_t _coverage; // Number of vertices that have been merged into this one
bool _contained;

Expand Down
2 changes: 1 addition & 1 deletion src/subgraph.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ class SubgraphExtractor {
void addVertex(const Vertex* vertex, Bigraph* sub) {
// Make sure the vertex hasn't been added yet
if (sub->getVertex(vertex->id()) == NULL) {
sub->addVertex(new Vertex(vertex->id(), vertex->seq(), vertex->contained()));
sub->addVertex(new Vertex(vertex->id(), vertex->seq(), vertex->contained(), vertex->index()));
}
}

Expand Down

0 comments on commit 1d34045

Please sign in to comment.