Skip to content

Commit

Permalink
ref: update temp_dir
Browse files Browse the repository at this point in the history
  • Loading branch information
Yenaled authored Oct 20, 2023
1 parent dd970ca commit d3ded6c
Showing 1 changed file with 19 additions and 10 deletions.
29 changes: 19 additions & 10 deletions kb_python/ref.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,6 +242,7 @@ def kallisto_index(
aa: bool = False,
distinguish: bool = False,
max_ec_size: int = None,
temp_dir: str = 'tmp',
) -> Dict[str, str]:
"""Runs `kallisto index`.
Expand Down Expand Up @@ -279,6 +280,8 @@ def kallisto_index(
command += ['-e', max_ec_size]
if dlist_overhang > 1:
command += ['--d-list-overhang', dlist_overhang]
if temp_dir != 'tmp':
command += ['-T', temp_dir]
command += [fasta_path]
run_executable(command)
return {'index': index_path}
Expand Down Expand Up @@ -357,7 +360,7 @@ def split_and_index(

built = []
for fasta_part_path, index_part_path in zip(fastas, indices):
result = kallisto_index(fasta_part_path, index_part_path, k=k)
result = kallisto_index(fasta_part_path, index_part_path, k=k, temp_dir=temp_dir)
built.append(result['index'])

return {'indices': built}
Expand Down Expand Up @@ -651,6 +654,7 @@ def ref(
aa=aa,
make_unique=make_unique,
max_ec_size=max_ec_size,
temp_dir=temp_dir,
)
results.update(index_result)
else:
Expand Down Expand Up @@ -713,7 +717,7 @@ def ref_kite(
index_result = split_and_index(
kite_path, index_path, n=n, k=k or optimal_k, temp_dir=temp_dir
) if n > 1 else kallisto_index(
kite_path, index_path, k=k or optimal_k, threads=threads
kite_path, index_path, k=k or optimal_k, threads=threads, temp_dir=temp_dir
)
results.update(index_result)
else:
Expand Down Expand Up @@ -781,7 +785,8 @@ def ref_custom(
dlist_overhang=dlist_overhang,
aa=aa,
make_unique=make_unique,
distinguish=distinguish
distinguish=distinguish,
temp_dir=temp_dir
)
logger.info('Finished creating custom index')
results.update(index_result)
Expand Down Expand Up @@ -988,7 +993,8 @@ def ref_nac(
dlist=dlist,
dlist_overhang=dlist_overhang,
make_unique=make_unique,
max_ec_size=max_ec_size
max_ec_size=max_ec_size,
temp_dir=temp_dir
)
elif n == 1:
index_result = kallisto_index(
Expand All @@ -999,7 +1005,8 @@ def ref_nac(
dlist=dlist,
dlist_overhang=dlist_overhang,
make_unique=make_unique,
max_ec_size=max_ec_size
max_ec_size=max_ec_size,
temp_dir=temp_dir
)
else:
cdna_index_result = kallisto_index(
Expand All @@ -1010,7 +1017,8 @@ def ref_nac(
dlist=dlist,
dlist_overhang=dlist_overhang,
make_unique=make_unique,
max_ec_size=max_ec_size
max_ec_size=max_ec_size,
temp_dir=temp_dir
)
if n == 2:
intron_index_result = kallisto_index(
Expand All @@ -1021,7 +1029,8 @@ def ref_nac(
dlist=dlist,
dlist_overhang=dlist_overhang,
make_unique=make_unique,
max_ec_size=max_ec_size
max_ec_size=max_ec_size,
temp_dir=temp_dir
)
index_result = {
'indices': [
Expand Down Expand Up @@ -1213,15 +1222,15 @@ def ref_lamanno(
# if n > 2, make n indices, one for spliced, another n - 1 for unspliced
if n == 1:
index_result = kallisto_index(
combined_path, index_path, k=k or 31, threads=threads
combined_path, index_path, k=k or 31, threads=threads, temp_dir=temp_dir
)
else:
cdna_index_result = kallisto_index(
cdna_path, f'{index_path}_cdna', k=k or 31
cdna_path, f'{index_path}_cdna', k=k or 31, temp_dir=temp_dir
)
if n == 2:
intron_index_result = kallisto_index(
intron_path, f'{index_path}_intron', k=k or 31
intron_path, f'{index_path}_intron', k=k or 31, temp_dir=temp_dir
)
index_result = {
'indices': [
Expand Down

0 comments on commit d3ded6c

Please sign in to comment.