Skip to content

Instantly share code, notes, and snippets.

View Colelyman's full-sized avatar

Cole Lyman Colelyman

View GitHub Profile
@Colelyman
Colelyman / simPairedReadsWithAdapter.py
Created October 7, 2022 19:54 — forked from kclem/simPairedReadsWithAdapter.py
Simulate paired reads with adapter readthrough and substitutions for testing adapter trimming and read merging
import random
simulate_deletion_lens = range(30) #deletions to simulate - here, 0 to 30bp deletions. The longer the deletion, the more adapter will be included in the read
simulate_mismatch_counts = range(3) #number of mismatches to simulate - her, 0, 1, and 2 mismatches between r1 and r2. The higher the number of mismatches, the less likely the read will be merged.
read_len = 210 #length of reads to generate
read = ' CGGATGTTCCAATCAGTACGCAGAGAGTCGCCGTCTCCAAGGTGAAAGCGGAAGTAGGGCCTTCGCGCACCTCATGGAATCCCTTCTGCAGCACCTGGATCGCTTTTCCGAGCTTCTGGCGGTCTCAAGCACTACCTACGTCAGCACCTGGGACCCCGCCACCGTGCGCCGGGCCTTGCAGTGGGCGCGCTACCTGCGCCACATCCATCGGCGCTTTGGTCGG '
readthrough = 'ACACTCTTTCCCTACACGACGCTCTTCCGATCTCGGATGTTCCAATCAGTACGCAGAGAGTCGCCGTCTCCAAGGTGAAAGCGGAAGTAGGGCCTTCGCGCACCTCATGGAATCCCTTCTGCAGCACCTGGATCGCTTTTCCGAGCTTCTGGCGGTCTCAAGCACTACCTACGTCAGCACCTGGGACCCCGCCACCGTGCGCCGGGCCTTGCAGTGGGCGCGCTACCTGCGCCACATCCATCGGCGCTTTGGTCGGAGATCGGAAGAGCACACGTCTGAACTCCAGTC
@Colelyman
Colelyman / eulerian_path.py
Created January 2, 2021 18:16
Discover an Eulerian Path from a Graph.
"""Discover an Eulerian Path from a graph."""
import argparse
from collections import Counter
from typing import Dict, List, Optional
def construct_graph_from_adjacency(
graph_file_path: str,
) -> Dict[str, List[str]]:
@Colelyman
Colelyman / eulerian_cycle.py
Last active January 2, 2021 18:16
Discover an Eulerian Cycle from a graph.
"""Discover an Eulerian Cycle from a graph."""
import argparse
from typing import Dict, List
def construct_graph_from_adjacency(
graph_file_path: str,
) -> Dict[str, List[str]]:
"""Construct a graph from an adjacency list in `graph_file_path`.
@Colelyman
Colelyman / citation
Created December 6, 2019 21:55
Generate a citation in Markdown from a BibTeX entry.
#!/bin/sh
TEMP_BIB_PATH=".mybib.bib"
TEMP_MD_PATH=".mybib.md"
TEMP_CITATION_PATH=".mycitation.md"
clean() {
rm -rf $TEMP_BIB_PATH $TEMP_MD_PATH $TEMP_CITATION_PATH
}
d_grimshawi
d_virilis
d_mojavensis
d_willistoni
d_persimilis
d_pseudoobscura
d_ananassae
d_erecta
d_yakuba
d_melanogaster
@Colelyman
Colelyman / file-defer-close.lisp
Last active October 23, 2018 03:39
A Common Lisp macro that opens a file and closes it after some computation is done.
(defmacro open-file-defer-close (file-path file-handle &body body)
"Opens FILE-PATH as FILE-HANDLE, executes BODY and finally closes FILE-HANDLE."
`(let ((,file-handle ,(open file-path)))
,@body
(close ,file-handle)))

Keybase proof

I hereby claim:

  • I am colelyman on github.
  • I am colelyman (https://keybase.io/colelyman) on keybase.
  • I have a public key ASDSxAqaZq-uEWXfjlA7FumgaGXm47CeKWxqphX0ITlVMQo

To claim this, I am signing this object:

@Colelyman
Colelyman / install.sh
Created January 2, 2018 21:02
How to link software installed in a custom location using autotools.
# to be run within your project that is built with autotools (aka has a configure script)
# replace the text within '<...>' with the respective paths
export LD_LIBRARY_PATH=<lib directory of the library>:$LD_LIBRARY_PATH
./configure CPPFLAGS="-I<include directory of the library> -L<lib directory of the library>"
make CPPFLAGS="-I<include directory of the library> -L<lib directory of the library>" LDFLAGS="-I<include directory of the library> -L<lib directory of the library>"
@Colelyman
Colelyman / sbatch_tricks.sh
Created December 9, 2017 07:15
Some tricks for doing cool things with sbatch scripts.
# start a job after another job succeeds
JOBID=$(sbatch --parsable job1.sh) && sbatch --dependency=afterok:$JOBID job2.sh
# start a job after another job fails
JOBID=$(sbatch --parsable job1.sh) && sbatch --dependency=afternotok:$JOBID job2.sh
# get the time and memory of a running node
sstat --format="CPUTime,Elapsed,MaxRSS" -j $SLURM_JOB_ID
@Colelyman
Colelyman / tibble-dplyr-tricks.R
Last active March 25, 2017 22:02
Useful tricks for manipulating tibbles with dplyr that I have found useful.
library(tibble)
# create a tibble with no rows, but defined columns
tbl <- tibble(name=character(), age=numeric(), gender=factor())
# add a row to the tibble. The values can even be vectors!!
tbl <- add_row(tbl, name='Steve', age='24', gender='male')