-
Notifications
You must be signed in to change notification settings - Fork 7
/
example_wfile.c
94 lines (76 loc) · 2.47 KB
/
example_wfile.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
/**
* @file example2.c
* @author Xiyu Peng
*
* An example for calling amplici_wfile function
*
* Note about formatting. Line widths are at 80 characters, not because we live
* in the 60's but to help force good coding and to reduce complexity. Function
* predeclarations may break this rule so that the entire prototype can be
* found with a simple grep on the source code.
*/
#include <stdlib.h>
#include "libamplici.h"
#include <stdio.h>
#include <stdarg.h>
/* header files below are just used in this example */
#include "amplici.h"
#include "io.h"
int main()
{
int err = NO_ERROR;
/* read input files */
char *fastq_file = "./test/SRR2990088_1_noN_3000_subset1_new.fastq";
char *error_profile_name = NULL; // or error profile name estimated by run_amplici
char *output_file = "./test.out";
double low_bound = 2.0;
/* initialize output */
unsigned int K = 0;
unsigned int *cluster_id = NULL;
unsigned int *cluster_size = NULL;
unsigned char *seeds = NULL;
unsigned int *seeds_length = NULL;
size_t sample_size = 0;
unsigned int max_read_length = 0;
double * abundance = NULL;
double * ll = NULL;
if ((err = amplici_wfile(fastq_file, error_profile_name, low_bound, &seeds, &seeds_length, &cluster_id,
&cluster_size, &K, &sample_size, &max_read_length, &abundance,&ll)))
goto CLEAR_AND_EXIT;
/* print and check */
FILE *fp = NULL;
fp = fopen(output_file, "w");
if (!fp){
mmessage(ERROR_MSG, FILE_OPEN_ERROR,
output_file);
goto CLEAR_AND_EXIT;
}
fprintf(fp, "K: %i\n", K);
fprintf(fp, "assignments: ");
fprint_assignment(fp, cluster_id, sample_size,
K, 2, 1);
fprintf(fp, "cluster sizes: ");
fprint_uints(fp, cluster_size, K, 3, 1);
fprintf(fp,"reads ll: ");
fprint_doubles(fp, ll, sample_size, 3, 1);
fprintf(fp, "scaled true abun: ");
fprint_doubles(fp, abundance, K, 3, 1);
fprint_fasta(fp, seeds, K, max_read_length, seeds_length, "H");
fclose(fp);
mmessage(INFO_MSG, NO_ERROR, "Output the final result file: "
"%s \n", output_file);
CLEAR_AND_EXIT:
if (cluster_id)
free(cluster_id);
if (cluster_size)
free(cluster_size);
if (seeds)
free(seeds);
if (seeds_length)
free(seeds_length);
if (abundance)
free(abundance);
if (ll)
free(ll);
return (EXIT_FAILURE);
} /* main */