Skip to content

Commit

Permalink
Fixed when fragment has no molblock
Browse files Browse the repository at this point in the history
Refs #45
  • Loading branch information
sverhoeven committed Mar 7, 2017
1 parent 73b3fc9 commit a67d4b6
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 2 deletions.
6 changes: 6 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,12 @@ Formatted as described on http://keepachangelog.com/.

## Unreleased

## [2.2.1] - 2017-03-07

### Fixed

- Web service has internal server error when fragment has no molblock (#45)

## [2.2.0] - 2017-02-23

### Changed
Expand Down
2 changes: 1 addition & 1 deletion kripodb/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@
# See the License for the specific language governing permissions and
# limitations under the License.

__version_info__ = ('2', '2', '0')
__version_info__ = ('2', '2', '1')
__version__ = '.'.join(__version_info__)
10 changes: 9 additions & 1 deletion kripodb/webservice/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@
"""Kripo datafiles wrapped in a webservice"""
from __future__ import absolute_import

from _ctypes import ArgumentError

from pkg_resources import resource_filename
import logging

Expand Down Expand Up @@ -125,7 +127,8 @@ def get_fragments(fragment_ids=None, pdb_codes=None):
# connexion.problem is using json.dumps instead of flask custom json encoder, so performing convert myself
# TODO remove mol2string conversion when https://github.com/zalando/connexion/issues/266 is fixed
for fragment in fragments:
fragment['mol'] = MolToMolBlock(fragment['mol'])
if fragment['mol']:
fragment['mol'] = MolToMolBlock(fragment['mol'])
ext = {'absent_identifiers': missing_ids, 'fragments': fragments}
return connexion.problem(404, title, description, ext=ext)
return fragments
Expand Down Expand Up @@ -154,6 +157,11 @@ def get_fragment_svg(fragment_id, width, height):
with FragmentsDb(fragments_db_filename) as fragmentsdb:
try:
fragment = fragmentsdb[fragment_id]
if not fragment['mol']:
title = 'Not Found'
description = 'Fragment with identifier \'{0}\' has no molblock'.format(fragment_id)
ext = {'identifier': fragment_id}
return connexion.problem(404, title, description, ext=ext)
mol = fragment['mol']
return mol2svg(mol, width, height)
except LookupError:
Expand Down

0 comments on commit a67d4b6

Please sign in to comment.