-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathForm1.cs
executable file
·396 lines (297 loc) · 14 KB
/
Form1.cs
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Diagnostics;
namespace Chromophobia
{
[System.Runtime.InteropServices.ComVisible(true)]
public partial class Form1 : Form
{
protected String appPath;
protected String chromosome, modelDatabase;
protected int runs, cuts;
protected float probability;
protected bool extendedOutput;
protected String nullModelName;
public Form1()
{
InitializeComponent();
webBrowser1.Url = new Uri(String.Format("file:///{0}html/index.html", App.Path));
webBrowser1.ObjectForScripting = this;
selectModelDatabase.SelectedIndex = 0;
RefreshForm();
}
private void webBrowser1_DocumentCompleted(object sender, WebBrowserDocumentCompletedEventArgs e)
{
WriteHtml("<div id='overview-container'><table id='overview-table'><tr><th>Simulation ID</th><th>Runs</th><th>Cuts</th><th>Probability</th><th>Chromosome</th><th>"
+ "Model</th><th>Total Score</th><th>#Genes</th><th>#ORFs</th><th>#Hits</th><th>#Hit ORFs</th><th>Runs/s</th></tr>"
+ "</table></div><div id='overviewCopyLink'><a href='#' onclick='window.clipboardData.setData(\"Text\",$(\"#overview-container\").html());writeElement(\"Copied. Paste to Excel or any other application.\", \"#progress\");return false;'>Copy overview table to clipboard</a>"
+ "</div>", "#overview");
}
private void Form1_Load(object sender, EventArgs e)
{
}
public void RefreshForm()
{
selectChromosome.Items.Clear();
selectChromosome.Items.Add("4q");
// Virtuelle Chromosomen laden
System.Data.Common.DbDataReader res = App.DB.Query("SELECT * FROM chromosome WHERE facFile != '' AND originalChromosomeId > 0 ORDER BY name ASC");
while (res.Read())
{
String chromosome = res["name"].ToString();
selectChromosome.Items.Add(chromosome);
}
selectChromosome.SelectedIndex = 0;
}
protected void WebBrowserInvoke(String func, object[] args)
{
if (webBrowser1.InvokeRequired)
{
this.Invoke((MethodInvoker)delegate
{
webBrowser1.Document.InvokeScript(func, args);
});
}
else webBrowser1.Document.InvokeScript(func, args);
}
public void LogScroll()
{
WebBrowserInvoke("logScroll", null);
}
public void Log(String s)
{
WebBrowserInvoke("log", new String[] { s });
}
public void WriteHtml(String sHtml, String sHtmlElementId)
{
WebBrowserInvoke("writeElement", new String[] { sHtml, sHtmlElementId });
}
public void AppendHtml(String sHtml, String sHtmlElementId)
{
WebBrowserInvoke("appendElement", new String[] { sHtml, sHtmlElementId });
}
public void SwitchToOutput()
{
tabControl.SelectTab("tabOutput");
}
private void buttonCreateNullModel_Click(object sender, EventArgs e)
{
nullModelName = textNullmodelName.Text;
SwitchToOutput();
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += worker_CreateNullModel;
bw.RunWorkerAsync();
bw.Dispose();
}
private void worker_CreateNullModel(object sender, DoWorkEventArgs e)
{
Chromosome chr4 = new Chromosome("4");
ChromosomeCreator creator = new ChromosomeCreator(chr4, chr4.GetQ());
creator.CreateNullModel(nullModelName);
}
private void buttonTestNull_Click(object sender, EventArgs e)
{
SwitchToOutput();
nullModelName = textNullmodelName.Text;
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += worker_TestNullModel;
bw.RunWorkerAsync();
bw.Dispose();
}
private void worker_TestNullModel(object sender, DoWorkEventArgs e)
{
Test.TestNullModell4(nullModelName);
}
private void buttonEnsemblSqlite_Click(object sender, EventArgs e)
{
tabControl.SelectTab("tabOutput");
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += worker_ConvertEnsembl;
bw.RunWorkerAsync();
bw.Dispose();
}
private void buttonImportEnsemblSynteny_Click(object sender, EventArgs e)
{
tabControl.SelectTab("tabOutput");
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += worker_SqliteSynteny;
bw.RunWorkerAsync();
bw.Dispose();
}
private void buttonConvertChromosome_Click(object sender, EventArgs e)
{
Import.ConvertFasta();
}
private void worker_SqliteSynteny(object sender, DoWorkEventArgs e)
{
Import.EnsemblSynteny();
}
private void worker_ConvertEnsembl(object sender, DoWorkEventArgs e)
{
App.DB.OpenFast();
Import.EnsemblToSqlite();
Import.ImportEnsemblChromosomes();
Import.ImportEnsemblExons();
}
private void buttonChromoBatch_Click(object sender, EventArgs e)
{
SwitchToOutput();
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += worker_ChromothripsisBatch;
bw.RunWorkerAsync();
bw.Dispose();
}
public void worker_ChromothripsisBatch(object sender, EventArgs e)
{
App.Log();
App.Log();
Chromothripsis chromo4q, chromo4qnull, chromo4qnull2, chromo4qnull3;
Chromosome chr4 = new Chromosome("4");
Range chr4q = chr4.GetQ();
chromo4q = new Chromothripsis(chr4, chr4q);
Chromosome chr4qnull = new Chromosome("4qnull");
chromo4qnull = new Chromothripsis(chr4qnull);
Chromosome chr4qnull2 = new Chromosome("4qnull_2");
chromo4qnull2 = new Chromothripsis(chr4qnull2);
Chromosome chr4qnull3 = new Chromosome("4qnull_3");
chromo4qnull3 = new Chromothripsis(chr4qnull3);
int i;
for (i = 0; i < 2; i++) chromo4qnull.RunSimulations(100000, 400, 0.5, "chromo");
for (i = 0; i < 2; i++) chromo4qnull2.RunSimulations(100000, 400, 0.5, "chromo");
for (i = 0; i < 2; i++) chromo4qnull3.RunSimulations(100000, 400, 0.5, "chromo");
for (i = 0; i < 20; i++) chromo4q.RunSimulations(100000, 200, 0.5, "chromo");
for (i = 0; i < 10; i++) chromo4qnull.RunSimulations(100000, 200, 0.5, "chromo");
chromo4q.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4q.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4q.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4q.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4q.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4q.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4qnull.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4qnull2.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4qnull3.RunSimulations(100000, 200, 0.5, "pfam-a");
for (i = 0; i < 20; i++) chromo4q.RunSimulations(100000, 200, 0.5, "chromo");
for (i = 0; i < 10; i++) chromo4qnull2.RunSimulations(100000, 200, 0.5, "chromo");
for (i = 0; i < 10; i++) chromo4qnull3.RunSimulations(100000, 200, 0.5, "chromo");
for (i = 0; i < 10; i++) chromo4qnull.RunSimulations(100000, 200, 0.5, "chromo");
for (i = 0; i < 100; i++) chromo4q.RunSimulations(100000, 200, 0.5, "chromo");
/*
for (i = 0; i < 5; i++) chromo4q.RunSimulations(250000, 200, 0.5, "chromo");
for (i = 0; i < 3; i++) chromo4qnull.RunSimulations(250000, 200, 0.5, "chromo");
for (i = 0; i < 3; i++) chromo4qnull2.RunSimulations(250000, 200, 0.5, "chromo");
for (i = 0; i < 3; i++) chromo4qnull3.RunSimulations(250000, 200, 0.5, "chromo");
for (i = 0; i < 15; i++) chromo4q.RunSimulations(100000, 100, 0.5, "chromo");
for (i = 0; i < 7; i++) chromo4qnull.RunSimulations(100000, 100, 0.5, "chromo");
for (i = 0; i < 7; i++) chromo4qnull2.RunSimulations(100000, 100, 0.5, "chromo");
for (i = 0; i < 7; i++) chromo4qnull3.RunSimulations(100000, 100, 0.5, "chromo");
for (i = 0; i < 12; i++) chromo4q.RunSimulations(100000, 400, 0.5, "chromo");
for (i = 0; i < 5; i++) chromo4qnull.RunSimulations(100000, 400, 0.5, "chromo");
for (i = 0; i < 5; i++) chromo4qnull2.RunSimulations(100000, 400, 0.5, "chromo");
for (i = 0; i < 5; i++) chromo4qnull3.RunSimulations(100000, 400, 0.5, "chromo");
*/
// App.Log("<h3>Original chromosome vs. null models</h3>", true);
/* for (i = 0; i < 9; i++) chromo4q.RunSimulations(100000, 200, 0.5, "chromo");
chromo4q.RunSimulations(100000, 200, 0.5, "chromo", true);
for (i = 0; i < 9; i++) chromo4qnull.RunSimulations(100000, 200, 0.5, "chromo");
chromo4qnull.RunSimulations(100000, 200, 0.5, "chromo", true);
for (i = 0; i < 10; i++) chromo4qnull2.RunSimulations(100000, 200, 0.5, "chromo");
for (i = 0; i < 10; i++) chromo4qnull3.RunSimulations(100000, 200, 0.5, "chromo");*/
/*
App.Log("<h3>PFam-A Test</h3>", true);
chromo4q.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4q.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4q.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4qnull.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4qnull.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4qnull2.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4qnull2.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4qnull2.RunSimulations(100000, 200, 0.5, "pfam-a");
chromo4qnull2.RunSimulations(100000, 200, 0.5, "pfam-a");
*/
/*
App.Log("<h3>Run numbers</h3>", true);
for (i = 0; i < 5; i++) chromo4q.RunSimulations(1000, 100, 0.5, "chromo");
for (i = 0; i < 5; i++) chromo4q.RunSimulations(5000, 100, 0.5, "chromo");
for (i = 0; i < 5; i++) chromo4q.RunSimulations(10000, 100, 0.5, "chromo");
for (i = 0; i < 5; i++) chromo4q.RunSimulations(50000, 100, 0.5, "chromo");
for (i = 0; i < 3; i++) chromo4q.RunSimulations(100000, 100, 0.5, "chromo");
for (i = 0; i < 2; i++) chromo4q.RunSimulations(500000, 100, 0.5, "chromo");
chromo4q.RunSimulations(1000000, 100, 0.5, "chromo");
chromo4q.RunSimulations(2000000, 100, 0.5, "chromo");
*/
// for (i = 0; i < 10; i++) chromo4q.RunSimulations(100000, 200, 0.5, "chromo");
}
private void buttonRun_Click(object sender, EventArgs e)
{
runs = (int)numericRuns.Value;
cuts = (int)numericCuts.Value;
probability = (float)numericProbability.Value;
chromosome = selectChromosome.Text;
modelDatabase = selectModelDatabase.Text;
extendedOutput = checkExtendedOutput.Checked;
tabControl.SelectTab("tabOutput");
// tabControl.Enabled = false;
BackgroundWorker bw = new BackgroundWorker();
bw.DoWork += worker_Chromothripsis;
bw.RunWorkerAsync();
bw.Dispose();
}
private void worker_Chromothripsis(object sender, DoWorkEventArgs e)
{
DoChromothripsis();
}
public void DoChromothripsis()
{
Chromothripsis chromo;
if (chromosome == "4q")
{
Chromosome chr = new Chromosome("4");
Range chr4q = chr.GetQ();
chromo = new Chromothripsis(chr, chr4q);
}
else
{
Chromosome chr = new Chromosome(chromosome);
chromo = new Chromothripsis(chr);
}
chromo.RunSimulations(runs, cuts, probability, modelDatabase, extendedOutput);
}
private void buttonHmmscan_Click(object sender, EventArgs e)
{
String title = textHmmTitle.Text;
String seq1 = textHmmSequence.Text;
String seq2 = textHmmSequence2.Text;
String res = Import.FusionHmmScan(title, seq1, seq2);
textHmmResults.Text += res;
textHmmResults.ScrollToCaret();
}
private void buttonHmmClear_Click(object sender, EventArgs e)
{
textHmmResults.Clear();
}
private void buttonHmmCreateFile_Click(object sender, EventArgs e)
{
int iWritten = Import.CreateHmmModelFile(textHmmDomains.Lines, textHmmFilename.Text);
labelHmmFileResult.Text = iWritten.ToString() + " models written";
}
private void selectChromosome_SelectedIndexChanged(object sender, EventArgs e)
{
}
private void buttonChromosomeRead_Click(object sender, EventArgs e)
{
String name = textCRChromosome.Text;
int start = Convert.ToInt32(textCRStart.Text);
int end = Convert.ToInt32(textCREnd.Text);
Chromosome chr = new Chromosome(name);
String res = chr.Read(start, end - start);
textCRRes.Text += res + Environment.NewLine + Environment.NewLine;
}
}
}