Skip to content

Instantly share code, notes, and snippets.

View alistairwalsh's full-sized avatar

Alistair Walsh alistairwalsh

  • Reservoir, Victoria, Australia
View GitHub Profile
@alistairwalsh
alistairwalsh / pubmed_search.py
Created May 17, 2017 06:06 — forked from langner/pubmed_search.py
A class that searches Pubmed for a list of PMIDs via the BioPython Entrez module and returns the results in a simpler dictionary format.
"""Tools for searching Pubmed for a list of PMIDs.
The goal here is to search for many PMIDs at once, since searching
sequentially can take a long time. Using the the BioPython Entrez module
is super convenient to this end.
The results results are returned in a simple dictionary format.
"""
@alistairwalsh
alistairwalsh / plos_sunburnt_demo.py
Created November 25, 2016 01:28 — forked from drewbuschhorn/plos_sunburnt_demo.py
PLOS API code for use with SunBurnt
#Sample PLOS api code for use with python Solr library Sunburnt
#( https://github.com/tow/sunburnt )
#!Note! requires sunburnt's external libraries: httplib2,lxml
#https://groups.google.com/d/topic/plos-api-developers/zv591sFz6TM/discussion
import sunburnt,urllib2
class PlosInterface(sunburnt.SolrInterface):
def __init__(self,api_key):
plos_url = "http://api.plos.org/search"
#either
1 2.12371 0
2 1.05275 0
3 0.865794 0
4 0.933986 0
5 1.09092 0
6 1.22333 0
7 1.54639 0
8 1.24223 0
9 1.10928 0
10 1.16232 0
@alistairwalsh
alistairwalsh / imputant.py
Created September 15, 2015 08:31
Impute missing values
import numpy as np
from sklearn.preprocessing import Imputer
#generate some data
df1 = np.array(np.random.randn(1000)).reshape(100,10)
#make some values 'NaN'
df1[(df1>-.05) & (df1<.05)] = np.nan
X = df1
@alistairwalsh
alistairwalsh / function and loop
Created February 19, 2015 12:24
Suggestion for a memorable loop and function example
def peel(name):
return name[1:-1]
bag = ['dutch cream','desiree','kifler']
for potato in bag:
print peel(potato)