This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import sys; from PIL import Image; import numpy as np | |
| chars = np.asarray(list(' .,:;irsXA253hMHGS#9B&@')) | |
| if len(sys.argv) != 4: print( 'Usage: ./asciinator.py image scale factor' ); sys.exit() | |
| f, SC, GCF, WCF = sys.argv[1], float(sys.argv[2]), float(sys.argv[3]), 7/4 | |
| img = Image.open(f) | |
| S = ( round(img.size[0]*SC*WCF), round(img.size[1]*SC) ) | |
| img = np.sum( np.asarray( img.resize(S) ), axis=2) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This line imports the modules we will need. The first is the sys module used | |
| # to read the command line arguments. Second the Python Imaging Library to read | |
| # the image and third numpy, a linear algebra/vector/matrix module. | |
| import sys; from PIL import Image; import numpy as np | |
| # This is a list of characters from low to high "blackness" in order to map the | |
| # intensities of the image to ascii characters | |
| chars = np.asarray(list(' .,:;irsXA253hMHGS#9B&@')) | |
| # Check whether all necessary command line arguments were given, if not exit and show a |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| a = "bla" | |
| b = "so on" | |
| class(a) = append("my_class", class(a)) | |
| '+.my_class' = function(x,y) paste(x,y,sep=" and ") | |
| print(a+b) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| library(scales) | |
| library(Hmisc) | |
| emsa_plot = ggplot(emsa, aes(x=Name, y=intensity, shape=charge_ratio, col=charge_ratio, width=0.8)) + | |
| geom_point(size=3, position=position_dodge(width=0.8)) + | |
| stat_summary(fun.data=mean_sdl, mult=0, color="black", geom="errorbar", size=1, position=position_dodge(width=0.8)) + | |
| scale_color_grey(start=0, end=0.5,name="charge ratio") + | |
| scale_shape(name="charge ratio") + | |
| scale_y_continuous(limits=c(-0.05,1), breaks=seq(0,1,by=0.2), label=percent) + |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # Caching operator executes command if there is no saved version of the data | |
| # just delete the saved file and code will be run again | |
| '%c%' = function(ex, file) if(file.exists(file), env=parent.frame(4)) load(file) else evalq(ex)) | |
| # Example | |
| # first execution | |
| { x <- rnorm(1e6); save(x, file="cache.Rd") } %c% "cache.Rd" # executes the sampling |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Rcpp::sourceCpp("matrix_reduce.cpp") | |
| #' Reduces an ExpressionSet by an n-to-n map of features to groups. All entries | |
| #' in \code{features} must exist in \code{eset}. \code{features} and | |
| #' \code{groups} must have the same length. | |
| #' | |
| #' @param eset An ExpressionSet object. | |
| #' @param features A character vector of features to be grouped. | |
| #' @param groups A factor or character vector mapping the entries in | |
| #' \code{features} to groups. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #/usr/bin/env python | |
| from cobra.test import create_test_model | |
| from cobra.flux_analysis import single_gene_deletion | |
| cobra_model = create_test_model("textbook") | |
| dels = {"b0008": 0.87, "b0114": 0.71, "b0116": 0.56, "b2276": 0.11, "b1779": 0.00} | |
| rates, statuses = single_gene_deletion(cobra_model, gene_list=dels.keys(), | |
| method="moma", solver="mosek") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ES <- function(p, w, pws, both=FALSE) { | |
| n <- length(pws) | |
| nr <- sum(abs(w[pws == p])) | |
| nh <- sum(pws == p) | |
| scores <- vector(length=n) | |
| scores[pws == p] <- abs(w[pws == p])/nr | |
| scores[pws != p] <- -1/(n - nh) | |
| r <- range(cumsum(scores)) | |
| i <- which.max(abs(r)) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import json | |
| import pandas as pd | |
| from sys import argv, exit | |
| def benchmark_to_df(json_file): | |
| with open(json_file) as jf: | |
| content = json.load(jf) | |
| df = pd.DataFrame(columns=("test", "time [ms]")) | |
| for b in content["benchmarks"]: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| { | |
| "workbench.colorTheme": "Sublime Material Theme - Dark", | |
| "workbench.iconTheme": "material-icon-theme", | |
| "editor.fontFamily": "'Fira Mono', monospace", | |
| "editor.fontSize": 17, | |
| "editor.rulers": [80], | |
| "window.zoomLevel": 0, | |
| "window.menuBarVisibility": "toggle", | |
| // Settings for Python |
OlderNewer