Commit c6cb61bc authored by Guillaume Jimenez's avatar Guillaume Jimenez

Fixed Compare Coverage

parent 54ac7cb0
......@@ -107,7 +107,7 @@ const CompareCoverage = {
return {
samplesVisible: true,
// sampleUpdateUrl: webAppRoot + "/getSampleItems",
sampleUpdateUrl: webAppRoot + "/getSampleItemsFiltered",
sampleUpdateUrl: webAppRoot + "/getSampleRunItemsFiltered",
populateSamples_0: null,
populateSamples_1: null,
populateSamples_2: null,
......@@ -166,10 +166,12 @@ const CompareCoverage = {
getAjaxData() {
this.loading = true;
var sampleIds = [];
var runIds = [];
for (var i = 0; i < this.sampleItems.length; i++) {
var value = this.$refs["sampleSelect_" + i].inputValue;
if (value) {
sampleIds.push(value);
sampleIds.push(value.sampleId);
runIds.push(value.runId);
}
}
if (sampleIds.length == 0) {
......@@ -178,6 +180,7 @@ const CompareCoverage = {
axios.get(webAppRoot + "/getCompareCoverageData", {
params: {
sampleIds: sampleIds.join(","),
runIds: runIds.join(","),
isTier1: this.isTier1 == "tier1Only",
uniqueOnly: this.uniqueOnly == "uniq"
}
......@@ -263,7 +266,8 @@ const CompareCoverage = {
});
},
loadSamples(query, currentSelectIndex) {
if (query) {
//prevent queries too short and query results (which are a concat of sampleName + runId)
if (query && query.length > 3 && query.indexOf(" - ") < 0) {
this.noDataText = "Fetching Samples...";
axios.get(this.sampleUpdateUrl, {
params: {
......
......@@ -108,10 +108,12 @@ public class ChartController {
@RequestMapping("/getCompareCoverageData")
@ResponseBody
public String getCompareCoverageData(Model model, HttpSession session, @RequestParam String sampleIds,
@RequestParam Boolean isTier1, @RequestParam Boolean uniqueOnly, @RequestParam String runId) {
@RequestParam String runIds,
@RequestParam Boolean isTier1, @RequestParam Boolean uniqueOnly) {
try {
if (!sampleIds.equals("")) {
String[] sampleIdParsed = sampleIds.split(",");
String[] runIdParsed = runIds.split(",");
List<Integer> sampleIdList = new ArrayList<Integer>();
for (String sampleId : sampleIdParsed) {
sampleIdList.add(Integer.parseInt(sampleId));
......@@ -120,7 +122,9 @@ public class ChartController {
List<Integer> exonsInCommon = coverageDAO.getExonsInCommon(sampleIdList, isTier1, uniqueOnly);
List<Marker> chrMarkers = coverageDAO.getChromosomeMarkers(sampleIdList, isTier1, uniqueOnly);
List<Sample> samplesInOrderReceived = new ArrayList<Sample>();
for (Integer sampleId : sampleIdList) {
for (int i = 0; i < sampleIdList.size(); i++) {
Integer sampleId = sampleIdList.get(i);
String runId = runIdParsed[i];
List<CompareCoverage> coverages = coverageDAO.getCoverageForSample(sampleId, isTier1, uniqueOnly, runId);
Sample sample = sampleDAO.getSample(sampleId);
coveragePerSample.put(sample, coverages);
......@@ -193,6 +197,30 @@ public class ChartController {
}
}
@RequestMapping("/getSampleRunItemsFiltered")
@ResponseBody
public String getSampleRunItemsFiltered(Model model, HttpSession session, @RequestParam String query, @RequestParam(required = false) Integer sampleId
, @RequestParam(required = false) Integer currentSelectIndex,
@RequestParam(required = false) String nucType) {
try {
// List<Sample> samples = sampleDAO.getAllSamples();
// List<Sample> samples = sampleDAO.getAllDNASamples();
List<Sample> samples = null;
if (query != null && query.length() > 0) {
samples = sampleDAO.getAllSamplesFilteredWithCoverage(query, nucType);
}
else {
samples = new ArrayList<Sample>();
samples.add(sampleDAO.getSample(sampleId));
}
SampleItems sampleItems = new SampleItems(samples, currentSelectIndex, modelDAO);
return sampleItems.createVuetifyObjectJSON();
} catch (JsonProcessingException e) {
e.printStackTrace();
return null;
}
}
// @RequestMapping("/getChromItems")
// @ResponseBody
// public String getChromItems(Model model, HttpSession session) {
......
package utsw.bicf.nucliavault.controller.serialization;
public class SearchItemSampleRun extends SearchItem {
Integer sampleId;
String runId;
public SearchItemSampleRun() {
}
public SearchItemSampleRun(String name, Integer sampleId, String runId) {
super();
this.name = name;
this.sampleId = sampleId;
this.runId = runId;
}
public Integer getSampleId() {
return sampleId;
}
public void setSampleId(Integer sampleId) {
this.sampleId = sampleId;
}
public String getRunId() {
return runId;
}
public void setRunId(String runId) {
this.runId = runId;
}
}
package utsw.bicf.nucliavault.controller.serialization.vuetify;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.stream.Collectors;
import utsw.bicf.nucliavault.controller.serialization.SearchItem;
import utsw.bicf.nucliavault.controller.serialization.SearchItemInteger;
import utsw.bicf.nucliavault.controller.serialization.SearchItemSampleRun;
import utsw.bicf.nucliavault.controller.serialization.SearchItems;
import utsw.bicf.nucliavault.dao.ModelDAO;
import utsw.bicf.nucliavault.model.Sample;
import utsw.bicf.nucliavault.model.SeqRun;
public class SampleItems extends SearchItems {
......@@ -18,6 +26,22 @@ public class SampleItems extends SearchItems {
.collect(Collectors.toList());
this.currentSelectIndex = currentSelectIndex;
}
public SampleItems(List<Sample> samples, Integer currentSelectIndex, ModelDAO modelDAO) {
super();
this.items = new ArrayList<SearchItem>();
Map<String, SearchItemSampleRun> uniqueItems = new HashMap<String, SearchItemSampleRun>();
for (Sample s : samples) {
List<SeqRun> runs = modelDAO.getSeqRunBySampleIds(Arrays.asList(s.getSampleId()));
for (SeqRun run : runs) {
String name = s.getSampleLabId() + " - " + run.getSeqRunId();
SearchItemSampleRun item = new SearchItemSampleRun(name, s.getSampleId(), run.getSeqRunId());
uniqueItems.put(name, item);
}
}
items.addAll(uniqueItems.values());
this.currentSelectIndex = currentSelectIndex;
}
public Integer getCurrentSelectIndex() {
return currentSelectIndex;
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment