Skip to content

Instantly share code, notes, and snippets.

View mgalardini's full-sized avatar

Marco Galardini mgalardini

View GitHub Profile
@mgalardini
mgalardini / ACTblastn.sh
Last active July 17, 2017 17:07
Bioinformatics one-liners
#!/bin/sh
blastn -query 1 -subject 2 -outfmt 6 -task megablast -evalue 1e-10 | awk '{if ($4 > 4999) print $3" "$3" "$9" "$10" "$2" "$7" "$8" "$1}' > 1-2
@mgalardini
mgalardini / flac2mp3.sh
Created July 2, 2012 16:00
Music one-liners
#!/bin/bash
# Take the flac files in a directory and turn them into mp3s
for file in *.flac; do flac -cd "$file" | lame -h --preset standard - "${file%.flac}.mp3"; done
@mgalardini
mgalardini / apacheLog.sh
Created July 18, 2012 10:55
Sysadmin one-liners
#!/bin/bash
if [ "$#" -lt 1 ]; then
search=$(cat /var/log/apache2/access.log | awk '{print $1"-"$4}')
else
search=$(cat /var/log/apache2/access.log | grep $1 | awk '{print $1"-"$4}')
fi
single=$(for i in $search; do ip=$(echo $i | awk 'BEGIN {FS = "-"}; {print $1}'); datetime=$(echo $i | awk 'BEGIN {FS = "-"}; {print $2}' | sed 's/\[//' | awk 'BEGIN {FS = ":"}; {print $1}'); loc=$(geoiplookup $ip | awk 'BEGIN { FS = ":" }; {print $2}' | sed -e 's/^[ \t]*//' | sed 's/ /_/g'); echo -e $datetime"-"$loc"-"$ip;done)
final=$(for i in $(echo $single | tr ' ' '\n' | sort | uniq); do ip=$(echo $i | awk 'BEGIN {FS = "-"}; {print $3}'); whoz=$(whois $ip | grep NetName | awk 'BEGIN {FS = ":"}; {print $2}' | sed 's/^ *//g' | sed 's/ /_/g' | head -n 1); whoz2=$(whois $ip | grep netname | awk 'BEGIN {FS = ":"}; {print $2}' | sed 's/^ *//g'| sed 's/ /_/g' | head -n 1); whoz3=$(whois $ip | grep OrgName | awk 'BEGIN {FS = ":"}; {print $2}' | sed 's/^ *//g'| sed 's/ /_/g' | head -n 1); whoz4=$(whois $ip | grep descr | a
@mgalardini
mgalardini / contiguatorLog.py
Last active October 10, 2015 12:37
CONTIGuator web tracking
#!/usr/bin/python
class bcolors:
HEADER = '\033[95m'
OKBLUE = '\033[94m'
OKGREEN = '\033[92m'
WARNING = '\033[93m'
FAIL = '\033[91m'
ENDC = '\033[0m'
print '%sSingle job stats for CONTIGuator%s'%(bcolors.HEADER,bcolors.ENDC)
@mgalardini
mgalardini / parallelPAML.py
Created September 18, 2012 15:40
Parallel Evolutionary Biology
#!/usr/bin/python
'''
Launch codeml on all the alignments
Marco Galardini 2012
University of Florence
GPL v3.0
'''
from optparse import OptionParser, OptionGroup
from time import strftime
@mgalardini
mgalardini / Rm1021.csv
Last active October 13, 2015 20:17
DuctApe
Data File C:\Documents and Settings\Standard\Desktop\Rm1021_25A.oka
Set up Time Oct 01 2007 3:12 PM
Position 25-A
Plate Type PM 1-
Strain Type NOT APPLICABLE
Sample Number Rm1021
Strain Name Rm1021
Strain Number Rm1021
Other
@mgalardini
mgalardini / removeCopies
Last active December 17, 2015 10:58
Sequence utils
#!/usr/bin/python
'''
Reads a FASTA files and rewrites it keeping only the unique IDs
Important: we assume that if two proteins have the same ID, they have the same sequence
'''
import sys
from Bio import SeqIO
if len(sys.argv) < 3:
@mgalardini
mgalardini / bacterial_genomes_report..ipynb
Last active January 2, 2016 16:49
Simple report on the bacterial genomes hosted in the NCBI FTP
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
rsync -av rsync://ftp.ncbi.nlm.nih.gov/genomes/Bacteria --include "*/" --include "Bacteria/Escherichia*/*.fna" --exclude=* . --prune-empty-dirs
@mgalardini
mgalardini / run_notebook
Last active August 29, 2015 14:07 — forked from davidshinn/ipnbdoctest.py
Allow longer run times
#!/usr/bin/env python
"""
simple example script for running and testing notebook resulting in a new workbook.
Usage: `run_notebook foo.ipynb foo_new.ipynb`
Each cell is submitted to the kernel, and the outputs are compared with those stored in the notebook.
Each cell is given half an hour to complete.
"""