Skip to content

Instantly share code, notes, and snippets.

View dpryan79's full-sized avatar

Devon Ryan dpryan79

  • Genedata AG
  • Basel, Switzerland / Freiburg, Germany
View GitHub Profile
@dpryan79
dpryan79 / iterative.nf
Created December 22, 2022 09:42
Iterative with connected inputs/outputs
rawFastqs = Channel.fromFilePairs(['data/*_{1,2}.fastq.gz', 'data/*_R{1,2}.fastq.gz'])
databases = Channel.of(['label1', '/some/path/database'], ['label2', '/some/other/path/database'], ...)
/+
The general structure of what I'd like to achieve, just without manually putting in all of the someProcess() calls
That won't work for a variety of reasons, among them being that someProcess() would need an alias each time
*/
workflow {
someProcess(rawFastqs, databases.first())
someProcess(someProcess.out.fastq, databases[2])
@dpryan79
dpryan79 / subsetBigWig.py
Created July 31, 2019 16:18
Subset a bigwig file
#!/usr/bin/env python
import pyBigWig
import argparse
import os.path
import sys
parser = argparse.ArgumentParser(description="Subset a single chromosome from a bigWig file.")
parser.add_argument("--headerToo", action="store_true", help="Subset the header too, which can expedite some downstream programs but possibly cause problems for others.")
parser.add_argument("input", help="Input bigWig file.")
parser.add_argument("output", help="Output bigWig file.")
@dpryan79
dpryan79 / findSites.py
Created May 13, 2019 20:11
Generate a blacklist file of polyX stretches of a given minimum length not within a specified distance of a TES
#!/usr/bin/env python
# This can take up to ~20 minutes and use up to ~2GB RAM for mammals
import argparse
import py2bit
from deeptoolsintervals import GTF, tree
from deeptoolsintervals.parse import openPossiblyCompressed, parseExonBounds, findRandomLabel
parser = argparse.ArgumentParser(description="Generate a blacklist file of polyX stretches of a given minimum length not within a specified distance of a TES")
parser.add_argument("--output", "-o", help="Output file", required=True)
parser.add_argument("--tb", help="2bit file", required=True)
@dpryan79
dpryan79 / README.md
Created September 2, 2018 14:00
Reproduction of snakemake issue #916

This demonstrates the issue discussed in https://bitbucket.org/snakemake/snakemake/issues/916/integrated-r-scripts-and-directory

To reproduce that and test any fixes, simply clone this github respository and chmod -R a-w it. Then go to a different directory and snakemake -s path/to/the/snakefile/here. With an unpatched copy of snakemake you'll get a permissions error. Note that the Snakefile has examples using R and Rmd files, so you'll need to ensure that R is in your PATH.

@dpryan79
dpryan79 / convertBigWigChroms.py
Last active September 7, 2021 12:49
Convert chromosome names in a bigWig file
#!/usr/bin/env python
import argparse
import pyBigWig
parser = argparse.ArgumentParser(description="Convert the chromosome names of a bigWig file.")
parser.add_argument("conv", metavar="conversion.txt", help="Text file with two columns, the first a chromosome name and the second the converted chromosome name.")
parser.add_argument("input", metavar="input.bigWig", help="Input bigWig file")
parser.add_argument("output", metavar="output.bigWig", help="Output bigWig file name")
args = parser.parse_args()
@dpryan79
dpryan79 / estimateReadFiltering.py
Last active May 4, 2017 13:12
estimate read filtering using deepTools
#!/usr/bin/env python
import argparse
import numpy as np
import sys
from deeptools import parserCommon, bamHandler, utilities
from deeptools.mapReduce import mapReduce
from deeptools._version import __version__
import deeptools.config as cfg
@dpryan79
dpryan79 / BamToInsertsizeBigWig.py
Last active April 24, 2017 11:35
Convert a BAM file to a bigWig or bedGraph file containing the mean insert size (uses the deepTools API)
#!/usr/bin/env python
import deeptools.utilities
from deeptools import bamHandler
from deeptools import mapReduce
from deeptools import writeBedGraph
from deeptools import utilities
from deeptools.utilities import getCommonChrNames, toBytes
import sys
import shutil
@dpryan79
dpryan79 / slack.py
Last active February 16, 2017 21:15
This is an only partially tested script to check that various NFS servers are still working and post messages to slack accordingly.
#!/usr/bin/env python3
import urllib.request
import json
from subprocess import Popen
from time import sleep
def checkUp(path, timeout):
p = Popen(['ls', path])
try:
#!/usr/bin/env python
e2g = []
e2u = []
g2e = []
g2u = []
u2e = []
u2g = []
ifile = open("GCA_000001405.22_GRCh38.p7_assembly_report.txt", "r")
for line in ifile:
if line.startswith("#"):
#!/usr/bin/env python
# This is just a quick hack and hasn't been tested, but it'll likely work
import pysam
import argparse
import gzip
def writeAlignment(of, al):
name = al.query_name
seq = al.query_sequence
qual = al.query_qualities