+ added information on cut positions of spliced reads
[qpalma.git] / scripts / Experiment.py
1 ###############################################################################
2 #
3 # This file contains settings for one experiment
4 #
5 # The general idea is as follows:
6 #
7 # Suppose you have an machine learning algorithm you want to perform model
8 # selection with. Then for each different value of for example C for a C-SVM this
9 # script generates a Run object a subclass of dict storing the parameters.
10 #
11 ###############################################################################
12
13 import qpalma.Configuration as Conf
14 from Run import *
15 import pdb
16 import os
17 import os.path
18
19 def createRuns():
20 # specify n for n-fold cross validation
21 numFolds=5
22
23 # the main directory where all results are stored
24 experiment_dir = '/fml/ag-raetsch/home/fabio/tmp/QPalma_test'
25
26 assert os.path.exists(experiment_dir), 'toplevel dir for experiment does not exist!'
27
28 # list of regularization parameters and additional flags for different runs
29 # for example:
30 # - with quality scores
31 # - without quality scores
32 #
33 bool2str = ['-','+']
34
35 allRuns = []
36
37 #dataset_filename = '/fml/ag-raetsch/home/fabio/svn/projects/QPalma/scripts/dataset_remapped_test'
38 dataset_filename = '/fml/ag-raetsch/home/fabio/svn/projects/QPalma/scripts/dataset_remapped_02_04_2008'
39
40 for QFlag in [True,False]:
41 for SSFlag in [True,False]:
42 #for ILFlag in [True]:
43 for ILFlag in [True,False]:
44
45 # create a new Run object
46 currentRun = Run()
47
48 # global settings for all runs
49 currentRun['anzpath'] = Conf.anzpath
50 currentRun['iter_steps'] = Conf.iter_steps
51 currentRun['matchmatrixRows'] = Conf.sizeMatchmatrix[0]
52 currentRun['matchmatrixCols'] = Conf.sizeMatchmatrix[1]
53 currentRun['mode'] = Conf.mode
54 currentRun['numConstraintsPerRound'] = Conf.numConstraintsPerRound
55
56 currentRun['remove_duplicate_scores'] = Conf.remove_duplicate_scores
57 currentRun['print_matrix'] = Conf.print_matrix
58 currentRun['read_size'] = Conf.read_size
59
60
61 currentRun['numLengthSuppPoints'] = 10 #Conf.numLengthSuppPoints
62
63 # if we are not using an intron length model at all we do not need the support points
64 if ILFlag == False:
65 currentRun['numLengthSuppPoints'] = 2 #Conf.numLengthSuppPoints
66
67 currentRun['numDonSuppPoints'] = 10
68 currentRun['numAccSuppPoints'] = 10
69
70 currentRun['numQualPlifs'] = Conf.numQualPlifs
71 currentRun['numQualSuppPoints'] = 10
72 currentRun['totalQualSuppPoints'] = currentRun['numQualPlifs']*currentRun['numQualSuppPoints']
73
74 currentRun['numFeatures'] = currentRun['numLengthSuppPoints']\
75 + currentRun['numDonSuppPoints'] + currentRun['numAccSuppPoints']\
76 + currentRun['matchmatrixRows'] * currentRun['matchmatrixCols']\
77 + currentRun['totalQualSuppPoints']
78
79 # run-specific settings
80 currentRun['training_begin'] = Conf.training_begin
81 currentRun['training_end'] = Conf.training_end
82 currentRun['prediction_begin'] = Conf.prediction_begin
83 currentRun['prediction_end'] = Conf.prediction_end
84
85 currentRun['enable_quality_scores'] = QFlag
86 currentRun['enable_splice_signals'] = SSFlag
87 currentRun['enable_intron_length'] = ILFlag
88
89 currentName = 'run_%s_quality_%s_splicesignals_%s_intron_len' %\
90 (bool2str[QFlag],bool2str[SSFlag],bool2str[ILFlag])
91
92 currentRun['C'] = 100
93
94 currentRun['name'] = currentName
95 currentRun['dataset_filename'] = dataset_filename
96 currentRun['experiment_path'] = experiment_dir
97
98 currentRun['min_intron_len'] = 20
99 currentRun['max_intron_len'] = 2000
100
101 #currentRun['min_intron_len'] = 10
102 #currentRun['max_intron_len'] = 100
103
104 currentRun['min_svm_score'] = 0.0
105 currentRun['max_svm_score'] = 1.0
106
107 currentRun['min_qual'] = -5
108 currentRun['max_qual'] = 40
109
110 currentRun['dna_flat_files'] = Conf.dna_flat_fn
111
112 allRuns.append(currentRun)
113
114 #
115 # check for valid paths / options etc
116 #
117 for currentRun in allRuns:
118
119 assert 0 < currentRun['anzpath'] < 100
120 assert 0 <= currentRun['training_begin'] < currentRun['training_end']
121 assert currentRun['training_end'] <= currentRun['prediction_begin'] < currentRun['prediction_end']
122
123 assert currentRun['iter_steps']
124
125 #assert currentRun['matchmatrixCols']
126 #assert currentRun['matchmatrixRows']
127
128 assert currentRun['mode'] in ['normal','using_quality_scores']
129
130 #assert currentRun['numConstraintsPerRound']
131
132 assert 0 < currentRun['numFeatures'] < 10000
133
134 # assert currentRun['numLengthSuppPoints']
135 # assert currentRun['numDonSuppPoints']
136 # assert currentRun['numAccSuppPoints']
137 #assert currentRun['numQualPlifs']
138 #assert currentRun['numQualSuppPoints']
139 #assert numQualPlifs >= 0
140 #assert numDonSuppPoints > 1
141 #assert numAccSuppPoints > 1
142 #assert numLengthSuppPoints > 1
143 #assert numQualSuppPoints > 1
144
145 assert currentRun['print_matrix'] in [True,False]
146 assert 0 < currentRun['read_size'] < 100
147 assert currentRun['remove_duplicate_scores'] in [True,False]
148
149 assert currentRun['enable_quality_scores'] in [True,False]
150 assert currentRun['enable_splice_signals'] in [True,False]
151 assert currentRun['enable_intron_length'] in [True,False]
152
153 #assert currentRun['totalQualSuppPoints']
154 assert os.path.exists(currentRun['dataset_filename'])
155 assert os.path.exists(currentRun['experiment_path'])
156
157 return allRuns
158
159 if __name__ == '__main__':
160 allRuns = createRuns()
161 pdb.set_trace()