forked from yarden/MISO
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_miso.py
More file actions
125 lines (102 loc) · 4.73 KB
/
Copy pathtest_miso.py
File metadata and controls
125 lines (102 loc) · 4.73 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
import unittest
import os
class TestMISO(unittest.TestCase):
"""
Test MISO functionality.
"""
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.tests_output_dir = os.path.join(self.miso_path, "test-output")
self.test_sam_filename = os.path.join(self.tests_data_dir,
"sam-data",
"c2c12.Atp2b1.sam")
self.gff_events_dir = os.path.join(self.miso_path, "gff-events")
self.sam_to_bam_script = os.path.join(self.miso_path, "sam_to_bam.py")
self.index_gff_script = os.path.join(self.miso_path, "index_gff.py")
def test_a_sam_to_bam(self):
"""
Test conversion of SAM to BAM.
The 'a' ensures this runs first.
"""
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)
print "Executing: %s" %(sam_to_bam_cmd)
os.system(sam_to_bam_cmd)
# Make sure conversion worked; sorted, indexed BAM file is outputted
assert(os.path.exists(os.path.join(output_dir,
"c2c12.Atp2b1.sorted.bam")))
def test_single_end_SE(self):
"""
Test skipped exons using single-end event counts files.
"""
print "Testing single-end SE event interface..."
sample_name = "se-sample"
counts_filename = os.path.join(self.tests_data_dir,
"se-counts",
"se_test.counts")
output_dir = os.path.join(self.tests_output_dir, "SE-output")
read_len = 35
overhang_len = 4
event_type = "SE"
miso_cmd = "%s --compute-events-psi %s %s --output-dir %s --read-len %d --overhang-len %d " \
" --event-type %s" %(self.events_analysis_cmd,
sample_name,
counts_filename,
output_dir,
read_len,
overhang_len,
event_type)
print "Executing: %s" %(miso_cmd)
os.system(miso_cmd)
def test_paired_end_scoring(self):
"""
Test scoring functions on synthetic gene model.
"""
pass
def test_z_gene_psi(self):
"""
Test gene-level Psi inferences using SAM/BAM reads.
The 'z' ensures this runs last.
"""
print "Testing gene-level Psi..."
sam_dir = os.path.join(self.tests_output_dir, "sam-output")
bam_filename = os.path.join(sam_dir, "c2c12.Atp2b1.sorted.bam")
read_len = 35
insert_mean = 250
insert_sd = 30
# 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", "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)
print "Executing: %s" %(index_cmd)
os.system(index_cmd)
output_dir = os.path.join(self.tests_output_dir, "gene-psi-output")
# miso_cmd = "%s --compute-genes-psi %s %s --output-dir %s --read-len %d " \
# " --paired-end %d %d" \
# %(self.events_analysis_cmd,
# gff_index_dir,
# bam_filename,
# output_dir,
# read_len,
# insert_mean,
# insert_sd)
miso_cmd = "%s --compute-genes-psi %s %s --output-dir %s --read-len %d " \
%(self.events_analysis_cmd,
gff_index_dir,
bam_filename,
output_dir,
read_len)
print "Executing: %s" %(miso_cmd)
os.system(miso_cmd)
if __name__ == '__main__':
unittest.main()