Skip to content

Commit

Permalink
Changing the available fields table on the documentation page.
Browse files Browse the repository at this point in the history
  • Loading branch information
cyrus0824 committed Jun 4, 2015
1 parent d27277e commit c6eb614
Show file tree
Hide file tree
Showing 4 changed files with 35 additions and 8 deletions.
9 changes: 7 additions & 2 deletions docs/_static/myvariant_doc.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,13 @@ jQuery(document).ready(function() {
jsonpCallback: "callback",
type: "GET",
success: function(data) {
jQuery.each(data, function(field, type) {
jQuery('.indexed-field-table > tbody:last').append('<tr><td>' + field + '</td><td><span class="italic">' + type + '</span></td><td>&nbsp;</td>');
jQuery.each(data, function(field, d) {
if(d.indexed) {
jQuery('.indexed-field-table > tbody:last').append('<tr><td>' + field + '</td><td>&#x2714</td><td><span class="italic">' + d.type + '</span></td><td>' + d.example + '</td>');
}
else {
jQuery('.indexed-field-table > tbody:last').append('<tr><td>' + field + '</td><td>&nbsp</td><td><span class="italic">' + d.type + '</span></td><td>' + d.example + '</td>');
}
});
jQuery('.indexed-field-table').DataTable({
"iDisplayLength": 50,
Expand Down
5 changes: 3 additions & 2 deletions docs/doc/variant_query_service.rst
Original file line number Diff line number Diff line change
Expand Up @@ -107,8 +107,9 @@ Available fields
<thead>
<tr>
<th>Field</th>
<th>Description</th>
<th>Examples</th>
<th>Indexed</th>
<th>Type</th>
<th>Example</th>
</tr>
</thead>
<tbody>
Expand Down
27 changes: 24 additions & 3 deletions src/utils/create_index_mapping_metadata.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,19 @@
from elasticsearch import Elasticsearch
import json

EXAMPLES = {'evs': "chr5:g.126147533G>A",
'cadd': "chr5:g.126141367T>A",
'wellderly': "chr2:g.208133534G>C",
'dbnsfp': "chr5:g.126141367T>A",
'snpedia': "chr7:g.117199646->CTT",
'clinvar': "chr19:g.36332612C>T",
'docm': "chr10:g.89692991A>T",
'mutdb': "chr13:g.88329134G>T",
'cosmic': "chr13:g.24167556C>T",
'dbsnp': "chr5:g.126147533G>A",
'emv': "chr2:g.179634392A>T",
'gwassnps': "chr1:g.117038287T>C"}


def main():
parser = argparse.ArgumentParser()
Expand All @@ -21,10 +34,18 @@ def get_indexed_properties_in_dict(d, prefix):
r = {}
for (k, v) in d.items():
if type(v) is dict:
if 'type' in v and ('index' not in v or ('index' in v and v['index'] != 'no')):
r[prefix + '.' + k] = v['type']
if 'type' in v:
r[prefix + '.' + k] = {}
r[prefix + '.' + k]['type'] = v['type']
if ('index' not in v) or ('index' in v and v['index'] != 'no'):
r[prefix + '.' + k]['indexed'] = True
r[prefix + '.' + k]['example'] = 'q=_exists_:' + prefix.lstrip('.') + '.' + k + '&fields=' + prefix.lstrip('.') + '.' + k
else:
r[prefix + '.' + k]['indexed'] = False
db_type = prefix.lstrip('.').split('.')[0]
r[prefix + '.' + k]['example'] = 'q=' + EXAMPLES[db_type] + '&fields=' + prefix.lstrip('.') + '.' + k
elif 'properties' in v:
r.update(get_indexed_properties_in_dict(v['properties'], prefix + '.' + k))
r.update(get_indexed_properties_in_dict(v['properties'], prefix + '.' + k))
return r

# get the dictionary, strip the leading . from the key names, and write the output
Expand Down
2 changes: 1 addition & 1 deletion src/www/context/myvariant_indexed_fields.json

Large diffs are not rendered by default.

0 comments on commit c6eb614

Please sign in to comment.