Mercurial > repos > devteam > data_manager_fetch_genome_dbkeys_all_fasta
changeset 10:872d7cf608f9 draft
planemo upload for repository https://github.com/galaxyproject/tools-iuc/tree/master/data_managers/data_manager_fetch_genome_dbkeys_all_fasta commit c17db435e1c3b53ef752e2b0b09ada388e264656-dirty
author | iuc |
---|---|
date | Mon, 13 Aug 2018 08:43:15 -0400 |
parents | 0d13eef4f46c |
children | 5ca251be8236 |
files | data_manager/.pytest_cache/README.md data_manager/.pytest_cache/v/cache/lastfailed data_manager/.pytest_cache/v/cache/nodeids data_manager/__pycache__/data_manager_fetch_genome_all_fasta_dbkeys.cpython-36-PYTEST.pyc data_manager/data_manager_fetch_genome_all_fasta_dbkeys.py |
diffstat | 5 files changed, 30 insertions(+), 32 deletions(-) [+] |
line wrap: on
line diff
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/.pytest_cache/README.md Mon Aug 13 08:43:15 2018 -0400 @@ -0,0 +1,8 @@ +# pytest cache directory # + +This directory contains data from the pytest's cache plugin, +which provides the `--lf` and `--ff` options, as well as the `cache` fixture. + +**Do not** commit this to version control. + +See [the docs](https://docs.pytest.org/en/latest/cache.html) for more information.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/.pytest_cache/v/cache/lastfailed Mon Aug 13 08:43:15 2018 -0400 @@ -0,0 +1,3 @@ +{ + "data_manager_fetch_genome_all_fasta_dbkeys.py::data_manager_fetch_genome_all_fasta_dbkeys.download_from_url": true +} \ No newline at end of file
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/data_manager/.pytest_cache/v/cache/nodeids Mon Aug 13 08:43:15 2018 -0400 @@ -0,0 +1,3 @@ +[ + "data_manager_fetch_genome_all_fasta_dbkeys.py::data_manager_fetch_genome_all_fasta_dbkeys.download_from_url" +] \ No newline at end of file
Binary file data_manager/__pycache__/data_manager_fetch_genome_all_fasta_dbkeys.cpython-36-PYTEST.pyc has changed
--- a/data_manager/data_manager_fetch_genome_all_fasta_dbkeys.py Thu Jun 15 13:13:28 2017 -0400 +++ b/data_manager/data_manager_fetch_genome_all_fasta_dbkeys.py Mon Aug 13 08:43:15 2018 -0400 @@ -118,20 +118,16 @@ def _write_sorted_fasta(sorted_names, fasta_offsets, sorted_fasta_filename, unsorted_fasta_filename): - unsorted_fh = open(unsorted_fasta_filename) - sorted_fh = open(sorted_fasta_filename, 'wb+') - - for name in sorted_names: - offset = fasta_offsets[name] - unsorted_fh.seek(offset) - sorted_fh.write(unsorted_fh.readline()) - while True: - line = unsorted_fh.readline() - if not line or line.startswith(">"): - break - sorted_fh.write(line) - unsorted_fh.close() - sorted_fh.close() + with open(unsorted_fasta_filename, 'rb') as unsorted_fh, open(sorted_fasta_filename, 'wb+') as sorted_fh: + for name in sorted_names: + offset = fasta_offsets[name] + unsorted_fh.seek(offset) + sorted_fh.write(unsorted_fh.readline()) + while True: + line = unsorted_fh.readline() + if not line or line.startswith(b">"): + break + sorted_fh.write(line) def _sort_fasta_as_is(fasta_filename, params): @@ -316,27 +312,15 @@ """ Download a file from a URL and return a list of filehandles from which to read the data. - >>> url = 'https://github.com/mvdbeek/tools-devteam/raw/data_manager/data_managers/data_manager_fetch_genome_dbkeys_all_fasta/test-data/test.tar' - >>> params = {'param_dict': {'reference_source': {'user_url': url}}} >>> tmp_dir = tempfile.mkdtemp() - >>> fh = download_from_url(params=params, tmp_dir=tmp_dir)[0][0] - >>> assert fh.readline().startswith('>FBtr0304171') - >>> url = 'https://github.com/mvdbeek/tools-devteam/raw/data_manager/data_managers/data_manager_fetch_genome_dbkeys_all_fasta/test-data/test.tar.bz2' + >>> url = 'https://github.com/galaxyproject/tools-iuc/raw/master/data_managers/data_manager_fetch_genome_dbkeys_all_fasta/test-data/test.tar.bz2' >>> params = {'param_dict': {'reference_source': {'user_url': url}}} >>> fh = download_from_url(params=params, tmp_dir=tmp_dir)[0][0] - >>> assert fh.readline().startswith('>FBtr0304171') - >>> url = 'https://github.com/mvdbeek/tools-devteam/raw/data_manager/data_managers/data_manager_fetch_genome_dbkeys_all_fasta/test-data/test.tar.gz' + >>> assert fh.readline().startswith('b>FBtr0304171') + >>> url = 'https://github.com/galaxyproject/tools-iuc/raw/master/data_managers/data_manager_fetch_genome_dbkeys_all_fasta/test-data/phiX174.fasta' >>> params = {'param_dict': {'reference_source': {'user_url': url}}} >>> fh = download_from_url(params=params, tmp_dir=tmp_dir)[0][0] - >>> assert fh.readline().startswith('>FBtr0304171') - >>> url = 'https://github.com/mvdbeek/tools-devteam/raw/data_manager/data_managers/data_manager_fetch_genome_dbkeys_all_fasta/test-data/test.zip' - >>> params = {'param_dict': {'reference_source': {'user_url': url}}} - >>> fh = download_from_url(params=params, tmp_dir=tmp_dir)[0][0] - >>> assert fh.readline().startswith('>FBtr0304171') - >>> url = 'https://raw.githubusercontent.com/galaxyproject/tools-devteam/master/data_managers/data_manager_fetch_genome_dbkeys_all_fasta/test-data/phiX174.fasta' - >>> params = {'param_dict': {'reference_source': {'user_url': url}}} - >>> fh = download_from_url(params=params, tmp_dir=tmp_dir)[0][0] - >>> assert fh.readline().startswith('>phiX174') + >>> assert fh.readline().startswith('b>phiX174') """ urls = filter(bool, [x.strip() for x in params['param_dict']['reference_source']['user_url'].split('\n')]) return [get_stream_reader(urlopen(url), tmp_dir) for url in urls] @@ -348,7 +332,7 @@ if isinstance(input_filename, list): fasta_readers = [get_stream_reader(open(filename, 'rb'), tmp_dir) for filename in input_filename] else: - fasta_readers = get_stream_reader(open(input_filename), tmp_dir) + fasta_readers = get_stream_reader(open(input_filename, 'rb'), tmp_dir) return fasta_readers @@ -504,7 +488,7 @@ finally: cleanup_before_exit(tmp_dir) # save info to json file - open(filename, 'wb').write(dumps(data_manager_dict).encode()) + open(filename, 'w').write(dumps(data_manager_dict)) if __name__ == "__main__":