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 / lv-comp.c
Created August 28, 2013 15:36
Model to reproduce the Box 2 of Gravel et al. 2011. C, uses the GSL, makefile included. Compiles on Arch 3.10.1 with clang and gcc. Gravel D., Guichard F. & Hochberg M.E. 2011. Coexistence in a variable world. Ecology Letters doi: 10.1111/j.1461-0248.2011.01643.x
// Compile with make
// Change the comp variable to gcc or clang
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <gsl/gsl_rng.h>
@tpoisot
tpoisot / makefile
Created August 28, 2013 13:05
Stochasticity in the logistic growth model, using the GSL. makefile included.
prog = logstoch
source = stoch.c
comp = gcc
flags = -lgsl -lgslcblas -O3 -DHAVE_INLINE
$(prog): $(source)
$(comp) $(source) -o $(prog) $(flags)
@tpoisot
tpoisot / bifurc.r
Created August 27, 2013 15:57
Bifurcation diagram for a badly integrated logistic growth model. Can be a little bit long to run. If so, just change the number of r used to fraw the figure.
pdyn = function(N, r, K, t)
{
for(i in c(1:(t-1))) N[i+1] = N[i] + r*N[i]*(1-N[i]/K)
return(N)
}
getNs = function(N, r, K, t, record)
{
N = pdyn(N, r, K, t)
Ns = unique(N[(length(N)-record):length(N)])
@tpoisot
tpoisot / zot-stats.py
Created July 9, 2013 16:37
Number of papers / journal in your zotero library
#!/bin/bash/env python2
# -*- coding: utf-8 -*-
zotdb = "zot.sqlite"
import json
import sys
import sqlite3 as lite
def count(array):
counts = {}
@tpoisot
tpoisot / nogaps.py
Last active December 27, 2021 23:19
#!/usr/bin/python
### Blast a list of fasta files
### Returns the results and measure similarity IGNORING gaps
###
### Tim Poisot - [email protected]
### May 20, 2013
### This code is in the public domain
from Bio.Blast import NCBIXML
@tpoisot
tpoisot / nb.c
Created May 6, 2013 22:27
Nicholson Bailey in space (in C)
// clang nb-sp.c -o nb -lgsl -lgslcblas -O3 -DHAVE_INLINE
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <sys/time.h>
#include <string.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
@tpoisot
tpoisot / nb.py
Created May 6, 2013 22:26
Nicholson Bailey in space (python)
import numpy as np
import scipy as sp
import matplotlib.pyplot as plt
from progressbar import *
# Simulation time
SimTime = 500
# A spatial version of the NB model
# Make a movie with
@tpoisot
tpoisot / zotero-standalone.desktop
Last active September 27, 2018 21:40
zotero desktop file for the standalone version in fedora -- https://developer.gnome.org/integration-guide/stable/desktop-files.html.en
[Desktop Entry]
Name=Zotero Standalone
Exec=/usr/local/bin/Zotero_linux-x86_64/zotero
Icon=/usr/local/bin/Zotero_linux-x86_64/chrome/icons/default/default48.png
Type=Application
Categories=Education;
@tpoisot
tpoisot / nichemodel.c
Created February 20, 2013 21:17
Niche model in c
// gcc niche.c -o nm -lgsl -lgslcblas -O3 -DHAVE_INLINE
// clang niche.c -o nm -lgsl -lgslcblas -O3 -DHAVE_INLINE
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <time.h>
#include <string.h>
#include <gsl/gsl_rng.h>
#include <gsl/gsl_randist.h>
@tpoisot
tpoisot / nichemodel.py
Created February 20, 2013 03:16
Niche model of food webs in python
def niche_foodweb(S, C):
G = nx.DiGraph()
G.add_nodes_from([n for n in xrange(S)])
## Step 1 - create random species
for n in G:
G.node[n]['n'] = np.round(np.random.uniform(),2)
G.node[n]['r'] = np.random.beta(1, 1/float(2*C)-1) * G.node[n]['n']
G.node[n]['c'] = np.random.uniform(G.node[n]['r']/float(2),G.node[n]['n'])
## Step 2 - smallest species are basal
Smallest = np.min([G.node[n]['n'] for n in G])