Skip to content

Instantly share code, notes, and snippets.

View widdowquinn's full-sized avatar

Leighton Pritchard widdowquinn

View GitHub Profile
@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 / paradox.py
Created February 9, 2013 17:32
Python code to illustrate the Tuesday Boy paradox ("I have two children. One is a boy born on a Tuesday. What is the probability I have two boys") for a blog post.
# paradox.py
#
# Python code to illustrate the Tuesday Boy paradox ("I have two children.
# One is a boy born on a Tuesday. What is the probability I have two boys")
# for a blog post.
#
# We're simulating two sampling modes to illustrate how the approach to
# sampling, and posing the initial question, is important. This has general
# implications for what we can reasonably infer from experiments where we
# did not design the experiment to answer a specific question.
@widdowquinn
widdowquinn / boy-girl.py
Created March 10, 2013 13:02
Python code to illustrate the Tuesday Boy paradox ("I have two children. One is a boy born on a Tuesday. What is the probability I have two boys") for a blog post. This time, unlike paradox.py, parents with one child of either sex are free to choose which child they tell you about, and rephrase the question accordingly.
# boy-girl.py
#
# Python code to illustrate the Tuesday Boy paradox ("I have two children.
# One is a boy born on a Tuesday. What is the probability I have two boys")
# for a blog post.
#
# This time, unlike paradox.py, we're not assuming that there is preselection
# for telling you that one of the children is a boy, or a boy born on a Tuesday.
# This radically alters the solution of the problem.
#
@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