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

Source Code for Module generic_fns.exp_info

  1  ############################################################################### 
  2  #                                                                             # 
  3  # Copyright (C) 2008-2012 Edward d'Auvergne                                   # 
  4  #                                                                             # 
  5  # This file is part of the program relax.                                     # 
  6  #                                                                             # 
  7  # relax 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 2 of the License, or           # 
 10  # (at your option) any later version.                                         # 
 11  #                                                                             # 
 12  # relax 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 relax; if not, write to the Free Software                        # 
 19  # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA   # 
 20  #                                                                             # 
 21  ############################################################################### 
 22   
 23  # Module docstring. 
 24  """Module containing functions for specifying the experimental details.""" 
 25   
 26  # relax module imports. 
 27  from info import Info_box 
 28  from data.exp_info import ExpInfo 
 29  from relax_errors import RelaxError 
 30  from relax_io import open_read_file 
 31  from version import version_full 
 32   
 33   
34 -class Software_store:
35 """Software storage container.""" 36
37 - def __init__(self):
38 """Initialise all variables.""" 39 40 self.name = None 41 self.authors = None 42 self.url = None 43 self.tasks = None
44 45 46 # Software data structure. 47 SOFTWARE = {} 48 49 # relax software. 50 SOFTWARE['relax'] = Software_store() 51 SOFTWARE['relax'].name = "relax" 52 SOFTWARE['relax'].authors = "The relax development team" 53 SOFTWARE['relax'].url = "http://www.nmr-relax.com" 54 SOFTWARE['relax'].tasks = ["data processing"] 55 56 # NMRPipe software and citation. 57 SOFTWARE['NMRPipe'] = Software_store() 58 SOFTWARE['NMRPipe'].name = "NMRPipe" 59 SOFTWARE['NMRPipe'].authors = "Delaglio, F., Grzesiek, S., Vuister, G. W., Zhu, G., Pfeifer, J., and Bax, A" 60 SOFTWARE['NMRPipe'].url = "http://spin.niddk.nih.gov/NMRPipe/" 61 SOFTWARE['NMRPipe'].tasks = ["processing"] 62 63 # Sparky software and citation. 64 SOFTWARE['Sparky'] = Software_store() 65 SOFTWARE['Sparky'].name = "Sparky" 66 SOFTWARE['Sparky'].authors = "Goddard, T. D. and Kneller, D. G." 67 SOFTWARE['Sparky'].ref = "Goddard, T. D. and Kneller, D. G., SPARKY 3, University of California, San Francisco." 68 SOFTWARE['Sparky'].url = "http://www.cgl.ucsf.edu/home/sparky/" 69 SOFTWARE['Sparky'].tasks = ["spectral analysis"] 70 71 # Bruker Dynamics Center software. 72 SOFTWARE['DC'] = Software_store() 73 SOFTWARE['DC'].name = "Bruker Dynamics Center" 74 SOFTWARE['DC'].authors = "Bruker BioSpin GmbH" 75 SOFTWARE['DC'].url = "http://www.bruker-biospin.com/software_nmr.html" 76 SOFTWARE['DC'].tasks = ["relaxation analysis"] 77 78
79 -def bmrb_write_citations(star):
80 """Generate the Citations saveframe records. 81 82 @param star: The NMR-STAR dictionary object. 83 @type star: NMR_STAR instance 84 """ 85 86 # Loop over the citations. 87 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'citations'): 88 for citations in cdp.exp_info.citations: 89 # Rearrange the author list. 90 author_given_name = [] 91 author_family_name = [] 92 author_first_init = [] 93 author_mid_init = [] 94 author_family_title = [] 95 for i in range(len(citations.authors)): 96 author_given_name.append(citations.authors[i][0]) 97 author_family_name.append(citations.authors[i][1]) 98 author_first_init.append(citations.authors[i][2]) 99 author_mid_init.append(citations.authors[i][3]) 100 author_family_title.append(None) 101 102 # Add the citation. 103 star.citations.add(citation_label=citations.cite_id, author_given_name=author_given_name, author_family_name=author_family_name, author_first_init=author_first_init, author_mid_init=author_mid_init, author_family_title=author_family_title, doi=citations.doi, pubmed_id=citations.pubmed_id, full_citation=citations.full_citation, title=citations.title, status=citations.status, type=citations.type, journal_abbrev=citations.journal_abbrev, journal_full=citations.journal_full, volume=citations.volume, issue=citations.issue, page_first=citations.page_first, page_last=citations.page_last, year=citations.year)
104 105
106 -def bmrb_write_methods(star):
107 """Generate the Software saveframe records. 108 109 @param star: The NMR-STAR dictionary object. 110 @type star: NMR_STAR instance 111 @return: A list BMRB software IDs and a list of software labels. 112 @rtype: tuple of list of int and list of str 113 """ 114 115 # The scripts. 116 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'scripts'): 117 for script in cdp.exp_info.scripts: 118 # Get the citation ID numbers. 119 cite_id_nums = [] 120 if script.cite_ids: 121 for cite in script.cite_ids: 122 cite_id_nums.append(cdp.exp_info.get_cite_id_num(cite)) 123 124 # The name. 125 name = script.file + " relax script" 126 127 # The method info. 128 star.method.add(name=name, details=None, cite_ids=cite_id_nums, file_name=script.file, file_text=script.text)
129 130
131 -def bmrb_write_software(star):
132 """Generate the Software saveframe records. 133 134 @param star: The NMR-STAR dictionary object. 135 @type star: NMR_STAR instance 136 @return: A list BMRB software IDs and a list of software labels. 137 @rtype: tuple of list of int and list of str 138 """ 139 140 # Loop over the software. 141 software_ids = [] 142 software_labels = [] 143 if hasattr(cdp, 'exp_info') and hasattr(cdp.exp_info, 'software'): 144 for software in cdp.exp_info.software: 145 # Get the citation ID numbers. 146 cite_id_nums = [] 147 for cite in software.cite_ids: 148 cite_id_nums.append(cdp.exp_info.get_cite_id_num(cite)) 149 150 # The program info. 151 id = star.software.add(name=software.name, version=software.version, vendor_name=software.vendor_name, vendor_eaddress=software.url, task=software.tasks, cite_ids=cite_id_nums) 152 153 # Append the software info. 154 software_ids.append(id) 155 software_labels.append(software.name) 156 157 # relax cannot be the only program used! 158 else: 159 raise RelaxError("relax cannot be the only program used in the analysis - spectral analysis programs, etc. must also have been used. Please use the relevant BMRB user functions to specify these.") 160 161 # Return the software info. 162 return software_ids, software_labels
163 164
165 -def citation(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):
166 """Store a citation. 167 168 @keyword cite_id: The citation ID string. 169 @type cite_id: str 170 @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. 171 @type authors: list of lists of str 172 @keyword doi: The DOI number, e.g. "10.1000/182". 173 @type doi: None or str 174 @keyword pubmed_id: The identification code assigned to the publication by PubMed. 175 @type pubmed_id: None or int 176 @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. 177 @type full_citation: str 178 @keyword title: The title of the publication. 179 @type title: str 180 @keyword status: The publication status. Can be one of in "preparation", "in press", "published", "retracted", or "submitted". 181 @type status: str 182 @keyword type: The publication type. Can be one of "abstract", "BMRB only", "book", "book chapter", "internet", "journal", "personal communication", or "thesis". 183 @type type: str 184 @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. 185 @type journal_abbrev: str 186 @keyword journal_full: The full journal name. 187 @type journal_full: str 188 @keyword volume: The volume number. 189 @type volume: int 190 @keyword issue: The issue number. 191 @type issue: int 192 @keyword page_first: The first page number. 193 @type page_first: int 194 @keyword page_last: The last page number. 195 @type page_last: int 196 @keyword year: The publication year. 197 @type year: int 198 """ 199 200 # Set up the experimental info data container, if needed. 201 if not hasattr(cdp, 'exp_info'): 202 cdp.exp_info = ExpInfo() 203 204 # Place the data in the container. 205 cdp.exp_info.add_citation(cite_id=cite_id, authors=authors, doi=doi, pubmed_id=pubmed_id, full_citation=full_citation, title=title, status=status, type=type, journal_abbrev=journal_abbrev, journal_full=journal_full, volume=volume, issue=issue, page_first=page_first, page_last=page_last, year=year)
206 207
208 -def script(file=None, dir=None, analysis_type=None, model_selection=None, engine=None, model_elim=False, universal_solution=False):
209 """Specify the scripts used in the analysis. 210 211 @keyword file: The name of the file to open. 212 @type file: str 213 @keyword dir: The directory containing the file (defaults to the current directory if None). 214 @type dir: None or 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 # Check. 228 allowed = ['frame order', 229 'jw', 230 'mf', 231 'N-state', 232 'noe', 233 'relax_fit' 234 ] 235 if analysis_type not in allowed: 236 raise RelaxError("The analysis type '%s' should be one of %s." % (analysis_type, allowed)) 237 238 # Set up the experimental info data container, if needed. 239 if not hasattr(cdp, 'exp_info'): 240 cdp.exp_info = ExpInfo() 241 242 # Extract the text. 243 f = open_read_file(file, dir) 244 text = f.read() 245 f.close() 246 247 # Init the citation structures. 248 cite_id = [] 249 cite_key = [] 250 251 # Model selection. 252 if model_selection in ['AIC', 'AICc', 'BIC', 'Bootstrap', 'CV', 'Expect', 'Overall']: 253 cite_id.append('model-free model selection') 254 cite_key.append('dAuvergneGooley03') 255 256 # Model-free model elimination. 257 if model_elim: 258 cite_id.append('model-free model elimination') 259 cite_key.append('dAuvergneGooley06') 260 261 # Universal solution citation. 262 if universal_solution: 263 cite_id.append('model-free set theory') 264 cite_key.append('dAuvergneGooley07') 265 266 # Get the info box. 267 info = Info_box() 268 269 # Loop over all citations. 270 for id, key in zip(cite_id, cite_key): 271 # Alias the bib entry. 272 bib = info.bib[key] 273 274 # Add the citation. 275 cdp.exp_info.add_citation(cite_id=id, authors=bib.author2, doi=bib.doi, pubmed_id=bib.pubmed_id, full_citation=bib.cite_short(doi=False, url=False), title=bib.title, status=bib.status, type=bib.type, journal_abbrev=bib.journal, journal_full=bib.journal_full, volume=bib.volume, page_first=bib.page_first, page_last=bib.page_last, year=bib.year) 276 277 # Place the data in the container. 278 cdp.exp_info.setup_script(file=file, dir=dir, text=text, cite_ids=cite_id, analysis_type=analysis_type, model_selection=model_selection, engine=engine, model_elim=model_elim, universal_solution=universal_solution)
279 280
281 -def software(name=None, version=None, url=None, vendor_name=None, cite_ids=None, tasks=None):
282 """Select by name the software used in the analysis. 283 284 @param name: The name of the software program. 285 @type name: str 286 @keyword version: The program version. 287 @type version: None or str 288 @keyword url: The program's URL. 289 @type url: None or str 290 @keyword vendor_name: The name of the company or person behind the program. 291 @type vendor_name: str 292 @keyword cite_ids: The citation ID numbers. 293 @type cite_ids: None or str 294 @keyword tasks: The tasks performed by the program. 295 @type tasks: list of str 296 """ 297 298 # Set up the experimental info data container, if needed. 299 if not hasattr(cdp, 'exp_info'): 300 cdp.exp_info = ExpInfo() 301 302 # Place the data in the container. 303 cdp.exp_info.software_setup(name=name, version=version, url=url, vendor_name=vendor_name, cite_ids=cite_ids, tasks=tasks)
304 305
306 -def software_select(name, version=None):
307 """Select by name the software used in the analysis. 308 309 @param name: The name of the software program. 310 @type name: str 311 @keyword version: The program version. 312 @type version: None or str 313 """ 314 315 # Unknown program. 316 if name not in ['relax', 'NMRPipe', 'Sparky', 'Bruker DC']: 317 raise RelaxError("The software '%s' is unknown. Please use the user function for manually specifying software details instead." % name) 318 319 # Set up the experimental info data container, if needed. 320 if not hasattr(cdp, 'exp_info'): 321 cdp.exp_info = ExpInfo() 322 323 # Init. 324 cite_ids = [] 325 keys = [] 326 software_keys = [] 327 versions = [] 328 329 # relax. 330 if name == 'relax': 331 # The info. 332 cite_ids.append(['relax_ref1', 'relax_ref2']) 333 keys.append(['dAuvergneGooley08a', 'dAuvergneGooley08b']) 334 software_keys.append('relax') 335 versions.append(version_full()) 336 337 # NMRPipe. 338 elif name == 'NMRPipe': 339 # The info. 340 cite_ids.append(['nmrpipe_ref']) 341 keys.append(['Delaglio95']) 342 software_keys.append('NMRPipe') 343 versions.append(version) 344 345 # Sparky. 346 elif name == 'Sparky': 347 # Check if the version information has been supplied. 348 if not version: 349 raise RelaxError("The Sparky version number has not been supplied.") 350 351 # The info. 352 cite_ids.append(['sparky_ref']) 353 keys.append(['GoddardKneller']) 354 software_keys.append('Sparky') 355 versions.append(version) 356 357 # Bruker Dynamics Center. 358 elif name == 'Bruker DC': 359 # The info. 360 software_keys.append('DC') 361 versions.append(version) 362 363 # Get the info box. 364 info = Info_box() 365 366 # Loop over the citations. 367 for i in range(len(cite_ids)): 368 for j in range(len(cite_ids[i])): 369 # Alias the bib entry. 370 bib = info.bib[keys[i][j]] 371 372 # Add the citations. 373 cdp.exp_info.add_citation(cite_id=cite_ids[i][j], authors=bib.author2, doi=bib.doi, pubmed_id=bib.pubmed_id, full_citation=bib.cite_short(doi=False, url=False), title=bib.title, status=bib.status, type=bib.type, journal_abbrev=bib.journal, journal_full=bib.journal_full, volume=bib.volume, issue=bib.number, page_first=bib.page_first, page_last=bib.page_last, year=bib.year) 374 375 # Add the software info. 376 cdp.exp_info.software_setup(name=SOFTWARE[software_keys[i]].name, version=versions[i], vendor_name=SOFTWARE[software_keys[i]].authors, url=SOFTWARE[software_keys[i]].url, cite_ids=cite_ids, tasks=SOFTWARE[software_keys[i]].tasks)
377 378
379 -def thiol_state(state=None):
380 """Set the thiol state of the system. 381 382 @keyword state: The thiol state of the molecule. 383 @type state: str 384 """ 385 386 # Set up the experimental info data container, if needed. 387 if not hasattr(cdp, 'exp_info'): 388 cdp.exp_info = ExpInfo() 389 390 # Place the data in the container. 391 cdp.exp_info.setup_thiol(state=state)
392