-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathplugin_setup.py
83 lines (72 loc) · 3.09 KB
/
plugin_setup.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
import pandas
from q2_types.feature_table import FeatureTable, Frequency
from q2_types.feature_data import FeatureData, Taxonomy
from qiime2.plugin import (Plugin, Citations, Bool)
import q2_surpi
from q2_surpi._formats_and_types import (
SurpiCountTable, SurpiCountTableFormat, SurpiCountTableDirectoryFormat,
SurpiSampleSheet, SurpiSampleSheetFormat, SurpiSampleSheetDirectoryFormat,
surpi_sample_sheet_fp_to_df)
plugin = Plugin(
name=q2_surpi.__plugin_name__,
version=q2_surpi.__version__,
website=q2_surpi.__url__,
package=q2_surpi.__package_name__,
citations=Citations.load(
q2_surpi.__citations_fname__, package=q2_surpi.__package_name__),
description=q2_surpi.__long_description__,
short_description=q2_surpi.__description__,
)
plugin.register_formats(SurpiCountTableFormat, SurpiCountTableDirectoryFormat)
plugin.register_semantic_types(SurpiCountTable)
plugin.register_semantic_type_to_format(
SurpiCountTable, SurpiCountTableDirectoryFormat)
plugin.register_semantic_types(SurpiSampleSheet)
plugin.register_formats(SurpiSampleSheetFormat,
SurpiSampleSheetDirectoryFormat)
plugin.register_semantic_type_to_format(
SurpiSampleSheet, SurpiSampleSheetDirectoryFormat)
@plugin.register_transformer
# load a SurpiCountTableFormat into a dataframe
def _1(ff: SurpiCountTableFormat) -> pandas.DataFrame:
result = pandas.read_csv(str(ff), sep='\t', header=0)
return result
@plugin.register_transformer
# load a SurpiSampleSheetFormat into a dataframe
def _2(ff: SurpiSampleSheetFormat) -> pandas.DataFrame:
result = surpi_sample_sheet_fp_to_df(str(ff))
return result
# plugin.methods.register_function(
# function=q2_surpi.extract_test,
# name='Extract test data',
# description='Extract test data.',
# inputs={'test_df': SurpiCountTable},
# input_descriptions={'test_df': 'Test data.'},
# parameters={},
# outputs=[('test_table', FeatureTable[Frequency]),
# ('test_taxonomy', FeatureData[Taxonomy])],
# output_descriptions={
# 'test_table': 'Test feature table.',
# 'test_taxonomy': 'Test feature metadata.'},
# )
plugin.methods.register_function(
function=q2_surpi.extract,
name='Extract SURPI data for use in QIIME.',
description=(
'Extract SURPI data into a feature table and a feature taxonomy.'),
inputs={'surpi_output': SurpiCountTable,
'surpi_sample_info': SurpiSampleSheet},
input_descriptions={
'surpi_output': "SURPI counts per species per barcode.",
'surpi_sample_info': 'Info linking sample ids to barcodes.'},
parameters={'ids_are_barcodes': Bool},
parameter_descriptions={
'ids_are_barcodes': ("True if the sample ids in the count tables are "
"barcodes. False if they are the sample sheet's "
"sample ids. Default is True.")},
outputs=[('table', FeatureTable[Frequency]),
('taxonomy', FeatureData[Taxonomy])],
output_descriptions={
'table': 'Output feature table.',
'taxonomy': 'Output feature metadata.'},
)