Skip to content

Instantly share code, notes, and snippets.

View mgalardini's full-sized avatar

Marco Galardini mgalardini

View GitHub Profile
@mgalardini
mgalardini / find_haplotypes.py
Created December 1, 2017 11:55
Find exact matches in fastq files
#!/usr/bin/env python
def get_options():
import argparse
parser = argparse.ArgumentParser()
parser.add_argument('reference',
help='Reference fasta file')
parser.add_argument('reads',
@mgalardini
mgalardini / nwk2mat.py
Created November 22, 2017 08:56
From newick to distance matrix
#!/usr/bin/env python
if __name__ == "__main__":
import sys
if len(sys.argv) < 2:
print('USAGE: python nwk2mat.py TREE.nwk')
sys.exit(1)
import pandas as pd
@mgalardini
mgalardini / template.py
Created September 14, 2017 09:31
Minimal python script template
#!/usr/bin/env python
'''Description here'''
import logging
import argparse
def get_options():
description = ''
parser = argparse.ArgumentParser(description=description)
@mgalardini
mgalardini / experimental_design.tsv
Created June 19, 2017 13:42
rna-seq experimental design table
batch strain replica
batch_1 strain_41 1
batch_4 strain_41 2
batch_1 strain_28 1
batch_4 strain_28 2
batch_1 strain_26 1
batch_4 strain_26 2
batch_5 strain_25 1
batch_3 strain_25 2
batch_5 strain_4 1
@mgalardini
mgalardini / run_notebook.py
Created June 14, 2017 10:00
Pass arguments to a Jupyter notebook and save it after re-running it
#!/usr/bin/env python
'''
Run and save a jupyter notebook by providing arguments from the command line
Uses the nbparameterise package, and requires the first cell to have variables
definitions.
Command line parsing based on this Stack Overflow answer:
https://stackoverflow.com/a/42355279/1237531
'''
@mgalardini
mgalardini / estimate-insert-sizes
Last active March 10, 2017 09:46 — forked from rchikhi/estimate-insert-sizes
Quickly estimates insert sizes of read datasets, given some sequence(s) they can be mapped to. Requires BWA. Short usage: <reference> <*.fastq>
#!/usr/bin/env python
doc = """
Quickly estimates insert sizes of read datasets, given some sequence(s) they can be mapped to.
Author: Rayan Chikhi
short usage: <reference> <*.fastq>
example:
estimate-insert-sizes contigs.fa readsA_1.fq readsA_2.fq readsB_1.fq readsB_2.fq
@mgalardini
mgalardini / skeleton2.py
Last active February 5, 2016 11:30
Python multiprocessing module evolution
#!/usr/bin/env python2
'''
skeleton for parallel python 2 scripts
Marco Galardini 2015
GPL v3.0
'''
import sys
from multiprocessing.queues import Queue
import multiprocessing
@mgalardini
mgalardini / roary_plots.py
Created October 28, 2015 18:20
Roary plots with strain names
#!/usr/bin/env python
# Copyright (C) <2015> EMBL-European Bioinformatics Institute
# This program is free software: you can redistribute it and/or
# modify it under the terms of the GNU General Public License as
# published by the Free Software Foundation, either version 3 of
# the License, or (at your option) any later version.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
@mgalardini
mgalardini / tutorial.ipynb
Last active May 19, 2020 21:53
PM data analysis tutorial using Biopython
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@mgalardini
mgalardini / roary.ipynb
Created June 11, 2015 16:34
Roary plots
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.