Skip to content

Instantly share code, notes, and snippets.

(setq numerals
'((ones "" "I" "II" "III" "IV" "V" "VI" "VII" "VIII" "IX")
(tens "" "X" "XX" "XXX" "XL" "L" "LX" "LXX" "LXXX" "XC")
(hundreds "" "C" "CC" "CCC" "CD" "D" "DC" "DCC" "DCCC" "CM")
(thousands "" "M" "MM" "MMM")))
(defun divmod (x y)
"Helper function to divide X by Y and return the quotient and remainder."
(let
((quotient (/ x y))

Keybase proof

I hereby claim:

  • I am calizarr on github.
  • I am calizarr (https://keybase.io/calizarr) on keybase.
  • I have a public key ASCswhV_yMXB4800m7qPltoaNEnhkIieTFC2QEI-kdSBFQo

To claim this, I am signing this object:

@calizarr
calizarr / Parallel_ConPADE.sh
Last active February 5, 2016 16:20
Bash script to parallelize ConPADE
#!/bin/bash
declare -a scaffolds
for ((i=$2; i<=$3; i++)); do
scaffolds+=("scaffold_$i")
done
for ((i=$2; i<=$3; i+=1000)); do
j=$((i+1000))
if [ -f scaffolds_$j.temp ]; then
echo "Scaffolds temp file already exists: $((i+1000))"
# Works
for x in {bed_dir}/*.bed;do y=$(basename ${{x%.*}});sed -- 's/{original}/chr/g' $x > {outdir}/$y.sicer.bed;done;echo Converting to Bed chromosome done
# Doesn't work
for x in {bed_dir}/*.bed;do y=$(basename ${{x%.*}});sed -- 's/{original}/chr/g' $x > {outdir}/$y.sicer.bed & done;wait;echo Converting to Bed chromosome done
@calizarr
calizarr / gist:7393194
Last active December 27, 2015 21:39
Find k-mers in (L,t) clumps.
def allBelow(genome,k,L,t):
kmerCount = 0
## print 'Beginning: '
results = set()
for x in range(len(genome)-k): #looping through the genome
kMer = genome[x:x+k] #getting each k-mer at a time
indices = collections.deque([]) #keeping track of the indices
start = 0 #for the string.find(sub) method
if kMer not in results: #Making sure we don't do extra work.
while True:
def makeMaps(filename):
f_in = open(filename,'r')
g, grev = {}, {}
print "Loading from: "+str(filename)
for line in f_in:
nodes = [int(x) for x in line.split()]
## print "Total nodes: "+str(nodes)
vertex = nodes[0]
neighbors = nodes[1:]
## print "g[vertex]: "+str(vertex)+" has these neighbors: "+(str(neighbors))
@calizarr
calizarr / gist:5703386
Created June 4, 2013 03:31
0/1 Knapsack Problem - Recursive
############################################################
############################################################
###
### 0/1 knapsack
###
############################################################
############################################################
# from earlier lecture...
class Item(object):
@calizarr
calizarr / gist:5392932
Created April 16, 2013 02:38
Specifications for virus reproduce
def reproduce(self, popDensity, activeDrugs):
"""
Stochastically determines whether this virus particle reproduces at a
time step. Called by the update() method in the TreatedPatient class.
A virus particle will only reproduce if it is resistant to ALL the drugs
in the activeDrugs list. For example, if there are 2 drugs in the
activeDrugs list, and the virus particle is resistant to 1 or no drugs,
then it will NOT reproduce.
#Reversal Distance
dataset = open('rosalind_rear_sample.txt','r')
data = dataset.read().split('\n')
dataset.close()
while len(data)>(len(data)-data.count('')):
data.remove('')
originals = [[int(x) for x in y.split()] for y in data[::2]]
perms = [[int(x) for x in y.split()] for y in data[1::2]]
def findBreak(perm):
num = 0
def findDecreaseStrip(perm,start,lst):
if start>len(perm)-1 or start+1>len(perm)-1:
return lst
breakpoint = abs(perm[start+1]-perm[start])
if start+1==len(perm)-1 and perm[start]>perm[start+1] and breakpoint==1:
lst.append(start),lst.append(start+1)
elif perm[start]>perm[start+1] and breakpoint==1:
lst.append(start)
return findDecreaseStrip(perm,start+1,lst)
else: