Skip to content

Commit

Permalink
Merge pull request #75 from jts/fix_snpeff_build
Browse files Browse the repository at this point in the history
snpEff database build support for different version
  • Loading branch information
rdeborja authored Mar 29, 2021
2 parents 21fd71f + 991784a commit 9fa0dbe
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 6 deletions.
14 changes: 12 additions & 2 deletions workflow/rules/annotation.smk
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,14 @@ def get_recurrent_heatmap_plot(wildcards):
out = "plots/%s_aa_mutation_heatmap.pdf" % (prefix)
return out

def get_snpeff_dirs():
snpeff_dirs = list()
for snpeff_dir in os.scandir('/'.join([os.environ['CONDA_PREFIX'], 'share'])):
if snpeff_dir.name.startswith('snpeff'):
snpeff_dirs.append(snpeff_dir.name)
return snpeff_dirs


#
# Rules for annotating variants with functional consequence
#
Expand All @@ -50,11 +58,13 @@ rule all_qc_annotation:

rule build_snpeff_db:
input:
expand(os.environ['CONDA_PREFIX'] + '/share/snpeff-5.0-0/data/MN908947.3/snpEffectPredictor.bin')
expand(os.environ['CONDA_PREFIX'] + '/share/{snpeff_dir}/data/MN908947.3/snpEffectPredictor.bin', snpeff_dir=get_snpeff_dirs())

rule download_db_files:
input:
expand(os.environ['CONDA_PREFIX'] + '/share/{snpeff_dir}', snpeff_dir=get_snpeff_dirs())
output:
expand(os.environ['CONDA_PREFIX'] + '/share/snpeff-5.0-0/data/MN908947.3/snpEffectPredictor.bin')
expand(os.environ['CONDA_PREFIX'] + '/share/{snpeff_dir}/data/MN908947.3/snpEffectPredictor.bin', snpeff_dir=get_snpeff_dirs())
params:
script=srcdir("../scripts/build_db.py")
shell:
Expand Down
9 changes: 5 additions & 4 deletions workflow/scripts/build_db.py
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -6,15 +6,16 @@

import os

SNPEFF_PREFIX = 'snpeff-5.0-0'
snpeff_dir_prefix = 'snpeff'

def main():
"""
Main function to run shell commands to build the MN908947.3 snpEff database
"""
snpeff_dir = '/'.join([os.environ['CONDA_PREFIX'], 'share', SNPEFF_PREFIX])
os.chdir(snpeff_dir)
os.system('./scripts/buildDbNcbi.sh MN908947.3')
for dir_name in os.scandir('/'.join([os.environ['CONDA_PREFIX'], 'share'])):
if dir_name.name.startswith(snpeff_dir_prefix):
os.chdir('/'.join([os.environ['CONDA_PREFIX'], 'share', dir_name.name]))
os.system(f'{"/".join([os.environ["CONDA_PREFIX"], "share", dir_name.name, "scripts/buildDbNcbi.sh"])} MN908947.3')


if __name__ == "__main__":
Expand Down

0 comments on commit 9fa0dbe

Please sign in to comment.