Skip to content

Instantly share code, notes, and snippets.

View tpoisot's full-sized avatar
🌴
On vacation

Timothée Poisot tpoisot

🌴
On vacation
View GitHub Profile
@tpoisot
tpoisot / flat.yml
Created January 25, 2014 23:36
Base16 scheme file for a FlatUI inspired color theme
# Flat scheme for the Base16 Builder (https://github.com/chriskempson/base16-builder)
scheme: "flat"
author: "Timothée Poisot (http://github.com/tpoisot)"
base00: "2c3e50" # ----
base01: "475767" # ---
base02: "62707d" # --
base03: "7e8a94" # -
base04: "99a3ab" # +
base05: "b5bdc3" # ++
base06: "d0d6da" # +++
import networkx as nx
import numpy as np
import itertools
## We define each S* motif as a directed graph in networkx
motifs = {
'S1': nx.DiGraph([(1,2),(2,3)]),
'S2': nx.DiGraph([(1,2),(1,3),(2,3)]),
'S3': nx.DiGraph([(1,2),(2,3),(3,1)]),
'S4': nx.DiGraph([(1,2),(3,2)]),
@tpoisot
tpoisot / crossref.py
Created January 17, 2014 00:56
I've invented a way NOT to get a citation from a DOI using the crossref API
#! /usr/bin/python2
import requests as re
doi = "10.1002/ece3.508"
base = "http://dx.doi.org/"
url = base + doi
@tpoisot
tpoisot / ecology.py
Created January 8, 2014 17:15
Read random tweets, and tweets mentioning words related to ecology
#! /usr/bin/python2
import json
from TwitterAPI import TwitterAPI
c_key = '...'
c_sec = '...'
t_key = '...'
t_sec = '...'
@tpoisot
tpoisot / autotaxaNCBI.r
Created January 7, 2014 21:31
Automatic curation of the mangal DB : fill in NCBI IDs using taxize
library(rmangal)
library(taxize)
api = mangalapi(usr='tpoisot', pwd='nope, not telling you')
all_taxa = listTaxa(api)
for(tax in all_taxa)
{
identifier <- get_uid(tax$name, ask = FALSE)
if(! is.na(identifier)) tax$ncbi <- identifier[1]
@tpoisot
tpoisot / 3d-metapop.r
Created November 19, 2013 16:20
Metapopulation model in 2 or 3D, using R / igraph
# Metapop model in R
library(igraph)
library(plyr)
library(reshape2)
library(RColorBrewer)
colorize <- function(x, pal='Oranges')
{
x <- x - min(x)
@tpoisot
tpoisot / extractbib.py
Created November 11, 2013 02:44
Usage: extractbib.py bib.keys main/library/file.bib refs.bib see http://timotheepoisot.fr/2013/11/10/shared-bibtex-file-markdown/ for more details
#! /usr/bin/python2
import sys
import codecs
from bibtexparser.bparser import BibTexParser
def dict2bib(ke,di):
b = "@"+di['type'].upper()+"{"+ke+","
for (k, v) in di.iteritems():
if k not in ['type', 'id', 'abstract', 'doi', 'keywords']:
@tpoisot
tpoisot / makefile
Created November 4, 2013 01:52
Model of plankton dynamics
comp=clang
opt= -O3 -DWall -lgsl -lgslcblas -DHAVE_INLINE -lm
src=src.c
out=lagoon
$(out): $(src)
$(comp) $(src) -o $(out) $(opt)
simuls: $(out)
./$(out)
@tpoisot
tpoisot / scriptoria-scheme.json
Created October 27, 2013 17:25
Scheme for scriptoria papers
{
"$schema": "http://json-schema.org/draft-04/schema#",
"title": "Scriptoria object",
"description": "Meta-data about a publication registered in scriptoria",
"type": "object",
"properties": {
"source": {
"description": "URI of the original repository",
"type": "string"
},
@tpoisot
tpoisot / transf.py
Last active December 25, 2015 11:19
python2 script to read an OTU file in mothur format, select a cutoff level, and write the file in qiime format Usage: ./transf.py mothurfile cutoff LICENSE: BSD 2
#! /usr/bin/python
# Timothee Poisot
# [email protected]
# released under the BSD 2 license
import sys
def onlyNonEmpty(table):
N_non_empty = int(table[1][2]) + 3