Skip to content

Commit

Permalink
Provided means to (1) name individual groups, (2) select DB by taxon
Browse files Browse the repository at this point in the history
  • Loading branch information
GuilhemSempere committed Jun 28, 2024
1 parent 8e9d491 commit e9c4475
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 30 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -948,8 +948,9 @@ public void run() {
List<List<String>> callsetIds = gr.getAllCallSetIds();
for (int i = 0; i < callsetIds.size(); i++)
try {
individualsByPop.put("Group" + (i+1), callsetIds.get(i).isEmpty() ? MgdbDao.getProjectIndividuals(info[0], projId) /* no selection means all selected */ : callsetIds.get(i).stream().map(csi -> csi.substring(1 + csi.lastIndexOf(Helper.ID_SEPARATOR))).collect(Collectors.toSet()));
annotationFieldThresholdsByPop.put("Group" + (i+1), gr.getAnnotationFieldThresholds(i));
String groupName = gr.getGroupName(i);
individualsByPop.put(groupName, callsetIds.get(i).isEmpty() ? MgdbDao.getProjectIndividuals(info[0], projId) /* no selection means all selected */ : callsetIds.get(i).stream().map(csi -> csi.substring(1 + csi.lastIndexOf(Helper.ID_SEPARATOR))).collect(Collectors.toSet()));
annotationFieldThresholdsByPop.put(groupName, gr.getAnnotationFieldThresholds(i));
}
catch (ObjectNotFoundException neverWillHappen) // module existence has been checked above
{}
Expand Down Expand Up @@ -2731,21 +2732,22 @@ public List<String> searchableGenesLookup(

@ApiOperation(authorizations = { @Authorization(value = "AuthorizationToken") }, value = INSTANCE_CONTENT_SUMMARY)
@GetMapping(value = BASE_URL + INSTANCE_CONTENT_SUMMARY, produces = "application/json")
public @ResponseBody Map<String, Object> getAllDatabaseInfo(HttpServletRequest request, HttpServletResponse response) throws AvroRemoteException {
public @ResponseBody Map<String, Object> getAllDatabaseInfo(HttpServletRequest request, HttpServletResponse response) throws AvroRemoteException {
SearchReferenceSetsResponse accessibleDBs = ga4ghController.searchReferenceSets(request, new SearchReferenceSetsRequest());
Iterator<ReferenceSet> dbIterator = accessibleDBs.getReferenceSets().iterator();

Map<String, Object> resultObjects = new LinkedHashMap<String, Object>();
int i = 1;
while (dbIterator.hasNext()) {
String dbName = dbIterator.next().getName();
MongoTemplate mongoTemplate = MongoTemplateManager.get(dbName);

Map<String, Object> resultObject = new LinkedHashMap<String, Object>();

resultObject.put("database", dbName);
resultObject.put("individuals", Helper.estimDocCount(dbName, Individual.class));
resultObject.put("markers", Helper.estimDocCount(dbName, VariantData.class));
resultObject.put("samples", Helper.estimDocCount(dbName, GenotypingSample.class));
resultObject.put("taxon", Helper.nullToEmptyString(MongoTemplateManager.getTaxonName(dbName)));

Query query = new Query();
query.fields().include(GenotypingProject.FIELDNAME_PLOIDY_LEVEL)
Expand All @@ -2762,7 +2764,8 @@ public List<String> searchableGenesLookup(
pj.put("description", project.getDescription());
pj.put("variantType", project.getVariantTypes());
pj.put("ploidy", project.getPloidyLevel());
pj.put("runNumber", project.getRuns().size());
pj.put("samples", mongoTemplate.count(new Query(Criteria.where(GenotypingSample.FIELDNAME_PROJECT_ID).is(project.getId())), GenotypingSample.class));
pj.put("runs", project.getRuns());
resultObject.put("Project" + j, pj);
j++;
}
Expand Down
58 changes: 47 additions & 11 deletions src/main/webapp/index.jsp
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
</div>
</div>
<div id="sequenceFilter">
<div class="custom-label margin-top-md" id="sequencesLabel">Sequences</div>
<div class="custom-label margin-top-md" id="sequencesLabel">Sequences <span style="font-weight:normal;"></span></div>
<div id="Sequences"></div>
</div>
<div id="positions" class="margin-top-md">
Expand Down Expand Up @@ -529,7 +529,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Load reference genome <span class="caret"></span>
</a>
<ul class="dropdown-menu" id="igvGenomeMenu" style="max-height:75vh;overflow-y:auto">
<ul class="dropdown-menu" id="igvGenomeMenu" style="max-height:75vh; z-index: 2000; overflow-y:auto;">
<li><a href="#" data-toggle="modal" data-target="#igvGenomeFileModal">Load from file</a></li>
<li><a href="#" data-toggle="modal" data-target="#igvGenomeURLModal">Load from URL</a></li>
<li role="separator" class="divider" id="igvDefaultGenomesDivider"></li>
Expand All @@ -548,7 +548,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
<a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false">
Displayed genotypes <span class="caret"></span>
</a>
<ul class="dropdown-menu" style="max-height:75vh;overflow-y:auto"></ul>
<ul class="dropdown-menu" style="max-height:75vh; z-index: 2000; overflow-y:auto;"></ul>
</li>
</ul>
</div>
Expand Down Expand Up @@ -733,6 +733,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
var referenceNames;
var exportedIndividualCount = 0;
var indOpt = [];
var databasesByTaxon = {};
$.ajaxSetup({cache: false});
Expand All @@ -758,8 +759,12 @@ https://doi.org/10.1093/gigascience/giz051</pre>
referenceset = $(this).val();
if (!loadProjects(referenceset))
if (referenceset == "" || !loadProjects(referenceset)) {
$("div.alert").hide();
$("div#searchPanel").fadeOut();
$("div#welcome").fadeIn();
return;
}
$("div#welcome").hide();
Expand Down Expand Up @@ -927,7 +932,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
});
$('#Sequences').on('multiple_select_change', function() {
var nCount = $('#Sequences').selectmultiple('count');
$('#sequencesLabel').html("Sequences (" + (nCount == 0 ? seqCount : nCount) + "/" + seqCount + ")");
$('#sequencesLabel span').text((nCount == 0 ? seqCount : nCount) + "/" + seqCount + "");
});
$('#displayAllGt').on('change', function() {
loadGenotypes(true);
Expand Down Expand Up @@ -1060,18 +1065,49 @@ https://doi.org/10.1093/gigascience/giz051</pre>
"pageToken": null
}),
success: function(jsonResult) {
var option = "";
var dbListOptions = "";
for (var set in jsonResult.referenceSets) {
option += '<option>' + jsonResult.referenceSets[set].name + '</option>';
let taxon = null;
jsonResult.referenceSets[set].description.split(" ; ").forEach(function(descItem) {
if (descItem.startsWith("Species:"))
taxon = descItem.substring("Species:".length).trim();
else if (descItem.startsWith("Taxon:"))
taxon = descItem.substring("Taxon:".length).trim();
});
if (taxon == null)
taxon = "(Unspecified taxon)";
if (databasesByTaxon[taxon] == null)
databasesByTaxon[taxon] = [];
databasesByTaxon[taxon].push(jsonResult.referenceSets[set].name);
dbListOptions += '<option data-taxon="' + taxon + '">' + jsonResult.referenceSets[set].name + '</option>';
}
$('#module').html(option).selectpicker('refresh');
let sortedTaxa = Object.keys(databasesByTaxon);
sortedTaxa.sort();
if (Object.keys(databasesByTaxon).length > 1) {
$('#grpTaxa').show();
for (let i in sortedTaxa) {
databasesByTaxon[sortedTaxa[i]].sort();
$("#taxa").append("<option>" + sortedTaxa[i] + "</option>")
}
}
$("#taxa").selectpicker("refresh");
$('#module').html(dbListOptions).selectpicker('refresh');
var module = $_GET("module"); // get module from url
if (module != null) // sometimes a # appears at the end of the url so we remove it with regexp
module = module.replace(new RegExp('#([^\\s]*)', 'g'), '');
if (module !== null) {
if (module != null) {
$('#module').selectpicker('val', module);
$('#module').trigger('change');
let moduleTaxon = $('#module option').filter(':selected').attr("data-taxon");
if (moduleTaxon != null) {
$("#taxa").val(moduleTaxon);
$("#taxa").selectpicker("refresh").trigger('change');
}
}
},
error: function(xhr, ajaxOptions, thrownError) {
Expand Down Expand Up @@ -1206,7 +1242,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
}),
success: function(jsonResult) {
seqCount = jsonResult.result.data.length;
$('#sequencesLabel').html("Sequences (" + seqCount + "/" + seqCount + ")");
$('#sequencesLabel span').text( seqCount + "/" + seqCount + "");
referenceNames = [];
jsonResult.result.data.forEach(ref => {
referenceNames.push(ref["referenceName"]);
Expand Down Expand Up @@ -2561,7 +2597,7 @@ https://doi.org/10.1093/gigascience/giz051</pre>
trackIndividuals.forEach(function (individuals, index, array) {
trackConfigs.push({
name: array.length > 1 ? "Group " + (index + 1) : "Query",
name: array.length > 1 ? $("input#group" + (index + 1)).val() : "Query",
type: "variant",
format: "custom",
sourceType: "file",
Expand Down
2 changes: 1 addition & 1 deletion src/main/webapp/js/charts.js
Original file line number Diff line number Diff line change
Expand Up @@ -990,7 +990,7 @@ function updateAvailableGroups() {
$("#chartGroupSelectionDesc").css("visibility", "hidden");
let selectOptions = "";
for (var i=1; i<=getGenotypeInvestigationMode(); i++)
selectOptions += '<option value="' + i + '">Investigation group #' + i + '</option>';
selectOptions += '<option value="' + i + '">' + $("input#group" + i).val() + '</option>';
$("select#plotGroupingMetadataValues").html(selectOptions);
if (!areGroupsOverlapping(groupSelect.val()))
$("select#plotGroupingMetadataValues").find('option').prop('selected', true);
Expand Down
Loading

0 comments on commit e9c4475

Please sign in to comment.