Skip to content

Instantly share code, notes, and snippets.

Michele Mattioni mattions

Block or report user

Report or block mattions

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile

Handy commands

Extract bam according to a bed file

bedtools intersect -abam path/to/input.bam -b path/to/regions.bed > out.bam

Extract region of a VCF

from import visual
def draw_cyl(coords):
x_ax = coords['x1'] -coords['x0']
y_ax = coords['y1'] -coords['y0']
z_ax = coords['z1'] -coords['z0']
cyl = visual.Cylinder(pos=(coords['x0'],coords['y0'],coords['z0']),
axis=(x_ax,y_ax,z_ax), radius=1, length=10)
mattions /
Created May 4, 2011
Using mlab to change a second scalar for the cilinders..
import numpy as np
from mayavi import mlab
class Animator(object):
def __init__(self):
self.scalar_active_attribute = None
def add_scalar_array(self, dataset, tube, scalar_data, scalar_data_name):
mattions / a.param
Created Jun 27, 2011
Easy way to get params from external file in the main script (and work with them)
View a.param
# Parameters file for simulation.
"dt" : 0.025, # integration dt [ms]
"dict_ampa_s1" :
{"t_stim" : 0.130, # t_stim [s]
"numbers" : 4, # number
"delay" : 0.1, # delay [s]
"type" : "ampa" # , type
"dict_ampa_s2" :
mattions /
Created Sep 12, 2011
Off screen rendering of a 3D window of Neuronvisio
import os
from shutil import copyfile
import numpy as np
# Getting the qt in before mayavi
from PyQt4 import QtGui
app = QtGui.QApplication.instance()
from enthought.mayavi import mlab
# Offscreen
mattions /
Created Sep 12, 2011
run a downloaded model in Neuronvisio
def run_model_in_neuronvisio(model_dir):
if os.path.exists(os.path.join (model_dir, 'mosinit.hoc')):
#TODO: We should check if the file is already compiled,
# and call the right executable according to the system.
from neuron import gui # to not freeze neuron gui
from neuron import h
from neuronvisio.controls import Controls
mattions /
Created Oct 2, 2011
importing the right Qstring for Python 3 on windows
This is a check to make sure the sip and the Qstrings play nicely in Windows,
where the PySide is using the new Python API (Python 3)
This could be easily removed when we move to Python 3
if == 'nt':
import sip
sip.setapi('QString', 2)
mattions / neuronvisio_dev_reqs.txt
Created Feb 8, 2012
Requirements for version 0.8.0 of neuronvisio
View neuronvisio_dev_reqs.txt
-e git+
-e git+
mattions /
Created Mar 16, 2012
parse_git function in bash which updates your prompt with the git branch if it is a git repo
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/(\1$(parse_git_dirty))/"
export PS1='\u@\h \[\033[1;33m\]\w\[\033[0m\]$(parse_git_branch)$ '
mattions /
Created Mar 30, 2012
Initial work to protect the Capital letters in latex with braces. WARNING: Does not work, but it is a start
#!/usr/bin/env python
# -*- coding: utf8 -*-
import re
def protect_with_braces(title):
new_title = ''
words = title.split()
for w in words:
You can’t perform that action at this time.