Skip to content

Commit db06b67

Browse files
committed
* delete tmp files after copy
* better detection of sra file args
1 parent fcddfa0 commit db06b67

File tree

2 files changed

+11
-5
lines changed

2 files changed

+11
-5
lines changed

README.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,6 @@ Protips
1515
* All extra arguments will be passed directly to ``fastq-dump``, ``--gzip``, ``--split-files`` and filters works as expected.
1616
* This tool is **not** a replacement, you still need ``fastq-dump`` and ``sra-stat`` on your ``PATH`` for it to work properly.
1717
* Speed improvements are better with bigger files, think at least 200k reads/pairs for each thread used.
18-
* Mind the disk usage, you will need about double the space compared to a normal ``fastq-dump`` run.
1918

2019
Install
2120
-------

parallel-fastq-dump

Lines changed: 11 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import tempfile
66
import subprocess
77
import argparse
88

9-
__version__ = "0.6.5"
9+
__version__ = "0.6.6"
1010

1111
def pfd(args, srr_id, extra_args):
1212
tmp_dir = tempfile.TemporaryDirectory(prefix="pfd_",dir=args.tmpdir)
@@ -43,6 +43,7 @@ def pfd(args, srr_id, extra_args):
4343
wfd[fo] = open(os.path.join(args.outdir,fo), "wb")
4444
with open(os.path.join(tmp_path,fo), "rb") as fd:
4545
shutil.copyfileobj(fd, wfd[fo])
46+
os.remove(os.path.join(tmp_path,fo))
4647

4748
def split_blocks(start, end, n_pieces):
4849
total = (end-start+1)
@@ -73,6 +74,14 @@ def partition(f, l):
7374
r[1].append(i)
7475
return r
7576

77+
def is_sra_file(path):
78+
f = os.path.basename(path)
79+
if f.lower().endswith('.sra'): return True
80+
if "SRR" in f.upper(): return True
81+
if "ERR" in f.upper(): return True
82+
if "DRR" in f.upper(): return True
83+
return False
84+
7685
def main():
7786
parser = argparse.ArgumentParser(description="parallel fastq-dump wrapper, extra args will be passed through")
7887
parser.add_argument("-s","--sra-id", help="SRA id", action="append")
@@ -90,9 +99,7 @@ def main():
9099
sys.exit(0)
91100

92101
elif args.sra_id:
93-
extra_srrs, extra_args = partition(
94-
lambda s: "SRR" in s.upper() or s.lower().endswith('.sra'),
95-
extra)
102+
extra_srrs, extra_args = partition(is_sra_file,extra)
96103
args.sra_id.extend(extra_srrs)
97104
sys.stderr.write("SRR ids: {}\n".format(args.sra_id))
98105
sys.stderr.write("extra args: {}\n".format(extra_args))

0 commit comments

Comments
 (0)