Skip to content

Commit

Permalink
Minor changes.
Browse files Browse the repository at this point in the history
  • Loading branch information
smelandr committed Aug 10, 2016
1 parent af58f40 commit 2d3e499
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 21 deletions.
17 changes: 14 additions & 3 deletions nmrstarlib/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""Routines for working with BMRB NMR-STAR format files.
This package includes the following modules:
Expand All @@ -20,13 +23,21 @@
JSONized file format.
``csviewer``
This module provides the :func:`~nmrstarlib.csviewer.csviewer` function that visualizes
This module provides the :class:`~nmrstarlib.csviewer.CSViewer` class that visualizes
chemical shift values using the Graphviz (http://www.graphviz.org/) DOT Languge description.
"""

import os
from . import nmrstarlib

this_directory = os.path.dirname(__file__)
config_file = os.path.join(this_directory, '../conf/constants.json')
nmrstarlib.update_constants(config_file)

if nmrstarlib.NMRSTAR_VERSION == "3":
config_filepath = os.path.join(this_directory, '../conf/constants_nmrstar3.json')
elif nmrstarlib.NMRSTAR_VERSION == "2":
config_filepath = os.path.join(this_directory, '../conf/constants_nmrstar2.json')
else:
config_filepath = os.path.join(this_directory, '../conf/constants_nmrstar3.json')

with open(config_filepath, "r") as infile:
nmrstarlib.update_constants(infile)
22 changes: 5 additions & 17 deletions nmrstarlib/bmrblex.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,16 +114,6 @@ def get_token(self):
raw = self._read_token()
return raw

def _get_nextchar(self):
nextchar = self.instream.read(1)
self.streamposition += 1
return nextchar

def _get_nextnextchar(self):
nextnextchar = self.instream.read(1)
self.instream.seek(self.streamposition + 1)
return nextnextchar

def _read_token(self):
"""Read token based on the parsing rules.
Expand All @@ -137,17 +127,15 @@ def _read_token(self):
while self.streamposition+1 < self.streamlength-1:
nextchar = self.instream.read(1)
self.streamposition += 1
# nextchar = self._get_nextchar()

nextnextchar = self.instream.read(1) # look up 1 char ahead
self.instream.seek(self.streamposition+1) # return to current stream position
# nextnextchar = self._get_nextnextchar()

if self.state is None:
self.token = '' # past end of file
self.token = "" # past end of file
break

elif self.state == ' ':
elif self.state == " ":
if not nextchar:
self.state = None # end of file
break
Expand Down Expand Up @@ -233,13 +221,13 @@ def _read_token(self):
else:
self.token = self.token + nextchar

#
elif self.state == 'a':
# process regular token (unquoted text)
elif self.state == "a":
if not nextchar:
self.state = None # end of file
break
elif nextchar in self.whitespace:
self.state = ' '
self.state = " "
if self.token or quoted:
break # emit current token
else:
Expand Down
2 changes: 1 addition & 1 deletion nmrstarlib/csviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
class CSViewer(object):
"""Chemical Shifts Viewer: uses:meth:`nmrstarlib.nmrstarlib.StarFile.chem_shifts_by_residue`
method chemical shifts organized by residue and visualizes chemical shifts values using the
Graphviz(http: // www.graphviz.org /) DOT Languge description.
Graphviz (http://www.graphviz.org/) DOT Languge description.
"""

dot_template = '''digraph {{
Expand Down

0 comments on commit 2d3e499

Please sign in to comment.