-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcppp.c
More file actions
69 lines (59 loc) · 2.6 KB
/
Copy pathcppp.c
File metadata and controls
69 lines (59 loc) · 2.6 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
/*
cppp - Compute a Constrained Perfect Phylogeny, if it exists
Copyright (C) 2014 Gianluca Della Vedova
This program is free software; you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation; either version 2, or (at your option)
any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program; if not, write to the Free Software Foundation,
Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
*/
#include "getopt/cmdline.h"
#include "cppp.h"
#include "logging.h"
#include "decision_tree.h"
static GSList*
alphabetic(state_s *stp) {
return (characters_list(stp));
}
int main(int argc, char **argv) {
igraph_i_set_attribute_table(&igraph_cattribute_table);
static struct gengetopt_args_info args_info;
assert(cmdline_parser(argc, argv, &args_info) == 0);
assert(args_info.inputs_num >= 1);
start_logging(args_info);
FILE* outf = fopen(args_info.output_arg, "w");
instances_schema_s props = {
.file = NULL,
.filename = args_info.inputs[0]
};
state_s temp;
for (read_instance_from_filename(&temp, &props);
props.num_species > 0; read_instance_from_filename(&temp, &props)) {
/**
Notice that each character is realized at most twice (once positive and once
negative) and that each species can be declared null at most once.
Therefore each partial solution con contain at most 2n+m statuses.
*/
state_s states[2 * props.num_species + props.num_characters];
for (uint32_t level=0; level < 2 * props.num_species + props.num_characters; level++)
init_state(states + level, props.num_species, props.num_characters);
copy_state(states, &temp);
assert(outf != NULL);
if (exhaustive_search(states, alphabetic)) {
for (uint32_t level=0; (states + level)->num_species > 0; level++)
fprintf(outf, "%d ", (states + level)->realized_char);
fprintf(outf, "\n");
} else {
fprintf(outf, "Not found\n");
}
}
fclose(outf);
cmdline_parser_free(&args_info);
return 0;
}