Skip to content

Instantly share code, notes, and snippets.

@nuada
nuada / refdiff.sh
Last active August 29, 2015 13:56
Compare regions of reference sequences
#!/bin/bash
# usage: refdiff.sh <h37>.bed <hg19>.bed
bedtools getfasta -fi /resources/h37/human_g1k_v37.fasta -bed $1 -fo - | sed -e 's/MT/M/' | tr '[:lower:]' '[:upper:]' > tmp.h37.fasta
bedtools getfasta -fi /resources/hg19/ucsc.hg19.fasta -bed $2 -fo - | sed -e 's/chr//' | tr '[:lower:]' '[:upper:]' > tmp.hg19.fasta
diff -u tmp.h*.fasta
rm tmp.h*.fasta
#!/bin/bash
source /etc/lsb-release
echo "deb http://r.meteo.uni.wroc.pl/bin/linux/ubuntu ${DISTRIB_CODENAME}/" > /etc/apt/sources.list.d/cran.list
apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E084DAB9
apt-get update
apt-get upgrade -y
apt-get install -y r-cran-dbi libcurl4-openssl-dev libxml2-dev libjpeg62
source("http://bioconductor.org/biocLite.R")
biocLite()
biocLite('AnnotationForge')
biocLite(c('illuminaio', 'beadarray', 'minfi', 'minfiData', 'limma', 'ChAMP', 'ChAMPdata'))
biocLite('IlluminaDataTestFiles')
#!/bin/bash
#usage: $0 <prefix> <number of parts>
#eg: $0 nt 17
# Download blast db form NCBI
for i in $(seq -f '%02.f' 0 $2); do
wget ftp://ftp.ncbi.nlm.nih.gov/blast/db/${1}.${i}.tar.gz
wget ftp://ftp.ncbi.nlm.nih.gov/blast/db/${1}.${i}.tar.gz.md5
done
@nuada
nuada / blast_unassigned_otus.sh
Created April 1, 2014 09:34
Parallel blasting of bacterial sequences, inspired by: http://students.washington.edu/bowmanjs/wordpress/?p=737
#!/bin/bash
number_of_jobs=4
# Opts for fast blasting, http://www.biostars.org/p/16425/#16431
source("http://bioconductor.org/biocLite.R")
biocLite();
biocLite("aCGH");
source("http://aroma-project.org/hbLite.R");
hbInstall("aroma.affymetrix");
install.packages("ggplot2")
install.packages("gplots")
#!/bin/bash
echo "track name=\"$(basename $1)\" description=\"hydra output\" useScore=0 colorByStrand=255,0,0 0,0,255 gffTags=on"
awk -F '\t' '{ \
gsub("+", "forward", $9); \
gsub("-", "reverse", $9); \
print $1 FS $2 FS $3 FS "Name=" $7 ";Strand=" $9 ";numMapping=" $16 FS FS $9; }' $1
awk -F '\t' '{
gsub("+", "forward", $10); \
gsub("-", "reverse", $10); \
@nuada
nuada / ab2bam.sh
Last active May 8, 2022 02:27
Convert ab1 sanger sequencing traces to fastq and align them to reference
#!/bin/bash
# Unzip files
for file in *.zip; do
@nuada
nuada / bed2reg
Last active August 29, 2015 14:02
Convert BED file to PLINK/SEQ REG format
#!/bin/bash
echo -e "#CHR\tBP1\tBP2\tID"
awk -F '\t' '{ print $1 FS $2+1 FS $3 FS NR }' | sed -e 's/^\([0-9]\+\)/chr\1/g'
@nuada
nuada / bed_cleanup.sh
Last active August 29, 2015 14:02
Cleanup BED: sort and merge intervals, extract gene symbols
bedtools sort -i foo.bed | bedtools merge -i - -nms | sed -e 's/\r//g' | awk -F '\t' '{ split($4, name, "."); print $1 FS $2 FS $3 FS name[1] }'