Skip to content

Instantly share code, notes, and snippets.

View alexpreynolds's full-sized avatar
👋
Hello

Alex Reynolds alexpreynolds

👋
Hello
  • Altius Institute for Biomedical Sciences
  • Seattle, WA USA
View GitHub Profile
@alexpreynolds
alexpreynolds / consolidate.py
Last active August 29, 2015 13:56
Consolidating genomic elements by ID relationship
#!/usr/bin/env python
import sys, copy
def sampleInput():
return '''gain_765 chr15 9681969 9685418 chr15 9660912 9712719 loss_1136
gain_766 chr15 9706682 9852347 chr15 9660912 9712719 loss_1136
gain_766 chr15 9706682 9852347 chr15 9765125 9863990 loss_765
gain_780 chr20 9706682 9852347 chr20 9765125 9863990 loss_769
gain_760 chr15 9706682 9852347 chr15 9660912 9712719 loss_1137
@alexpreynolds
alexpreynolds / seqIdTest.mtx
Last active August 29, 2015 13:57
Example sequence identifier adjacency matrix
410488935 410488927 410488931 410488939 410488937 410488923 410488933
410488935 0.0000
410488927 0.0065 0.0000
410488931 0.0098 0.0098 0.0000
410488939 0.0850 0.0850 0.0784 0.0000
410488937 0.0817 0.0817 0.0752 0.0033 0.0000
410488923 0.0817 0.0817 0.0752 0.0033 0.0065 0.0000
410488933 0.1340 0.1340 0.1275 0.1340 0.1307 0.1307 0.0000
@alexpreynolds
alexpreynolds / minSeqIdLister.py
Last active August 29, 2015 13:57
Output the minimum value in an adjacency matrix, along with a list of row and column IDs for that minimum value
#!/usr/bin/env python
import sys
fn = sys.stdin
ids = list()
vd = dict()
rowIdx = -1
>seq0
FQTWEEFSRAAEKLYLADPMKVRVVLKYRHVDGNLCIKVTDDLVCLVYRTDQAQDVKKIEKF
>seq1
KYRTWEEFTRAAEKLYQADPMKVRVVLKYRHCDGNLCIKVTDDVVCLLYRTDQAQDVKKIEKFHSQLMRLME
LKVTDNKECLKFKTDQAQEAKKMEKLNNIFFTLM
>seq2
EEYQTWEEFARAAEKLYLTDPMKVRVVLKYRHCDGNLCMKVTDDAVCLQYKTDQAQDVKKVEKLHGK
>seq3
MYQVWEEFSRAVEKLYLTDPMKVRVVLKYRHCDGNLCIKVTDNSVCLQYKTDQAQDVK
>seq4
@alexpreynolds
alexpreynolds / randomSampleFastaWithoutReplacement.pl
Last active August 29, 2015 13:57
Randomly sample from an ordered FASTA file without replacement, preserving sequence order in output
#!/usr/bin/env perl
use strict;
use warnings;
use List::Util qw(shuffle);
use Fcntl qw(SEEK_CUR);
my $inFn = "example.fa";
my $n = 5;
@alexpreynolds
alexpreynolds / mtx2runall.pl
Created April 29, 2014 22:36
Converts a matrix of set memberships to an Eulergrid runall statement with cardinalities
#!/usr/bin/perl -w
use strict;
use Getopt::Long;
use Data::Dumper;
use EulerSet;
#
# sample input:
#
@alexpreynolds
alexpreynolds / example.mtx
Created April 29, 2014 22:39
Example matrix of set memberships to use as input to mtx2runall.pl
A B C
0 1 0
0 1 0
0 1 0
0 1 0
0 0 1
0 1 1
0 1 1
0 1 1
0 1 0
@alexpreynolds
alexpreynolds / EulerSet.pm
Created April 29, 2014 22:40
Perl module (dependency) for mtx2runall.pl
#!/usr/bin/perl
package EulerSet;
sub new {
my $class = shift;
my $self = {
_subsetRef => shift,
_indicator => shift,
_length => shift,
@alexpreynolds
alexpreynolds / candle_test.c
Last active August 29, 2015 14:15
Test of string copying with memcpy()
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAX_LETTERS 5
int main(int argc, char *argv[])
{
const char *source = "candle";
char *destination = NULL;
@alexpreynolds
alexpreynolds / fiddlehead.massif.out.30303.transcript.txt
Created February 26, 2015 00:26
debug.sort-bed transcript (fiddlehead test)
[areynolds@fiddlehead src]$ pwd
/home/areynolds/proj/sjn/25Feb2015/src
[areynolds@fiddlehead src]$ ./merge-all-dhs.parallel.debug.tcsh
set hotdir = ../data/hotspots
find -L ../data/hotspots/ -maxdepth 2 -mindepth 2 -type f -name *.gz -print0
parallel -0 -X -m zcat {}
valgrind --tool=massif --pages-as-heap=yes --peak-inaccuracy=0.1 /home/sjn/Github/BEDOPS/bedops/applications/b\
ed/sort-bed/bin/debug.sort-bed --max-mem 1G -
==30303== Massif, a heap profiler