Skip to content

Instantly share code, notes, and snippets.

View widdowquinn's full-sized avatar

Leighton Pritchard widdowquinn

View GitHub Profile
library(ggplot2)
library(reshape2)
# Load data, and rerank teams by points
data = read.table("SL_points.txt", sep="\t", header=T)
data$old_rank = rank(-data$Old, ties.method="first")
data$bonus_rank = rank(-data$Bonus, ties.method="first")
data$penalty_rank = rank(-data$Penalty, ties.method="first")
# New dataframe of ranked teams under each scheme
@widdowquinn
widdowquinn / get_kgml_file.py
Created January 30, 2013 18:32
A very short example of using the KGML_scrape utility functions to download a specific KEGG pathway, by pathway ID.
from KGML_scrape import retrieve_kgml_to_file
retrieve_kgml_to_file('ddc00190', 'ddc00190.kgml')
@widdowquinn
widdowquinn / KGML_scrape_iPython_example.txt
Created January 30, 2013 18:44
A worked example of three modes of obtaining KEGG pathways using KGML_scrape: (1) KGML as a string; (2) a stream/handle containing KGML; (3) as a KGMLPathway object.
In [1]: from KGML_scrape import *
In [2]: ex1 = retrieve_kgml('eco00010')
In [3]: ex1[:100]
Out[3]: '<?xml version="1.0"?>\n<!DOCTYPE pathway SYSTEM "http://www.genome.jp/kegg/xml/KGML_v0.7.1_.dtd">\n<!-'
In [4]: ex2 = retrieve_kgml_stream('ype02040')
In [5]: type(ex2)
Out[5]: instance
In [6]: ex2.readline()
Out[6]: '<?xml version="1.0"?>\n'
In [7]: ex3 = retrieve_KEGG_pathway('ara01120')
@widdowquinn
widdowquinn / kgml_ex1.py
Created February 1, 2013 17:45
Example code to generate three metabolic maps with different rendering options.
import KGML_parser
from KGML_scrape import retrieve_KEGG_pathway
from KGML_vis import KGMLCanvas
# Get the ko01110 map from KEGG, and write it out to file, visualised as
# the .png, and as the elements from the KGML file
pathway = retrieve_KEGG_pathway('ko01110')
kgml_map = KGMLCanvas(pathway, show_maps=True)
# Default settings are for the KGML elements only
kgml_map.draw('ex1_kgml_render.pdf')
@widdowquinn
widdowquinn / kgml_ex2.py
Created February 1, 2013 18:07
Example code to generate three renderings of a non-metabolic KEGG pathway, with important information in the .png.
import KGML_parser
from KGML_scrape import retrieve_KEGG_pathway
from KGML_vis import KGMLCanvas
from Bio.Graphics.ColorSpiral import ColorSpiral
# Get the ko03070 map from KEGG, and write it out to file, visualised as
# the .png, and as the elements from the KGML file
pathway = retrieve_KEGG_pathway('ko03070')
kgml_map = KGMLCanvas(pathway, show_maps=True)
@widdowquinn
widdowquinn / kgml_ex3.py
Created February 1, 2013 18:45
Example code to generate three renderings of a modified metabolic map, highlighting a specific set of pathways.
import KGML_parser
from KGML_scrape import retrieve_KEGG_pathway
from KGML_vis import KGMLCanvas
# Get list of pathway elements to enhance
glyc_path = retrieve_KEGG_pathway('ko00010')
tca_path = retrieve_KEGG_pathway('ko00020')
enhance_list = []
for pathway in (glyc_path, tca_path):
for e in pathway.entries.values():
@widdowquinn
widdowquinn / chlorobium.txt
Last active December 27, 2015 20:48
Download locations for Chlorobium genomes.
ftp://ftp.ncbi.nih.gov/genomes/Bacteria/Chlorobium_chlorochromatii_CaD3_uid58375/NC_007514.fna
ftp://ftp.ncbi.nih.gov/genomes/Bacteria/Chlorobium_limicola_DSM_245_uid58127/NC_010803.fna
ftp://ftp.ncbi.nih.gov/genomes/Bacteria/Chlorobium_luteolum_DSM_273_uid58175/NC_007512.fna
ftp://ftp.ncbi.nih.gov/genomes/Bacteria/Chlorobium_phaeobacteroides_BS1_uid58131/NC_010831.fna
ftp://ftp.ncbi.nih.gov/genomes/Bacteria/Chlorobium_phaeobacteroides_DSM_266_uid58133/NC_008639.fna
ftp://ftp.ncbi.nih.gov/genomes/Bacteria/Chlorobium_phaeovibrioides_DSM_265_uid58129/NC_009337.fna
ftp://ftp.ncbi.nih.gov/genomes/Bacteria/Chlorobium_tepidum_TLS_uid57897/NC_002932.fna
@widdowquinn
widdowquinn / chlorobium_dl.txt
Last active December 27, 2015 20:49
Grab Chlorobium genome sequences, using the chlorobium.txt file.
mkdir test_isolates
cd test_isolates/
wget -i chlorobium.txt
cd ..
@widdowquinn
widdowquinn / chlorobium_cmd.txt
Last active December 27, 2015 20:49
Command lines for running the calculate_ani.py script on downloaded Chlorobium sequences in the test_isolates subdirectory, drawing graphical output and keeping a verbose log in each case.
time python calculate_ani.py -i test_isolates/ -m ANIb -o chlorobium_anib -g -v -l chlorobium_anib.log
time python calculate_ani.py -i test_isolates/ -m ANIm -o chlorobium_anim -g -v -l chlorobium_anim.log
time python calculate_ani.py -i test_isolates/ -m TETRA -o chlorobium_tetra -g -v -l chlorobium_tetra.log
@widdowquinn
widdowquinn / anaplasma_cmd.txt
Created November 10, 2013 10:05
Commands for running Anaplasma blog examplestime python calculate_ani.py -i test_anaplasma/ -m ANIb -o anaplasma_anib -g
time python calculate_ani.py -i test_anaplasma/ -m ANIb -o anaplasma_anib -g
time python calculate_ani.py -i test_anaplasma/ -m ANIb -o anaplasma_anib -g -v --noclobber -f --format png --skip_blast
time python calculate_ani.py -i test_anaplasma/ -m ANIm -o anaplasma_anim -g -v
time python calculate_ani.py -i test_anaplasma/ -m ANIm -o anaplasma_anim -g -v --noclobber -f --format png --skip_nucmer
time python calculate_ani.py -i test_anaplasma/ -m TETRA -o anaplasma_tetra -g -v -f
time python calculate_ani.py -i test_anaplasma/ -m TETRA -o anaplasma_tetra -g -v -f --format png