Created
February 27, 2013 14:36
-
-
Save mercutio22/5048327 to your computer and use it in GitHub Desktop.
Have this snakemake rule use wildcards instead of the for loop
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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