Package data_store :: Module exp_info
[hide private]
[frames] | no frames]

Source Code for Module data_store.exp_info

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2009,2011,2014 Edward d'Auvergne                              # 
  4  #                                                                             # 
  5  # This file is part of the program relax (http://www.nmr-relax.com).          # 
  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  """The experimental information data container of the relax data store.""" 
 24   
 25  # relax module imports. 
 26  from data_store.data_classes import RelaxListType, Element 
 27  from lib.xml import xml_to_object 
 28   
 29   
30 -class ExpInfo(Element):
31 """The experimental information data container.""" 32
33 - def __init__(self):
34 """Initialise the data container.""" 35 36 # The name of the container. 37 self.name = "exp_info" 38 39 # The description of the container. 40 self.desc = "Experimental information" 41 42 # Blacklisted objects. 43 self.blacklist = []
44 45
46 - def add_citation(self, cite_id=None, authors=None, doi=None, pubmed_id=None, full_citation=None, title=None, status=None, type=None, journal_abbrev=None, journal_full=None, volume=None, issue=None, page_first=None, page_last=None, year=None):
47 """Store a citation. 48 49 @keyword cite_id: The citation ID string. 50 @type cite_id: str 51 @keyword authors: The list of authors. Each author element is a list of four elements: the first name, last name, first initial, and middle initials. 52 @type authors: list of lists of str 53 @keyword doi: The DOI number, e.g. "10.1000/182". 54 @type doi: None or str 55 @keyword pubmed_id: The identification code assigned to the publication by PubMed. 56 @type pubmed_id: None or int 57 @keyword full_citation: A full citation in a format similar to that used in a journal article by either cutting and pasting from another document or by typing. Please include author names, title, journal, page numbers, and year or equivalent information for the type of publication given. 58 @type full_citation: str 59 @keyword title: The title of the publication. 60 @type title: str 61 @keyword status: The publication status. Can be one of in "preparation", "in press", "published", "retracted", or "submitted". 62 @type status: str 63 @keyword type: The publication type. Can be one of "abstract", "BMRB only", "book", "book chapter", "internet", "journal", "personal communication", or "thesis". 64 @type type: str 65 @keyword journal_abbrev: A standard journal abbreviation as defined by the Chemical Abstract Services for the journal where the data are or will be published. If the data in the deposition are related to a J. Biomol. NMR paper, the value must be 'J. Biomol. NMR' to alert the BMRB annotators so that the deposition is properly processed. If the depositor truly does not know the journal, a value of 'not known' or 'na' is acceptable. 66 @type journal_abbrev: str 67 @keyword journal_full: The full journal name. 68 @type journal_full: str 69 @keyword volume: The volume number. 70 @type volume: int 71 @keyword issue: The issue number. 72 @type issue: int 73 @keyword page_first: The first page number. 74 @type page_first: int 75 @keyword page_last: The last page number. 76 @type page_last: int 77 @keyword year: The publication year. 78 @type year: int 79 """ 80 81 # Initialise the list container if needed. 82 if not hasattr(self, "citations"): 83 # The list. 84 self.citations = RelaxListType() 85 86 # The name of the container. 87 self.citations.list_name = "citation_list" 88 89 # The description of the container. 90 self.citations.list_desc = "List of citations" 91 92 # Init the container. 93 cite = Element() 94 95 # The name of the container. 96 cite.name = "citation" 97 98 # The description of the container. 99 cite.desc = "Literature citation" 100 101 # Set the attributes. 102 cite.cite_id = cite_id 103 cite.authors = authors 104 cite.doi = doi 105 cite.pubmed_id = pubmed_id 106 cite.full_citation = full_citation 107 cite.title = title 108 cite.status = status 109 cite.type = type 110 cite.journal_abbrev = journal_abbrev 111 cite.journal_full = journal_full 112 cite.volume = volume 113 cite.issue = issue 114 cite.page_first = page_first 115 cite.page_last = page_last 116 cite.year = year 117 118 # Append the container. 119 self.citations.append(cite)
120 121
122 - def from_xml(self, exp_info_node, file_version=1):
123 """Recreate the element data structure from the XML element node. 124 125 @param exp_info_node: The element XML node. 126 @type exp_info_node: xml.dom.minicompat.Element instance 127 @keyword file_version: The relax XML version of the XML file. 128 @type file_version: int 129 """ 130 131 # Recreate the list structures. 132 list_node_names = ['citation_list', 'script_list', 'software_list'] 133 list_subnode_names = ['citation', 'script', 'software'] 134 list_str_names = ['citations', 'scripts', 'software'] 135 for i in range(len(list_node_names)): 136 # Get the list node. 137 list_node = exp_info_node.getElementsByTagName(list_node_names[i]) 138 139 # Necreate the structure, if the node exists. 140 if list_node: 141 # Initialise the data structure. 142 setattr(self, list_str_names[i], RelaxListType()) 143 list_obj = getattr(self, list_str_names[i]) 144 145 # Get all the subnodes. 146 list_nodes = list_node[0].getElementsByTagName(list_subnode_names[i]) 147 148 # Loop over the nodes. 149 for node in list_nodes: 150 # Add a blank container. 151 list_obj.append(Element(name=node.tagName, desc=node.getAttribute('desc'))) 152 153 # Recreate the element. 154 list_obj[-1].from_xml(node, file_version=file_version) 155 156 # Recreate all the other data structures. 157 xml_to_object(exp_info_node, self, file_version=file_version, blacklist=list_node_names)
158 159
160 - def get_cite_id_num(self, cite_id):
161 """Return the citation ID number for the given citation ID string. 162 163 @param cite_id: The citation ID string. 164 @type cite_id: str 165 @return: The citation ID number. 166 @rtype: int 167 """ 168 169 # Loop over the citations. 170 for i in range(len(self.citations)): 171 # Match. 172 if self.citations[i].cite_id == cite_id: 173 return i + 1
174 175
176 - def setup_peak_intensity_type(self, ri_id, type):
177 """Store the peak intensity type. 178 179 @param ri_id: The relaxation data ID string. 180 @type ri_id: str 181 @param type: The peak intensity type, one of 'height' or 'volume'. 182 @type type: str 183 """ 184 185 # Initialise the container if needed. 186 if not hasattr(self, "peak_intensity_type"): 187 self.peak_intensity_type = {} 188 189 # Set the type. 190 self.peak_intensity_type[ri_id] = type
191 192
193 - def setup_thiol(self, state):
194 """Set up the thiol state of the system. 195 196 @param state: The thiol state of the molecule. 197 @type state: str 198 """ 199 200 # Set the attribute. 201 self.thiol_state = state
202 203
204 - def setup_script(self, file=None, dir=None, cite_ids=None, text=None, analysis_type=None, model_selection=None, engine=None, model_elim=False, universal_solution=False):
205 """Specify the scripts used in the analysis. 206 207 @keyword file: The name of the script file. 208 @type file: str 209 @keyword dir: The directory containing the file (defaults to the current directory if None). 210 @type dir: None or str 211 @keyword cite_ids: The citation ID numbers. 212 @type cite_ids: None or str 213 @param text: The script text. 214 @type text: str 215 @keyword analysis_type: The type of analysis performed. 216 @type analysis_type: str 217 @keyword model_selection: The model selection technique used, if relevant. 218 @type model_selection: None or str 219 @keyword engine: The software engine used in the analysis. 220 @type engine: str 221 @keyword model_elim: A model-free specific flag specifying if model elimination was performed. 222 @type model_elim: bool 223 @keyword universal_solution: A model-free specific flag specifying if the universal solution was sought after. 224 @type universal_solution: bool 225 """ 226 227 # Initialise the container if needed. 228 if not hasattr(self, "scripts"): 229 # The list. 230 self.scripts = RelaxListType() 231 232 # The name of the container. 233 self.scripts.list_name = "script_list" 234 235 # The description of the container. 236 self.scripts.list_desc = "List of scripts used for the analysis" 237 238 # Init the container. 239 script = Element() 240 241 # The name of the container. 242 script.name = "script" 243 244 # The description of the container. 245 script.desc = "Script used for the analysis" 246 247 # Set the attributes. 248 script.file = file 249 script.dir = dir 250 script.cite_ids = cite_ids 251 script.text = text 252 script.analysis_type = analysis_type 253 script.model_selection = model_selection 254 script.engine = engine 255 script.model_elim = model_elim 256 script.universal_solution = universal_solution 257 258 # Append the container. 259 self.scripts.append(script)
260 261
262 - def software_setup(self, name, version=None, url=None, vendor_name=None, cite_ids=None, tasks=None):
263 """Set up the software information. 264 265 @param name: The name of the software program. 266 @type name: str 267 @keyword version: The program version. 268 @type version: None or str 269 @keyword url: The program's URL. 270 @type url: None or str 271 @keyword vendor_name: The name of the company or person behind the program. 272 @type vendor_name: str 273 @keyword cite_ids: The citation ID numbers. 274 @type cite_ids: None or str 275 @keyword tasks: The tasks performed by the program. 276 @type tasks: list of str 277 """ 278 279 # Initialise the container if needed. 280 if not hasattr(self, "software"): 281 # The list. 282 self.software = RelaxListType() 283 284 # The name of the container. 285 self.software.list_name = "software_list" 286 287 # The description of the container. 288 self.software.list_desc = "List of software programs used in the analysis" 289 290 # Init the container. 291 software = Element() 292 293 # The name of the container. 294 software.name = "software" 295 296 # The description of the container. 297 software.desc = "Software program used in the analysis" 298 299 # Set the attributes. 300 software.software_name = name 301 software.url = url 302 software.version = version 303 software.vendor_name = vendor_name 304 software.cite_ids = cite_ids 305 software.tasks = tasks 306 307 # Append the container. 308 self.software.append(software)
309 310
311 - def temp_calibration_setup(self, ri_id, method):
312 """Store the temperature calibration method. 313 314 @param ri_id: The relaxation data ID string. 315 @type ri_id: str 316 @param method: The temperature calibration method. 317 @type method: str 318 """ 319 320 # Initialise the container if needed. 321 if not hasattr(self, "temp_calibration"): 322 self.temp_calibration = {} 323 324 # Set the method. 325 self.temp_calibration[ri_id] = method
326 327
328 - def temp_control_setup(self, ri_id, method):
329 """Store the temperature control method. 330 331 @param ri_id: The relaxation data ID string. 332 @type ri_id: str 333 @param method: The temperature control method. 334 @type method: str 335 """ 336 337 # Initialise the container if needed. 338 if not hasattr(self, "temp_control"): 339 self.temp_control = {} 340 341 # Set the method. 342 self.temp_control[ri_id] = method
343