Skip to content

Instantly share code, notes, and snippets.

View CnrLwlss's full-sized avatar

Conor Lawless CnrLwlss

View GitHub Profile
@CnrLwlss
CnrLwlss / Resize.py
Last active December 15, 2015 22:00
Find all images in the current directory and generate resized versions, together with a single preview file displaying all patched versions pasted together.
import PIL, os, math
from PIL import Image
resizeWidth=500
allfiles=os.listdir(os.getcwd())
filelist=[f for f in allfiles if f[-4:] in ['.jpg','.JPG','.jpeg','.JPEG','.png','.PNG']]
Nimages=len(filelist)
im0=Image.open(filelist[0])
w,h=im0.size
@CnrLwlss
CnrLwlss / align.sh
Last active December 19, 2015 02:39
Aligning yeast sequences to a reference genome.
#!/bin/bash
echo Making indices...
# Set up path to include bowtie2 and samtools
export PATH=$PATH:/home/username/bowtie2-2.1.0:/home/username/samtools:/home/username/samtools/bcftools:/home/username/samtools/misc
# Generate an index file from the reference genome
bowtie2-build reference_SGD/S288C_reference_genome_R64-1-1_20110203/S288C_reference_sequence_R64-1-1_20110203.fsa indices/SGD_S288C
roots=(
@echo off
:: Make indices
bowtie2-build reference_SGD/S288C_reference_genome_R64-1-1_20110203/S288C_reference_sequence_R64-1-1_20110203.fsa indices/SGD_S288C
for /f "tokens=*" %%x in (roots.txt) do (
echo %%x
:: Align reads
bowtie2-align -x indices/SGD_S288C -1 data/%%x_1_sequence.fq -2 data/%%x_2_sequence.fq -S alignments/%%x.sam -p 12 --end-to-end
)
@CnrLwlss
CnrLwlss / Coverage.R
Last active December 19, 2015 04:09
library(ShortRead)
# Root of .bam filename
sname="HG00100.unmapped.ILLUMINA.bwa.GBR.low_coverage.20130415"
# Construct path to file
fname=file.path("alignments",paste(sname,".bam",sep=""))
# Read alignments
bm=readGappedAlignments(fname)
#!/bin/bash
echo Generating consensus sequences
export PATH=$PATH:/home/username/bowtie2-2.1.0:/home/username/samtools:/home/username/samtools/bcftools:/home/username/samtools/misc
roots=(
SN7640178_10172_8183
SN7640178_10173_8265
SN7640178_10174_8266
@CnrLwlss
CnrLwlss / mtDNA.R
Last active December 19, 2015 06:19
Generating a circular plot of sequencing coverage along the mitochondrial genome, annotating gene locations.
#source("http://bioconductor.org/biocLite.R")
#biocLite("ecolitk")
#biocLite("ShortRead")
library(ecolitk)
library(plotrix)
library(ShortRead)
# Read in some alignments
getReads=function(fname,rad=1.5,readmax=29000,logb=10){
bm=readGappedAlignments(fname)
@CnrLwlss
CnrLwlss / CheckGenes.py
Last active December 19, 2015 09:39
Example script demonstrating the use of BioPython to compare genomic sequences at a given gene location. See http://cnr.lwlss.net/seqConsensus
# http://cnr.lwlss.net/seqConsensus
import os
from Bio import SeqIO
def checkMutations(ref_dict, roots, genedict,showSeq=False):
'''Comparing a reference sequence (ref_dict) with a series of sample sequences.'''
# Sample sequences are read in from .fastq files in a "pileups" directory.
# Filenames are constructed from a list of roots (e.g. filenames without extensions).
# A Python dictionary specifying genes to analyze connects gene labels (e.g. "HIS3") with a tuple of chromosome number, start position and stop position (e.g. (15,721946,722608)).
@CnrLwlss
CnrLwlss / ChemReactionNet.R
Created November 30, 2013 16:00
Describing and simulating the ODEs representing a chemical network, and plotting the simulated output.
# Install and load ODE solver package
install.packages("deSolve")
library(deSolve)
# Named vector of parameter values
parameters=c(k1=0.15,k2=0.075,V=1.0)
# Named vector of initial conditions
state=c(A=4,B=2,AB=0)
<?xml version="1.0" encoding="UTF-8"?>
<sbml xmlns="http://www.sbml.org/sbml/level2/version3" level="2" version="3">
<model id="ProteinExample">
<listOfCompartments>
<compartment id="cell" size="1"/>
</listOfCompartments>
<listOfSpecies>
<species id="A" compartment="cell" initialAmount="4"/>
<species id="B" compartment="cell" initialAmount="2"/>
<species id="AB" compartment="cell" initialAmount="0"/>
@CnrLwlss
CnrLwlss / ProtExample.mod
Last active December 29, 2015 20:19
SBML-shorthand version of https://gist.github.com/CnrLwlss/7720846 You can quickly convert this shorthand to full SBML with this useful tool: http://semanticsbml.org/semanticSBML/default/shorthand_sbml Note that you need to include a blank line at the end of the shorthand.
@model:2.3.1=ProteinExample
@compartments
cell=1
@species
cell:A=4
cell:B=2
cell:AB=0
cell:NULL=0
@parameters
k1=0.15