Example #1
0
    def set_host_genus(self, value=None, attribute=None, format="empty_string"):
        """Set the host_genus from a value parsed from the indicated attribute.

        The input data is split into multiple parts, and the first word is
        used to set host_genus.

        :param value:
            the host genus of the phage genome
        :type value: str
        :param attribute:
            the name of the genome attribute from which the
            host_genus attribute will be set
        :type attribute: str
        :param format:
            the default format if the input is an empty/null value.
        :type format: str
        """

        if value is None:
            if (attribute is not None and hasattr(self, attribute)):
                value = getattr(self, attribute)
            else:
                value = ""
        if isinstance(value, str):
            value = value.strip()

        # The host_genus value may need to be split. But don't split until
        # it is determined if the value is a null value.
        value = basic.convert_empty(value, "empty_string")
        if value != "":
            self.host_genus = value.split(" ")[0]
        else:
            self.host_genus = basic.convert_empty(value, format)
Example #2
0
    def set_date(self, value, format="empty_datetime_obj"):
        """Set the date attribute.

        :param value: Date
        :type value: misc
        :param format: Indicates the format if the value is empty.
        :type format: str
        """
        self.date = basic.convert_empty(value, format)
Example #3
0
    def set_accession(self, value, format="empty_string"):
        """Set the accession.

        The Accession field in the MySQL database defaults to ''.
        Some flat file accessions have the version number suffix, so discard
        the version number.

        :param value:
            GenBank accession number.
        :type value: str
        :param format:
            indicates the format of the data if it is not a
            valid accession. Default is ''.
        :type format: misc.
        """
        if isinstance(value, str):
            value = value.strip()
            value = value.split(".")[0]
        self.accession = basic.convert_empty(value, format)