-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathRun.java
More file actions
executable file
·121 lines (106 loc) · 2.93 KB
/
Run.java
File metadata and controls
executable file
·121 lines (106 loc) · 2.93 KB
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
import java.util.ArrayList;
import java.util.Collections;
import java.util.Set;
import hime.model.HIMEFactory;
import hime.model.MotifInterval;
import hime.model.MotifSet;
import interfaces.SAXNode;
import utils.StatUtils;
public class Run {
/**
* Main Class for Hierarchical based Motif Enumeration
*
*
* @author yfeng
*
*/
/** Default input **/
public static int paa = 4, a = 5, x = 300;
public static String INPUT_FILE = "demo.txt";
public static String dir = "";
public static void main(String[] args) throws Exception {
// HIME settings
HIMEFactory.thres = 0.04;
HIMEFactory.adaptive = true;
Parseinput(args);
HIMEFactory.paa = paa;
HIMEFactory.ww = x;
HIMEFactory.a = a;
// System.out.println("Alp: "+HIMEFactory.a);
HIMEFactory.runHIME(dir + INPUT_FILE, paa, a, x);
writeMotifSet();
}
/**
* Parsing input string
*
* @param args
*
*/
private static void Parseinput(String[] args) {
if (args.length == 1)
INPUT_FILE = args[0];
if (args.length == 2) {
INPUT_FILE = args[0];
x = Integer.parseInt(args[1]);
}
if (args.length == 3) {
INPUT_FILE = args[0];
paa = Integer.parseInt(args[1]);
x = Integer.parseInt(args[2]);
}
if (args.length == 4) {
INPUT_FILE = args[0];
paa = Integer.parseInt(args[1]);
x = Integer.parseInt(args[2]);
a = Integer.parseInt(args[3]);
HIMEFactory.adaptive = false;
}
if (args.length == 5) {
INPUT_FILE = args[0];
paa = Integer.parseInt(args[1]);
x = Integer.parseInt(args[2]);
a = Integer.parseInt(args[3]);
HIMEFactory.thres = Double.parseDouble(args[4]);
}
}
private static void writeMotifSet() {
Set<SAXNode> seed = MotifSet.keySet();
int i = 1;
for (SAXNode s : seed) {
ArrayList<MotifInterval> ss2 = new ArrayList<MotifInterval>(MotifSet.get(s));
Collections.sort(ss2);
ArrayList<MotifInterval> sx = new ArrayList<MotifInterval>();
long tmp = -HIMEFactory.ww - 1000;
for (MotifInterval r : ss2) {
long tmp2 = r.getStart();
if (tmp2 - tmp < r.getLength()) {
continue;
}
sx.add(r);
tmp = tmp2;
}
i++;
double dmin = 1000000;
int p1 = 0;
int p2 = 0;
for (int c = 0; c < sx.size(); c++) {
for (int c2 = c + 1; c2 < sx.size(); c2++) {
double d = StatUtils.distance((int) sx.get(c).getStart(), (int) sx.get(c2).getStart(),
Math.min(sx.get(c).getLength(), sx.get(c2).getLength()));
if (dmin > d) {
dmin = d;
p1 = c;
p2 = c2;
}
}
}
if (dmin >= 1000000)
continue;
int l = Math.min(sx.get(p1).getLength(), sx.get(p2).getLength());
if (i % 10000 == 0)
System.out.println(i + " Out of " + seed.size());
System.out.println("Motif: " + sx.get(p1).getStart() + " " + sx.get(p1).getEnd() + " " + sx.get(p2).getStart()
+ " " + sx.get(p2).getEnd() + " " + l + " " + dmin);
}
}
}