Exemple #1
0
    def __format__(self, format_spec):
        """Returns the alignment as a string in the specified file format.

        This method supports the python format() function added in
        Python 2.6/3.0.  The format_spec should be a lower case
        string supported by Bio.AlignIO as an output file format.
        See also the alignment's format() method."""
        if format_spec:
            from SAP.Bio._py3k import StringIO
            from SAP.Bio import AlignIO
            handle = StringIO()
            AlignIO.write([self], handle, format_spec)
            return handle.getvalue()
        else:
            #Follow python convention and default to using __str__
            return str(self)
Exemple #2
0
    def __format__(self, format_spec):
        """Serialize the tree as a string in the specified file format.

        This method supports the ``format`` built-in function added in Python
        2.6/3.0.

        :param format_spec: a lower-case string supported by `Bio.Phylo.write`
            as an output file format.
        """
        if format_spec:
            from SAP.Bio._py3k import StringIO
            from SAP.Bio.Phylo import _io
            handle = StringIO()
            _io.write([self], handle, format_spec)
            return handle.getvalue()
        else:
            # Follow python convention and default to using __str__
            return str(self)
Exemple #3
0
    def __format__(self, format_spec):
        """Serialize the tree as a string in the specified file format.

        This method supports the ``format`` built-in function added in Python
        2.6/3.0.

        :param format_spec: a lower-case string supported by `Bio.Phylo.write`
            as an output file format.
        """
        if format_spec:
            from SAP.Bio._py3k import StringIO
            from SAP.Bio.Phylo import _io
            handle = StringIO()
            _io.write([self], handle, format_spec)
            return handle.getvalue()
        else:
            # Follow python convention and default to using __str__
            return str(self)