Author: bugman Date: Fri Oct 9 18:32:18 2009 New Revision: 9702 URL: http://svn.gna.org/viewcvs/relax?rev=9702&view=rev Log: The software saveframe is now being created. This information does not need to be read from the BMRB file. Added: branches/bmrb/bmrblib/experimental_details/software.py branches/bmrb/generic_fns/bmrb_saveframes.py Modified: branches/bmrb/bmrblib/nmr_star_dict.py branches/bmrb/bmrblib/nmr_star_dict_v3_1.py branches/bmrb/bmrblib/nmr_star_dict_v3_2.py branches/bmrb/specific_fns/model_free/bmrb.py Added: branches/bmrb/bmrblib/experimental_details/software.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/experimental_details/software.py?rev=9702&view=auto ============================================================================== --- branches/bmrb/bmrblib/experimental_details/software.py (added) +++ branches/bmrb/bmrblib/experimental_details/software.py Fri Oct 9 18:32:18 2009 @@ -1,0 +1,191 @@ +############################################################################### +# # +# Copyright (C) 2009 Edward d'Auvergne # +# # +# This file is part of the program relax. # +# # +# relax is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# relax is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +############################################################################### + +# Module docstring. +"""The software saveframe category. + +For example, see http://www.bmrb.wisc.edu/dictionary/3.1html_frame/frame_SaveFramePage.html#software +""" + +# relax module imports. +from bmrblib.base_classes import BaseSaveframe, TagCategory +from bmrblib.pystarlib.SaveFrame import SaveFrame +from bmrblib.pystarlib.TagTable import TagTable +from bmrblib.misc import translate + + +class SoftwareSaveframe(BaseSaveframe): + """The software saveframe class.""" + + def __init__(self, datanodes): + """Initialise the class, placing the pystarlib data nodes into the namespace. + + @param datanodes: The pystarlib data nodes object. + @type datanodes: list + """ + + # Place the data nodes into the namespace. + self.datanodes = datanodes + + # The number of software programs used. + self.software_num = 0 + + # Add the specific tag category objects. + self.add_tag_categories() + + + def add(self, name, version=None, vendor_name=None, vendor_address=None, vendor_eaddress=None): + """Add the software info to the data nodes. + + @param name: The name of the software program. + @type name: str + @keyword version: The software version. + @type version: None or str + @keyword vendor_name: The vendor or developers of the software. + @type vendor_name: None or str + @keyword vendor_address: The vendor address. + @type vendor_address: None or str + @keyword vendor_eaddress: The vendor electronic address. + @type vendor_eaddress: None or str + """ + + # Place the args into the namespace. + self.program_name = name + self.program_version = version + self.vendor_name = [translate(vendor_name)] + self.vendor_address = [translate(vendor_address)] + self.vendor_eaddress = [translate(vendor_eaddress)] + + # Increment the ID number. + self.software_num = self.software_num + 1 + self.software_id_num = [str(translate(self.software_num))] + + # The category name. + self.cat_name = ['Software'] + + # Initialise the save frame. + self.frame = SaveFrame(title=self.program_name) + + # Create the tag categories. + self.Software.create() + self.Vendor.create() + + # Add the saveframe to the data nodes. + self.datanodes.append(self.frame) + + + def add_tag_categories(self): + """Create the tag categories.""" + + # The tag category objects. + self.Software = Software(self) + self.Software_citation = SoftwareCitation(self) + self.Task = Task(self) + self.Vendor = Vendor(self) + + + +class Software(TagCategory): + """Base class for the Software tag category.""" + + def create(self): + """Create the ChemShiftAnisotropy tag category.""" + + # The save frame category. + self.sf.frame.tagtables.append(self.create_tag_table([['SfCategory', 'cat_name']], free=True)) + + # Software ID number. + self.sf.frame.tagtables.append(TagTable(free=True, tagnames=[self.tag_names_full['SoftwareID']], tagvalues=[[str(self.sf.software_num)]])) + + # The program name. + self.sf.frame.tagtables.append(TagTable(free=True, tagnames=[self.tag_names_full['Name']], tagvalues=[[self.sf.program_name]])) + + # The program version. + if self.sf.program_version: + self.sf.frame.tagtables.append(TagTable(free=True, tagnames=[self.tag_names_full['Version']], tagvalues=[[self.sf.program_version]])) + + + def tag_setup(self, tag_category_label=None, sep=None): + """Replacement method for setting up the tag names. + + @keyword tag_category_label: The tag name prefix specific for the tag category. + @type tag_category_label: None or str + @keyword sep: The string separating the tag name prefix and suffix. + @type sep: str + """ + + # Execute the base class tag_setup() method. + TagCategory.tag_setup(self, tag_category_label='Software', sep=sep) + + # Tag names for the relaxation data. + self.tag_names['SfCategory'] = 'Sf_category' + self.tag_names['SoftwareID'] = 'ID' + self.tag_names['Name'] = 'Name' + self.tag_names['Version'] = 'Version' + + +class SoftwareCitation(TagCategory): + """Base class for the SoftwareCitation tag category.""" + + +class Task(TagCategory): + """Base class for the Task tag category.""" + + +class Vendor(TagCategory): + """Base class for the Vendor tag category.""" + + def create(self): + """Create the Vendor tag category.""" + + # Keys and objects. + info = [ + ['Name', 'vendor_name'], + ['Address', 'vendor_address'], + ['ElectronicAddress', 'vendor_eaddress'], + ['SoftwareID', 'software_id_num'] + ] + + # Get the TabTable. + table = self.create_tag_table(info) + + # Add the tagtable to the save frame. + self.sf.frame.tagtables.append(table) + + + def tag_setup(self, tag_category_label=None, sep=None): + """Replacement method for setting up the tag names. + + @keyword tag_category_label: The tag name prefix specific for the tag category. + @type tag_category_label: None or str + @keyword sep: The string separating the tag name prefix and suffix. + @type sep: str + """ + + # Execute the base class tag_setup() method. + TagCategory.tag_setup(self, tag_category_label='Vendor', sep=sep) + + # Tag names for the relaxation data. + self.tag_names['Name'] = 'Name' + self.tag_names['Address'] = 'Address' + self.tag_names['ElectronicAddress'] = 'ElectronicAddress' + self.tag_names['SoftwareID'] = 'SoftwareID' Modified: branches/bmrb/bmrblib/nmr_star_dict.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/nmr_star_dict.py?rev=9702&r1=9701&r2=9702&view=diff ============================================================================== --- branches/bmrb/bmrblib/nmr_star_dict.py (original) +++ branches/bmrb/bmrblib/nmr_star_dict.py Fri Oct 9 18:32:18 2009 @@ -29,6 +29,7 @@ # relax module imports. from bmrblib.assembly_supercategory.entity import EntitySaveframe +from bmrblib.experimental_details.software import SoftwareSaveframe from bmrblib.kinetics.relaxation import Relaxation from bmrblib.NMR_parameters.chem_shift_anisotropy import ChemShiftAnisotropySaveframe from bmrblib.thermodynamics.order_parameters import OrderParameterSaveframe @@ -61,16 +62,19 @@ def create_saveframes(self): """Create all the saveframe objects.""" - # Initialise the assembly_supercategory saveframe supergroup. + # Initialise Supergroup 3 : The molecular assembly saveframe API. self.entity = EntitySaveframe(self.data.datanodes) - # Initialise the NMR parameters saveframe supergroup. + # Initialise Supergroup 4: The experimental descriptions saveframe API. + self.software = SoftwareSaveframe(self.data.datanodes) + + # Initialise Supergroup 5 : The NMR parameters saveframe API. self.chem_shift_anisotropy = ChemShiftAnisotropySaveframe(self.data.datanodes) - # Initialise the kinetic saveframe supergroup API. + # Initialise Supergroup 6 : The kinetic data saveframe API. self.relaxation = Relaxation(self.data.datanodes) - # Initialise the thermodynamics saveframe supergroup. + # Initialise Supergroup 7 : The thermodynamics saveframe API. self.order_parameters = OrderParameterSaveframe(self.data.datanodes) Modified: branches/bmrb/bmrblib/nmr_star_dict_v3_1.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/nmr_star_dict_v3_1.py?rev=9702&r1=9701&r2=9702&view=diff ============================================================================== --- branches/bmrb/bmrblib/nmr_star_dict_v3_1.py (original) +++ branches/bmrb/bmrblib/nmr_star_dict_v3_1.py Fri Oct 9 18:32:18 2009 @@ -29,6 +29,7 @@ # relax module imports. from bmrblib.assembly_supercategory.entity_v3_1 import EntitySaveframe_v3_1 +from bmrblib.experimental_details.software import SoftwareSaveframe from bmrblib.kinetics.relaxation import Relaxation_v3_1 from bmrblib.NMR_parameters.chem_shift_anisotropy_v3_1 import ChemShiftAnisotropySaveframe_v3_1 from bmrblib.thermodynamics.order_parameters_v3_1 import OrderParameterSaveframe_v3_1 @@ -45,14 +46,17 @@ def create_saveframes(self): """Create all the saveframe objects.""" - # Initialise the assembly_supercategory saveframe supergroup. + # Initialise Supergroup 3 : The molecular assembly saveframe API. self.entity = EntitySaveframe_v3_1(self.data.datanodes) - # Initialise the NMR parameters saveframe supergroup. + # Initialise Supergroup 4: The experimental descriptions saveframe API. + self.software = SoftwareSaveframe(self.data.datanodes) + + # Initialise Supergroup 5 : The NMR parameters saveframe API. self.chem_shift_anisotropy = ChemShiftAnisotropySaveframe_v3_1(self.data.datanodes) - # Initialise the kinetic saveframe supergroup API. + # Initialise Supergroup 6 : The kinetic data saveframe API. self.relaxation = Relaxation_v3_1(self.data.datanodes) - # Initialise the thermodynamics saveframe supergroup. + # Initialise Supergroup 7 : The thermodynamics saveframe API. self.order_parameters = OrderParameterSaveframe_v3_1(self.data.datanodes) Modified: branches/bmrb/bmrblib/nmr_star_dict_v3_2.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/bmrblib/nmr_star_dict_v3_2.py?rev=9702&r1=9701&r2=9702&view=diff ============================================================================== --- branches/bmrb/bmrblib/nmr_star_dict_v3_2.py (original) +++ branches/bmrb/bmrblib/nmr_star_dict_v3_2.py Fri Oct 9 18:32:18 2009 @@ -29,6 +29,7 @@ # relax module imports. from bmrblib.assembly_supercategory.entity_v3_1 import EntitySaveframe_v3_1 +from bmrblib.experimental_details.software import SoftwareSaveframe from bmrblib.kinetics.relaxation import Relaxation_v3_2 from bmrblib.NMR_parameters.chem_shift_anisotropy_v3_1 import ChemShiftAnisotropySaveframe_v3_1 from bmrblib.thermodynamics.order_parameters_v3_1 import OrderParameterSaveframe_v3_1 @@ -45,14 +46,17 @@ def create_saveframes(self): """Create all the saveframe objects.""" - # Initialise the assembly_supercategory saveframe supergroup. + # Initialise Supergroup 3 : The molecular assembly saveframe API. self.entity = EntitySaveframe_v3_1(self.data.datanodes) - # Initialise the NMR parameters saveframe supergroup. + # Initialise Supergroup 4: The experimental descriptions saveframe API. + self.software = SoftwareSaveframe(self.data.datanodes) + + # Initialise Supergroup 5 : The NMR parameters saveframe API. self.chem_shift_anisotropy = ChemShiftAnisotropySaveframe_v3_1(self.data.datanodes) - # Initialise the kinetic saveframe supergroup API. + # Initialise Supergroup 6 : The kinetic data saveframe API. self.relaxation = Relaxation_v3_2(self.data.datanodes) - # Initialise the thermodynamics saveframe supergroup. + # Initialise Supergroup 7 : The thermodynamics saveframe API. self.order_parameters = OrderParameterSaveframe_v3_1(self.data.datanodes) Added: branches/bmrb/generic_fns/bmrb_saveframes.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/generic_fns/bmrb_saveframes.py?rev=9702&view=auto ============================================================================== --- branches/bmrb/generic_fns/bmrb_saveframes.py (added) +++ branches/bmrb/generic_fns/bmrb_saveframes.py Fri Oct 9 18:32:18 2009 @@ -1,0 +1,38 @@ +############################################################################### +# # +# Copyright (C) 2009 Edward d'Auvergne # +# # +# This file is part of the program relax. # +# # +# relax is free software; you can redistribute it and/or modify # +# it under the terms of the GNU General Public License as published by # +# the Free Software Foundation; either version 2 of the License, or # +# (at your option) any later version. # +# # +# relax is distributed in the hope that it will be useful, # +# but WITHOUT ANY WARRANTY; without even the implied warranty of # +# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # +# GNU General Public License for more details. # +# # +# You should have received a copy of the GNU General Public License # +# along with relax; if not, write to the Free Software # +# Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA # +# # +############################################################################### + +# Module docstring. +"""Module containing read/write functions for miscellaneous BMRB NMR-STAR saveframes.""" + +# relax module imports. +from version import version + + +def write_relax(star): + """Generate the Software saveframe records for relax. + + @param star: The NMR-STAR dictionary object. + @type star: NMR_STAR instance + """ + + # The relax info. + star.software.add(name='relax', version=version, vendor_name='The relax development team', vendor_eaddress='http://nmr-relax.com') Modified: branches/bmrb/specific_fns/model_free/bmrb.py URL: http://svn.gna.org/viewcvs/relax/branches/bmrb/specific_fns/model_free/bmrb.py?rev=9702&r1=9701&r2=9702&view=diff ============================================================================== --- branches/bmrb/specific_fns/model_free/bmrb.py (original) +++ branches/bmrb/specific_fns/model_free/bmrb.py Fri Oct 9 18:32:18 2009 @@ -28,7 +28,7 @@ from bmrblib.nmr_star_dict import NMR_STAR from bmrblib.nmr_star_dict_v3_1 import NMR_STAR_v3_1 from bmrblib.nmr_star_dict_v3_2 import NMR_STAR_v3_2 -from generic_fns import mol_res_spin, pipes, relax_data +from generic_fns import bmrb_saveframes, mol_res_spin, pipes, relax_data from generic_fns.mol_res_spin import spin_loop @@ -79,12 +79,6 @@ star = NMR_STAR_v3_1('relax_model_free_results', file_path) else: star = NMR_STAR('relax_model_free_results', file_path) - - # Generate the entity saveframe. - mol_res_spin.bmrb_write_entity(star) - - # Generate the relaxation data saveframes. - relax_data.bmrb_write(star) # Rex frq. rex_frq = cdp.frq[0] @@ -168,11 +162,41 @@ # Opt stats. chi2_list.append(spin.chi2) + + # Create Supergroup 3 : The molecular assembly saveframes. + ########################################################## + + # Generate the entity saveframe. + mol_res_spin.bmrb_write_entity(star) + + + # Create Supergroup 4: The experimental descriptions saveframes. + ################################################################# + + # Generate the software saveframe. + bmrb_saveframes.write_relax(star) + + + # Create Supergroup 5 : The NMR parameters saveframes. + ###################################################### + # Generate the CSA saveframe. star.chem_shift_anisotropy.add(res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, isotope=isotope_list, csa=csa_list) + + # Create Supergroup 6 : The kinetic data saveframes. + #################################################### + + # Generate the relaxation data saveframes. + relax_data.bmrb_write(star) + + + # Create Supergroup 7 : The thermodynamics saveframes. + ###################################################### + # Generate the model-free data saveframe. star.order_parameters.add(res_nums=res_num_list, res_names=res_name_list, atom_names=atom_name_list, s2=s2_list, s2f=s2f_list, s2s=s2s_list, te=te_list, tf=tf_list, ts=ts_list, rex=rex_list, s2_err=s2_err_list, s2f_err=s2f_err_list, s2s_err=s2s_err_list, te_err=te_err_list, tf_err=tf_err_list, ts_err=ts_err_list, rex_err=rex_err_list, rex_frq=rex_frq, chi2=chi2_list) + # Write the contents to the STAR formatted file. star.write()