Codebase list snp-sites / b4b2079
New upstream version 2.5.1 Sascha Steinbiss 4 years ago
13 changed file(s) with 345 addition(s) and 14 deletion(s). Raw diff Collapse all Expand all
11 compiler:
22 - gcc
33 - clang
4 addons:
5 apt:
6 packages:
7 - check
48 before_install:
59 - sudo apt-get update -qq
6 - sudo apt-get install -qq check
7 script: autoreconf -i && ./configure && make && make check
10 script:
11 - autoreconf -i && ./configure --enable-maintainer-mode CFLAGS='-O0 --coverage' && make && make check
12 after_success:
13 - bash <(curl -s https://codecov.io/bash)
00 Andrew J. Page <ap13@sanger.ac.uk>
11 Ben Taylor <path-help@sanger.ac.uk>
22 Jorge Soares <path-help@sanger.ac.uk>
3 Peter van Heusden
0 # Change Log
1
2 ## [Unreleased](https://github.com/sanger-pathogens/snp-sites/tree/HEAD)
3
4 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/v2.4.1...HEAD)
5
6 **Closed issues:**
7
8 - SegFault for unknown reason [\#72](https://github.com/sanger-pathogens/snp-sites/issues/72)
9
10 **Merged pull requests:**
11
12 - Include tests in README [\#73](https://github.com/sanger-pathogens/snp-sites/pull/73) ([ssjunnebo](https://github.com/ssjunnebo))
13
14 ## [v2.4.1](https://github.com/sanger-pathogens/snp-sites/tree/v2.4.1) (2018-10-04)
15 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/v2.4.0...v2.4.1)
16
17 **Implemented enhancements:**
18
19 - Print to screen [\#63](https://github.com/sanger-pathogens/snp-sites/issues/63)
20
21 **Fixed bugs:**
22
23 - Docker file typo [\#60](https://github.com/sanger-pathogens/snp-sites/issues/60)
24
25 **Closed issues:**
26
27 - Info in VCF output format [\#68](https://github.com/sanger-pathogens/snp-sites/issues/68)
28
29 **Merged pull requests:**
30
31 - Include docker and conda badges [\#70](https://github.com/sanger-pathogens/snp-sites/pull/70) ([ssjunnebo](https://github.com/ssjunnebo))
32 - fixed Dockerfile [\#67](https://github.com/sanger-pathogens/snp-sites/pull/67) ([trstickland](https://github.com/trstickland))
33
34 ## [v2.4.0](https://github.com/sanger-pathogens/snp-sites/tree/v2.4.0) (2018-01-29)
35 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.3.3...v2.4.0)
36
37 **Fixed bugs:**
38
39 - segmentation fault with `-b` option [\#58](https://github.com/sanger-pathogens/snp-sites/issues/58)
40 - Segmentation fault with larger sequences \(on Desktop and HPC\) [\#57](https://github.com/sanger-pathogens/snp-sites/issues/57)
41
42 **Closed issues:**
43
44 - Gaps not reported in output? [\#61](https://github.com/sanger-pathogens/snp-sites/issues/61)
45
46 **Merged pull requests:**
47
48 - update readme [\#65](https://github.com/sanger-pathogens/snp-sites/pull/65) ([ssjunnebo](https://github.com/ssjunnebo))
49 - Jk seg fault [\#59](https://github.com/sanger-pathogens/snp-sites/pull/59) ([andrewjpage](https://github.com/andrewjpage))
50
51 ## [2.3.3](https://github.com/sanger-pathogens/snp-sites/tree/2.3.3) (2017-06-09)
52 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.3.2...2.3.3)
53
54 **Closed issues:**
55
56 - brew recipe needs to be updated to the latest release. [\#55](https://github.com/sanger-pathogens/snp-sites/issues/55)
57 - Linuxbrew installation issue \(links issue\) [\#54](https://github.com/sanger-pathogens/snp-sites/issues/54)
58
59 **Merged pull requests:**
60
61 - update LICENSE and AUTHORS [\#56](https://github.com/sanger-pathogens/snp-sites/pull/56) ([ssjunnebo](https://github.com/ssjunnebo))
62
63 ## [2.3.2](https://github.com/sanger-pathogens/snp-sites/tree/2.3.2) (2016-05-12)
64 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.3.1...2.3.2)
65
66 **Closed issues:**
67
68 - Didn't mean to open this [\#52](https://github.com/sanger-pathogens/snp-sites/issues/52)
69 - Failing tests on various platforms [\#51](https://github.com/sanger-pathogens/snp-sites/issues/51)
70
71 ## [2.3.1](https://github.com/sanger-pathogens/snp-sites/tree/2.3.1) (2016-03-18)
72 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.3.0...2.3.1)
73
74 **Merged pull requests:**
75
76 - allow pure bases and monomorphic, making it work with BEAST [\#50](https://github.com/sanger-pathogens/snp-sites/pull/50) ([andrewjpage](https://github.com/andrewjpage))
77
78 ## [2.3.0](https://github.com/sanger-pathogens/snp-sites/tree/2.3.0) (2016-03-17)
79 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.2.2...2.3.0)
80
81 ## [2.2.2](https://github.com/sanger-pathogens/snp-sites/tree/2.2.2) (2016-03-14)
82 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.2.1...2.2.2)
83
84 **Merged pull requests:**
85
86 - make sure original API is not changed [\#49](https://github.com/sanger-pathogens/snp-sites/pull/49) ([satta](https://github.com/satta))
87 - update to 2.2.1 [\#48](https://github.com/sanger-pathogens/snp-sites/pull/48) ([andrewjpage](https://github.com/andrewjpage))
88
89 ## [2.2.1](https://github.com/sanger-pathogens/snp-sites/tree/2.2.1) (2016-03-11)
90 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.2.0...2.2.1)
91
92 **Merged pull requests:**
93
94 - adjust manpage [\#47](https://github.com/sanger-pathogens/snp-sites/pull/47) ([satta](https://github.com/satta))
95 - output reference and change name to snp-sites [\#46](https://github.com/sanger-pathogens/snp-sites/pull/46) ([andrewjpage](https://github.com/andrewjpage))
96
97 ## [2.2.0](https://github.com/sanger-pathogens/snp-sites/tree/2.2.0) (2016-03-11)
98 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.1.3...2.2.0)
99
100 **Closed issues:**
101
102 - Build is failing on Mac OS [\#45](https://github.com/sanger-pathogens/snp-sites/issues/45)
103 - specify reference sequence [\#44](https://github.com/sanger-pathogens/snp-sites/issues/44)
104 - Add Arxiv paper link to README.md [\#43](https://github.com/sanger-pathogens/snp-sites/issues/43)
105
106 ## [2.1.3](https://github.com/sanger-pathogens/snp-sites/tree/2.1.3) (2016-01-27)
107 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.1.1...2.1.3)
108
109 **Closed issues:**
110
111 - possible to convert to redhat? [\#39](https://github.com/sanger-pathogens/snp-sites/issues/39)
112
113 **Merged pull requests:**
114
115 - Ensure C99 compliance [\#42](https://github.com/sanger-pathogens/snp-sites/pull/42) ([AidanDelaney](https://github.com/AidanDelaney))
116 - Test data [\#41](https://github.com/sanger-pathogens/snp-sites/pull/41) ([andrewjpage](https://github.com/andrewjpage))
117 - Running the clang static analyser turns up an issue with unintialised… [\#40](https://github.com/sanger-pathogens/snp-sites/pull/40) ([AidanDelaney](https://github.com/AidanDelaney))
118
119 ## [2.1.1](https://github.com/sanger-pathogens/snp-sites/tree/2.1.1) (2015-12-14)
120 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.1.0...2.1.1)
121
122 **Implemented enhancements:**
123
124 - Opens \<file\> twice? [\#26](https://github.com/sanger-pathogens/snp-sites/issues/26)
125
126 **Fixed bugs:**
127
128 - make check =\> cannot find -lsubunit [\#33](https://github.com/sanger-pathogens/snp-sites/issues/33)
129 - autoreconf -i warnings =\> option 'subdir-objects' is disabled [\#29](https://github.com/sanger-pathogens/snp-sites/issues/29)
130
131 **Merged pull requests:**
132
133 - Autotoolize checking for dependencies [\#38](https://github.com/sanger-pathogens/snp-sites/pull/38) ([satta](https://github.com/satta))
134
135 ## [2.1.0](https://github.com/sanger-pathogens/snp-sites/tree/2.1.0) (2015-12-03)
136 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.0.3...2.1.0)
137
138 **Merged pull requests:**
139
140 - Reduce times input file is opened [\#37](https://github.com/sanger-pathogens/snp-sites/pull/37) ([andrewjpage](https://github.com/andrewjpage))
141
142 ## [2.0.3](https://github.com/sanger-pathogens/snp-sites/tree/2.0.3) (2015-12-03)
143 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.0.2...2.0.3)
144
145 **Closed issues:**
146
147 - How do we run the tests? [\#30](https://github.com/sanger-pathogens/snp-sites/issues/30)
148 - Add a --version switch? [\#27](https://github.com/sanger-pathogens/snp-sites/issues/27)
149 - FYI - updated brew package to 2.x series [\#24](https://github.com/sanger-pathogens/snp-sites/issues/24)
150
151 **Merged pull requests:**
152
153 - Bump version to 2.0.3 [\#36](https://github.com/sanger-pathogens/snp-sites/pull/36) ([bewt85](https://github.com/bewt85))
154 - 496468: Allow '?' in fasta input [\#35](https://github.com/sanger-pathogens/snp-sites/pull/35) ([bewt85](https://github.com/bewt85))
155 - Major cleanup to use standard C string functions [\#34](https://github.com/sanger-pathogens/snp-sites/pull/34) ([tseemann](https://github.com/tseemann))
156 - Add -V version flag \(Issue \#27\) [\#32](https://github.com/sanger-pathogens/snp-sites/pull/32) ([tseemann](https://github.com/tseemann))
157 - Use stdio FILENAME\_MAX for path char\[\] sizes [\#31](https://github.com/sanger-pathogens/snp-sites/pull/31) ([tseemann](https://github.com/tseemann))
158 - fix recent compilation failure in Debian [\#23](https://github.com/sanger-pathogens/snp-sites/pull/23) ([satta](https://github.com/satta))
159
160 ## [2.0.2](https://github.com/sanger-pathogens/snp-sites/tree/2.0.2) (2015-09-03)
161 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.0.1...2.0.2)
162
163 **Merged pull requests:**
164
165 - Remove a tab in VCF header [\#22](https://github.com/sanger-pathogens/snp-sites/pull/22) ([bewt85](https://github.com/bewt85))
166 - Added bt5 and Jorge emails \(Jorge as path-help\) [\#21](https://github.com/sanger-pathogens/snp-sites/pull/21) ([aslett1](https://github.com/aslett1))
167
168 ## [2.0.1](https://github.com/sanger-pathogens/snp-sites/tree/2.0.1) (2015-07-17)
169 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.5.0...2.0.1)
170
171 **Merged pull requests:**
172
173 - Add reference sequence length to VCF output [\#20](https://github.com/sanger-pathogens/snp-sites/pull/20) ([bewt85](https://github.com/bewt85))
174 - Change output format to show Genotype rather than Alt Base [\#19](https://github.com/sanger-pathogens/snp-sites/pull/19) ([bewt85](https://github.com/bewt85))
175 - Reformat README [\#18](https://github.com/sanger-pathogens/snp-sites/pull/18) ([bewt85](https://github.com/bewt85))
176
177 ## [1.5.0](https://github.com/sanger-pathogens/snp-sites/tree/1.5.0) (2014-02-01)
178 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.11...1.5.0)
179
180 ## [1.4.11](https://github.com/sanger-pathogens/snp-sites/tree/1.4.11) (2014-01-24)
181 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.10...1.4.11)
182
183 ## [1.4.10](https://github.com/sanger-pathogens/snp-sites/tree/1.4.10) (2014-01-24)
184 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.9...1.4.10)
185
186 ## [1.4.9](https://github.com/sanger-pathogens/snp-sites/tree/1.4.9) (2014-01-24)
187 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.8...1.4.9)
188
189 ## [1.4.8](https://github.com/sanger-pathogens/snp-sites/tree/1.4.8) (2014-01-23)
190 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.7...1.4.8)
191
192 ## [1.4.7](https://github.com/sanger-pathogens/snp-sites/tree/1.4.7) (2014-01-23)
193 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.6...1.4.7)
194
195 ## [1.4.6](https://github.com/sanger-pathogens/snp-sites/tree/1.4.6) (2014-01-23)
196 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.5...1.4.6)
197
198 ## [1.4.5](https://github.com/sanger-pathogens/snp-sites/tree/1.4.5) (2014-01-23)
199 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.4...1.4.5)
200
201 ## [1.4.4](https://github.com/sanger-pathogens/snp-sites/tree/1.4.4) (2014-01-23)
202 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.3...1.4.4)
203
204 ## [1.4.3](https://github.com/sanger-pathogens/snp-sites/tree/1.4.3) (2014-01-23)
205 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.2...1.4.3)
206
207 ## [1.4.2](https://github.com/sanger-pathogens/snp-sites/tree/1.4.2) (2014-01-23)
208 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.1...1.4.2)
209
210 ## [1.4.1](https://github.com/sanger-pathogens/snp-sites/tree/1.4.1) (2014-01-21)
211 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4...1.4.1)
212
213 ## [1.4](https://github.com/sanger-pathogens/snp-sites/tree/1.4) (2014-01-20)
214 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.3...1.4)
215
216 ## [1.3](https://github.com/sanger-pathogens/snp-sites/tree/1.3) (2014-01-15)
217 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.2...1.3)
218
219 ## [1.2](https://github.com/sanger-pathogens/snp-sites/tree/1.2) (2014-01-14)
220 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.1...1.2)
221
222 ## [1.1](https://github.com/sanger-pathogens/snp-sites/tree/1.1) (2014-01-13)
223 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.0...1.1)
224
225 ## [1.0](https://github.com/sanger-pathogens/snp-sites/tree/1.0) (2014-01-06)
226 [Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/0.1...1.0)
227
228 ## [0.1](https://github.com/sanger-pathogens/snp-sites/tree/0.1) (2013-07-25)
229 **Merged pull requests:**
230
231 - travis install check [\#17](https://github.com/sanger-pathogens/snp-sites/pull/17) ([andrewjpage](https://github.com/andrewjpage))
232 - travis autoreconf [\#16](https://github.com/sanger-pathogens/snp-sites/pull/16) ([andrewjpage](https://github.com/andrewjpage))
233 - travis ci [\#15](https://github.com/sanger-pathogens/snp-sites/pull/15) ([andrewjpage](https://github.com/andrewjpage))
234 - Update version and readme [\#14](https://github.com/sanger-pathogens/snp-sites/pull/14) ([andrewjpage](https://github.com/andrewjpage))
235 - Fix memory leaks [\#13](https://github.com/sanger-pathogens/snp-sites/pull/13) ([andrewjpage](https://github.com/andrewjpage))
236 - fix memory leaks and update make [\#12](https://github.com/sanger-pathogens/snp-sites/pull/12) ([andrewjpage](https://github.com/andrewjpage))
237 - GPL [\#11](https://github.com/sanger-pathogens/snp-sites/pull/11) ([andrewjpage](https://github.com/andrewjpage))
238 - rollback changes to fasta file parsing [\#10](https://github.com/sanger-pathogens/snp-sites/pull/10) ([andrewjpage](https://github.com/andrewjpage))
239 - print unequal length error message to stderr [\#9](https://github.com/sanger-pathogens/snp-sites/pull/9) ([andrewjpage](https://github.com/andrewjpage))
240 - vcf coords from 1 [\#8](https://github.com/sanger-pathogens/snp-sites/pull/8) ([andrewjpage](https://github.com/andrewjpage))
241 - speedup [\#7](https://github.com/sanger-pathogens/snp-sites/pull/7) ([andrewjpage](https://github.com/andrewjpage))
242 - print out an error if the sequence lengths are uneven [\#6](https://github.com/sanger-pathogens/snp-sites/pull/6) ([andrewjpage](https://github.com/andrewjpage))
243 - speedup phylip creation [\#5](https://github.com/sanger-pathogens/snp-sites/pull/5) ([andrewjpage](https://github.com/andrewjpage))
244 - output filename [\#4](https://github.com/sanger-pathogens/snp-sites/pull/4) ([andrewjpage](https://github.com/andrewjpage))
245 - Tests for when an N is present in input [\#3](https://github.com/sanger-pathogens/snp-sites/pull/3) ([andrewjpage](https://github.com/andrewjpage))
246 - Choose output file formats [\#2](https://github.com/sanger-pathogens/snp-sites/pull/2) ([andrewjpage](https://github.com/andrewjpage))
247 - Treat N as a gap [\#1](https://github.com/sanger-pathogens/snp-sites/pull/1) ([andrewjpage](https://github.com/andrewjpage))
248
77 [![Container ready](https://img.shields.io/badge/container-ready-brightgreen.svg)](https://quay.io/repository/biocontainers/gubbins)
88 [![Docker Build Status](https://img.shields.io/docker/build/sangerpathogens/gubbins.svg)](https://hub.docker.com/r/sangerpathogens/gubbins)
99 [![Docker Pulls](https://img.shields.io/docker/pulls/sangerpathogens/gubbins.svg)](https://hub.docker.com/r/sangerpathogens/gubbins)
10 [![codecov](https://codecov.io/gh/sanger-pathogens/snp-sites/branch/master/graph/badge.svg)](https://codecov.io/gh/sanger-pathogens/snp-sites)
1011
1112
1213 ## Contents
1718 * [OSX/Linux \- from source](#osxlinux---from-source)
1819 * [OSX/Linux \- from a release tarball](#osxlinux---from-a-release-tarball)
1920 * [All platforms \- Docker](#all-platforms---docker)
21 * [Running the tests](#running-the-tests)
2022 * [Usage](#usage)
2123 * [Example input](#example-input)
2224 * [Example usage](#example-usage)
7779
7880 ### All platforms - Docker
7981 Bioconda produce a Docker container so you can use the software out of the box. Install Docker and then pull the container from Bioconda https://quay.io/repository/biocontainers/snp-sites
82
83 ### Running the tests
84 The test can be run from the top level directory:
85
86 ```
87 autoreconf -i
88 ./configure
89 make
90 make check
91 ```
92
93 This requires libcheck (the `check` package in Ubuntu) to be installed.
8094
8195 ## Usage
8296
0 2.4.1
0 2.5.1
99 AC_MSG_WARN(["'Check' unit testing framework not found. It would be impossible to run unit tests!"])
1010 [have_check="no"])
1111
12
1213 AC_CHECK_HEADERS([zlib.h math.h getopt.h])
1314 AC_CHECK_LIB(m, floor)
1415 AX_CHECK_ZLIB
104104 gzclose(fp);
105105 }
106106
107 void detect_snps(char filename[], int pure_mode, int output_monomorphic)
107 void detect_snps(char filename[], int pure_mode, int output_monomorphic) {
108 detect_snps_count_constant_sites(filename, pure_mode, output_monomorphic, NULL);
109 }
110
111 void detect_snps_count_constant_sites(char filename[], int pure_mode, int output_monomorphic, int* constant_site_counts)
108112 {
109113 int i;
110114 int l;
112116 number_of_samples = 0;
113117 length_of_genome = 0;
114118 char * first_sequence;
115
116 gzFile fp;
119 /* array below allows quick mapping of A, C, T and G characters to indices in base_counts array */
120 const int char_to_base_count_index[] = {-1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 0, -1, 1, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, 3};
121
122
123 gzFile fp;
117124 kseq_t *seq;
118125
119126 fp = gzopen(filename, "r");
190197 {
191198 snp_locations[current_snp_index] = i;
192199 current_snp_index++;
193 }
194 }
200 } else if (constant_site_counts != NULL && is_pure(first_sequence[i])) {
201 constant_site_counts[char_to_base_count_index[(int) toupper(first_sequence[i])]]++;
202 }
203
204 }
205
195206 free(first_sequence);
196207 kseq_destroy(seq);
197208 gzclose(fp);
2222 #include "kseq.h"
2323
2424 void detect_snps( char filename[], int pure_mode, int output_monomorphic);
25 void detect_snps_count_constant_sites(char filename[], int pure_mode, int output_monomorphic, int *constant_site_counts);
2526 void get_bases_for_each_snp(char filename[], char ** bases_for_snps);
2627 int is_unknown(char base);
2728 int get_length_of_genome();
3939 printf(" -p output a phylip file\n");
4040 printf(" -o STR specify an output filename [STDOUT]\n");
4141 printf(" -c only output columns containing exclusively ACGT\n");
42 printf(" -C only output count of constant sites (suitable for IQ-TREE -fconst) and nothing else\n");
4243 printf(" -b output monomorphic sites, used for BEAST\n");
4344 printf(" -h this help message\n");
4445 printf(" -V print version and exit\n");
6970 int output_vcf_file = 0;
7071 int output_phylip_file = 0;
7172 int output_reference = 0;
73 int output_constant_site_counts = 0;
7274 int pure_mode = 0;
7375 int output_monomorphic =0;
7476
75 while ((c = getopt (argc, argv, "mvrbpco:V")) != -1)
77 while ((c = getopt (argc, argv, "mvrbpcCo:V")) != -1)
7678 switch (c)
7779 {
7880 case 'm':
9294 break;
9395 case 'c':
9496 pure_mode = 1;
97 break;
98 case 'C':
99 output_constant_site_counts = 1;
95100 break;
96101 case 'b':
97102 output_monomorphic = 1;
117122 }
118123
119124 strncpy(multi_fasta_filename, argv[optind], FILENAME_MAX);
120
121 if( pure_mode || output_monomorphic)
125
126 if (output_constant_site_counts) {
127 count_constant_sites(multi_fasta_filename, output_filename);
128 } else if( pure_mode || output_monomorphic)
122129 {
123130 generate_snp_sites_with_ref_pure_mono(multi_fasta_filename,
124131 output_multi_fasta_file,
3333 int output_vcf_file,
3434 int output_phylip_file,
3535 char output_filename[],
36 int output_reference, int pure_mode, int output_monomorphic)
36 int output_reference, int pure_mode,
37 int output_monomorphic)
3738 {
3839 int i;
3940 detect_snps(filename, pure_mode, output_monomorphic);
139140 output_filename, output_reference, pure_mode, output_monomorphic);
140141 }
141142
143 void count_constant_sites(char multi_fasta_filename[], char output_filename[]) {
144 char cwd[100];
145 FILE *input_file;
146 FILE *output_file;
147 int *constant_site_counts = NULL;
142148
149 output_file = (FILE *) fopen(output_filename, "w");
150 if (!output_file) {
151 fprintf(stderr, "ERROR: cannot open %s for writing: %s\n", output_filename, strerror(errno));
152 exit(EXIT_FAILURE);
153 }
154
155 constant_site_counts = (int *) calloc(4, sizeof(int));
156 if (constant_site_counts == NULL) {
157 fprintf(stderr, "ERROR: cannot allocated memory for constant_site_counts");
158 exit(EXIT_FAILURE);
159 }
160
161 detect_snps_count_constant_sites(multi_fasta_filename, 0, 0, constant_site_counts);
162
163
164 fprintf(output_file, "%d,%d,%d,%d\n", constant_site_counts[0], constant_site_counts[1],
165 constant_site_counts[2], constant_site_counts[3]);
166 fclose(output_file);
167 free(constant_site_counts);
168 }
143169 // Inefficient
144170 void strip_directory_from_filename(char * input_filename, char * output_filename)
145171 {
2121 #define _SNP_SITES_H_
2222
2323 #include <stdio.h>
24 #include <stdlib.h>
25 #include <string.h>
26 #include <errno.h>
2427
2528 int generate_snp_sites(char filename[],
2629 int output_multi_fasta_file,
4144 int output_reference,
4245 int pure_mode,
4346 int output_monomorphic);
44
47
48 void count_constant_sites(char multi_fasta_filename[], char filename[]);
49
4550 void strip_directory_from_filename(char *input_filename,
4651 char *output_filename);
4752
268268 }
269269 END_TEST
270270
271 START_TEST (check_count_constant_sites)
272 {
273 count_constant_sites("../tests/data/small_alignment.aln", "small_alignment.constant_site_counts.txt");
274 fail_unless(compare_files("../tests/data/small_alignment.constant_site_counts.txt", "small_alignment.constant_site_counts.txt"));
275 remove("small_alignment.constant_site_counts.txt");
276 }
277 END_TEST
278
271279 Suite * snp_sites_suite (void)
272280 {
273281 Suite *s = suite_create ("Creating_SNP_Sites");
301309 tcase_add_test (tc_snp_sites, valid_phylip_plus_reference);
302310 tcase_add_test (tc_snp_sites, valid_alignment_with_pure_mode);
303311 tcase_add_test (tc_snp_sites, valid_alignment_with_monomorphic_sites);
304
312 tcase_add_test (tc_snp_sites, check_count_constant_sites);
313
305314 tcase_add_exit_test(tc_snp_sites, invalid_with_uneven_file_lengths,EXIT_FAILURE);
306315 remove("uneven_alignment.aln.snp_sites.aln");
307316 suite_add_tcase (s, tc_snp_sites);