Skip to content
This repository was archived by the owner on Aug 1, 2024. It is now read-only.

Commit 2cf429b

Browse files
committed
Merge remote-tracking branch 'origin/zodiac_in_sirius_4_release' into zodiac_in_sirius_4_release
2 parents 4766b2e + 5c1d538 commit 2cf429b

File tree

2 files changed

+19
-43
lines changed

2 files changed

+19
-43
lines changed

gibbs_sampling/src/main/java/de/unijena/bioinf/GibbsSampling/model/EdgeThresholdMinConnectionsFilter.java

Lines changed: 15 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -128,68 +128,40 @@ public int[][] postprocessCompleteGraph(Graph graph, MasterJJob masterJJob) thro
128128

129129
start = System.currentTimeMillis();
130130
for(int i = 0; i < graph.getSize(); ++i) {
131-
for(int j = i + 1; j < graph.getSize(); ++j) {
132-
double a = graph.getLogWeight(i, j);
133-
double b = graph.getLogWeight(j, i);
131+
int[] connections = graph.getLogWeightConnections(i);
132+
for (int j = 0; j < connections.length; j++) {
133+
int c = connections[j];
134+
135+
//check if this pair of edges has already beend considered
136+
if (c<i && graph.hasLogWeightConnections(c, i)) continue;
137+
138+
double a = graph.getLogWeight(i, c);
139+
double b = graph.getLogWeight(c, i);
134140
double max;
135141
if(a < b) {
136-
graph.setLogWeight(i, j, b);
142+
graph.setLogWeight(i, c, b);
137143
max = b;
138144
} else if(b < a) {
139-
graph.setLogWeight(j, i, a);
145+
graph.setLogWeight(c, i, a);
140146
max = a;
141147
} else {
142148
max = a;
143149
}
144150

145151
if(max > 0.0D) {
146-
connectionsList[i].add(j);
147-
connectionsList[j].add(i);
152+
connectionsList[i].add(c);
153+
connectionsList[c].add(i);
148154
} else if (max < 0d) {
149155
throw new RuntimeException("Edge has a negative weight");
150156
}
151157
}
152158
}
153159

154-
//todo errors with parallelization.
155-
// allIndices = new ArrayList<>(graph.getSize());
156-
// for (int i = 0; i < graph.numberOfCompounds(); i++) {
157-
// allIndices.add(i);
158-
// }
159-
// System.out.println("size "+allIndices.size());
160-
// ConcurrentLinkedQueue<Integer> candidateIndicesQueue = new ConcurrentLinkedQueue<>(allIndices);
161-
// System.out.println("size2 "+candidateIndicesQueue.size());
162-
// jobs = new ArrayList<>();
163-
// for (int i = 0; i < SiriusJobs.getGlobalJobManager().getCPUThreads(); i++) {
164-
// BasicJJob job = new MakeEdgeScoresSymmetricWorker(candidateIndicesQueue, graph, connectionsList);
165-
// jobs.add(job);
166-
// masterJJob.submitSubJob(job);
167-
// }
168-
// System.out.println("running "+jobs.size()+" workers to postprocess edges, symmetry step");
169-
//
170-
//
171-
// for (BasicJJob job : jobs) {
172-
// job.awaitResult();
173-
// }
174-
//
175-
// for (TIntArrayList intArrayList : connectionsList) {
176-
// intArrayList.sort();
177-
// }
178-
System.out.println("postprocess: second step symmetry took "+(System.currentTimeMillis()-start));
179160

161+
System.out.println("postprocess: second step symmetry took "+(System.currentTimeMillis()-start));
180162

181-
// candidateIndicesQueue = new ConcurrentLinkedQueue<>(allIndices);
182-
// System.out.println("size3 "+candidateIndicesQueue.size());
183163
int[][] connections = new int[graph.getSize()][];
184-
// jobs = new ArrayList<>();
185-
// for (int i = 0; i < SiriusJobs.getGlobalJobManager().getCPUThreads(); i++) {
186-
// BasicJJob job = new CopyArrayJob(connections, connectionsList, candidateIndicesQueue);
187-
// jobs.add(job);
188-
// masterJJob.submitSubJob(job);
189-
// }
190-
// for (BasicJJob job : jobs) {
191-
// job.awaitResult();
192-
// }
164+
193165
for(int i = 0; i < graph.getSize(); ++i) {
194166
connections[i] = connectionsList[i].toArray();
195167
}

gibbs_sampling/src/main/java/de/unijena/bioinf/GibbsSampling/model/Graph.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,10 @@ public int[] getLogWeightConnections(int i) {
145145
return this.indexMap[i].keys();
146146
}
147147

148+
public boolean hasLogWeightConnections(int i, int j) {
149+
return this.indexMap[i].containsKey(j);
150+
}
151+
148152
public void setLogWeight(int i, int j, double weight) {
149153
int relJ = this.indexMap[i].get(j);
150154
if(relJ < 0) {

0 commit comments

Comments
 (0)