Skip to content

Instantly share code, notes, and snippets.

View yannabraham's full-sized avatar

Yann Abraham yannabraham

  • Janssen Pharmaceutical Companies of Johnson & Johnson
  • Beerse (BE)
View GitHub Profile
//Demonstrates basic manipulation to predict a EI-MS in Bioclipse using
//a sdf file containing a list of molecule.
//Requires medea data installed in default location
var mols = cdk.loadMolecules("/Sample Data/SDFfiles/CAS.5.sdf");
for (var i = 0; i < mols.size(); i++) {
var mol = mols.get(i);
mol = cdk.generate2dCoordinates(mol);
ui.open(mol);
cmlSpectrum = medea.predictMassSpectrum(mol)
@mattismyname
mattismyname / imgupload.py
Created January 3, 2011 04:20
Python script to upload a batch of files to Evernote
#!/usr/bin/env python
#
# To run, first set this environment variable to point to the Evernote API python bindings you downloaded from Evernote:
# export PYTHONPATH=/path/to/evernote/python/api
#
import sys
import hashlib
import time
import thrift.protocol.TBinaryProtocol as TBinaryProtocol
@drewconway
drewconway / noticeEMail.py
Created April 12, 2011 20:42
Sends an email message through GMail once the script is completed. Developed to be used with AWS (or other system) so that instances can be terminated once a long job is done. Only works for those with GMail accounts.
#!/usr/bin/env python
# encoding: utf-8
import smtplib
from datetime import datetime
def noticeEMail(starttime, usr, psw, fromaddr, toaddr):
"""
Sends an email message through GMail once the script is completed.
@lindenb
lindenb / translate.html
Created April 22, 2011 20:29
Translate a DNA to protein using HTML5+ File API.
<html>
<head>
</head>
<body>
<form>
<label for="ZmlsZXMKfiles">Select a FASTA file</label>:<input type="file" id="ZmlsZXMKfiles" multiple="true"/>
</form>
<script type="application/ecmascript">
@mbostock
mbostock / .block
Last active February 26, 2019 22:38
Horizon Chart
license: gpl-3.0
redirect: https://observablehq.com/@d3/d3-horizon-chart
@simecek
simecek / facebook_friendship1.r
Created January 18, 2012 11:28
Facebook Friendship Graph
# the code uses 'facebook' function from the previous gist (https://gist.github.com/1634662) or
# see the original http://romainfrancois.blog.free.fr/index.php?post/2012/01/15/Crawling-facebook-with-R
# scrape the list of friends
friends <- facebook( path="me/friends" , access_token=access_token)
# extract Facebook IDs
friends.id <- sapply(friends$data, function(x) x$id)
# extract names
friends.name <- sapply(friends$data, function(x) iconv(x$name,"UTF-8","ASCII//TRANSLIT"))
# short names to initials
@jeromyanglim
jeromyanglim / example-r-markdown.rmd
Created May 17, 2012 04:23
Example of using R Markdown
This post examines the features of [R Markdown](http://www.rstudio.org/docs/authoring/using_markdown)
using [knitr](http://yihui.name/knitr/) in Rstudio 0.96.
This combination of tools provides an exciting improvement in usability for
[reproducible analysis](http://stats.stackexchange.com/a/15006/183).
Specifically, this post
(1) discusses getting started with R Markdown and `knitr` in Rstudio 0.96;
(2) provides a basic example of producing console output and plots using R Markdown;
(3) highlights several code chunk options such as caching and controlling how input and output is displayed;
(4) demonstrates use of standard Markdown notation as well as the extended features of formulas and tables; and
(5) discusses the implications of R Markdown.
@bobthecat
bobthecat / Rcpp_cosine.r
Created June 9, 2012 23:29
Rcpp cosine similarity
require(inline)
require(RcppArmadillo)
## extract cosine similarity between columns
cosine <- function(x) {
y <- t(x) %*% x
res <- 1 - y / (sqrt(diag(y)) %*% t(sqrt(diag(y))))
return(res)
}
@dsparks
dsparks / stat_2d.R
Created November 13, 2012 02:06
Encoding two-dimensional density in graphical variables
doInstall <- TRUE # Change to FALSE if you don't want packages installed.
toInstall <- c("ggplot2")
if(doInstall){install.packages(toInstall, repos = "http://cran.r-project.org")}
lapply(toInstall, library, character.only = TRUE)
# Generate some randomly-distributed data
nObs <- 5000
myData <- data.frame(X = rnorm(nObs), Y = rnorm(nObs))
nClusters <- 7 # Cluster it
kMeans <- kmeans(myData, centers = nClusters)
@cengel
cengel / server.R
Created November 15, 2012 00:44
Shiny intro tutorial example rewritten for ggplot2
library(shiny)
library(datasets)
library(ggplot2) # load ggplot
# Define server logic required to plot various variables against mpg
shinyServer(function(input, output) {
# Compute the forumla text in a reactive function since it is
# shared by the output$caption and output$mpgPlot functions
formulaText <- reactive(function() {