Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change os.rename for shutil.move #9

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions download.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import functools
import time
import subprocess
from shutil import move as shutil_move
from shutil import copy as shutil_copy


def get_read_run_info(ena_id):
Expand Down Expand Up @@ -126,14 +128,12 @@ def download_with_sra_prefetch(aspera_key, outdir, pickle_prefix, ena_id):
_, prefetch_outdir, _ = utils.runCommandPopenCommunicate(['echo', '$HOME/ncbi/public/sra'], True, None, False)

try:
os.rename(os.path.join(prefetch_outdir.splitlines()[0], ena_id + '.sra'),
os.path.join(outdir, ena_id + '.sra'))
shutil_move(os.path.join(prefetch_outdir.splitlines()[0], ena_id + '.sra'),
os.path.join(outdir, ena_id + '.sra'))
except OSError as e:
print('Found the following error:'
'{}'.format(e))

from shutil import copy as shutil_copy

shutil_copy(os.path.join(prefetch_outdir.splitlines()[0], ena_id + '.sra'),
os.path.join(outdir, ena_id + '.sra'))
os.remove(os.path.join(prefetch_outdir.splitlines()[0], ena_id + '.sra'))
Expand Down Expand Up @@ -476,7 +476,7 @@ def rename_move_files(list_files, new_name, outdir, download_paired_type):
if os.path.isfile(list_files[i]):
os.remove(list_files[i])
else:
os.rename(list_files[i], list_new_files[i])
shutil_move(list_files[i], list_new_files[i])
list_new_files = list_new_files.values()
except Exception as e:
print(e)
Expand Down