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