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
# Copy SSH keys to remote server for passwordless login | |
ssh-copy-id <username>@<remote.server> | |
ssh -XY <username>@<remote.server> | |
# Additionally add this to ~/.ssh/config file | |
Host <name> | |
User <username_on_remote_server> | |
HostName <remote.server> | |
proxyCommand ssh -W <remote.server>:22 <username>@<login.server> | |
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 pandas as pd | |
BLAST_output_file = "" # set to the path of the BLAST output file | |
df = pd.read_csv(BLAST_output_file, | |
sep="\t", | |
header=None, | |
names=["query_id", "subject_id", "pct_identity", "aln_length", "n_of_mismatches", | |
"gap_openings", "q_start", "q_end", "s_start", "s_end", "e_value", "bit_score"]) |
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
codes = ["EXP", "IDA", "IPI", "IMP", "IGI", "IEP", # experimental | |
"ISS", "ISO", "ISA", "ISM", "IGC", "IBA", "IBD", "IKR", "IRD", "RCA", "IC", "TAS", # curated | |
"IEA"] # automatically-assigned |
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
from scipy import sparse | |
# generate a random sparse matrix | |
M = sparse.random(100,100) | |
M | |
# <100x100 sparse matrix of type '<class 'numpy.float64'>' | |
# with 100 stored elements in COOrdinate format> | |
# create boolean array of the data stord in the sparse matrix |
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
# dependencies: conda, autoenv | |
# cd into dir containing environment.yml file and run: conda env create | |
# save this gist to file named .env in the dir | |
# run: source /usr/local/opt/autoenv/activate.sh | |
# set to the name of the Anaconda environment contained in environment.yml | |
venv= | |
# get the current environment |
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
organism=spo | |
# Download S. pombe KEGG pathways | |
wget -O kegg_pathways.tsv http://rest.kegg.jp/list/pathway/${organism} | |
ids=$(cut -f1 kegg_pathways.tsv) | |
for id in $ids; do | |
wget -O ${id}.json http://togows.dbcls.jp/entry/pathway/${id}/genes.json | |
done |
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
## e.g. for NetworkX (https://github.com/networkx/networkx/blob/master/CONTRIBUTE.rst) | |
## set up repo | |
# fork repo on GitHub | |
cd ~/git | |
git clone git@github.com:harryscholes/networkx.git | |
cd networkx | |
git remote add upstream git@github.com:networkx/networkx.git | |
git checkout master |
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 string, secrets | |
pool = list(string.ascii_uppercase[:] + str(9)) | |
seed = "".join(secrets.choice(pool) for _ in range(81)) |
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
# set these to the name of the markdown file exported from Dropbox Paper and the desired name of the LaTeX file | |
MARKDOWN_FILE= | |
LATEX_FILE= | |
# Dropbox uses '$$' for markdown math, so this must be replaced with '$' | |
sed -i '' -e 's/\$\$/\$/g' $MARKDOWN_FILE | |
# convert markdown to LaTeX | |
pandoc $MARKDOWN_FILE -f markdown -t latex -o $LATEX_FILE --mathjax --top-level-division=chapter --wrap=none |
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
class Meta(type): | |
""" | |
Flexible metaclass for defining useful decorator functions. | |
""" | |
def __new__(cls, clsname, bases, clsdict): | |
clsobj = super().__new__(cls, clsname, bases, clsdict) | |
return clsobj | |
class Base(object, metaclass=Meta): |
OlderNewer