Skip to content

Instantly share code, notes, and snippets.

class Thing:
def speak(self) -> str:
raise NotImplementedError("Things don't inherently speak.")
class Rock(Thing):
def speak(self, msg):
return ValueError("Rocks cannot speak")
class Plant(Thing):
def speak(self) -> str:
from pyteomics import parser, mass
import matplotlib.pyplot as plt
# ============================
# 1. Define protein sequence
# ============================
protein_seq = "RELEELNVPGEIVESLSSSEESITRINKKIEKFQSEEQQQTEDELQDKIHPFAQTQSLVYPFPGPI"
# ============================
# 2. In-silico trypsin digestion
import numpy as np
import matplotlib.pyplot as plt
import argparse
import os
def generate_vectors(num_slots, num_values, spacing, variance, diff_variance, diff_positions, diff_weight=1, aligned=True):
"""Generate two vectors with specified characteristics."""
if spacing == "even":
positions = np.linspace(0, num_slots - 1, num_values, dtype=int)
else:
# Load required libraries
library(cmapR) # For handling GCT files
library(ComplexHeatmap) # For visualization, see https://jokergoo.github.io/ComplexHeatmap-reference/book/ for a complete reference
library(RColorBrewer) # For color palettes
library(dplyr)
make_random_gct <- function(nrow = 100, ncol = 10) {
set.seed(369)
nrow <- max(nrow, 1)
ncol <- max(ncol, 1)
import pickle
import hashlib
import time
import os
import pandas as pd
from datetime import datetime
class BaseCache:
"""Base class for caching strategies."""
def __init__(self):
@asalt
asalt / maxquant_separate_experiments.py
Created September 12, 2018 01:12
Simple script to separate MaxQuant experiments
"""
Simple script to separate MaxQuant experiments
"""
import os
import sys
import numpy as np
import pandas as pd
def main(f):
df = pd.read_table(f)
@asalt
asalt / make_iter.py
Last active March 10, 2016 21:49
Decorator to make a specific argument an iterator
from functools import wraps
def make_iterable(argn=0, exceptions=[]):
"""Check to make sure an argument is an iterator.
Default argument is args[0]
Add exceptions that you wish to enclose in an iterator by providing an
iterator of their type.
Ironically, exceptions must be encapsulated in an iterator"""
def decorate(func):
@wraps(func)
@asalt
asalt / latex_hide_figure.tex
Created January 21, 2016 21:15
How to hide whole sections in a latex document.
%http://tex.stackexchange.com/questions/77920/comment-package-excludecomment-gives-error
\documentclass[12pt]{article}
\usepackage{todonotes} % \missingfigure
\usepackage{comment} % to exclude whole sections when I want to
\newif\ifshow % toggle true or false based on if want to hide section
%\showtrue % show the sections
\showfalse % hide the sections
\ifshow
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
#check if files in directory aren't in log of previously encountered log
from time import sleep
def filechecker():
print '{} : Checking for new files...'.format(time.ctime())
try : log = open('filelog.log','r+U') #open log file in append mode
except : log = open('filelog.log','ab+') # if it doesn't exist, create it
files = [line.strip('\n') for line in log.readlines()] # list of all files in log
for f in os.listdir(inputdir): # iterate through all files in directory