875 |
05 Dec 08 |
jari |
1 |
/* |
875 |
05 Dec 08 |
jari |
* $Id$ |
875 |
05 Dec 08 |
jari |
3 |
* |
875 |
05 Dec 08 |
jari |
* Copyright (C) 2005 Johan Enell |
875 |
05 Dec 08 |
jari |
* Copyright (C) 2008 Jari Häkkinen |
875 |
05 Dec 08 |
jari |
6 |
|
875 |
05 Dec 08 |
jari |
* This file is part of the se.lu.onk.Center plug-in for |
875 |
05 Dec 08 |
jari |
* BASE. Available at http://baseplugins.thep.lu.se/ and BASE web site |
875 |
05 Dec 08 |
jari |
* is http://base.thep.lu.se |
875 |
05 Dec 08 |
jari |
10 |
|
875 |
05 Dec 08 |
jari |
* This is free software; you can redistribute it and/or modify it |
875 |
05 Dec 08 |
jari |
* under the terms of the GNU General Public License as published by |
875 |
05 Dec 08 |
jari |
* the Free Software Foundation; either version 3 of the License, or |
875 |
05 Dec 08 |
jari |
* (at your option) any later version. |
875 |
05 Dec 08 |
jari |
15 |
|
875 |
05 Dec 08 |
jari |
* The software is distributed in the hope that it will be useful, but |
875 |
05 Dec 08 |
jari |
* WITHOUT ANY WARRANTY; without even the implied warranty of |
875 |
05 Dec 08 |
jari |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU |
875 |
05 Dec 08 |
jari |
* General Public License for more details. |
875 |
05 Dec 08 |
jari |
20 |
|
875 |
05 Dec 08 |
jari |
* You should have received a copy of the GNU General Public License |
875 |
05 Dec 08 |
jari |
* along with this software. If not, see <http://www.gnu.org/licenses/>. |
875 |
05 Dec 08 |
jari |
23 |
*/ |
875 |
05 Dec 08 |
jari |
24 |
|
149 |
10 Aug 06 |
enell |
25 |
package center; |
149 |
10 Aug 06 |
enell |
26 |
|
149 |
10 Aug 06 |
enell |
27 |
import basefile.BASEFileReader; |
149 |
10 Aug 06 |
enell |
28 |
import basefile.BASEFileSection; |
149 |
10 Aug 06 |
enell |
29 |
|
149 |
10 Aug 06 |
enell |
30 |
import java.io.File; |
149 |
10 Aug 06 |
enell |
31 |
import java.io.FileOutputStream; |
149 |
10 Aug 06 |
enell |
32 |
import java.io.PrintStream; |
149 |
10 Aug 06 |
enell |
33 |
|
149 |
10 Aug 06 |
enell |
34 |
public class Main |
149 |
10 Aug 06 |
enell |
35 |
{ |
149 |
10 Aug 06 |
enell |
36 |
public static void main(String[] args) |
149 |
10 Aug 06 |
enell |
37 |
{ |
149 |
10 Aug 06 |
enell |
38 |
try |
149 |
10 Aug 06 |
enell |
39 |
{ |
149 |
10 Aug 06 |
enell |
40 |
BASEFileReader bfr = null; |
149 |
10 Aug 06 |
enell |
41 |
if (args.length == 1) |
149 |
10 Aug 06 |
enell |
42 |
{ |
149 |
10 Aug 06 |
enell |
43 |
bfr = new BASEFileReader(new File(args[0])); |
149 |
10 Aug 06 |
enell |
44 |
} |
149 |
10 Aug 06 |
enell |
45 |
else if (args.length == 0) |
149 |
10 Aug 06 |
enell |
46 |
{ |
149 |
10 Aug 06 |
enell |
47 |
bfr = new BASEFileReader(new File("stdin.txt")); |
149 |
10 Aug 06 |
enell |
48 |
} |
149 |
10 Aug 06 |
enell |
49 |
else |
149 |
10 Aug 06 |
enell |
50 |
{ |
149 |
10 Aug 06 |
enell |
51 |
System.err.println("center: invalid input given"); |
149 |
10 Aug 06 |
enell |
52 |
System.exit(-1); |
149 |
10 Aug 06 |
enell |
53 |
} |
149 |
10 Aug 06 |
enell |
54 |
System.setOut(new PrintStream(new FileOutputStream("stdout.txt"))); |
149 |
10 Aug 06 |
enell |
55 |
System.out.println("BASEfile"); |
149 |
10 Aug 06 |
enell |
56 |
|
149 |
10 Aug 06 |
enell |
57 |
Center center = new Center(); |
149 |
10 Aug 06 |
enell |
58 |
BASEFileSection section = bfr.readSection(true); |
149 |
10 Aug 06 |
enell |
59 |
while (section != null) |
149 |
10 Aug 06 |
enell |
60 |
{ |
149 |
10 Aug 06 |
enell |
61 |
if (section.isType("center settings")) |
149 |
10 Aug 06 |
enell |
62 |
{ |
149 |
10 Aug 06 |
enell |
63 |
center.extractSettings(section); |
149 |
10 Aug 06 |
enell |
64 |
} |
149 |
10 Aug 06 |
enell |
65 |
else if (section.isType("assays")) |
149 |
10 Aug 06 |
enell |
66 |
{ |
149 |
10 Aug 06 |
enell |
67 |
center.extractAssays(section, bfr); |
149 |
10 Aug 06 |
enell |
68 |
} |
149 |
10 Aug 06 |
enell |
69 |
else if (section.isType("spots")) |
149 |
10 Aug 06 |
enell |
70 |
{ |
149 |
10 Aug 06 |
enell |
71 |
center.extractSpots(section, bfr); |
149 |
10 Aug 06 |
enell |
72 |
} |
149 |
10 Aug 06 |
enell |
73 |
section = bfr.readSection(); |
149 |
10 Aug 06 |
enell |
74 |
} |
149 |
10 Aug 06 |
enell |
75 |
center.center(); |
149 |
10 Aug 06 |
enell |
76 |
|
149 |
10 Aug 06 |
enell |
77 |
} |
149 |
10 Aug 06 |
enell |
78 |
catch (OutOfMemoryError oome) |
149 |
10 Aug 06 |
enell |
79 |
{ |
149 |
10 Aug 06 |
enell |
80 |
System.err.println("No more memory in the java virtual machine. Try to start the application with 'java -Xmx256m Center' or 'java -Xmx512m Center'. If you need even more memory, duplicate the digit"); |
149 |
10 Aug 06 |
enell |
81 |
System.exit(-1); |
149 |
10 Aug 06 |
enell |
82 |
} |
149 |
10 Aug 06 |
enell |
83 |
catch (Exception e) |
149 |
10 Aug 06 |
enell |
84 |
{ |
149 |
10 Aug 06 |
enell |
85 |
e.printStackTrace(); |
149 |
10 Aug 06 |
enell |
86 |
System.exit(-1); |
149 |
10 Aug 06 |
enell |
87 |
} |
149 |
10 Aug 06 |
enell |
88 |
} |
149 |
10 Aug 06 |
enell |
89 |
} |