Skip to content

Splitter part 1#1509

Merged
asl merged 15 commits into
mainfrom
barcode-index
Nov 24, 2025
Merged

Splitter part 1#1509
asl merged 15 commits into
mainfrom
barcode-index

Conversation

@Itolstoganov

Copy link
Copy Markdown
Contributor
  • Barcode index structure
  • Contracted graph structure
  • Scaffold graph vertices can store either edges or paths

@asl asl left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See comments, overall good, though would be better to have some things fixed :)

@@ -0,0 +1,18 @@
############################################################################
# Copyright (c) 2019 Saint Petersburg State University

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us use default copyright headers here and everywhere :)

typedef std::map<VertexId, std::unordered_set<ScaffoldVertex>>::value_type value_type;

AdjacencyMap() = default;
AdjacencyMap(const VertexId &vertex, const ScaffoldVertex &edge) : data_({{vertex, {edge}}}) {}

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Let us pass small things (e.g. VertexId / EdgeId) by value – they are trivially copyable small things and we're outlining the methods, so there is no way these will be inlined.

typedef debruijn_graph::VertexId VertexId;
typedef debruijn_graph::EdgeId EdgeId;
typedef scaffold_graph::ScaffoldVertex ScaffoldVertex;
typedef std::map<VertexId, std::unordered_set<ScaffoldVertex>>::const_iterator const_iterator;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd have a single typename for a map type and use dependent types from it. This way changing map type would require a single-line change.

ContractedGraph(ContractedGraph &&other) = default;

void InsertVertex(const VertexId &vertex);
void InsertEdge(const VertexId &head, const VertexId &tail, const ScaffoldVertex &edge);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

See all comments above about AdjacencyMap

visited.insert(start);
ScaffoldVertex curr_vertex = start;
while(edge_to_next.find(curr_vertex) != edge_to_next.end()) {
curr_vertex = edge_to_next.at(curr_vertex);

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You can use the value from the iterator to save on double lookups.

};

inline std::ostream& operator <<(std::ostream& os, const SimpleBarcodeInfo& info)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code style here and below

BarcodeId barcode;
FrameBarcodeInfo info(number_of_frames_);
BinRead(str, barcode, info);
barcode_distribution_.insert({std::move(barcode), std::move(info)});

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

better use emplace

};

inline std::ostream& operator <<(std::ostream& os, const FrameBarcodeInfo& info)
{

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

see above

}
}
INFO("Number of encountered barcodes: " << barcodes.size());
std::random_device rd;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can it be downsampled deterministically? This would yield different result on different platforms and on different seeds.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

empty file?

codes_[barcode] = encoder_size + start_;
return encoder_size;
BarcodeId find_or_insert(const std::string &barcode_string) {
try {

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you really need to throw / catch exceptions in the normal flow? Can't you just do something like this:

  size_t num_barcodes = barcodes_map_.size();
  auto [it, inserted] = barcodes_map_.insert(barcode_string, num_barcodes + start_);
  return it->second;

(you original code used num_barcodes + start_ as value, but returned num_barcodes was it intentional?)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oh, realized that it it is a concurrent hash table. You'd use upsert here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed (not sure how to do this in a single lookup though, upsert does not seem to help)

@Itolstoganov
Itolstoganov force-pushed the barcode-index branch 2 times, most recently from 0011903 to cac7943 Compare November 10, 2025 17:31
@asl
asl merged commit c3bfce0 into main Nov 24, 2025
91 of 93 checks passed
@asl
asl deleted the barcode-index branch November 24, 2025 17:22
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants