Skip to content

Instantly share code, notes, and snippets.

@jfear
Last active February 21, 2017 22:44
Show Gist options
  • Save jfear/4b2e4a7e4a9d40b8d2e795cb5c8a3707 to your computer and use it in GitHub Desktop.
Save jfear/4b2e4a7e4a9d40b8d2e795cb5c8a3707 to your computer and use it in GitHub Desktop.
Minimal test file for conda error
#/usr/bin/env python
import os
from lcdblib.snakemake import helpers
from lcdblib.utils import utils
URI = '../lcdb-wrapper-tests'
TMPDIR='/mnt/threeTB/centos_scratch'
references = {
'dmel': {
'gtf': '/data/LCDB/lcdb-references/dmel/r6-11/gtf/dmel_r6-11.gtf',
'hisat2': '/data/LCDB/lcdb-references/dmel/r6-11/hisat2/dmel_r6-11.1.ht2',
'refflat': '/data/LCDB/lcdb-references/dmel/r6-11/gtf/dmel_r6-11.refflat',
},
}
shell.prefix("set -euo pipefail; export TMPDIR={};".format(TMPDIR))
# Set working dir
workdir: '.'
def wrapper_for(path):
return 'file:' + os.path.join(URI, 'wrappers', path)
################################################################################
# Set up file naming patterns and targets
################################################################################
patterns = {
'fastq_clean': {
'r1': '../output/prealignment/raw/{experiment}/{sample}/{sample}_1.clean.fastq.gz',
},
'hisat2': {
'bam': '../output/prealignment/raw/{experiment}/{sample}/{sample}.fq.bam',
},
'feature_counts': {
'counts': '../output/prealignment/raw/{experiment}/{sample}/{sample}_{featurecount_strand}.fq.bam.counts',
'summary': '../output/prealignment/raw/{experiment}/{sample}/{sample}_{featurecount_strand}.fq.bam.counts.summary',
},
'picard_collectrnaseqmetrics': {
'metrics': '../output/prealignment/raw/{experiment}/{sample}/{sample}_{picard_collectrnaseqmetrics}.fq.bam.picard.metrics',
},
}
# Build target files
targets = helpers.fill_patterns(patterns, {'sample': 'ERR489286', 'experiment': 'ERX455041', 'featurecount_strand': 1, 'picard_collectrnaseqmetrics': 'FIRST_READ_TRANSCRIPTION_STRAND'})
rule targets:
input:
utils.flatten(targets['feature_counts']) +
utils.flatten(targets['picard_collectrnaseqmetrics'])
rule fastq_clean:
output: r1=temp(patterns['fastq_clean']['r1'])
conda: 'fastq_clean.yaml'
shell:
'fastq-dump -O $TMPDIR -X 1000000 --split-files --gzip {wildcards.sample} '
'&& cp $TMPDIR/{wildcards.sample}_1.fastq.gz {output.r1} '
'&& rm $TMPDIR/{wildcards.sample}_1.fastq.gz '
rule hisat2_fastq:
input:
index=references['dmel']['hisat2'],
fastq=rules.fastq_clean.output.r1
output: bam=temp(patterns['hisat2']['bam'])
threads: 8
log: patterns['hisat2']['bam'] + '.log'
wrapper: wrapper_for('hisat2/align')
rule featurecounts:
input:
annotation=references['dmel']['gtf'],
bam=patterns['hisat2']['bam']
output:
counts=patterns['feature_counts']['counts'],
summary=patterns['feature_counts']['summary']
params: extra='-s {featurecount_strand}'
wrapper: wrapper_for('featurecounts')
rule collectrnaseqmetrics:
input:
bam=patterns['hisat2']['bam'],
refflat=references['dmel']['refflat']
output: metrics=patterns['picard_collectrnaseqmetrics']['metrics']
params: extra='STRAND={picard_collectrnaseqmetrics}'
log: patterns['picard_collectrnaseqmetrics']['metrics'] + '.log'
wrapper: wrapper_for('picard/collectrnaseqmetrics')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment