Skip to content

Instantly share code, notes, and snippets.

@mercutio22
Created February 27, 2013 14:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mercutio22/5048327 to your computer and use it in GitHub Desktop.
Save mercutio22/5048327 to your computer and use it in GitHub Desktop.
Have this snakemake rule use wildcards instead of the for loop
import glob
import os.path
#These don't have to be hardcoded:
MANIFEST = '/media/Mario/bit/gather.newest.files'
BASEFOLDER = '/media/Mario/bit/original'
def parseManifest(manifest):
"""Lazily parses Simon's tabbed manifest file yielding a dictionary of the
form {column_name: value}
"""
column_names = [
'project',
'library',
'libtype',
'lims',
'flowcell',
'lane',
'run',
]
with open(manifest) as metadata:
for line in metadata:
values = line.strip().split('\t')
yield { name: value for name, value in zip(column_names, values) }
METADATA = [ d for d in parseManifest(MANIFEST) ]
FILES = [
'ResultCount_{flowcell}_{lane}_{lims}.male.hg19.fa.mdups.bam'.format(
**d) for d in METADATA
]
FASTQS = ['{library}_{libtype}.fastq'.format(**d) for d in METADATA ]
rule bam2fastq:
version: '0.1'
input: [ os.path.join(BASEFOLDER, filename) for filename in FILES ]
output: [ os.path.join(BASEFOLDER, i) for i in FASTQS ]
run:
for infile, outfile in zip(input, output):
shell('bam2fastq {infile} -o {outfile}')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment