[med-svn] [Git][med-team/snp-sites][upstream] New upstream version 2.5.1

Sascha Steinbiss gitlab at salsa.debian.org
Wed Oct 23 18:02:20 BST 2019



Sascha Steinbiss pushed to branch upstream at Debian Med / snp-sites


Commits:
b4b20798 by Sascha Steinbiss at 2019-10-23T16:45:12Z
New upstream version 2.5.1
- - - - -


13 changed files:

- .travis.yml
- AUTHORS
- + CHANGELOG.md
- README.md
- VERSION
- configure.ac
- src/alignment-file.c
- src/alignment-file.h
- src/main.c
- src/snp-sites.c
- src/snp-sites.h
- tests/check-snp-sites.c
- + tests/data/small_alignment.constant_site_counts.txt


Changes:

=====================================
.travis.yml
=====================================
@@ -2,7 +2,13 @@ language: c
 compiler:
   - gcc
   - clang
+addons:
+  apt:
+    packages:
+    - check
 before_install:
  - sudo apt-get update -qq
- - sudo apt-get install -qq check 
-script: autoreconf -i && ./configure && make && make check
+script: 
+ - autoreconf -i && ./configure --enable-maintainer-mode CFLAGS='-O0 --coverage' && make && make check
+after_success:
+  - bash <(curl -s https://codecov.io/bash)


=====================================
AUTHORS
=====================================
@@ -1,3 +1,4 @@
 Andrew J. Page <ap13 at sanger.ac.uk>
 Ben Taylor <path-help at sanger.ac.uk>
 Jorge Soares <path-help at sanger.ac.uk>
+Peter van Heusden


=====================================
CHANGELOG.md
=====================================
@@ -0,0 +1,249 @@
+# Change Log
+
+## [Unreleased](https://github.com/sanger-pathogens/snp-sites/tree/HEAD)
+
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/v2.4.1...HEAD)
+
+**Closed issues:**
+
+- SegFault for unknown reason [\#72](https://github.com/sanger-pathogens/snp-sites/issues/72)
+
+**Merged pull requests:**
+
+- Include tests in README [\#73](https://github.com/sanger-pathogens/snp-sites/pull/73) ([ssjunnebo](https://github.com/ssjunnebo))
+
+## [v2.4.1](https://github.com/sanger-pathogens/snp-sites/tree/v2.4.1) (2018-10-04)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/v2.4.0...v2.4.1)
+
+**Implemented enhancements:**
+
+- Print to screen [\#63](https://github.com/sanger-pathogens/snp-sites/issues/63)
+
+**Fixed bugs:**
+
+- Docker file typo [\#60](https://github.com/sanger-pathogens/snp-sites/issues/60)
+
+**Closed issues:**
+
+- Info in VCF output format [\#68](https://github.com/sanger-pathogens/snp-sites/issues/68)
+
+**Merged pull requests:**
+
+- Include docker and conda badges [\#70](https://github.com/sanger-pathogens/snp-sites/pull/70) ([ssjunnebo](https://github.com/ssjunnebo))
+- fixed Dockerfile [\#67](https://github.com/sanger-pathogens/snp-sites/pull/67) ([trstickland](https://github.com/trstickland))
+
+## [v2.4.0](https://github.com/sanger-pathogens/snp-sites/tree/v2.4.0) (2018-01-29)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.3.3...v2.4.0)
+
+**Fixed bugs:**
+
+- segmentation fault with `-b` option [\#58](https://github.com/sanger-pathogens/snp-sites/issues/58)
+- Segmentation fault with larger sequences \(on Desktop and HPC\) [\#57](https://github.com/sanger-pathogens/snp-sites/issues/57)
+
+**Closed issues:**
+
+- Gaps not reported in output? [\#61](https://github.com/sanger-pathogens/snp-sites/issues/61)
+
+**Merged pull requests:**
+
+- update readme [\#65](https://github.com/sanger-pathogens/snp-sites/pull/65) ([ssjunnebo](https://github.com/ssjunnebo))
+- Jk seg fault [\#59](https://github.com/sanger-pathogens/snp-sites/pull/59) ([andrewjpage](https://github.com/andrewjpage))
+
+## [2.3.3](https://github.com/sanger-pathogens/snp-sites/tree/2.3.3) (2017-06-09)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.3.2...2.3.3)
+
+**Closed issues:**
+
+- brew recipe needs to be updated to the latest release. [\#55](https://github.com/sanger-pathogens/snp-sites/issues/55)
+- Linuxbrew installation issue \(links issue\) [\#54](https://github.com/sanger-pathogens/snp-sites/issues/54)
+
+**Merged pull requests:**
+
+- update LICENSE and AUTHORS [\#56](https://github.com/sanger-pathogens/snp-sites/pull/56) ([ssjunnebo](https://github.com/ssjunnebo))
+
+## [2.3.2](https://github.com/sanger-pathogens/snp-sites/tree/2.3.2) (2016-05-12)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.3.1...2.3.2)
+
+**Closed issues:**
+
+- Didn't mean to open this [\#52](https://github.com/sanger-pathogens/snp-sites/issues/52)
+- Failing tests on various platforms [\#51](https://github.com/sanger-pathogens/snp-sites/issues/51)
+
+## [2.3.1](https://github.com/sanger-pathogens/snp-sites/tree/2.3.1) (2016-03-18)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.3.0...2.3.1)
+
+**Merged pull requests:**
+
+- 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))
+
+## [2.3.0](https://github.com/sanger-pathogens/snp-sites/tree/2.3.0) (2016-03-17)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.2.2...2.3.0)
+
+## [2.2.2](https://github.com/sanger-pathogens/snp-sites/tree/2.2.2) (2016-03-14)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.2.1...2.2.2)
+
+**Merged pull requests:**
+
+- make sure original API is not changed [\#49](https://github.com/sanger-pathogens/snp-sites/pull/49) ([satta](https://github.com/satta))
+- update to 2.2.1 [\#48](https://github.com/sanger-pathogens/snp-sites/pull/48) ([andrewjpage](https://github.com/andrewjpage))
+
+## [2.2.1](https://github.com/sanger-pathogens/snp-sites/tree/2.2.1) (2016-03-11)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.2.0...2.2.1)
+
+**Merged pull requests:**
+
+- adjust manpage [\#47](https://github.com/sanger-pathogens/snp-sites/pull/47) ([satta](https://github.com/satta))
+- output reference and change name to snp-sites [\#46](https://github.com/sanger-pathogens/snp-sites/pull/46) ([andrewjpage](https://github.com/andrewjpage))
+
+## [2.2.0](https://github.com/sanger-pathogens/snp-sites/tree/2.2.0) (2016-03-11)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.1.3...2.2.0)
+
+**Closed issues:**
+
+- Build is failing on Mac OS [\#45](https://github.com/sanger-pathogens/snp-sites/issues/45)
+- specify reference sequence [\#44](https://github.com/sanger-pathogens/snp-sites/issues/44)
+- Add Arxiv paper link to README.md [\#43](https://github.com/sanger-pathogens/snp-sites/issues/43)
+
+## [2.1.3](https://github.com/sanger-pathogens/snp-sites/tree/2.1.3) (2016-01-27)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.1.1...2.1.3)
+
+**Closed issues:**
+
+- possible to convert to redhat? [\#39](https://github.com/sanger-pathogens/snp-sites/issues/39)
+
+**Merged pull requests:**
+
+- Ensure C99 compliance [\#42](https://github.com/sanger-pathogens/snp-sites/pull/42) ([AidanDelaney](https://github.com/AidanDelaney))
+- Test data [\#41](https://github.com/sanger-pathogens/snp-sites/pull/41) ([andrewjpage](https://github.com/andrewjpage))
+- 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))
+
+## [2.1.1](https://github.com/sanger-pathogens/snp-sites/tree/2.1.1) (2015-12-14)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.1.0...2.1.1)
+
+**Implemented enhancements:**
+
+- Opens \<file\> twice? [\#26](https://github.com/sanger-pathogens/snp-sites/issues/26)
+
+**Fixed bugs:**
+
+- make check =\> cannot find -lsubunit [\#33](https://github.com/sanger-pathogens/snp-sites/issues/33)
+- autoreconf -i warnings =\> option 'subdir-objects' is disabled [\#29](https://github.com/sanger-pathogens/snp-sites/issues/29)
+
+**Merged pull requests:**
+
+- Autotoolize checking for dependencies [\#38](https://github.com/sanger-pathogens/snp-sites/pull/38) ([satta](https://github.com/satta))
+
+## [2.1.0](https://github.com/sanger-pathogens/snp-sites/tree/2.1.0) (2015-12-03)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.0.3...2.1.0)
+
+**Merged pull requests:**
+
+- Reduce times input file is opened [\#37](https://github.com/sanger-pathogens/snp-sites/pull/37) ([andrewjpage](https://github.com/andrewjpage))
+
+## [2.0.3](https://github.com/sanger-pathogens/snp-sites/tree/2.0.3) (2015-12-03)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.0.2...2.0.3)
+
+**Closed issues:**
+
+- How do we run the tests? [\#30](https://github.com/sanger-pathogens/snp-sites/issues/30)
+- Add a --version switch? [\#27](https://github.com/sanger-pathogens/snp-sites/issues/27)
+- FYI - updated brew package to 2.x series [\#24](https://github.com/sanger-pathogens/snp-sites/issues/24)
+
+**Merged pull requests:**
+
+- Bump version to 2.0.3 [\#36](https://github.com/sanger-pathogens/snp-sites/pull/36) ([bewt85](https://github.com/bewt85))
+- 496468: Allow '?' in fasta input [\#35](https://github.com/sanger-pathogens/snp-sites/pull/35) ([bewt85](https://github.com/bewt85))
+- Major cleanup to use standard C string functions [\#34](https://github.com/sanger-pathogens/snp-sites/pull/34) ([tseemann](https://github.com/tseemann))
+- Add -V version flag \(Issue \#27\) [\#32](https://github.com/sanger-pathogens/snp-sites/pull/32) ([tseemann](https://github.com/tseemann))
+- Use stdio FILENAME\_MAX for path char\[\] sizes [\#31](https://github.com/sanger-pathogens/snp-sites/pull/31) ([tseemann](https://github.com/tseemann))
+- fix recent compilation failure in Debian [\#23](https://github.com/sanger-pathogens/snp-sites/pull/23) ([satta](https://github.com/satta))
+
+## [2.0.2](https://github.com/sanger-pathogens/snp-sites/tree/2.0.2) (2015-09-03)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/2.0.1...2.0.2)
+
+**Merged pull requests:**
+
+- Remove a tab in VCF header [\#22](https://github.com/sanger-pathogens/snp-sites/pull/22) ([bewt85](https://github.com/bewt85))
+- Added bt5 and Jorge emails \(Jorge as path-help\) [\#21](https://github.com/sanger-pathogens/snp-sites/pull/21) ([aslett1](https://github.com/aslett1))
+
+## [2.0.1](https://github.com/sanger-pathogens/snp-sites/tree/2.0.1) (2015-07-17)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.5.0...2.0.1)
+
+**Merged pull requests:**
+
+- Add reference sequence length to VCF output [\#20](https://github.com/sanger-pathogens/snp-sites/pull/20) ([bewt85](https://github.com/bewt85))
+- 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))
+- Reformat README [\#18](https://github.com/sanger-pathogens/snp-sites/pull/18) ([bewt85](https://github.com/bewt85))
+
+## [1.5.0](https://github.com/sanger-pathogens/snp-sites/tree/1.5.0) (2014-02-01)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.11...1.5.0)
+
+## [1.4.11](https://github.com/sanger-pathogens/snp-sites/tree/1.4.11) (2014-01-24)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.10...1.4.11)
+
+## [1.4.10](https://github.com/sanger-pathogens/snp-sites/tree/1.4.10) (2014-01-24)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.9...1.4.10)
+
+## [1.4.9](https://github.com/sanger-pathogens/snp-sites/tree/1.4.9) (2014-01-24)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.8...1.4.9)
+
+## [1.4.8](https://github.com/sanger-pathogens/snp-sites/tree/1.4.8) (2014-01-23)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.7...1.4.8)
+
+## [1.4.7](https://github.com/sanger-pathogens/snp-sites/tree/1.4.7) (2014-01-23)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.6...1.4.7)
+
+## [1.4.6](https://github.com/sanger-pathogens/snp-sites/tree/1.4.6) (2014-01-23)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.5...1.4.6)
+
+## [1.4.5](https://github.com/sanger-pathogens/snp-sites/tree/1.4.5) (2014-01-23)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.4...1.4.5)
+
+## [1.4.4](https://github.com/sanger-pathogens/snp-sites/tree/1.4.4) (2014-01-23)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.3...1.4.4)
+
+## [1.4.3](https://github.com/sanger-pathogens/snp-sites/tree/1.4.3) (2014-01-23)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.2...1.4.3)
+
+## [1.4.2](https://github.com/sanger-pathogens/snp-sites/tree/1.4.2) (2014-01-23)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4.1...1.4.2)
+
+## [1.4.1](https://github.com/sanger-pathogens/snp-sites/tree/1.4.1) (2014-01-21)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.4...1.4.1)
+
+## [1.4](https://github.com/sanger-pathogens/snp-sites/tree/1.4) (2014-01-20)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.3...1.4)
+
+## [1.3](https://github.com/sanger-pathogens/snp-sites/tree/1.3) (2014-01-15)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.2...1.3)
+
+## [1.2](https://github.com/sanger-pathogens/snp-sites/tree/1.2) (2014-01-14)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.1...1.2)
+
+## [1.1](https://github.com/sanger-pathogens/snp-sites/tree/1.1) (2014-01-13)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/1.0...1.1)
+
+## [1.0](https://github.com/sanger-pathogens/snp-sites/tree/1.0) (2014-01-06)
+[Full Changelog](https://github.com/sanger-pathogens/snp-sites/compare/0.1...1.0)
+
+## [0.1](https://github.com/sanger-pathogens/snp-sites/tree/0.1) (2013-07-25)
+**Merged pull requests:**
+
+- travis install check [\#17](https://github.com/sanger-pathogens/snp-sites/pull/17) ([andrewjpage](https://github.com/andrewjpage))
+- travis autoreconf [\#16](https://github.com/sanger-pathogens/snp-sites/pull/16) ([andrewjpage](https://github.com/andrewjpage))
+- travis ci [\#15](https://github.com/sanger-pathogens/snp-sites/pull/15) ([andrewjpage](https://github.com/andrewjpage))
+- Update version and readme [\#14](https://github.com/sanger-pathogens/snp-sites/pull/14) ([andrewjpage](https://github.com/andrewjpage))
+- Fix memory leaks [\#13](https://github.com/sanger-pathogens/snp-sites/pull/13) ([andrewjpage](https://github.com/andrewjpage))
+- fix memory leaks and update make [\#12](https://github.com/sanger-pathogens/snp-sites/pull/12) ([andrewjpage](https://github.com/andrewjpage))
+- GPL [\#11](https://github.com/sanger-pathogens/snp-sites/pull/11) ([andrewjpage](https://github.com/andrewjpage))
+- rollback changes to fasta file parsing [\#10](https://github.com/sanger-pathogens/snp-sites/pull/10) ([andrewjpage](https://github.com/andrewjpage))
+- print unequal length error message to stderr [\#9](https://github.com/sanger-pathogens/snp-sites/pull/9) ([andrewjpage](https://github.com/andrewjpage))
+- vcf coords from 1 [\#8](https://github.com/sanger-pathogens/snp-sites/pull/8) ([andrewjpage](https://github.com/andrewjpage))
+- speedup [\#7](https://github.com/sanger-pathogens/snp-sites/pull/7) ([andrewjpage](https://github.com/andrewjpage))
+- 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))
+- speedup phylip creation [\#5](https://github.com/sanger-pathogens/snp-sites/pull/5) ([andrewjpage](https://github.com/andrewjpage))
+- output filename [\#4](https://github.com/sanger-pathogens/snp-sites/pull/4) ([andrewjpage](https://github.com/andrewjpage))
+- Tests for when an N is present in input [\#3](https://github.com/sanger-pathogens/snp-sites/pull/3) ([andrewjpage](https://github.com/andrewjpage))
+- Choose output file formats [\#2](https://github.com/sanger-pathogens/snp-sites/pull/2) ([andrewjpage](https://github.com/andrewjpage))
+- Treat N as a gap [\#1](https://github.com/sanger-pathogens/snp-sites/pull/1) ([andrewjpage](https://github.com/andrewjpage))
+


=====================================
README.md
=====================================
@@ -8,6 +8,7 @@ Rapidly extracts SNPs from a multi-FASTA alignment.
 [![Container ready](https://img.shields.io/badge/container-ready-brightgreen.svg)](https://quay.io/repository/biocontainers/gubbins)  
 [![Docker Build Status](https://img.shields.io/docker/build/sangerpathogens/gubbins.svg)](https://hub.docker.com/r/sangerpathogens/gubbins)  
 [![Docker Pulls](https://img.shields.io/docker/pulls/sangerpathogens/gubbins.svg)](https://hub.docker.com/r/sangerpathogens/gubbins)  
+[![codecov](https://codecov.io/gh/sanger-pathogens/snp-sites/branch/master/graph/badge.svg)](https://codecov.io/gh/sanger-pathogens/snp-sites)   
 
 
 ## Contents
@@ -18,6 +19,7 @@ Rapidly extracts SNPs from a multi-FASTA alignment.
   * [OSX/Linux \- from source](#osxlinux---from-source)
   * [OSX/Linux \- from a release tarball](#osxlinux---from-a-release-tarball)
   * [All platforms \- Docker](#all-platforms---docker)
+  * [Running the tests](#running-the-tests)
 * [Usage](#usage)
   * [Example input](#example-input)
   * [Example usage](#example-usage)
@@ -79,6 +81,18 @@ sudo make install
 ### All platforms - Docker
 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
 
+### Running the tests
+The test can be run from the top level directory:  
+
+```
+autoreconf -i
+./configure
+make
+make check
+```
+
+This requires libcheck (the `check` package in Ubuntu) to be installed.
+
 ## Usage
 
 ```


=====================================
VERSION
=====================================
@@ -1 +1 @@
-2.4.1
+2.5.1


=====================================
configure.ac
=====================================
@@ -10,6 +10,7 @@ PKG_CHECK_MODULES([CHECK],[check >= 0.8.2],[have_check="yes"],
   AC_MSG_WARN(["'Check' unit testing framework not found. It would be impossible to run unit tests!"])
   [have_check="no"])
 
+
 AC_CHECK_HEADERS([zlib.h math.h getopt.h])
 AC_CHECK_LIB(m, floor)
 AX_CHECK_ZLIB


=====================================
src/alignment-file.c
=====================================
@@ -105,7 +105,11 @@ void get_bases_for_each_snp(char filename[], char ** bases_for_snps)
   gzclose(fp);
 }
 
-void detect_snps(char filename[], int pure_mode, int output_monomorphic)
+void detect_snps(char filename[], int pure_mode, int output_monomorphic) {
+    detect_snps_count_constant_sites(filename, pure_mode, output_monomorphic, NULL);
+}
+
+void detect_snps_count_constant_sites(char filename[], int pure_mode, int output_monomorphic, int* constant_site_counts)
 {
   int i;
   int l;
@@ -113,8 +117,11 @@ void detect_snps(char filename[], int pure_mode, int output_monomorphic)
   number_of_samples = 0; 
   length_of_genome = 0;
   char * first_sequence;
-  
-  gzFile fp;
+  /* array below allows quick mapping of A, C, T and G characters to indices in base_counts array */
+  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};
+
+
+    gzFile fp;
   kseq_t *seq;
   
   fp = gzopen(filename, "r");
@@ -191,8 +198,12 @@ void detect_snps(char filename[], int pure_mode, int output_monomorphic)
       {
           snp_locations[current_snp_index] = i;
           current_snp_index++;
+      } else if (constant_site_counts != NULL && is_pure(first_sequence[i])) {
+          constant_site_counts[char_to_base_count_index[(int) toupper(first_sequence[i])]]++;
       }
+
   }
+
   free(first_sequence);
   kseq_destroy(seq);
   gzclose(fp);


=====================================
src/alignment-file.h
=====================================
@@ -23,6 +23,7 @@
 #include "kseq.h"
 
 void detect_snps( char filename[], int pure_mode, int output_monomorphic);
+void detect_snps_count_constant_sites(char filename[], int pure_mode, int output_monomorphic, int *constant_site_counts);
 void get_bases_for_each_snp(char filename[], char ** bases_for_snps);
 int is_unknown(char base);
 int get_length_of_genome();


=====================================
src/main.c
=====================================
@@ -40,6 +40,7 @@ static void print_usage()
   printf(" -p     output a phylip file\n");
   printf(" -o STR specify an output filename [STDOUT]\n");
   printf(" -c     only output columns containing exclusively ACGT\n");
+  printf(" -C     only output count of constant sites (suitable for IQ-TREE -fconst) and nothing else\n");
   printf(" -b     output monomorphic sites, used for BEAST\n");
   printf(" -h     this help message\n");
   printf(" -V     print version and exit\n");
@@ -70,10 +71,11 @@ int main (int argc, char **argv) {
   int output_vcf_file = 0;
   int output_phylip_file = 0;
   int output_reference = 0;
+  int output_constant_site_counts = 0;
 	int pure_mode = 0;
   int output_monomorphic =0;
   
-	 while ((c = getopt (argc, argv, "mvrbpco:V")) != -1)
+	 while ((c = getopt (argc, argv, "mvrbpcCo:V")) != -1)
       switch (c)
         {
         case 'm':
@@ -94,6 +96,9 @@ int main (int argc, char **argv) {
         case 'c':
           pure_mode = 1;
           break;
+        case 'C':
+          output_constant_site_counts = 1;
+          break;
         case 'b':
           output_monomorphic = 1;
           break;
@@ -118,8 +123,10 @@ int main (int argc, char **argv) {
     }
     
     strncpy(multi_fasta_filename, argv[optind], FILENAME_MAX); 
-    
-    if( pure_mode || output_monomorphic)
+
+    if (output_constant_site_counts) {
+        count_constant_sites(multi_fasta_filename, output_filename);
+    } else if( pure_mode || output_monomorphic)
     {
       generate_snp_sites_with_ref_pure_mono(multi_fasta_filename,
                                   output_multi_fasta_file,


=====================================
src/snp-sites.c
=====================================
@@ -34,7 +34,8 @@ static int generate_snp_sites_generic(char filename[],
                                       int output_vcf_file,
                                       int output_phylip_file,
                                       char output_filename[],
-                                      int output_reference, int pure_mode, int output_monomorphic)
+                                      int output_reference, int pure_mode,
+                                      int output_monomorphic)
 {
 	int i;
 	detect_snps(filename, pure_mode, output_monomorphic);
@@ -140,7 +141,32 @@ int generate_snp_sites_with_ref_pure_mono(char filename[],
                                     output_filename, output_reference, pure_mode, output_monomorphic);
 }
 
+void count_constant_sites(char multi_fasta_filename[], char output_filename[]) {
+    char cwd[100];
+    FILE *input_file;
+    FILE *output_file;
+    int *constant_site_counts = NULL;
 
+    output_file = (FILE *) fopen(output_filename, "w");
+    if (!output_file) {
+        fprintf(stderr, "ERROR: cannot open %s for writing: %s\n", output_filename, strerror(errno));
+        exit(EXIT_FAILURE);
+    }
+
+    constant_site_counts = (int *) calloc(4, sizeof(int));
+    if (constant_site_counts == NULL) {
+        fprintf(stderr, "ERROR: cannot allocated memory for constant_site_counts");
+        exit(EXIT_FAILURE);
+    }
+
+    detect_snps_count_constant_sites(multi_fasta_filename, 0, 0, constant_site_counts);
+
+
+    fprintf(output_file, "%d,%d,%d,%d\n", constant_site_counts[0], constant_site_counts[1],
+            constant_site_counts[2], constant_site_counts[3]);
+    fclose(output_file);
+    free(constant_site_counts);
+}
 // Inefficient
 void strip_directory_from_filename(char * input_filename, char * output_filename)
 {


=====================================
src/snp-sites.h
=====================================
@@ -22,6 +22,9 @@
 #define _SNP_SITES_H_
 
 #include <stdio.h>
+#include <stdlib.h>
+#include <string.h>
+#include <errno.h>
 
 int generate_snp_sites(char filename[],
                        int output_multi_fasta_file,
@@ -42,7 +45,9 @@ int generate_snp_sites_with_ref_pure_mono(char filename[],
                                 int output_reference,
                                 int pure_mode,
                                 int output_monomorphic);
-                                
+
+void count_constant_sites(char multi_fasta_filename[], char filename[]);
+
 void strip_directory_from_filename(char *input_filename,
                                    char *output_filename);
 


=====================================
tests/check-snp-sites.c
=====================================
@@ -269,6 +269,14 @@ START_TEST (check_strip_directory_from_filename_with_directory)
 }
 END_TEST
 
+START_TEST (check_count_constant_sites)
+{
+    count_constant_sites("../tests/data/small_alignment.aln", "small_alignment.constant_site_counts.txt");
+    fail_unless(compare_files("../tests/data/small_alignment.constant_site_counts.txt", "small_alignment.constant_site_counts.txt"));
+    remove("small_alignment.constant_site_counts.txt");
+}
+END_TEST
+
 Suite * snp_sites_suite (void)
 {
   Suite *s = suite_create ("Creating_SNP_Sites");
@@ -302,7 +310,8 @@ Suite * snp_sites_suite (void)
   tcase_add_test (tc_snp_sites, valid_phylip_plus_reference);
   tcase_add_test (tc_snp_sites, valid_alignment_with_pure_mode);
   tcase_add_test (tc_snp_sites, valid_alignment_with_monomorphic_sites);
-  
+  tcase_add_test (tc_snp_sites, check_count_constant_sites);
+
   tcase_add_exit_test(tc_snp_sites, invalid_with_uneven_file_lengths,EXIT_FAILURE);
   remove("uneven_alignment.aln.snp_sites.aln");
   suite_add_tcase (s, tc_snp_sites);


=====================================
tests/data/small_alignment.constant_site_counts.txt
=====================================
@@ -0,0 +1 @@
+2,2,1,2



View it on GitLab: https://salsa.debian.org/med-team/snp-sites/commit/b4b20798e93738f488e415d7cf0bf99f5279bb12

-- 
View it on GitLab: https://salsa.debian.org/med-team/snp-sites/commit/b4b20798e93738f488e415d7cf0bf99f5279bb12
You're receiving this email because of your account on salsa.debian.org.


-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://alioth-lists.debian.net/pipermail/debian-med-commit/attachments/20191023/5a9e49c1/attachment-0001.html>


More information about the debian-med-commit mailing list