This file contains 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
public static String fixLinks(String src, Wiki target) { | |
// add a marker to all the links so we can iterate through them (except the ones that point to wikipedia) | |
String src2 = src.replaceAll("\\[\\[(?!(wikipedia))", "[[%"); | |
try { | |
while (src2.contains("[[%")) { | |
// extract the link text | |
int a = src2.indexOf("[[%")+3; // left inner bound |
This file contains 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
postParams.add(new BasicNameValuePair("longestOnly","false")); | |
postParams.add(new BasicNameValuePair("wholeWordOnly","true")); | |
postParams.add(new BasicNameValuePair("filterNumber", "true")); | |
postParams.add(new BasicNameValuePair("stopWords","protein,gene,disease,disorder,cell,syndrome,CAN")); | |
postParams.add(new BasicNameValuePair("withDefaultStopWords","true")); | |
postParams.add(new BasicNameValuePair("isTopWordsCaseSensitive","false")); | |
postParams.add(new BasicNameValuePair("mintermSize","3")); | |
postParams.add(new BasicNameValuePair("scored", "true")); | |
postParams.add(new BasicNameValuePair("withSynonyms","true")); | |
postParams.add(new BasicNameValuePair("ontologiesToExpand", "")); |
This file contains 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 | |
import re | |
import json | |
import clint | |
def import_go(gofile='go.json'): | |
try: | |
return json.loads(json.load(open(gofile))) | |
except IOError: |
This file contains 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 sqlite3 | |
import multiprocessing | |
store_results_sql = """ some sql code here """ | |
select_results_sql = """ some other sql code here """ | |
def find_enriched(**kwargs): | |
# do some heavy computation task here | |
results = enrichment_analysis(**kwargs) | |
# sqlite is not ideal for parallel processing, but with a timeout it should be fine |
This file contains 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 | |
"""Usage: python taxonomy_fixer.py [FILE] | |
Converts an ITS taxonomy file to eliminate taxa marked as unidentified, | |
swaps [kpcofg]__unidentified;s__Fungi to k__Fungi, and eliminates species | |
taxa that are simply s__[genus]_sp. | |
Writes to stdout. | |
""" | |
# Erik Clarke <ecl@mail.med.upenn.edu> |
This file contains 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
function toggleproxy { | |
# checks to see if SOCKS proxy is enabled | |
if [[ $(networksetup -getsocksfirewallproxy Wi-Fi | grep '^Enabled') == "Enabled: No" ]]; then | |
networksetup -setsocksfirewallproxystate Wi-Fi on | |
echo "SOCKS on!" | |
# checks to see if there's an existing SSH tunnel and if not, it starts one | |
if [[ -z $(ps aux | grep '[0-9] ssh -D 8080') ]]; then | |
echo -ne "Don't see a ssh tunnel on 8080 active, starting one now..." | |
ssh -D 8080 -f -C -q -N USERNAME@HOSTNAME.EDU # Change this from the defaults! | |
[[ $? == 0 ]] && echo " success!" || echo " failed :(" |
This file contains 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
prop_presence_absence <- function(otu.pa, groups) { | |
# Creates a proportional presence-absence melted dataframe suitable for use in | |
# ggplot heatmaps to show varying within-group proportions of species. | |
# | |
# Args: | |
# otu.pa: Matrix of presence-absence data. Columns are samples, rows are | |
# species. | |
# groups: Grouping data frame. A column named "SampleID" should be unique | |
# list of sample identifiers that match the column names of otu.pa. | |
# The other column, named "group", should correspond to the group |
This file contains 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
# Multiple plot function | |
# | |
# ggplot objects can be passed in ..., or to plotlist (as a list of ggplot objects) | |
# - cols: Number of columns in layout | |
# - layout: A matrix specifying the layout. If present, 'cols' is ignored. | |
# | |
# If the layout is something like matrix(c(1,2,3,3), nrow=2, byrow=TRUE), | |
# then plot 1 will go in the upper left, 2 will go in the upper right, and | |
# 3 will go all the way across the bottom. | |
# |
This file contains 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
plot_ggheatmap <- function(obj, n=nrow(obj), norm=TRUE, log=TRUE, | |
colnames.in.pdata="NewSampleID", | |
col.labels=NULL, | |
row.labels=NULL, | |
facet.by=NULL, | |
annotate.cols=NULL, | |
dendrogram=FALSE, | |
col.annotation.offset=1, | |
col.annotation.width=4) { | |
## |
This file contains 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
(defun ensure-in-vc-or-checkin () | |
(interactive) | |
(if (file-exists-p (format "%s" (buffer-file-name))) | |
(progn (vc-next-action nil) (message "Committed")) | |
(ding) (message "File not checked in."))) | |
(defun export-bibtex () | |
"Exports Papers library using a custom applescript." | |
(interactive) | |
(message "Exporting papers library...") |
OlderNewer