Skip to content

Commit

Permalink
Added multiple subgraph contigs option.
Browse files Browse the repository at this point in the history
  • Loading branch information
richardmleggett committed Apr 20, 2016
1 parent 08af449 commit bf4c30a
Show file tree
Hide file tree
Showing 5 changed files with 24 additions and 17 deletions.
3 changes: 2 additions & 1 deletion include/cortex/cmd_line.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,8 @@ typedef struct
boolean graphviz;
boolean print_uncertain_as_n;
boolean output_log;
boolean output_kmer_coverage_know ;
boolean output_kmer_coverage_know;
boolean multiple_subgraph_contigs;

//-----------
//parameters
Expand Down
2 changes: 1 addition & 1 deletion include/cortex/metagraphs.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ typedef struct {
*/
//int grow_graph_from_node(dBNode* start_node, dBNode** best_node, dBGraph* graph, Queue* graph_queue);

void metacortex_find_subgraphs(dBGraph* graph, char* consensus_contigs_filename, int min_subgraph_kmers, int min_contig_length);
void metacortex_find_subgraphs(dBGraph* graph, char* consensus_contigs_filename, int min_subgraph_kmers, int min_contig_length, boolean multiple_subgraph_contigs);
8 changes: 6 additions & 2 deletions src/cortex/cmd_line.c
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,7 @@ int default_opts(CmdLine * c)
c->low_coverage_node_clip = false;
c->remove_low_coverage_supernodes = false;
c->remove_spurious_links = false;
c->multiple_subgraph_contigs = false;

//output
c->dump_binary = false;
Expand Down Expand Up @@ -190,6 +191,7 @@ CmdLine parse_cmdline(int argc, char *argv[], int unit_size)
{"input_reference", required_argument, NULL, 'H'},
{"output_kmer_coverage", required_argument, NULL, 'J'},
{"remove_spurious_links",required_argument,NULL,'L'},
{"multiple_subgraph_contigs",no_argument,NULL,'M'},
{"hash_output_file", required_argument, NULL, 'O'},
{"tip_clip_iterations", required_argument, NULL, 'P'},
{"graph_stats", no_argument, NULL, 'S'},
Expand All @@ -198,7 +200,7 @@ CmdLine parse_cmdline(int argc, char *argv[], int unit_size)
};

while ((opt = getopt_long(argc, argv,
"ab:c:d:ef:g:hi:jk:l:m:n:o:p:q:s:t:uvw:x:z:A:B:C:D:E:FG:H:I:J:K:L:N:O:P:STZ:",
"ab:c:d:ef:g:hi:jk:l:m:n:o:p:q:s:t:uvw:x:z:A:B:C:D:E:FG:H:I:J:K:L:MN:O:P:STZ:",
long_options, &longopt_index)) > 0)
{
//Parse the default options
Expand Down Expand Up @@ -501,10 +503,12 @@ CmdLine parse_cmdline(int argc, char *argv[], int unit_size)
}
}
break;
case 'M':
cmd_line.multiple_subgraph_contigs = true;
break;
case 'N':
cmd_line.print_uncertain_as_n = false;
break;

case 'O':
cmd_line.dump_hash = true;
if (strlen(optarg) < LENGTH_FILENAME) {
Expand Down
4 changes: 2 additions & 2 deletions src/cortex/metacortex.c
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ int main(int argc, char **argv)
break;
case METACORTEX_CONSENSUS:
log_and_screen_printf("\nDumping subgraph consensus contigs: %s\n", cmd_line.output_fasta_filename);
metacortex_find_subgraphs(db_graph, cmd_line.output_fasta_filename, cmd_line.min_subgraph_size, cmd_line.min_contig_length);
metacortex_find_subgraphs(db_graph, cmd_line.output_fasta_filename, cmd_line.min_subgraph_size, cmd_line.min_contig_length, cmd_line.multiple_subgraph_contigs);
break;
case GRAPH_STATS:

Expand All @@ -470,7 +470,7 @@ int main(int argc, char **argv)
//db_graph_walk_branches(cmd_line.output_fasta_filename, total_max_length, db_graph->kmer_size * 10 + 1, bubble_max_depth, db_graph);

//db_graph_walk_branches(char *filename, int total_max_length, int bubble_max_length, int bubble_max_depth, dBGraph * db_graph)
//metacortex_find_subgraphs(db_graph, cmd_line.output_fasta_filename, cmd_line.min_subgraph_size, cmd_line.min_contig_length);
//metacortex_find_subgraphs(db_graph, cmd_line.output_fasta_filename, cmd_line.min_subgraph_size, cmd_line.min_contig_length, cmd_line.multiple_subgraph_contigs);
break;
default:
log_and_screen_printf("Algorithm not implemented \n");
Expand Down
24 changes: 13 additions & 11 deletions src/cortex/metagraphs.c
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,7 @@ int grow_graph_from_node(dBNode* start_node, dBNode** best_node, dBGraph* graph,
return current_graph_size;
}

void metacortex_find_subgraphs(dBGraph* graph, char* consensus_contigs_filename, int min_subgraph_kmers, int min_contig_length)
void metacortex_find_subgraphs(dBGraph* graph, char* consensus_contigs_filename, int min_subgraph_kmers, int min_contig_length, boolean multiple_subgraph_contigs)
{
FILE* fp_analysis;
FILE* fp_contigs;
Expand Down Expand Up @@ -260,17 +260,19 @@ void metacortex_find_subgraphs(dBGraph* graph, char* consensus_contigs_filename,
} else {
log_printf("Didn't write path of size %d\n", final_path->length);
}

if (multiple_subgraph_contigs) {
/* Now clear visited flags for subgraph */
while (graph_queue->number_of_items > 0) {
queue_node = (dBNode*)queue_pop(graph_queue);
db_node_action_unset_flag(queue_node, VISITED);
}

/* Now clear visited flags for subgraph */
while (graph_queue->number_of_items > 0) {
queue_node = (dBNode*)queue_pop(graph_queue);
db_node_action_unset_flag(queue_node, VISITED);
}

/* Now disconnect path from other nodes and mark path as visited, so it's not visited again */
for (pi=0; pi<final_path->length; pi++) {
cleaning_prune_db_node(final_path->nodes[pi], graph);
db_node_action_set_flag(final_path->nodes[pi], VISITED);
/* Now disconnect path from other nodes and mark path as visited, so it's not visited again */
for (pi=0; pi<final_path->length; pi++) {
cleaning_prune_db_node(final_path->nodes[pi], graph);
db_node_action_set_flag(final_path->nodes[pi], VISITED);
}
}

/* Reset paths */
Expand Down

0 comments on commit bf4c30a

Please sign in to comment.