Skip to content

Commit

Permalink
async computation fix
Browse files Browse the repository at this point in the history
  • Loading branch information
bvdmitri committed Mar 9, 2016
1 parent 65c39de commit 68cd5fc
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 19 deletions.
19 changes: 1 addition & 18 deletions app/controllers/AccountAPI.java
Original file line number Diff line number Diff line change
Expand Up @@ -616,23 +616,6 @@ private static Result rarefaction(Account account, Boolean needToCreateNew) thro
return ok(Json.toJson(new CacheServerResponse("success", rarefactionChart.create(needToCreateNew))));
}

private static F.Promise<WebSocket.Out<JsonNode>> asyncCompute(final ComputationUtil computationUtil, final WebSocket.Out<JsonNode> out) {
F.Promise<ComputationUtil> promise = F.Promise.promise(new F.Function0<ComputationUtil>() {
@Override
public ComputationUtil apply() throws Throwable {
computationUtil.createSampleCache();
return computationUtil;
}
});
return promise.map(new F.Function<ComputationUtil, WebSocket.Out<JsonNode>>() {
@Override
public WebSocket.Out<JsonNode> apply(ComputationUtil computationUtil) throws Throwable {
out.close();
return out;
}
});
}

public static class TagRequest {
public String description;
public String color;
Expand Down Expand Up @@ -769,7 +752,7 @@ public void invoke(JsonNode event) {

//Trying to render cache files for sample
ComputationUtil computationUtil = new ComputationUtil(file, sample, out);
asyncCompute(computationUtil, out);
computationUtil.createSampleCache();
return;
} catch (Exception e) {
//On exception delete file and inform user about fail
Expand Down
4 changes: 4 additions & 0 deletions app/graph/VJUsageChart/VJUsageChartCreator.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import java.io.FileNotFoundException;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;

Expand All @@ -35,6 +36,9 @@ public VJUsageChartCreator create() {
SegmentUsage segmentUsage = new SegmentUsage(sampleArray, false);
List<String> labels = new ArrayList<>();
String sampleId = sample.getSampleMetadata().getSampleId();
if (segmentUsage.vjUsageMatrix(sampleId).length == 0) {
throw new RuntimeException("Empty segment usage data");
}
MatrixMath matrixMath = new MatrixMath(segmentUsage.vjUsageMatrix(sampleId),
segmentUsage.jUsageHeader(),
segmentUsage.vUsageHeader(),
Expand Down
2 changes: 1 addition & 1 deletion test/ApplicationTest.java
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@

import com.antigenomics.vdjtools.Software;
import com.antigenomics.vdjtools.io.SampleFileConnection;
import com.antigenomics.vdjtools.misc.Software;
import com.antigenomics.vdjtools.sample.Clonotype;
import com.antigenomics.vdjtools.sample.CompositeClonotypeFilter;
import com.antigenomics.vdjtools.sample.Sample;
Expand Down

0 comments on commit 68cd5fc

Please sign in to comment.