-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathcluster_dbscan_pca.c
66 lines (51 loc) · 1.53 KB
/
cluster_dbscan_pca.c
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
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<ctype.h>
#include<unistd.h>
#include"dataset.h"
#include"cluster.h"
#include"dbscan.h"
void file_error(char* path) {
printf("failed to open file %s\n",path);
_exit(1);
}
int main(int argc, char** argv) {
dataset ds;
size_t dimensions;
float epsilon;
int minpts;
FILE* fasta_f;
FILE* projection_f;
split_set set_of_clusters;
if(argc < 7) {
printf("Arguments are: \n"
" [file] Sequences in FASTA \n"
" [file] Corresponding PCA from kmers \n"
" dimensions: dimensions in projections file \n"
" Epsilon \n"
" minPoints \n"
" output-files prefix (FASTA) \n"
" optional: out-files with values (Projections)\n");
return(1);
}
sscanf(argv[3], "%lu", &dimensions);
sscanf(argv[4], "%f", &epsilon);
sscanf(argv[5], "%i", &minpts);
if ( NULL == (fasta_f = fopen(argv[1], "r"))) file_error(argv[1]);
ds = dataset_from_fasta(fasta_f);
fclose(fasta_f);
if ( NULL == (projection_f = fopen(argv[2], "r"))) file_error(argv[2]);
load_projections_from_file_into_dataset(projection_f,dimensions,&ds);
fclose(projection_f);
set_of_clusters = dbscan_L2(ds, epsilon, minpts);
printf("%u clusters obtained \n", set_of_clusters.n_clusters);
if (set_of_clusters.n_clusters < 500) {
create_cluster_files(argv[6], set_of_clusters, ds);
if(argc == 8) {
create_cluster_files_with_values(argv[7], set_of_clusters,ds);
}
}
free_split_set_and_associated_clusters(set_of_clusters);
free_dataset(ds);
}