Esempio n. 1
0
    def from_xml(self, diff_tensor_node, file_version=1):
        """Recreate the diffusion tensor data structure from the XML diffusion tensor node.

        @param diff_tensor_node:    The diffusion tensor XML node.
        @type diff_tensor_node:     xml.dom.minicompat.Element instance
        @keyword file_version:      The relax XML version of the XML file.
        @type file_version:         int
        """

        # First set the diffusion type.  Doing this first is essential for the proper reconstruction of the object.
        self.__dict__['type'] = str(diff_tensor_node.getAttribute('type'))

        # A temporary object to pack the structures from the XML data into.
        temp_obj = Element()

        # Recreate all the other data structures (into the temporary object).
        xml_to_object(diff_tensor_node, temp_obj, file_version=file_version)

        # Loop over all modifiable objects in the temporary object and make soft copies of them.
        for name in self._mod_attr:
            # Skip if missing from the object.
            if not hasattr(temp_obj, name):
                continue

            # The category.
            if search('_err$', name):
                category = 'err'
                param = name.replace('_err', '')
            elif search('_sim$', name):
                category = 'sim'
                param = name.replace('_sim', '')
            else:
                category = 'val'
                param = name

            # Get the object.
            value = getattr(temp_obj, name)

            # Normal parameters.
            if category == 'val':
                self.set(param=param, value=value)

            # Errors.
            elif category == 'err':
                self.set(param=param, value=value, category='err')

            # Simulation objects objects.
            else:
                # Recreate the list elements.
                for i in range(len(value)):
                    self.set(param=param,
                             value=value[i],
                             category='sim',
                             sim_index=i)

        # Delete the temporary object.
        del temp_obj
Esempio n. 2
0
    def software_setup(self, name, version=None, url=None, vendor_name=None, cite_ids=None, tasks=None):
        """Set up the software information.

        @param name:            The name of the software program.
        @type name:             str
        @keyword version:       The program version.
        @type version:          None or str
        @keyword url:           The program's URL.
        @type url:              None or str
        @keyword vendor_name:   The name of the company or person behind the program.
        @type vendor_name:      str
        @keyword cite_ids:      The citation ID numbers.
        @type cite_ids:         None or str
        @keyword tasks:         The tasks performed by the program.
        @type tasks:            list of str
        """

        # Initialise the container if needed.
        if not hasattr(self, "software"):
            # The list.
            self.software = RelaxListType()

            # The name of the container.
            self.software.list_name = "software_list"

            # The description of the container.
            self.software.list_desc = "List of software programs used in the analysis"

        # Init the container.
        software = Element()

        # The name of the container.
        software.name = "software"

        # The description of the container.
        software.desc = "Software program used in the analysis"

        # Set the attributes.
        software.software_name = name
        software.url = url
        software.version = version
        software.vendor_name = vendor_name
        software.cite_ids = cite_ids
        software.tasks = tasks

        # Append the container.
        self.software.append(software)
Esempio n. 3
0
File: gui.py Progetto: tlinnet/relax
    def add(self, type=None):
        """Add a new analysis type.

        @keyword type:  The analysis type.  This can be currently one of 'noe', 'r1', 'r2', or 'model-free'.
        @type type:     str
        @return:        The index of the data container added to the list.
        @rtype:         int
        """

        # Append an empty element.
        self.append(Element(name='analysis', desc='GUI information for a relax analysis'))

        # Set the analysis type.
        self[-1].analysis_type = type

        # Return the index of the container.
        return len(self)-1
Esempio n. 4
0
    def from_xml(self, align_tensor_super_node, file_version=1):
        """Recreate the alignment tensor data structure from the XML alignment tensor node.

        @param align_tensor_super_node:     The alignment tensor XML nodes.
        @type align_tensor_super_node:      xml.dom.minicompat.Element instance
        @keyword file_version:              The relax XML version of the XML file.
        @type file_version:                 int
        """

        # Recreate all the alignment tensor data structures.
        xml_to_object(align_tensor_super_node,
                      self,
                      file_version=file_version,
                      blacklist=['align_tensor'])

        # Get the individual tensors.
        align_tensor_nodes = align_tensor_super_node.getElementsByTagName(
            'align_tensor')

        # Loop over the child nodes.
        for align_tensor_node in align_tensor_nodes:
            # Add the alignment tensor data container.
            self.add_item(align_tensor_node.getAttribute('name'))

            # A temporary object to pack the structures from the XML data into.
            temp_obj = Element()

            # Recreate all the other data structures (into the temporary object).
            xml_to_object(align_tensor_node,
                          temp_obj,
                          file_version=file_version)

            # Loop over all modifiable objects in the temporary object and make soft copies of them.
            for name in self[-1]._mod_attr:
                # Skip if missing from the object.
                if not hasattr(temp_obj, name):
                    continue

                # The category.
                if search('_err$', name):
                    category = 'err'
                    param = name.replace('_err', '')
                elif search('_sim$', name):
                    category = 'sim'
                    param = name.replace('_sim', '')
                else:
                    category = 'val'
                    param = name

                # Get the object.
                value = getattr(temp_obj, name)

                # Normal parameters.
                if category == 'val':
                    self[-1].set(param=param,
                                 value=value,
                                 category=category,
                                 update=False)

                # Errors.
                elif category == 'err':
                    self[-1].set(param=param,
                                 value=value,
                                 category=category,
                                 update=False)

                # Simulation objects objects.
                else:
                    # Set the simulation number if needed.
                    if not hasattr(self[-1],
                                   '_sim_num') or self[-1]._sim_num == None:
                        self[-1].set_sim_num(len(value))

                    # Recreate the list elements.
                    for i in range(len(value)):
                        self[-1].set(param=param,
                                     value=value[i],
                                     category=category,
                                     sim_index=i,
                                     update=False)

                # Update the data structures.
                for target, update_if_set, depends in dependency_generator():
                    self[-1]._update_object(param, target, update_if_set,
                                            depends, category)

            # Delete the temporary object.
            del temp_obj
Esempio n. 5
0
    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):
        """Store a citation.

        @keyword cite_id:           The citation ID string.
        @type cite_id:              str
        @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.
        @type authors:              list of lists of str
        @keyword doi:               The DOI number, e.g. "10.1000/182".
        @type doi:                  None or str
        @keyword pubmed_id:         The identification code assigned to the publication by PubMed.
        @type pubmed_id:            None or int
        @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.
        @type full_citation:        str
        @keyword title:             The title of the publication.
        @type title:                str
        @keyword status:            The publication status.  Can be one of in "preparation", "in press", "published", "retracted", or "submitted".
        @type status:               str
        @keyword type:              The publication type.  Can be one of "abstract", "BMRB only", "book", "book chapter", "internet", "journal", "personal communication", or "thesis".
        @type type:                 str
        @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.
        @type journal_abbrev:       str
        @keyword journal_full:      The full journal name.
        @type journal_full:         str
        @keyword volume:            The volume number.
        @type volume:               int
        @keyword issue:             The issue number.
        @type issue:                int
        @keyword page_first:        The first page number.
        @type page_first:           int
        @keyword page_last:         The last page number.
        @type page_last:            int
        @keyword year:              The publication year.
        @type year:                 int
        """

        # Initialise the list container if needed.
        if not hasattr(self, "citations"):
            # The list.
            self.citations = RelaxListType()

            # The name of the container.
            self.citations.list_name = "citation_list"

            # The description of the container.
            self.citations.list_desc = "List of citations"

        # Init the container.
        cite = Element()

        # The name of the container.
        cite.name = "citation"

        # The description of the container.
        cite.desc = "Literature citation"

        # Set the attributes.
        cite.cite_id = cite_id
        cite.authors = authors
        cite.doi = doi
        cite.pubmed_id = pubmed_id
        cite.full_citation = full_citation
        cite.title = title
        cite.status = status
        cite.type = type
        cite.journal_abbrev = journal_abbrev
        cite.journal_full = journal_full
        cite.volume = volume
        cite.issue = issue
        cite.page_first = page_first
        cite.page_last = page_last
        cite.year = year

        # Append the container.
        self.citations.append(cite)
Esempio n. 6
0
    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):
        """Specify the scripts used in the analysis.

        @keyword file:                  The name of the script file.
        @type file:                     str
        @keyword dir:                   The directory containing the file (defaults to the current directory if None).
        @type dir:                      None or str
        @keyword cite_ids:              The citation ID numbers.
        @type cite_ids:                 None or str
        @param text:                    The script text.
        @type text:                     str
        @keyword analysis_type:         The type of analysis performed.
        @type analysis_type:            str
        @keyword model_selection:       The model selection technique used, if relevant.
        @type model_selection:          None or str
        @keyword engine:                The software engine used in the analysis.
        @type engine:                   str
        @keyword model_elim:            A model-free specific flag specifying if model elimination was performed.
        @type model_elim:               bool
        @keyword universal_solution:    A model-free specific flag specifying if the universal solution was sought after.
        @type universal_solution:       bool
        """

        # Initialise the container if needed.
        if not hasattr(self, "scripts"):
            # The list.
            self.scripts = RelaxListType()

            # The name of the container.
            self.scripts.list_name = "script_list"

            # The description of the container.
            self.scripts.list_desc = "List of scripts used for the analysis"

        # Init the container.
        script = Element()

        # The name of the container.
        script.name = "script"

        # The description of the container.
        script.desc = "Script used for the analysis"

        # Set the attributes.
        script.file = file
        script.dir = dir
        script.cite_ids = cite_ids
        script.text = text
        script.analysis_type = analysis_type
        script.model_selection = model_selection
        script.engine = engine
        script.model_elim = model_elim
        script.universal_solution = universal_solution

        # Append the container.
        self.scripts.append(script)