Skip to content

Commit

Permalink
Merge pull request #3 from bewt85/bt5_rename_everything
Browse files Browse the repository at this point in the history
Rename project to snpEffWrapper
  • Loading branch information
satta committed Oct 28, 2015
2 parents b0a9b08 + 0bc8016 commit 11a8cea
Show file tree
Hide file tree
Showing 13 changed files with 47 additions and 45 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -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
4 changes: 2 additions & 2 deletions MANIFEST.in
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
recursive-include annotateVCF/data *
recursive-include annotateVCF/tests/data *
recursive-include snpEffWrapper/data *
recursive-include snpEffWrapper/tests/data *
38 changes: 20 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -45,30 +45,30 @@ 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`

## Alternative coding tables

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}'
```

Expand All @@ -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
```
4 changes: 2 additions & 2 deletions scripts/annotateVCF → scripts/snpEffBuildAndRun
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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)
10 changes: 5 additions & 5 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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',
Expand All @@ -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
Expand Down
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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']
Expand Down Expand Up @@ -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'
Expand All @@ -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
Expand All @@ -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
Expand All @@ -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,
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion annotateVCF/annotateVCF.py → snpEffWrapper/wrapper.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down

0 comments on commit 11a8cea

Please sign in to comment.