Skip to content

Commit

Permalink
Merge pull request #199 from SBRG/escher-fixes-195
Browse files Browse the repository at this point in the history
Changes for v1.2
  • Loading branch information
zakandrewking committed May 11, 2016
2 parents 15d1a9c + 6a4e219 commit 669123d
Show file tree
Hide file tree
Showing 7 changed files with 51 additions and 12 deletions.
5 changes: 3 additions & 2 deletions bigg_models/model_dumper.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
def autodetect_model_polisher():
"""Return the path to ModelPolisher."""
return abspath(join(dirname(__file__), '..', 'bin',
'ModelPolisher-1.2.jar'))
'ModelPolisher-1.3.jar'))


def make_all_static_models():
Expand Down Expand Up @@ -96,7 +96,8 @@ def write_static_model(bigg_id, model_polisher_path=None):
'--compression-type=NONE',
'--check-mass-balance=true',
'--omit-generic-terms=false',
'--log-level=INFO']
'--log-level=INFO',
'--include-any-uri=false']
polish_result = call(command)
print('Polishing finished in %.2f seconds' % (time.time() - t))
if polish_result == 0:
Expand Down
6 changes: 3 additions & 3 deletions bigg_models/templates/advanced_search.html
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ <h1 class="centered">Advanced Search</h1>

<hr/>
<h2>
Search Metabolites by External IDs
{% with question_title='Search Metabolites by External IDs'%}
{% with question_text='You can search for metabolites in the BiGG Database by entering an identifier from an external database. Use the dropdown menu to choose the external database, and enter the identifier in the Database ID box.'%}
Search Metabolites and Reactions by External IDs
{% with question_title='Search Metabolites and Reactions by External IDs'%}
{% with question_text='You can search for metabolites and reactions in the BiGG Database by entering an identifier from an external database. Use the dropdown menu to choose the external database, and enter the identifier in the Database ID box.'%}
{% include 'question_mark.html' %}
{% endwith %}
{% endwith %}
Expand Down
4 changes: 2 additions & 2 deletions bigg_models/templates/escher_div.html
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,8 @@ <h2>
{% endwith %}
{% endwith %}
</h2>
<div id="map" class="escher-map"></div>
<a class="btn btn-default btn-md" href="https://escher.github.io/builder.html?map_name={{escher_maps[0]['map_name']}}" target="_blank">
<div id="map" class="escher-map"></div>
<a class="btn btn-default btn-md" href="https://escher.github.io/builder/index.html?enable_editing=true&map_name={{escher_maps[0]['map_name']}}" target="_blank">
Open map in a new window
</a>
<a class="btn btn-default btn-md" href="https://escher.github.io/" target="_blank">
Expand Down
7 changes: 5 additions & 2 deletions bigg_models/templates/escher_script.html
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,11 @@
})
map_sel.selectAll('.reaction').on('click', function (d) {
console.log('clicked ', d)
if (d.bigg_id)
window.location.href = '/models/{{model_bigg_id}}/reactions/' + d.bigg_id;
if (d.bigg_id) {
// Strip _copy1, etc
url = '/models/{{model_bigg_id}}/reactions/' + d.bigg_id.replace(/_copy[0-9]+$/, '')
window.location.href = url
}
})
}

Expand Down
2 changes: 1 addition & 1 deletion bigg_models/version.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# BiGG Models follows semantic versioning, with the added requirement that
# namespace changes only occur with major releases (e.g. 1.1.2 -> 2.0.0).
__version__ = '1.1.0'
__version__ = '1.2.0'
# The BiGG Models web API is versioned separately.
__api_version__ = 'v2'
Binary file not shown.
39 changes: 37 additions & 2 deletions bin/load_metanetx
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ files = {
# XREF <tab> MNX_ID
# bigg:10FTHF5GLUtl <tab> MNXR1

# 'reac_prop': 'reac_prop.tsv',
'reac_prop': 'reac_prop.tsv',
# MNX_ID <tab> Equation <tab> Description <tab> Balance <tab> EC <tab> Source
}

Expand Down Expand Up @@ -81,11 +81,15 @@ def main():
update_synonyms(parse_xref('chem_xref', 'metabolite'), 'metabolite', session)

# Update reactions
update_synonyms(parse_xref('reac_xref', 'reaction'), 'reaction', session)
reaction_xref = parse_xref('reac_xref', 'reaction')
reaction_xref = add_ec_numbers('reac_prop', reaction_xref)
update_synonyms(reaction_xref, 'reaction', session)

# Update compartments
# TODO compartment synonyms

session.close()


def add_prefix(loc):
"""Add the MetaNetX url prefix."""
Expand Down Expand Up @@ -161,6 +165,37 @@ def update_synonyms(xref_dict, ref_type, session):
print 'New %s synonyms: %d' % (ref_type, stats['not_found'])


def add_ec_numbers(file_key, reaction_xref):
"""Add EC numbers from the reaction properties file to the xref object.
"""

# read the file
ec_numbers = {}
with open(join(data_dir, files[file_key]), 'r') as f:
for line in f.readlines():
if line.strip().startswith('#') or line.strip() == '':
continue
split_line = [x.strip() for x in line.split('\t')]
# no ec number
if split_line[4].strip() == '':
continue
for ec in [x.strip() for x in split_line[4].split(';')]:
# ec_numbers[MNX_ID] = EC
ec_numbers[split_line[0]] = ec

for bigg_id, val in reaction_xref.iteritems():
if not 'mnx.equation' in val:
continue
for mnx_id in val['mnx.equation']:
if not mnx_id in ec_numbers:
continue
if not 'ec' in val:
val['ec'] = []
val['ec'].append(ec_numbers[mnx_id])

return reaction_xref

def parse_xref(file_key, ref_type):
"""Read an xref file and generate a dict like this:
Expand Down

0 comments on commit 669123d

Please sign in to comment.