| 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 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.
26 """
27
28 # The version number.
29 __version__ = '1.0.2'
30
31 # The list of all modules and packages.
32 __all__ = ['base_classes',
33 'misc',
34 'nmr_star_dict',
35 'nmr_star_dict_v2_1',
36 'nmr_star_dict_v3_1']
37
38 # Python module imports.
39 from os import F_OK, access
40 from re import search
41 import sys
42
43 # Bmrblib module imports.
44 from bmrblib.nmr_star_dict_v2_1 import NMR_STAR_v2_1
45 from bmrblib.nmr_star_dict_v3_1 import NMR_STAR_v3_1
46 from bmrblib.version import Star_version
47
48
50 """Initialise the NMR-STAR object.
51
52 @param title: The title of the NMR-STAR data.
53 @type title: str
54 @param file_path: The full file path.
55 @type file_path: str
56 @keyword version: The NMR-STAR version to use.
57 @type version: str
58 @return: The NMR-STAR python object.
59 @rtype: class instance
60 """
61
62 # Determine the version.
63 if not version and access(file_path, F_OK):
64 version = determine_version(file_path)
65
66 # The default version.
67 if not version:
68 version = '3.1'
69
70 # Store the version in the singleton.
71 star_version = Star_version()
72 star_version.set_version(version)
73
74 # Print out.
75 sys.stdout.write("NMR-STAR version %s\n" % star_version.version)
76
77 # Initialise the NMR-STAR data object.
78 if star_version.major == 3:
79 star = NMR_STAR_v3_1('relax_model_free_results', file_path)
80 elif star_version.major == 2:
81 star = NMR_STAR_v2_1('relax_model_free_results', file_path)
82 else:
83 raise NameError("The NMR-STAR version %s is unknown." % star_version.version)
84
85 # Return the object.
86 return star
87
88
90 """Determine the version of the given NMR-STAR file.
91
92 @param file_path: The full file path.
93 @type file_path: str
94 @return: The NMR-STAR version number.
95 @rtype: str
96 """
97
98 # Read the file.
99 file = open(file_path)
100 lines = file.readlines()
101 file.close()
102
103 # Loop over the lines of the file.
104 for line in lines:
105 # Find the version line.
106 if search('\.NMR_STAR_version', line) or search('_NMR_STAR_version', line):
107 # Split the line.
108 row = line.split()
109
110 # Return the version number.
111 return row[1]
112
| Trees | Indices | Help |
|
|---|
| Generated by Epydoc 3.0.1 on Wed Apr 10 15:07:07 2013 | http://epydoc.sourceforge.net |