| Trees | Indices | Help | 
 | 
|---|
|  | 
  1  ############################################################################# 
  2  #                                                                           # 
  3  # The BMRB library.                                                         # 
  4  #                                                                           # 
  5  # Copyright (C) 2008-2013 Edward d'Auvergne                                 # 
  6  #                                                                           # 
  7  # This program is free software: you can redistribute it and/or modify      # 
  8  # it under the terms of the GNU General Public License as published by      # 
  9  # the Free Software Foundation, either version 3 of the License, or         # 
 10  # (at your option) any later version.                                       # 
 11  #                                                                           # 
 12  # This program is distributed in the hope that it will be useful,           # 
 13  # but WITHOUT ANY WARRANTY; without even the implied warranty of            # 
 14  # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the             # 
 15  # GNU General Public License for more details.                              # 
 16  #                                                                           # 
 17  # You should have received a copy of the GNU General Public License         # 
 18  # along with this program.  If not, see <http://www.gnu.org/licenses/>.     # 
 19  #                                                                           # 
 20  ############################################################################# 
 21   
 22  # Module docstring. 
 23  """Package for interfacing with the U{BioMagResBank<http://www.bmrb.wisc.edu/>}. 
 24   
 25  This file is part of the U{BMRB library<https://sourceforge.net/projects/bmrblib>}. 
 26   
 27  The Biological Magnetic Resonance Data Bank, or BioMagResBank and BMRB for short, is a repository for data from NMR spectroscopy on proteins, peptides, nucleic acids, and other biomolecules.  This U{bmrblib library<https://sourceforge.net/projects/bmrblib/>} handles the U{NMR-STAR formatted files<http://www.bmrb.wisc.edu/dictionary/>}, the base format of all BMRB data.  It can both read and write NMR-STAR files. 
 28  """ 
 29   
 30  # The version number. 
 31  __version__ = '1.0.4' 
 32   
 33  # The list of all modules and packages. 
 34  __all__ = ['base_classes', 
 35             'misc', 
 36             'nmr_star_dict', 
 37             'nmr_star_dict_v2_1', 
 38             'nmr_star_dict_v3_1'] 
 39   
 40  # Python module imports. 
 41  from os import F_OK, access 
 42  from re import search 
 43  import sys 
 44   
 45  # Bmrblib module imports. 
 46  from bmrblib.nmr_star_dict_v2_1 import NMR_STAR_v2_1 
 47  from bmrblib.nmr_star_dict_v3_1 import NMR_STAR_v3_1 
 48  from bmrblib.version import Star_version 
 49   
 50   
 52      """Initialise the NMR-STAR object. 
 53   
 54      @param title:       The title of the NMR-STAR data. 
 55      @type title:        str 
 56      @param file_path:   The full file path. 
 57      @type file_path:    str 
 58      @keyword version:   The NMR-STAR version to use. 
 59      @type version:      str 
 60      @return:            The NMR-STAR python object. 
 61      @rtype:             class instance 
 62      """ 
 63   
 64      # Determine the version. 
 65      if not version and access(file_path, F_OK): 
 66          version = determine_version(file_path) 
 67   
 68      # The default version. 
 69      if not version: 
 70          version = '3.1' 
 71   
 72      # Store the version in the singleton. 
 73      star_version = Star_version() 
 74      star_version.set_version(version) 
 75   
 76      # Print out. 
 77      sys.stdout.write("NMR-STAR version %s\n" % star_version.version) 
 78   
 79      # Initialise the NMR-STAR data object. 
 80      if star_version.major == 3: 
 81          star = NMR_STAR_v3_1('relax_model_free_results', file_path) 
 82      elif star_version.major == 2: 
 83          star = NMR_STAR_v2_1('relax_model_free_results', file_path) 
 84      else: 
 85          raise NameError("The NMR-STAR version %s is unknown." % star_version.version) 
 86   
 87      # Return the object. 
 88      return star 
 89   
 90   
 92      """Determine the version of the given NMR-STAR file. 
 93   
 94      @param file_path:   The full file path. 
 95      @type file_path:    str 
 96      @return:            The NMR-STAR version number. 
 97      @rtype:             str 
 98      """ 
 99   
100      # Read the file. 
101      file = open(file_path) 
102      lines = file.readlines() 
103      file.close() 
104   
105      # Loop over the lines of the file. 
106      for line in lines: 
107          # Find the version line. 
108          if search('\.NMR_STAR_version', line) or search('_NMR_STAR_version', line): 
109              # Split the line. 
110              row = line.split() 
111   
112              # Return the version number. 
113              return row[1] 
114   
| Trees | Indices | Help | 
 | 
|---|
| Generated by Epydoc 3.0.1 on Fri Oct 28 15:38:16 2016 | http://epydoc.sourceforge.net |