diff --git a/.travis.yml b/.travis.yml index da120e6..d25c301 100644 --- a/.travis.yml +++ b/.travis.yml @@ -12,4 +12,4 @@ before_install: - "source install_dependencies.sh" install: - "python setup.py develop" -script: ./annotateVCF/tests/test_annotateVCF.py +script: ./snpEffWrapper/tests/test_wrapper.py diff --git a/MANIFEST.in b/MANIFEST.in index 8c94753..838c0be 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,2 +1,2 @@ -recursive-include annotateVCF/data * -recursive-include annotateVCF/tests/data * +recursive-include snpEffWrapper/data * +recursive-include snpEffWrapper/tests/data * diff --git a/README.md b/README.md index 0c85b24..5541b34 100644 --- a/README.md +++ b/README.md @@ -1,24 +1,24 @@ -# AnnotateVCF +# SnpEffWrapper -[![Build Status](https://travis-ci.org/sanger-pathogens/AnnotateVCF.svg?branch=master)](https://travis-ci.org/sanger-pathogens/AnnotateVCF) +[![Build Status](https://travis-ci.org/sanger-pathogens/SnpEffWrapper.svg?branch=master)](https://travis-ci.org/sanger-pathogens/SnpEffWrapper) -Takes a VCF and applies annotations from a GFF using [SnpEff](http://snpeff.sourceforge.net/) +Takes a VCF and infers annotations and variant effects from a GFF using [SnpEff](http://snpeff.sourceforge.net/) If you use this, please consider [citing SnpEff](http://snpeff.sourceforge.net/SnpEff.html#citing); it -made making this tool a lot easier. +made making this tool a lot easier. This software is not endorsed in any respect by the original authors. ## Usage ``` -$ annotateVCF annotateVCF/tests/data/minimal.gff annotateVCF/tests/data/minimal.vcf -o minimal.annotated.vcf +$ snpEffBuildAndRun snpEffWrapper/tests/data/minimal.gff snpEffWrapper/tests/data/minimal.vcf -o minimal.annotated.vcf ``` ``` -$ annotateVCF --help -usage: annotateVCF [-h] [--snpeff-exec SNPEFF_EXEC] [--java-exec JAVA_EXEC] - [--coding-table CODING_TABLE] [-o OUTPUT_VCF] [--debug] - [--keep] - gff_file vcf_file +$ snpEffBuildAndRun --help +usage: snpEffBuildAndRun [-h] [--snpeff-exec SNPEFF_EXEC] + [--java-exec JAVA_EXEC] [--coding-table CODING_TABLE] + [-o OUTPUT_VCF] [--debug] [--keep] + gff_file vcf_file Takes a VCF and applies annotations from a GFF using SnpEff @@ -45,11 +45,11 @@ optional arguments: debugging) ``` -* annotateVCF will look for SnpEFF.jar in the following locations: +* snpEffBuildAndRun will look for SnpEFF.jar in the following locations: * the file specified by `--snpeff-exec` * `snpEff.jar` in your local directory * `snpEff.jar` in your `PATH` -* SnpEff needs Java 1.7 to run; annotateVCF will look in the following locations: +* SnpEff needs Java 1.7 to run; snpEffBuildAndRun will look in the following locations: * the file specified by `--java-exec` * `java` in your `PATH` @@ -57,18 +57,18 @@ optional arguments: You can provide a coding table for each VCF contig otherwise it'll default to SnpEff's 'Bacterial_and_Plant_Plastid'. You can do this by providing a mapping for -each contig in your VCF to the relevant table in [annotateVCF/data/config.template](annotateVCF/data/config.template) +each contig in your VCF to the relevant table in [snpEffWrapper/data/config.template](snpEffWrapper/data/config.template) in YAML format. For example: ``` -annotateVCF minimal.gff minimal.vcf \ +snpEffBuildAndRun minimal.gff minimal.vcf \ --coding-table 'default: Standard' -annotateVCF minimal.gff minimal.vcf \ +snpEffBuildAndRun minimal.gff minimal.vcf \ --coding-table '{CHROM1: Standard, MITO1: Mitochondrial}' -annotateVCF minimal.gff minimal.vcf \ +snpEffBuildAndRun minimal.gff minimal.vcf \ --coding-table '{default: Standard, MITO1: Mitochondrial}' ``` @@ -81,10 +81,12 @@ NB you don't need curly brackets if you're only mapping one contig (or setting a * At least one of the contigs in the VCF must have annotation data in the GFF (you'll get warnings for each VCF config not in the GFF) * You cannot provide unknown coding tables (i.e. that can't be found in - [config.template](annotateVCF/data/config.template)) + [config.template](snpEffWrapper/data/config.template)) ## Installation +Install [snpEff](http://snpeff.sourceforge.net/) and Java 1.7 then + ``` -pip install git+https://github.com/sanger-pathogens/AnnotateVCF.git +pip install git+https://github.com/sanger-pathogens/SnpEffWrapper.git ``` diff --git a/scripts/annotateVCF b/scripts/snpEffBuildAndRun similarity index 94% rename from scripts/annotateVCF rename to scripts/snpEffBuildAndRun index 73ec424..152dc79 100755 --- a/scripts/annotateVCF +++ b/scripts/snpEffBuildAndRun @@ -5,7 +5,7 @@ import logging import shutil import sys -from annotateVCF.annotateVCF import annotate_vcf, check_and_amend_executables +from snpEffWrapper.wrapper import annotate_vcf, check_and_amend_executables def parse_arguments(): parser = argparse.ArgumentParser( @@ -42,5 +42,5 @@ if __name__ == '__main__': else: logging.basicConfig(format="[%(asctime)s] %(levelname)s: %(message)s", level=logging.INFO) - logger = logging.getLogger('annotateVCF') + logger = logging.getLogger('snpEffWrapper') annotate_vcf(args) diff --git a/setup.py b/setup.py index 32b5e29..9daea9a 100644 --- a/setup.py +++ b/setup.py @@ -2,10 +2,10 @@ from setuptools import setup, find_packages import multiprocessing -setup(name='annotateVCF', - version='0.1.0', +setup(name='snpEffWrapper', + version='0.2.0', scripts=[ - 'scripts/annotateVCF' + 'scripts/snpEffBuildAndRun' ], install_requires=[ 'Jinja2', @@ -14,8 +14,8 @@ ], include_package_data=True, package_data={ - 'data': 'annotateVCF/data/*', - 'test_data': 'annotateVCF/tests/data/*' + 'data': 'snpEffWrapper/data/*', + 'test_data': 'snpEffWrapper/tests/data/*' }, packages=find_packages(), zip_safe=False diff --git a/annotateVCF/__init__.py b/snpEffWrapper/__init__.py similarity index 100% rename from annotateVCF/__init__.py rename to snpEffWrapper/__init__.py diff --git a/annotateVCF/data/config.template b/snpEffWrapper/data/config.template similarity index 100% rename from annotateVCF/data/config.template rename to snpEffWrapper/data/config.template diff --git a/annotateVCF/tests/__init__.py b/snpEffWrapper/tests/__init__.py similarity index 100% rename from annotateVCF/tests/__init__.py rename to snpEffWrapper/tests/__init__.py diff --git a/annotateVCF/tests/data/config b/snpEffWrapper/tests/data/config similarity index 100% rename from annotateVCF/tests/data/config rename to snpEffWrapper/tests/data/config diff --git a/annotateVCF/tests/data/minimal.gff b/snpEffWrapper/tests/data/minimal.gff similarity index 100% rename from annotateVCF/tests/data/minimal.gff rename to snpEffWrapper/tests/data/minimal.gff diff --git a/annotateVCF/tests/data/minimal.vcf b/snpEffWrapper/tests/data/minimal.vcf similarity index 100% rename from annotateVCF/tests/data/minimal.vcf rename to snpEffWrapper/tests/data/minimal.vcf diff --git a/annotateVCF/tests/test_annotateVCF.py b/snpEffWrapper/tests/test_wrapper.py similarity index 93% rename from annotateVCF/tests/test_annotateVCF.py rename to snpEffWrapper/tests/test_wrapper.py index a0e4141..9065678 100755 --- a/annotateVCF/tests/test_annotateVCF.py +++ b/snpEffWrapper/tests/test_wrapper.py @@ -8,18 +8,18 @@ from io import StringIO from unittest.mock import patch, MagicMock -from annotateVCF.annotateVCF import * -from annotateVCF.annotateVCF import _java_version_ok, _choose_java +from snpEffWrapper.wrapper import * +from snpEffWrapper.wrapper import _java_version_ok, _choose_java -class TestAnnotateVCF(unittest.TestCase): +class TestSnpEffWrapper(unittest.TestCase): def setUp(self): class FakeArgs(object): pass self.fake_args = FakeArgs() - @patch('annotateVCF.annotateVCF.os.path.isfile') - @patch('annotateVCF.annotateVCF._java_version_ok') - @patch('annotateVCF.annotateVCF.shutil') + @patch('snpEffWrapper.wrapper.os.path.isfile') + @patch('snpEffWrapper.wrapper._java_version_ok') + @patch('snpEffWrapper.wrapper.shutil') def test_snpeff_not_in_path(self, shutil_mock, java_ok, isfile_mock): isfile_mock.side_effect = lambda path: path in ['/foo/snpEff.jar', '/bin/snpEff.jar'] parsed_args = MagicMock() @@ -99,7 +99,7 @@ def test_get_vcf_contigs(self): actual_contigs = get_vcf_contigs(fake_vcf) self.assertEqual(actual_contigs, expected_contigs) - @patch('annotateVCF.annotateVCF.logger.warn') + @patch('snpEffWrapper.wrapper.logger.warn') def test_check_contigs(self, warn_mock): vcf_contigs = ['CHROM1'] gff_contigs = ['CHROM1'] @@ -196,17 +196,17 @@ def __init__(self, name): gff_file = FakeFile('foo.gz') self.assertEqual(get_genome_name(gff_file), 'foo.gz') - @patch('annotateVCF.annotateVCF.open', create=True) + @patch('snpEffWrapper.wrapper.open', create=True) def test_create_config_file(self, open_mock): try: fake_output_file = tempfile.NamedTemporaryFile(mode='w', - prefix='annotateVCF_tmp_', + prefix='snpEffWrapper_tmp_', dir=os.getcwd(), delete=False) open_mock.return_value = fake_output_file fake_output_filename = fake_output_file.name - tests_dir = pkg_resources.resource_filename('annotateVCF', 'tests') + tests_dir = pkg_resources.resource_filename('snpEffWrapper', 'tests') expected_config_filename = os.path.join(tests_dir, 'data', 'config') temp_database_dir = '/tmp/fake_dir' genome_name = 'fake_genome' @@ -229,8 +229,8 @@ def test_create_config_file(self, open_mock): finally: os.remove(fake_output_filename) - @patch('annotateVCF.annotateVCF.shutil.which') - @patch('annotateVCF.annotateVCF._java_version_ok') + @patch('snpEffWrapper.wrapper.shutil.which') + @patch('snpEffWrapper.wrapper._java_version_ok') def test_choose_java(self, java_ok_mock, which_mock): which_mock.return_value = '/foo/bar/java' java_ok_mock.side_effect = lambda java: java in list_of_ok_javas @@ -255,7 +255,7 @@ def test_choose_java(self, java_ok_mock, which_mock): list_of_ok_javas = [] self.assertRaises(WrongJavaError, _choose_java) - @patch('annotateVCF.annotateVCF.logger.warn') + @patch('snpEffWrapper.wrapper.logger.warn') def test_check_annotations(self, warn_mock): fake_vcf = StringIO("""\ ##fileformat=VCFv4.1 @@ -274,8 +274,8 @@ def test_check_annotations(self, warn_mock): expected_warning = "1 instances of 'ERROR_CHROMOSOME_NOT_FOUND': A contig in your VCF could not be found in your GFF. Are you sure that contigs use consitent names between your input data and the reference?" warn_mock.assert_called_once_with(expected_warning) - @patch('annotateVCF.annotateVCF.delete_temp_database') - @patch('annotateVCF.annotateVCF._get_snpeff_output_files') + @patch('snpEffWrapper.wrapper.delete_temp_database') + @patch('snpEffWrapper.wrapper._get_snpeff_output_files') def test_happy_case(self, output_mock, delete_database_mock): delete_database_mock.side_effect = shutil.rmtree temp_annotated_vcf = tempfile.NamedTemporaryFile(mode='w', delete=False, @@ -300,7 +300,7 @@ def test_happy_case(self, output_mock, delete_database_mock): fake_args.coding_table = 'default: Bacterial_and_Plant_Plastid' - tests_dir = pkg_resources.resource_filename('annotateVCF', 'tests') + tests_dir = pkg_resources.resource_filename('snpEffWrapper', 'tests') minimal_gff_filename = os.path.join(tests_dir, 'data', 'minimal.gff') minimal_vcf_filename = os.path.join(tests_dir, 'data', 'minimal.vcf') fake_args.gff_file = open(minimal_gff_filename, 'r') diff --git a/annotateVCF/annotateVCF.py b/snpEffWrapper/wrapper.py similarity index 99% rename from annotateVCF/annotateVCF.py rename to snpEffWrapper/wrapper.py index bce96c4..6bdaa66 100755 --- a/annotateVCF/annotateVCF.py +++ b/snpEffWrapper/wrapper.py @@ -192,7 +192,7 @@ def get_genome_name(gff_file): def create_config_file(temp_database_dir, genome_name, vcf_contigs, coding_table): - env = Environment(loader=PackageLoader('annotateVCF', 'data')) + env = Environment(loader=PackageLoader('snpEffWrapper', 'data')) template = env.get_template('config.template') output_filename = os.path.join(temp_database_dir, 'config') config_content = template.render(