+ fixed bug in the index calculation of donor/acceptor scores
[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_test_new'
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 currentRun['numLengthSuppPoints'] = 10 #Conf.numLengthSuppPoints
61 currentRun['numDonSuppPoints'] = 10
62 currentRun['numAccSuppPoints'] = 10
63
64 currentRun['numQualPlifs'] = Conf.numQualPlifs
65 currentRun['numQualSuppPoints'] = 10
66 currentRun['totalQualSuppPoints'] = currentRun['numQualPlifs']*currentRun['numQualSuppPoints']
67
68 currentRun['numFeatures'] = currentRun['numLengthSuppPoints']\
69 + currentRun['numDonSuppPoints'] + currentRun['numAccSuppPoints']\
70 + currentRun['matchmatrixRows'] * currentRun['matchmatrixCols']\
71 + currentRun['totalQualSuppPoints']
72
73 # run-specific settings
74 currentRun['training_begin'] = Conf.training_begin
75 currentRun['training_end'] = Conf.training_end
76 currentRun['prediction_begin'] = Conf.prediction_begin
77 currentRun['prediction_end'] = Conf.prediction_end
78
79 currentRun['enable_quality_scores'] = QFlag
80 currentRun['enable_splice_signals'] = SSFlag
81 currentRun['enable_intron_length'] = ILFlag
82
83 currentName = 'run_%s_quality_%s_splicesignals_%s_intron_len' %\
84 (bool2str[QFlag],bool2str[SSFlag],bool2str[ILFlag])
85
86 currentRun['C'] = 100
87
88 currentRun['name'] = currentName
89 currentRun['dataset_filename'] = dataset_filename
90 currentRun['experiment_path'] = experiment_dir
91
92 currentRun['min_intron_len'] = 20
93 currentRun['max_intron_len'] = 2000
94
95 #currentRun['min_intron_len'] = 10
96 #currentRun['max_intron_len'] = 100
97
98 currentRun['min_svm_score'] = 0.0
99 currentRun['max_svm_score'] = 1.0
100
101 currentRun['min_qual'] = -5
102 currentRun['max_qual'] = 40
103
104 currentRun['dna_flat_files'] = Conf.dna_flat_fn
105
106 allRuns.append(currentRun)
107
108 #
109 # check for valid paths / options etc
110 #
111 for currentRun in allRuns:
112
113 assert 0 < currentRun['anzpath'] < 100
114 assert 0 <= currentRun['training_begin'] < currentRun['training_end']
115 assert currentRun['training_end'] <= currentRun['prediction_begin'] < currentRun['prediction_end']
116
117 assert currentRun['iter_steps']
118
119 #assert currentRun['matchmatrixCols']
120 #assert currentRun['matchmatrixRows']
121
122 assert currentRun['mode'] in ['normal','using_quality_scores']
123
124 #assert currentRun['numConstraintsPerRound']
125
126 assert 0 < currentRun['numFeatures'] < 10000
127
128 # assert currentRun['numLengthSuppPoints']
129 # assert currentRun['numDonSuppPoints']
130 # assert currentRun['numAccSuppPoints']
131 #assert currentRun['numQualPlifs']
132 #assert currentRun['numQualSuppPoints']
133 #assert numQualPlifs >= 0
134 #assert numDonSuppPoints > 1
135 #assert numAccSuppPoints > 1
136 #assert numLengthSuppPoints > 1
137 #assert numQualSuppPoints > 1
138
139 assert currentRun['print_matrix'] in [True,False]
140 assert 0 < currentRun['read_size'] < 100
141 assert currentRun['remove_duplicate_scores'] in [True,False]
142
143 assert currentRun['enable_quality_scores'] in [True,False]
144 assert currentRun['enable_splice_signals'] in [True,False]
145 assert currentRun['enable_intron_length'] in [True,False]
146
147 #assert currentRun['totalQualSuppPoints']
148 assert os.path.exists(currentRun['dataset_filename'])
149 assert os.path.exists(currentRun['experiment_path'])
150
151 return allRuns
152
153 if __name__ == '__main__':
154 allRuns = createRuns()
155 pdb.set_trace()