Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,6 @@
*.pyc
splicing_0.1.tar.gz
pysplicing-0.1.tar.gz
env/*
build/*
misopy/test-output/*
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
@@ -1,6 +1,9 @@

all: Pythonpackage

virtualenv: Pythonpackage
./install.sh

########################################################

RSRC=$(wildcard src/*.c) $(wildcard src/*.h) $(wildcard src/*.pmt)
Expand Down
25 changes: 25 additions & 0 deletions install.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
#!/bin/bash
VIRTUALENV=`which virtualenv-2.7`
if [ "$VIRTUALENV" == "" ]; then
VIRTUALENV=`which virtualenv-2.6`
fi
if [ "$VIRTUALENV" == "" ]; then
VIRTUALENV=`which virtualenv`
fi
if [ "$VIRTUALENV" == "" ]; then
echo "Missing virtualenv!"
exit 1
fi

if [ ! -e env ]; then
echo "Initializing virtualenv folder (env)"
$VIRTUALENV env
fi
. env/bin/activate
python setup.py install --prefix env
pip install numpy
pip install -r requirements.txt

#
# If you're on a Mac, and matplotlib won't install, try this:
# LDFLAGS="-L/usr/X11/lib" CFLAGS="-I/usr/X11/include -I/usr/X11/include/freetype2 -I/usr/X11/include/libpng15" pip install matplotlib
44 changes: 44 additions & 0 deletions miso
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
#!/bin/bash
function usage() {
echo "Usage: $(basename $0) command args..."
echo ""
echo "Valid commands: exon_utils"
echo " filter_events"
echo " index_gff"
echo " module_availability"
echo " pe_utils"
echo " plot"
echo " run_events_analysis"
echo " run"
echo " sam_to_bam"
echo ""
exit 1
}
REAL=`python -c 'import os,sys;print os.path.realpath(sys.argv[1])' "$0"`
DIR=`dirname "$REAL"`
. $DIR/env/bin/activate


if [ ! "$1" ]; then
usage
fi

cmd="$1"
shift

export MISO_SHELL_EXEC="$0"

if [ "$cmd" == "run" ]; then
python $DIR/env/bin/run_miso.py "$@"
elif [ -e "$DIR/env/bin/$cmd.py" ]; then
python "$DIR/env/bin/$cmd.py" "$@"
elif [ -e "$DIR/env/bin/$cmd" ]; then
python "$DIR/env/bin/$cmd" "$@"
elif [ -e "$cmd" ]; then
# this is for hard-coded commands, such as used in the cluster code
# or to run test-scripts
python "$cmd" "$@"
else
echo "Unknown command: $cmd"
usage
fi
9 changes: 5 additions & 4 deletions misopy/run_events_analysis.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,8 @@ def compute_all_genes_psi(gff_dir, bam_filename, read_len, output_dir,
all_miso_cmds = []

for gene_id, gff_index_filename in gene_ids_to_gff_index.iteritems():
miso_cmd = "python %s --compute-gene-psi \"%s\" \"%s\" %s %s --read-len %d " \
%(miso_run, gene_id, gff_index_filename, bam_filename, output_dir,
miso_cmd = "%s %s --compute-gene-psi \"%s\" \"%s\" %s %s --read-len %d " \
%(Settings.get_miso_exec(), miso_run, gene_id, gff_index_filename, bam_filename, output_dir,
read_len)
if paired_end != None:
# Run in paired-end mode
Expand Down Expand Up @@ -183,8 +183,9 @@ def compute_psi(sample_filenames, output_dir, event_type, read_len, overhang_len
events_filename = events.output_file(results_output_dir, sample_label)

# Run MISO on them
miso_cmd = 'python %s --compute-two-iso-psi %s %s --event-type %s --read-len %d --overhang-len %d ' \
%(os.path.join(miso_path, 'run_miso.py'),
miso_cmd = '%s %s --compute-two-iso-psi %s %s --event-type %s --read-len %d --overhang-len %d ' \
%(Settings.get_miso_exec(),
os.path.join(miso_path, 'run_miso.py'),
events_filename,
results_output_dir,
event_type,
Expand Down
7 changes: 4 additions & 3 deletions misopy/run_miso.py
Original file line number Diff line number Diff line change
Expand Up @@ -148,8 +148,9 @@ def run_two_iso_on_cluster(miso_path, events_filename, event_type, psi_outdir,
num_jobs_per_batch = len(event_batch)
print "Processing a batch of size %d events" %(num_jobs_per_batch)
for event_name in event_batch:
miso_event_cmd = 'python %s --run-two-iso-event \"%s\" %s %s --event-type %s --read-len %d --overhang-len %d' \
%(os.path.join(miso_path, 'run_miso.py'),
miso_event_cmd = '%s %s --run-two-iso-event \"%s\" %s %s --event-type %s --read-len %d --overhang-len %d' \
%(Settings.get_miso_exec(),
os.path.join(miso_path, 'run_miso.py'),
event_name,
events_filename,
psi_outdir,
Expand Down Expand Up @@ -181,7 +182,7 @@ def get_curr_script_cmd():
Get the invocation of the current script (with its command line arguments) as a
full command for use in a script.
"""
return 'python ' + get_current_args()
return '%s %s' % (Settings.get_miso_exec(), get_current_args())

def strip_option(cmd, option):
"""
Expand Down
8 changes: 8 additions & 0 deletions misopy/settings.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
##
## Settings with relevant directories
##

import misopy
from misopy.parse_csv import *
import ConfigParser
import os
import sys

miso_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))

Expand Down Expand Up @@ -141,6 +143,12 @@ def get_filters(cls, event_type):
@classmethod
def get(cls):
return cls.global_settings

@classmethod
def get_miso_exec(cls):
if 'MISO_SHELL_EXEC' in os.environ:
return os.environ['MISO_SHELL_EXEC']
return sys.executable


def load_settings(settings_filename):
Expand Down
8 changes: 5 additions & 3 deletions misopy/test_cluster.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
##
import unittest
import os
from misopy.settings import Settings

class TestCluster(unittest.TestCase):
"""
Expand All @@ -13,8 +14,8 @@ def setUp(self):
# Find out the current directory
self.miso_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
self.tests_data_dir = os.path.join(self.miso_path, "test-data")
self.events_analysis_cmd = "python %s " %(os.path.join(self.miso_path,
"run_events_analysis.py"))
self.events_analysis_cmd = "%s %s " % (Settings.get_miso_exec(),
os.path.join(self.miso_path, "run_events_analysis.py"))
self.tests_output_dir = os.path.join(self.miso_path, "test-output")
self.test_sam_filename = os.path.join(self.tests_data_dir,
"sam-data",
Expand Down Expand Up @@ -69,7 +70,7 @@ def test_cluster_gene_psi(self):
# First index the GFF of interest
gff_filename = os.path.join(self.gff_events_dir, "mm9", "genes", "Atp2b1.mm9.gff")
gff_index_dir = os.path.join(self.gff_events_dir, "mm9", "indexed")
index_cmd = "python %s --index %s %s" %(self.index_gff_script,
index_cmd = "%s %s --index %s %s" %(Settings.get_miso_exec(), self.index_gff_script,
gff_filename,
gff_index_dir)

Expand All @@ -92,4 +93,5 @@ def test_cluster_gene_psi(self):


if __name__ == '__main__':
Settings.load()
unittest.main()
20 changes: 12 additions & 8 deletions misopy/test_miso.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/usr/bin/env python
import unittest
import os
from misopy.settings import Settings

class TestMISO(unittest.TestCase):
"""
Expand All @@ -10,8 +11,9 @@ def setUp(self):
# Find out the current directory
self.miso_path = os.path.dirname(os.path.abspath(os.path.expanduser(__file__)))
self.tests_data_dir = os.path.join(self.miso_path, "test-data")
self.events_analysis_cmd = "python %s " %(os.path.join(self.miso_path,
"run_events_analysis.py"))
self.events_analysis_cmd = "%s %s" % (Settings.get_miso_exec(),
os.path.join(self.miso_path,
"run_events_analysis.py"))
self.tests_output_dir = os.path.join(self.miso_path, "test-output")
self.test_sam_filename = os.path.join(self.tests_data_dir,
"sam-data",
Expand All @@ -29,9 +31,10 @@ def test_a_sam_to_bam(self):

print "Testing conversion of SAM to BAM..."
output_dir = os.path.join(self.tests_output_dir, "sam-output")
sam_to_bam_cmd = "python %s --convert %s %s" %(self.sam_to_bam_script,
self.test_sam_filename,
output_dir)
sam_to_bam_cmd = "%s %s --convert %s %s" % (Settings.get_miso_exec(),
self.sam_to_bam_script,
self.test_sam_filename,
output_dir)
print "Executing: %s" %(sam_to_bam_cmd)
os.system(sam_to_bam_cmd)

Expand All @@ -58,9 +61,10 @@ def test_z_gene_psi(self):
gff_filename = os.path.join(self.gff_events_dir, "mm9", "genes", "Atp2b1.mm9.gff")
gff_index_dir = os.path.join(self.gff_events_dir, "mm9", "genes", "Atp2b1", "indexed")
print "Testing GFF indexing of: %s" %(gff_filename)
index_cmd = "python %s --index %s %s" %(self.index_gff_script,
gff_filename,
gff_index_dir)
index_cmd = "%s %s --index %s %s" % (Settings.get_miso_exec(),
self.index_gff_script,
gff_filename,
gff_index_dir)

print "Executing: %s" %(index_cmd)
os.system(index_cmd)
Expand Down
5 changes: 5 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
numpy
scipy
simplejson
pysam
matplotlib