Commit d993b066 authored by Andreas Tille's avatar Andreas Tille
Browse files

New upstream version 2.1.8+dfsg

parent 485d2f6c
Loading
Loading
Loading
Loading
+7 −9
Original line number Diff line number Diff line
# Modified from https://github.com/biocore/scikit-bio/
# Modified from https://github.com/biocore/scikit-bio
language: python
env:
  - PYTHON_VERSION=2.7 WITH_DOCTEST=False USE_CYTHON=True
  - PYTHON_VERSION=3.5 WITH_DOCTEST=True USE_CYTHON=True
  - PYTHON_VERSION=3.6 WITH_DOCTEST=True USE_CYTHON=True
  - PYTHON_VERSION=3.7 WITH_DOCTEST=True USE_CYTHON=True
  - PYTHON_VERSION=3.6 WITH_DOCTEST=True 
  - PYTHON_VERSION=3.7 WITH_DOCTEST=True 
  - PYTHON_VERSION=3.8 WITH_DOCTEST=True 
before_install:
  - wget https://repo.continuum.io/miniconda/Miniconda3-latest-Linux-x86_64.sh -O miniconda.sh
  - chmod +x miniconda.sh
  - ./miniconda.sh -b
  - export PATH=/home/travis/miniconda3/bin:$PATH
install:
  - conda create --yes -n env_name python=$PYTHON_VERSION pip click numpy scipy pep8 flake8 coverage future six "pandas>=0.20.0" nose h5py>=2.2.0 cython
  - conda create --yes -n env_name python=$PYTHON_VERSION pip click numpy "scipy>=1.3.1" pep8 flake8 coverage future six "pandas>=0.20.0" nose h5py>=2.2.0 cython
  - rm biom/*.c
  - source activate env_name
  - if [ ${PYTHON_VERSION} = "2.7" ]; then pip install pyqi; fi
  - if [ ${PYTHON_VERSION} = "2.7" ]; then conda install --yes Sphinx=1.2.2; fi
  - if [ ${PYTHON_VERSION} = "3.6" ]; then pip install sphinx==1.2.2; fi
  - pip install coveralls
  - pip install -e . --no-deps
script:
  - make test 
  - biom show-install-info
  - if [ ${PYTHON_VERSION} = "2.7" ]; then make -C doc html; fi
  - if [ ${PYTHON_VERSION} = "3.6" ]; then make -C doc html; fi
  # we can only validate the tables if we have H5PY
  - for table in examples/*hdf5.biom; do echo ${table}; biom validate-table -i ${table}; done
  # validate JSON formatted tables
+30 −6
Original line number Diff line number Diff line
BIOM-Format ChangeLog
=====================

biom 2.1.8
----------

New features and bug fixes, released on 6 January 2020.

Important:

* Python 2.7 and 3.5 support has been dropped.
* Python 3.8 support has been added into Travis CI. 
* A change to the defaults for `Table.nonzero_counts` was performed such that the default now is to count the number of nonzero features. See [issue #685](https://github.com/biocore/biom-format/issues/685)
* We now require a SciPy >= 1.3.1. See [issue #816](https://github.com/biocore/biom-format/issues/816)

New Features:

* The detailed report is no longer part of the table validator. See [issue #378](https://github.com/biocore/biom-format/issues/378).
* `load_table` now accepts open file handles. See [issue #481](https://github.com/biocore/biom-format/issues/481).
* `biom export-metadata` has been added to export metadata as TSV. See [issue #820](https://github.com/biocore/biom-format/issues/820).

Bug fixes:

* `Table.to_dataframe(dense=False)` does now correctly produce sparse data frames (and not accidentally dense ones as before). See [issue #808](https://github.com/biocore/biom-format/issues/808).
* Order of error evaluations was unstable in Python versions without implicit `OrderedDict`. See [issue #813](https://github.com/biocore/biom-format/issues/813). Thanks @gwarmstrong for identifying this bug.
* `Table._extract_data_from_tsv` would fail if taxonomy was provided, and if the first row had the empty string for taxonomy. See [issue #827](https://github.com/biocore/biom-format/issues/827). Thanks @KasperSkytte for identifying this bug.

biom 2.1.7
----------

+1 −0
Original line number Diff line number Diff line
@@ -30,6 +30,7 @@ def cli(ctx):

import_module('biom.cli.table_summarizer')
import_module('biom.cli.metadata_adder')
import_module('biom.cli.metadata_exporter')
import_module('biom.cli.table_converter')
import_module('biom.cli.installation_informer')
import_module('biom.cli.table_subsetter')
+51 −0
Original line number Diff line number Diff line
# -----------------------------------------------------------------------------
# Copyright (c) 2011-2017, The BIOM Format Development Team.
#
# Distributed under the terms of the Modified BSD License.
#
# The full license is in the file COPYING.txt, distributed with this software.
# -----------------------------------------------------------------------------

import click

from biom import load_table
from biom.cli import cli


@cli.command(name='export-metadata')
@click.option('-i', '--input-fp', required=True,
              type=click.Path(exists=True, dir_okay=False),
              help='The input BIOM table')
@click.option('-m', '--sample-metadata-fp', required=False,
              type=click.Path(exists=False, dir_okay=False),
              help='The sample metadata output file.')
@click.option('--observation-metadata-fp', required=False,
              type=click.Path(exists=False, dir_okay=False),
              help='The observation metadata output file.')
def export_metadata(input_fp, sample_metadata_fp, observation_metadata_fp):
    """Export metadata as TSV.

    Example usage:

    Export metadata as TSV:

    $ biom export-metadata -i otu_table.biom
      --sample-metadata-fp sample.tsv
      --observation-metadata-fp observation.tsv
    """
    table = load_table(input_fp)

    if sample_metadata_fp:
        _export_metadata(table, 'sample', input_fp, sample_metadata_fp)
    if observation_metadata_fp:
        _export_metadata(table, 'observation', input_fp,
                         observation_metadata_fp)


def _export_metadata(table, axis, input_fp, output_fp):
    try:
        metadata = table.metadata_to_dataframe(axis)
        metadata.to_csv(output_fp, sep='\t')
    except KeyError:
        click.echo('File {} does not contain {} metadata'.format(input_fp,
                                                                 axis))
+6 −39
Original line number Diff line number Diff line
@@ -29,9 +29,7 @@ from biom.util import HAVE_H5PY, biom_open, is_hdf5_file
                   ' specification')
@click.option('-f', '--format-version', default=None,
              help='The specific format version to validate against')
@click.option('--detailed-report', is_flag=True, default=False,
              help='Include more details in the output report')
def validate_table(input_fp, format_version, detailed_report):
def validate_table(input_fp, format_version):
    """Validate a BIOM-formatted file.

    Test a file for adherence to the Biological Observation Matrix (BIOM)
@@ -46,7 +44,7 @@ def validate_table(input_fp, format_version, detailed_report):
    $ biom validate-table -i table.biom

    """
    valid, report = _validate_table(input_fp, format_version, detailed_report)
    valid, report = _validate_table(input_fp, format_version)
    click.echo("\n".join(report))
    if valid:
        # apparently silence is too quiet to be golden.
@@ -57,9 +55,8 @@ def validate_table(input_fp, format_version, detailed_report):
        sys.exit(1)


def _validate_table(input_fp, format_version=None, detailed_report=False):
    result = TableValidator()(table=input_fp, format_version=format_version,
                              detailed_report=detailed_report)
def _validate_table(input_fp, format_version=None):
    result = TableValidator()(table=input_fp, format_version=format_version)
    return result['valid_table'], result['report_lines']


@@ -108,23 +105,15 @@ class TableValidator(object):
                raise IOError("h5py is not installed, can only validate JSON "
                              "tables")

    def __call__(self, table, format_version=None, detailed_report=False):
        return self.run(table=table, format_version=format_version,
                        detailed_report=detailed_report)
    def __call__(self, table, format_version=None):
        return self.run(table=table, format_version=format_version)

    def _validate_hdf5(self, **kwargs):
        table = kwargs['table']

        # Need to make this an attribute so that we have this info during
        # validation.
        detailed_report = kwargs['detailed_report']

        report_lines = []
        valid_table = True

        if detailed_report:
            report_lines.append("Validating BIOM table...")

        required_attrs = [
            ('format-url', self._valid_format_url),
            ('format-version', self._valid_hdf5_format_version),
@@ -154,9 +143,6 @@ class TableValidator(object):
                report_lines.append("Missing attribute: '%s'" % required_attr)
                continue

            if detailed_report:
                report_lines.append("Validating '%s'..." % required_attr)

            status_msg = attr_validator(table)

            if len(status_msg) > 0:
@@ -166,20 +152,12 @@ class TableValidator(object):
        for group in required_groups:
            if group not in table:
                valid_table = False
                if detailed_report:
                    report_lines.append("Missing group: %s" % group)

        for dataset in required_datasets:
            if dataset not in table:
                valid_table = False
                if detailed_report:
                    report_lines.append("Missing dataset: %s" % dataset)

        if 'shape' in table.attrs:
            if detailed_report:
                report_lines.append("Validating 'shape' versus number of "
                                    "samples and observations...")

            n_obs, n_samp = table.attrs['shape']
            obs_ids = table.get('observation/ids', None)
            samp_ids = table.get('sample/ids', None)
@@ -270,14 +248,10 @@ class TableValidator(object):
        # Need to make this an attribute so that we have this info during
        # validation.
        self._format_version = kwargs['format_version']
        detailed_report = kwargs['detailed_report']

        report_lines = []
        valid_table = True

        if detailed_report:
            report_lines.append("Validating BIOM table...")

        required_keys = [
            ('format', self._valid_format),
            ('format_url', self._valid_format_url),
@@ -299,9 +273,6 @@ class TableValidator(object):
                report_lines.append("Missing field: '%s'" % key)
                continue

            if detailed_report:
                report_lines.append("Validating '%s'..." % key)

            status_msg = method(table_json)

            if len(status_msg) > 0:
@@ -309,10 +280,6 @@ class TableValidator(object):
                report_lines.append(status_msg)

        if 'shape' in table_json:
            if detailed_report:
                report_lines.append("Validating 'shape' versus number of rows "
                                    "and columns...")

            if ('rows' in table_json and
                    len(table_json['rows']) != table_json['shape'][0]):
                valid_table = False
Loading