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
numbers.so: numbers.c | |
gcc --std=c99 -fPIC -c numbers.c | |
gcc -shared numbers.o -o numbers.so | |
clean: | |
rm -f numbers.o numbers.so |
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
#this is a simple way to plot a matrix from a txt file | |
mat_data_frame=read.table("data.txt",header=F) | |
#rev is there to start plotting M(0,0) in the upper left corner | |
#col=rainbow(10) uses the rainbow color palette. You can find other ones here: | |
#http://stat.ethz.ch/R-manual/R-devel/library/grDevices/html/palettes.html | |
image(as.matrix(rev(mat_data_frame)),col=rainbow(10)) |
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
#include "mkl.h" | |
#include <math.h> | |
#include <float.h> | |
#include <ctime> | |
#include <stdio.h> | |
/* Auxiliary routine: printing a matrix */ | |
void print_matrix(double * matrix, int nrow, int ncol) { | |
for (int i = 0; i < nrow; i++) { | |
for (int j = 0; j < ncol; j++) { |
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
#include "mkl.h" | |
#include <math.h> | |
#include <float.h> | |
#include <stdio.h> | |
/* Auxiliary routine: printing a matrix */ | |
void print_matrix(float * matrix, int nrow, int ncol) { | |
for (int i = 0; i < nrow; i++) { | |
for (int j = 0; j < ncol; j++) { | |
printf("%.*e\t",FLT_DIG, matrix[i * ncol + j]); |
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/perl | |
use warnings; | |
#not sure how to use strict here - does not allow bareword in "Inline CPP" | |
use Inline CPP; | |
my @data = (0..10); | |
my $result_ref = do_stuff(\@data); | |
my @result = @$result_ref; | |
print "@result\n"; | |
__END__ | |
__CPP__ |
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
#get sequences by regex match from a fasta file | |
from argparse import ArgumentParser | |
import re | |
parser = ArgumentParser(description="grep for fasta IDs") | |
group = parser.add_mutually_exclusive_group() | |
group.add_argument("--query_string","-q") | |
group.add_argument("--query_file","-f") |
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 inspect | |
def render(string,variables=None): | |
"""Wrapper method for String Template: | |
name="Jeff" | |
render("Hello, $name") | |
>>Hello, Jeff | |
""" | |
t = Template(string) | |
if not variables: |
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 | |
from ftplib import FTP | |
def ftp_download(server,remote_path,local_path,username="anonymous",password="",verbose=True): | |
#new ft object | |
ftp = FTP(server) | |
if verbose: print("Connected to %s"%server) | |
#notice that default login is "anonymous" with no password. works on most public servers |
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 python | |
import fastaparse | |
import sys | |
sequences = [i.seq for i in fastaparse.parse_fasta(sys.argv[1])] | |
def substrings(string): | |
n = len(string) | |
for length in range(n,0,-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
def qw(s,t=str): | |
return list(map(t,s.split())) |