Skip to content

Commit d1cb02d

Browse files
committed
REF: feature_table
1 parent f561977 commit d1cb02d

13 files changed

+76
-61
lines changed

q2_types/__init__.py

-1
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,6 @@
1313
__version__ = get_versions()['version']
1414
del get_versions
1515

16-
importlib.import_module('q2_types.feature_table')
1716
importlib.import_module('q2_types.tree')
1817
importlib.import_module('q2_types.ordination')
1918
importlib.import_module('q2_types.sample_data')

q2_types/citations.bib

-12
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,3 @@
1-
@article{mcdonald2012biological,
2-
title={The Biological Observation Matrix (BIOM) format or: how I learned to stop worrying and love the ome-ome},
3-
author={McDonald, Daniel and Clemente, Jose C and Kuczynski, Justin and Rideout, Jai Ram and Stombaugh, Jesse and Wendel, Doug and Wilke, Andreas and Huse, Susan and Hufnagle, John and Meyer, Folker and Knight, Rob and Caporaso, J Gregory},
4-
journal={GigaScience},
5-
volume={1},
6-
number={1},
7-
pages={7},
8-
year={2012},
9-
publisher={BioMed Central},
10-
doi={10.1186/2047-217X-1-7}
11-
}
12-
131
@InProceedings{ mckinney-proc-scipy-2010,
142
author = { Wes McKinney },
153
title = { Data Structures for Statistical Computing in Python },

q2_types/feature_table/__init__.py

+5-9
Original file line numberDiff line numberDiff line change
@@ -6,17 +6,13 @@
66
# The full license is in the file LICENSE, distributed with this software.
77
# ----------------------------------------------------------------------------
88

9-
import importlib
10-
11-
from ._format import (BIOMV100Format, BIOMV210Format, BIOMV100DirFmt,
12-
BIOMV210DirFmt)
13-
from ._type import (FeatureTable, Frequency, RelativeFrequency,
14-
PresenceAbsence, Composition, Balance,
15-
PercentileNormalized, Design)
9+
from ._formats import (BIOMV100Format, BIOMV210Format, BIOMV100DirFmt,
10+
BIOMV210DirFmt)
11+
from ._types import (FeatureTable, Frequency, RelativeFrequency,
12+
PresenceAbsence, Composition, Balance,
13+
PercentileNormalized, Design)
1614

1715
__all__ = ['BIOMV100Format', 'BIOMV100DirFmt', 'FeatureTable', 'Frequency',
1816
'RelativeFrequency', 'PresenceAbsence', 'BIOMV210Format',
1917
'BIOMV210DirFmt', 'Composition', 'Balance', 'PercentileNormalized',
2018
'Design']
21-
22-
importlib.import_module('q2_types.feature_table._transformer')

q2_types/feature_table/_type.py q2_types/feature_table/_deferred_setup/__init__.py

+14-22
Original file line numberDiff line numberDiff line change
@@ -6,34 +6,24 @@
66
# The full license is in the file LICENSE, distributed with this software.
77
# ----------------------------------------------------------------------------
88

9-
from qiime2.plugin import SemanticType
9+
import importlib
1010

11-
from ..plugin_setup import plugin
12-
from . import BIOMV210DirFmt
11+
import biom
1312

13+
from qiime2.plugin import Citations
1414

15-
FeatureTable = SemanticType('FeatureTable', field_names='content')
15+
from .. import (BIOMV100Format, BIOMV210Format, BIOMV100DirFmt,
16+
BIOMV210DirFmt, FeatureTable, Frequency, RelativeFrequency,
17+
PresenceAbsence, Composition, Balance,
18+
PercentileNormalized, Design)
1619

17-
Frequency = SemanticType('Frequency', variant_of=FeatureTable.field['content'])
20+
from ...plugin_setup import plugin
1821

19-
RelativeFrequency = SemanticType('RelativeFrequency',
20-
variant_of=FeatureTable.field['content'])
22+
citations = Citations.load('citations.bib', package='q2_types.feature_table')
2123

22-
PresenceAbsence = SemanticType('PresenceAbsence',
23-
variant_of=FeatureTable.field['content'])
24-
25-
Composition = SemanticType('Composition',
26-
variant_of=FeatureTable.field['content'])
27-
28-
Balance = SemanticType('Balance',
29-
variant_of=FeatureTable.field['content'])
30-
31-
PercentileNormalized = SemanticType('PercentileNormalized',
32-
variant_of=FeatureTable.field['content'])
33-
34-
# Design is the type of design matrices for linear regressions that have
35-
# been transformed/coded.
36-
Design = SemanticType('Design', variant_of=FeatureTable.field['content'])
24+
plugin.register_views(BIOMV100Format, BIOMV210Format, BIOMV100DirFmt,
25+
BIOMV210DirFmt, biom.Table,
26+
citations=[citations['mcdonald2012biological']])
3727

3828
plugin.register_semantic_types(FeatureTable, Frequency, RelativeFrequency,
3929
PresenceAbsence, Balance, Composition,
@@ -86,3 +76,5 @@
8676
FeatureTable[Design],
8777
directory_format=BIOMV210DirFmt
8878
)
79+
80+
importlib.import_module('._transformers', __name__)

q2_types/feature_table/_transformer.py q2_types/feature_table/_deferred_setup/_transformers.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
import pandas as pd
1313
import qiime2
1414

15-
from . import BIOMV100Format, BIOMV210Format
16-
from ..plugin_setup import plugin
15+
from .. import BIOMV100Format, BIOMV210Format
16+
from ...plugin_setup import plugin
1717

1818
# NOTE: In the readers and writers for BIOM v1 and v2 below, metadata must be
1919
# ignored on both axes because BIOM v1 and v2 are incompatible with certain

q2_types/feature_table/_format.py q2_types/feature_table/_formats.py

-7
Original file line numberDiff line numberDiff line change
@@ -7,12 +7,9 @@
77
# ----------------------------------------------------------------------------
88
import ijson
99
import h5py
10-
import biom
1110

1211
import qiime2.plugin.model as model
1312

14-
from ..plugin_setup import plugin, citations
15-
1613

1714
class BIOMV100Format(model.TextFileFormat):
1815
top_level_keys = {
@@ -95,7 +92,3 @@ def sniff(self):
9592
BIOMV210DirFmt = model.SingleFileDirectoryFormat('BIOMV210DirFmt',
9693
'feature-table.biom',
9794
BIOMV210Format)
98-
99-
plugin.register_views(BIOMV100Format, BIOMV210Format, BIOMV100DirFmt,
100-
BIOMV210DirFmt, biom.Table,
101-
citations=[citations['mcdonald2012biological']])

q2_types/feature_table/_types.py

+33
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
# ----------------------------------------------------------------------------
2+
# Copyright (c) 2016-2023, QIIME 2 development team.
3+
#
4+
# Distributed under the terms of the Modified BSD License.
5+
#
6+
# The full license is in the file LICENSE, distributed with this software.
7+
# ----------------------------------------------------------------------------
8+
9+
from qiime2.plugin import SemanticType
10+
11+
12+
FeatureTable = SemanticType('FeatureTable', field_names='content')
13+
14+
Frequency = SemanticType('Frequency', variant_of=FeatureTable.field['content'])
15+
16+
RelativeFrequency = SemanticType('RelativeFrequency',
17+
variant_of=FeatureTable.field['content'])
18+
19+
PresenceAbsence = SemanticType('PresenceAbsence',
20+
variant_of=FeatureTable.field['content'])
21+
22+
Composition = SemanticType('Composition',
23+
variant_of=FeatureTable.field['content'])
24+
25+
Balance = SemanticType('Balance',
26+
variant_of=FeatureTable.field['content'])
27+
28+
PercentileNormalized = SemanticType('PercentileNormalized',
29+
variant_of=FeatureTable.field['content'])
30+
31+
# Design is the type of design matrices for linear regressions that have
32+
# been transformed/coded.
33+
Design = SemanticType('Design', variant_of=FeatureTable.field['content'])

q2_types/feature_table/citations.bib

+11
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
@article{mcdonald2012biological,
2+
title={The Biological Observation Matrix (BIOM) format or: how I learned to stop worrying and love the ome-ome},
3+
author={McDonald, Daniel and Clemente, Jose C and Kuczynski, Justin and Rideout, Jai Ram and Stombaugh, Jesse and Wendel, Doug and Wilke, Andreas and Huse, Susan and Hufnagle, John and Meyer, Folker and Knight, Rob and Caporaso, J Gregory},
4+
journal={GigaScience},
5+
volume={1},
6+
number={1},
7+
pages={7},
8+
year={2012},
9+
publisher={BioMed Central},
10+
doi={10.1186/2047-217X-1-7}
11+
}

q2_types/feature_table/tests/test_transformer.py q2_types/feature_table/tests/test_transformers.py

+7-7
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,16 @@
1010

1111
import biom
1212
import pandas as pd
13-
import qiime2
14-
1513
from numpy.testing import assert_array_equal
1614
from pandas.testing import assert_frame_equal
17-
from q2_types.feature_table import BIOMV100Format, BIOMV210Format
15+
16+
import qiime2
1817
from qiime2.plugin.testing import TestPluginBase
19-
from q2_types.feature_table._transformer import (_parse_biom_table_v100,
20-
_parse_biom_table_v210,
21-
_table_to_dataframe,
22-
_table_to_metadata)
18+
19+
from q2_types.feature_table import BIOMV100Format, BIOMV210Format
20+
from q2_types.feature_table._deferred_setup._transformers import (
21+
_parse_biom_table_v100, _parse_biom_table_v210, _table_to_dataframe,
22+
_table_to_metadata)
2323

2424

2525
class TestTransformers(TestPluginBase):

q2_types/feature_table/tests/test_type.py q2_types/feature_table/tests/test_types.py

+2-1
Original file line numberDiff line numberDiff line change
@@ -8,11 +8,12 @@
88

99
import unittest
1010

11+
from qiime2.plugin.testing import TestPluginBase
12+
1113
from q2_types.feature_table import (FeatureTable, Frequency,
1214
RelativeFrequency, PercentileNormalized,
1315
Composition, Balance,
1416
PresenceAbsence, BIOMV210DirFmt, Design)
15-
from qiime2.plugin.testing import TestPluginBase
1617

1718

1819
class TestTypes(TestPluginBase):

q2_types/plugin_setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -33,5 +33,6 @@
3333
importlib.import_module('q2_types.feature_data._deferred_setup')
3434
importlib.import_module('q2_types.feature_data_mag._deferred_setup')
3535
importlib.import_module('q2_types.feature_map._deferred_setup')
36+
importlib.import_module('q2_types.feature_table._deferred_setup')
3637

3738
importlib.import_module('q2_types.per_sample_sequences._deferred_setup')

setup.py

+1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
'data/emp_multiplexed/*',
3535
'data/emp_multiplexed_single_end/*'],
3636
'q2_types.feature_map.tests': ['data/*'],
37+
'q2_types.feature_table': ['citations.bib'],
3738
'q2_types.feature_table.tests': ['data/*'],
3839
'q2_types.metadata.tests': ['data/*'],
3940
'q2_types.multiplexed_sequences.tests': [

0 commit comments

Comments
 (0)