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 python3 | |
import sys | |
from Bio import SeqIO | |
for fn in sys.argv[1:]: | |
with open(fn, 'r') as f: | |
print('\t<data id="{}" name="alignment">'.format(fn[:-len('_unphased.nex')])) | |
for record in SeqIO.parse(f, 'nexus'): | |
if record.id.endswith('_1'): |
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 ruby | |
Encoding.default_external = "UTF-8" | |
i = 0 | |
puts STDIN.read.sub(/(WEBVTT\s+)(\d{2}:)/){|s| "#{$2}"}.gsub(/(\d{2}:\d{2})\.(\d{3}\s+)-->(\s+\d{2}:\d{2})\.(\d{3}\s*)/) { |s| | |
"#{i+=1}\n#{s.sub(/(\d{2}:\d{2})\.(\d{3}\s+)-->(\s+)(\d{2}:\d{2})\.(\d{3}\s*)/){|t| "00:#{$1},#{$2}-->#{$3}00:#{$4},#{$5}"}}" | |
} |
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 string | |
from collections import Counter | |
def leastFrequentLetters(s): | |
C = Counter(c for c in s.lower() if c in string.ascii_lowercase) | |
return ''.join(k for k in string.ascii_lowercase if C[k] == min(C.itervalues())) |
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
public static void main(String... args) throws IOException, Importer.ImportException { | |
final TreeModel tree = new TreeModel(new NewickImporter("(a:1,b:1);").importNextTree()); | |
final SimpleAlignment alignment = new SimpleAlignment(); | |
alignment.setDataType(Nucleotides.INSTANCE); | |
alignment.addSequence(new Sequence(new Taxon("a"), "A")); | |
alignment.addSequence(new Sequence(new Taxon("b"), "C")); | |
final PatternList patterns = new SitePatterns(alignment); | |
final SiteModel siteModel = new GammaSiteModel(new GTR(new Variable.D(1, 1), new Variable.D(1, 1), new Variable.D(1, 1), new Variable.D(1, 1), new Variable.D(1, 1), new Variable.D(1, 1), new FrequencyModel(Nucleotides.INSTANCE, new double[]{0.25, 0.25, 0.25, 0.25}))); | |
final TreeLikelihood likelihood = new TreeLikelihood(patterns, tree, siteModel, new DefaultBranchRateModel(), null, true, false, true, true, false); | |
final Variable<Double> var = tree.createNodeHeightsParameter(true, true, false |
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
from string import ascii_lowercase as alphabet | |
f = lambda i: alphabet[i] if i < 26 else alphabet[i / 26 - 1] + alphabet[i % 26] |
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
\documentclass[11pt]{article} | |
\usepackage[margin=1in]{geometry} | |
\usepackage{amsmath} | |
\frenchspacing | |
\begin{document} | |
\begin{tabular}{l c l} |
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
next_poisson <- function(lambdas) { | |
lambda <- sum(lambdas) | |
t <- rexp(1, rate = lambda) | |
i <- sample(length(lambdas), 1, prob = lambdas / lambda) | |
return(c(t, i)) | |
} | |
duplication <- function(s) { | |
i <- sample(length(s), 1, prob = s / sum(s)) | |
s[i] <- s[i] + 1 |
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/python | |
import smtplib | |
from email.MIMEMultipart import MIMEMultipart | |
from email.MIMEBase import MIMEBase | |
from email.MIMEText import MIMEText | |
from email import Encoders | |
import os | |
gmail_user = "[email protected]" |
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 python3 | |
import sys | |
from fractions import Fraction | |
mult = lambda r,f: [f * x for x in r] | |
add = lambda r1,r2: [x + y for x,y in zip(r1,r2)] | |
def print_matrix(m): | |
for r in m: print('\t'.join(str(x) for x in 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 sys; print '\n'.join([l.split(',')[0] + '\t' + l.split(',')[-5] for l in open(sys.argv[1])]); |