32 #define TOPO_SORT_LOCAL_NODE_SET_SIZE 200
33 #define MAX_IN_DEGREE 20
60 while(s_last - s_first != 0) {
61 const uint32 n = S[s_first];
72 for(
uint32 i = 0; i < out_degree; i++) {
82 printf(
"ERROR: Topological sort exceeded max locally allocated set size!\n");
92 if(n_sorted != n_nodes) {
93 printf(
"Found cycle! %u %u \n", n_sorted, n_nodes);
115 for(
uint32 i = 0; i < n_nodes; i++) {
122 for(
uint32 j = 0; j <
k; j++) {
124 bool set_score =
false;
125 for(
uint32 v = 0; v < in_degree; v++) {
127 uint32 j_score_offset = nbr_top_offsets[v]*n_nodes + m;
141 if(new_score > max_score) {
142 max_score = new_score;
143 nbr_top_offsets[v]++;
169 for(
uint32 i = 0; i < out_degree; i++) {
173 for(
uint32 i = 0; i < out_degree; i++) {
192 for(
uint32 i = 0; i < n_nbrs; i++) {
198 while(val != (
uint32) -1) {
208 template <
typename string_set_type>
211 typedef typename string_set_type::string_type
sequence;
227 const uint32 seq_pos = node_coord.y;
239 template <
typename string_set_type>
254 const uint32* _seq_active_region_ids,
const uint32* _global_to_UID_map,
const uint32* _global_to_sorted_map,
267 if(global_coord_idx != 0 &&
coords[global_to_sorted_map[global_coord_idx - 1]].w == source_coord.w)
return;
281 const uint32 _kmer_size,
bool allow_low_complexity)
311 thrust::make_permutation_iterator(
312 thrust::make_permutation_iterator(
313 graph_kmer_set.
coords.begin(),
315 thrust::make_permutation_iterator(
318 thrust::make_permutation_iterator(
319 graph_kmer_set.
coords.begin(),
337 printf(
"Number of kmers %u \n", graph_kmer_set.
n_kmers);
338 printf(
"Number distinct kmers %u \n", graph_kmer_set.
n_distinct);
339 printf(
"Number unique kmers %u \n", graph_kmer_set.
n_unique);
364 unique_prefix_node_uids.begin(),
375 unique_suffix_node_uids.begin(),
380 D_VectorU32 unique_prefix_uids_idx(n_unique_nodes);
383 thrust::make_counting_iterator(0),
384 thrust::make_counting_iterator(0) + graph_kmer_set.
n_unique,
385 thrust::constant_iterator<uint32>(1),
386 unique_prefix_uids_idx.begin(),
387 unique_prefix_counts.begin(),
392 unique_prefix_counts.begin(),
393 unique_prefix_counts.begin() + n_unique_prefix_uids,
394 thrust::make_permutation_iterator(
395 unique_prefix_node_uids.begin(),
396 unique_prefix_uids_idx.begin()),
401 repeat_edges_from_uids.begin(),
402 repeat_edges_from_uids.end(),
403 thrust::make_zip_iterator(thrust::make_tuple(repeat_edges_to_uids.begin(), repeat_edge_counts.begin())));
405 D_VectorU32 repeat_prefix_uids_idx(repeat_edges_from_uids.size());
406 D_VectorU32 repeat_prefix_counts(repeat_edges_from_uids.size());
408 thrust::make_counting_iterator(0),
409 thrust::make_counting_iterator(0) + repeat_edges_from_uids.size(),
410 thrust::constant_iterator<uint32>(1),
411 repeat_prefix_uids_idx.begin(),
412 repeat_prefix_counts.begin(),
417 thrust::device_vector<uint8> temp_storage;
419 n_repeat_prefix_uids,
421 thrust::make_permutation_iterator(
422 repeat_edges_from_uids.begin(),
423 repeat_prefix_uids_idx.begin()),
425 thrust::plus<uint32>(),
430 repeat_prefix_counts.begin() + n_unique_prefixes,
431 repeat_prefix_counts.begin() + n_repeat_prefix_uids,
432 thrust::make_permutation_iterator(
433 repeat_edges_from_uids.begin(),
434 repeat_prefix_uids_idx.begin() + n_unique_prefixes),
442 thrust::plus<uint32>(),
450 repeat_prefix_uids_idx.begin(),
451 repeat_prefix_uids_idx.begin() + n_repeat_prefix_uids,
462 unique_prefix_uids_idx.begin(),
463 unique_prefix_uids_idx.begin() + n_unique_prefix_uids,
484 thrust::make_counting_iterator(0u),
485 thrust::make_counting_iterator(0u) +
n_nodes,
503 thrust::make_constant_iterator<uint32>(1),
504 distinct_node_UIDs.begin(),
505 counts.begin()).first - distinct_node_UIDs.begin();
510 counts.begin() + n_distinct,
511 distinct_node_UIDs.begin(),
515 thrust::device_vector<uint8> temp_storage;
521 thrust::plus<uint32>(),
532 thrust::make_counting_iterator(0u),
533 thrust::make_counting_iterator(0u) +
n_nodes,
544 active_region_ids.begin(),
547 thrust::sort(active_region_ids.begin(), active_region_ids.end());
552 active_region_ids.begin(),
553 active_region_ids.end(),
554 thrust::make_constant_iterator<uint32>(1),
555 active_regions.begin(),
556 counts.begin()).first - active_regions.begin();
561 counts.begin() + n_distinct,
562 active_regions.begin(),
566 thrust::device_vector<uint8> temp_storage;
572 thrust::plus<uint32>(),
591 thrust::make_counting_iterator(0u),
604 thrust::make_counting_iterator(0u),
614 thrust::make_counting_iterator<uint64>(0u),
615 thrust::make_counting_iterator<uint64>(0u) + n_nodes,
619 std::ofstream dot_file;
620 dot_file.open(
"cuda_test_graph.txt");
623 uint64 offset = node_adj_offests[i];
626 std::string node_seq(labels.begin() + label_offset, labels.begin() + label_offset +
kmer_size);
628 for(
uint32 j = 0; j < n_out_edges; j++) {
633 std::string nbr_seq(labels.begin() + label_offset, labels.begin() + label_offset +
kmer_size);
635 dot_file << node_seq <<
"_" << i <<
"\t" << nbr_seq <<
"_" << nbr_uid <<
"\n";
640 dot_file.open(
"cuda_test_graph.dot");
642 dot_file <<
"digraph assemblyGraphs { \n";
645 uint64 offset = node_adj_offests[i];
648 std::string node_seq(labels.begin() + label_offset, labels.begin() + label_offset +
kmer_size);
650 for(
uint32 j = 0; j < n_out_edges; j++) {
655 std::string nbr_seq(labels.begin() + label_offset, labels.begin() + label_offset +
kmer_size);
657 dot_file << node_seq <<
"_" << i <<
" -> " << nbr_seq <<
"_" << nbr_uid <<
" [label=\"" << count<<
"\"];\n";
663 std::string node_seq(labels.begin() + offset, labels.begin() + offset +
kmer_size);
664 dot_file << node_seq <<
"_" << i <<
" [label=\"" << node_seq <<
"\",shape=box];\n";