Source code

Download source archive ↓

src/galaxy_sql_key_row_number.py

1from contract import Adapter
2from sql_views import execute
3
4adapter = Adapter('SELECT k AS key,v AS value,row_number() OVER(PARTITION BY k ORDER BY i) AS position FROM source ORDER BY i', ('source',), 'tsv', {'key_column': {'type': 'integer', 'default': 1, 'minimum': 1, 'maximum': 256, 'description': 'One-based key column of each TSV input.'}, 'value_column': {'type': 'integer', 'default': 2, 'minimum': 1, 'maximum': 256, 'description': 'One-based primary numeric column.'}, 'second_column': {'type': 'integer', 'default': 0, 'minimum': 0, 'maximum': 256, 'description': 'One-based optional secondary numeric column; zero supplies NULL.'}, 'header': {'type': 'boolean', 'default': False, 'description': 'Skip the first row of each TSV input.'}}, execute)
5
6def process(context):
7    adapter.process(context)
8
9def infer_outputs(inputs, params):
10    return adapter.infer_outputs(inputs, params)
11
12def preview_outputs(inputs, params, limits):
13    return adapter.preview_outputs(inputs, params, limits)
14
15if __name__ == "__main__":
16    adapter.main()