Skip to content
This repository has been archived by the owner. It is now read-only.

Commit

Permalink
Added salmon quantification logic.
Browse files Browse the repository at this point in the history
  • Loading branch information
jenzopr committed Apr 5, 2018
1 parent 0a23d6a commit 030df8d
Show file tree
Hide file tree
Showing 2 changed files with 55 additions and 0 deletions.
4 changes: 4 additions & 0 deletions sc-preprocess.snake
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ if config["action"]["clean"]:
clean_files = expand('{o}/{s}.clean.fastq.gz', o = config['dirs']['fastq'], s = SAMPLE_NAMES)
output_files.extend(clean_files)

quant_files = expand('{o}/{s}/quant.sf', o = config['dirs']['quant'], s = SAMPLE_NAMES)
output_files.extend(quant_files)

#-------------------------------------------------------------------------------#
#---------------------------------- RUN :-) ------------------------------------#
#-------------------------------------------------------------------------------#
Expand All @@ -49,6 +52,7 @@ include: "src/auxiliary.snake"
#include: "src/demultiplex.snake" # not yet implemented
include: "src/reference.snake"
include: "src/clean.snake"
include: "src/salmon.snake"

if config["debug"]:
print_debug()
Expand Down
51 changes: 51 additions & 0 deletions src/salmon.snake
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
# vim: syntax=python tabstop=4 expandtab
# coding: utf-8

'''
@author: jpreuss
Provides Salmon alignment-free quantification
'''

SALMON_VERSION = subprocess.check_output("salmon -v", shell=True)

rule salmon_index:
input:
REFERENCE_FASTA
output:
join(config['dirs']['ref'], 'salmon', basename(REFERENCE_FASTA).rstrip(".fa"))
threads: 30
params:
flags = config['salmon']['index_flags'] if 'index_flags' in config.get('salmon', {}) else ''
log:
'logs/salmon_index.log'
message: 'Creating Salmon index for {input}.'
version: SALMON_VERSION
shell:
"""
salmon index -p {threads} -t {input} -i {output} {params.flags} &> {log}
"""

def salmon_input_r1(wildcards):
if config['action']['clean']:
return('{o}/{s}.clean.fastq.gz'.format(o = config['dirs']['fastq'], s = wildcards.sample))
else:
return(SAMPLES[wildcards.sample]['URL_r1'])

rule salmon_quant_se:
input:
r1 = salmon_input_r1,
index = rules.salmon_index.output
output:
config['dirs']['quant'] + '/{sample}/quant.sf'
params:
flags = config['salmon']['quant_flags'] if 'quant_flags' in config.get('salmon', {}) else ''
log:
'logs/salmon_quant_{sample}.log'
message: 'Quantifying {wildcards.sample} with Salmon using {threads} threads.'
threads: 30
version: SALMON_VERSION
shell:
"""
salmon quant -p {threads} -i {input.index} -l ISR -r {input.r1} -o {config[dirs][quant]}/{wildcards.sample} {params.flags} &> {log}
"""

0 comments on commit 030df8d

Please sign in to comment.