Exemple #1
0
    def write(self, stream, schema, **kwargs):
        """
        Writes this `DataSet` object to the file-like object `stream`
        in `schema`. `schema` must be a recognized and supported
        phylogenetic data file schema. If writing is not implemented for
        the schema specified, then a `UnsupportedSchemaError` is raised.

        The following optional keyword arguments are also recognized:

            - `exclude_trees` if True skips over tree data
            - `exclude_chars` if True skips over character data

        Additional keyword arguments may be handled by various writers
        specialized to handle specific data formats.
        """
        from dendropy.utility.iosys import require_format_from_kwargs
        from dendropy.dataio import get_writer
        kwargs["dataset"] = self
        #        if self.attached_taxon_set is not None:
        #            if "taxon_set" not in kwargs:
        #                kwargs["taxon_set"] = self.attached_taxon_set
        #            elif kwargs["taxon_set"] is not self.attached_taxon_set:
        #                raise TypeError("DataSet object is already attached to a TaxonSet, but different TaxonSet passed using 'taxon_set' keyword argument")
        writer = get_writer(schema=schema, **kwargs)
        writer.write(stream)
Exemple #2
0
    def _format_and_write_to_stream(self,
                                    stream,
                                    schema,
                                    exclude_trees=False,
                                    exclude_chars=False,
                                    **kwargs):
        """
        Writes out ``self`` in ``schema`` format to a destination given by
        file-like object ``stream``.

        Parameters
        ----------
        stream : file or file-like object
            Destination for data.
        schema : string
            Must be a recognized character file schema, such as "nexus",
            "phylip", etc, for which a specialized tree list writer is
            available. If this is not implemented for the schema specified, then
            a UnsupportedSchemaError is raised.

        \*\*kwargs : keyword arguments, optional
            Keyword arguments will be passed directly to the writer for the
            specified schema. See documentation for details on keyword
            arguments supported by writers of various schemas.

        """
        writer = dataio.get_writer(schema, **kwargs)
        writer.write_dataset(self, stream, exclude_trees, exclude_chars)
Exemple #3
0
    def write(self, stream, schema, **kwargs):
        """
        Writes this `DataSet` object to the file-like object `stream`
        in `schema`. `schema` must be a recognized and supported
        phylogenetic data file schema. If writing is not implemented for
        the schema specified, then a `UnsupportedSchemaError` is raised.

        The following optional keyword arguments are also recognized:

            - `exclude_trees` if True skips over tree data
            - `exclude_chars` if True skips over character data

        Additional keyword arguments may be handled by various writers
        specialized to handle specific data formats.
        """
        from dendropy.utility.iosys import require_format_from_kwargs
        from dendropy.dataio import get_writer
        kwargs["dataset"] = self
#        if self.attached_taxon_set is not None:
#            if "taxon_set" not in kwargs:
#                kwargs["taxon_set"] = self.attached_taxon_set
#            elif kwargs["taxon_set"] is not self.attached_taxon_set:
#                raise TypeError("DataSet object is already attached to a TaxonSet, but different TaxonSet passed using 'taxon_set' keyword argument")
        writer = get_writer(schema=schema, **kwargs)
        writer.write(stream)
Exemple #4
0
    def _format_and_write_to_stream(self,
            stream,
            schema,
            exclude_trees=False,
            exclude_chars=False,
            **kwargs):
        """
        Writes out ``self`` in ``schema`` format to a destination given by
        file-like object ``stream``.

        Parameters
        ----------
        stream : file or file-like object
            Destination for data.
        schema : string
            Must be a recognized character file schema, such as "nexus",
            "phylip", etc, for which a specialized tree list writer is
            available. If this is not implemented for the schema specified, then
            a UnsupportedSchemaError is raised.

        \*\*kwargs : keyword arguments, optional
            Keyword arguments will be passed directly to the writer for the
            specified schema. See documentation for details on keyword
            arguments supported by writers of various schemas.

        """
        writer = dataio.get_writer(schema, **kwargs)
        writer.write_dataset(self, stream, exclude_trees, exclude_chars)
Exemple #5
0
 def write(self, dest, format):
     """
     Writes dataset to `dest`, a file descriptor object, in `format`.
     """
     from dendropy import dataio
     writer = dataio.get_writer(format)
     writer.write_dataset(self, dest)