Skip to content

Instantly share code, notes, and snippets.

View afrendeiro's full-sized avatar

André F. Rendeiro afrendeiro

View GitHub Profile
@afrendeiro
afrendeiro / cutdiff_output_parser.py
Created June 18, 2013 22:36
Parses output from Cufflinks' cuffdiff averaging two samples. Outputs tab-delimited csv files (log2 transformed and not).
#!/usr/bin/python
from sys import argv
import csv,StringIO
import math
expr = open(argv[1], 'r')
output = open(argv[1] + '.bed','w')
output_log = open(argv[1] + '_log2.bed','w')
@afrendeiro
afrendeiro / split_xml_blast_output.awk
Created August 5, 2013 10:33
Blastx xml output parser
#!/usr/bin/awk -f
# Author: Laurent Manchon ([email protected])
# Split big blast output in xml format into severals files
# Type split_xml_blast without parameters to see usage.
BEGIN{
{
@afrendeiro
afrendeiro / jaspar2fasta.pl
Created August 5, 2013 10:38
The tool reads the description of JASPAR and reads all files required to provide decent input to clover. jaspar2fasta takes the directory containing all the matrix_list.txt file of JASPAR as the only argument. The output should be redirected into a new file on which to subsequently work with clover.
#!/usr/bin/perl -w
# Convert JASPAR matrices to fasta-like format
# Written by Martin C Frith
# I intend that anyone who finds this code useful be free to use,
# modify, or redistribute it without any restrictions
=head1 NAME
jaspar2fasta - conversion of JASPAR database release for use with clover
@afrendeiro
afrendeiro / ChIP_mapping_pipeline.sh
Last active December 20, 2015 15:29
Batch script to preprocess ChIP PE reads samples. Parallelization with GNU parallel.
#!/bin/bash
# Pipeline for PE samples
# paths and variables to change
RAW=/sysdev/s3/share/data/oikopleura/chip-seq/raw
MAPPED=/sysdev/s3/share/data/oikopleura/chip-seq/mapped
GENOMEREF=~/data/oikopleura/assembly/Oikopleura_reference_unmasked_v3.0.fa
CHRSIZES=~/data/oikopleura/assembly/Oikopleura_reference_chrSizes.tsv
@afrendeiro
afrendeiro / flac+cue2mp3.sh
Created September 15, 2013 10:39
Command-line conversion of flac+cue files to mp3 split tracks
#!/bin/sh
# Flacon-style convert to mp3 and split tracks from flac+cue files
# Made by André Rendeiro ([email protected])
# Rename
{
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; mv "$file" "$target"; done
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; mv "$file" "$target"; done
find . -name '* *' | while read file; do target=`echo "$file" | sed 's/ /_/g'`; mv "$file" "$target"; done
@afrendeiro
afrendeiro / speedtouchkey.py
Created December 26, 2013 09:41
Reveal likely WPA key for Thompson Routers based on network's SSID. Usage: speedtouchkey.py <SSID>
#!/usr/bin/env python
#original: http://www.korokithakis.net/posts/thomsonspeedtouch-routers-and-wpa-keys/
#modified from: http://pastie.org/3108591
import sys
import hashlib
from binascii import hexlify, unhexlify
from itertools import product
from multiprocessing import Process
@afrendeiro
afrendeiro / annotateTSSs.sh
Created January 27, 2014 23:13
Takes a bed file with gene annotation ("annotationFile.bed") and makes another with TSS annotation ("annotationFile.TSSs.bed")
awk -v OFS='\t' '$6 == "+" {print $1, $2, $2+1, $4, $5, $6}' annotationFile.bed > tmp
awk -v OFS='\t' '$6 == "-" {print $1, $3, $3+1, $4, $5, $6}' annotationFile.bed >> tmp
bedtools sort -i tmp > annotationFile.TSSs.bed
@afrendeiro
afrendeiro / gradeStuff.py
Last active January 4, 2016 19:19
Reads in a score (1-100) and prints out the corresponding character (grade). Done without the if control structure.
#Create a method that reads in a score (1-100) and prints out the corresponding character (grade).
#Assume the following grade assignment: 'A' = 100-81 points, 'B' = 80-61 points, 'C' = 60-41 points, 'D' = 40-21 points and 'E' = 20-1 points.
# Don't use the "if" control structure
score = 1
scale = [range(81,100), range(61,80), range(41,60), range(21,40), range(1,20)]
grades = ["A", "B", "C", "D", "E"]
for grade in range(0, len(scale)):
while score in scale[grade]:
@afrendeiro
afrendeiro / getChrSizesFromFasta.py
Last active January 4, 2016 21:09
Make tab-delimited chromossome size file from fasta genome
import csv
from Bio import SeqIO
fastagenome = "data/oikopleura/assembly/Oikopleura_reference_unmasked_v3.0.fa"
output = "data/oikopleura/assembly/Oikopleura_reference_chrSizes.tsv"
myfile = open(output, "wb")
spamwriter = csv.writer(myfile, delimiter='\t', quoting=csv.QUOTE_MINIMAL)
for seq_record in SeqIO.parse(fastagenome, "fasta"):
@afrendeiro
afrendeiro / pairwiseAlign.py
Created June 4, 2014 22:28
Exact pairwise alignment by dynamic programming. Forward recursion with pruning
#! /usr/bin/python
# Forward-recursion with pruning
# An algorithm for doing exact alignment of two sequences
# Forward recursion is used, with pruning of cells
# two sequences to align
S1 = 'APPLR'
S2 = 'APPLS'