Skip to content

Commit 415e5ae

Browse files
authored
Merge pull request #232 from pachterlab/devel
Devel
2 parents 34396d5 + 9a595bd commit 415e5ae

File tree

9 files changed

+26
-15
lines changed

9 files changed

+26
-15
lines changed
-16 KB
Binary file not shown.
-16 KB
Binary file not shown.
-1.94 KB
Binary file not shown.
-1006 Bytes
Binary file not shown.

kb_python/count.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,8 @@ def kallisto_bus(
204204

205205
if technology.upper() in ('BULK', 'SMARTSEQ3'):
206206
results['saved_index'] = os.path.join(out_dir, SAVED_INDEX_FILENAME)
207+
if os.path.exists(results['saved_index']):
208+
os.remove(results['saved_index']) # TODO: Fix this in kallisto?
207209
return results
208210

209211

kb_python/main.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -636,7 +636,7 @@ def parse_count(
636636
parser.error(
637637
f'Technology `{args.x}` can not be used with workflow {args.workflow}.'
638638
)
639-
if args.sum is not None:
639+
if args.sum != "none":
640640
parser.error('--sum incompatible with lamanno/nucleus')
641641
if args.x.upper() == 'SMARTSEQ3':
642642
from .count import count_velocity_smartseq3
@@ -1036,8 +1036,8 @@ def setup_ref_args(
10361036
'--workflow',
10371037
metavar='{standard,nac,kite,custom}',
10381038
help=(
1039-
'Type of workflow to prepare files for. '
1040-
'Use `nac` for RNA velocity or single-nucleus RNA-seq reads. '
1039+
'The type of index to create. '
1040+
'Use `nac` for an index type that can quantify nascent and mature RNA. '
10411041
'Use `custom` for indexing targets directly. '
10421042
'Use `kite` for feature barcoding. (default: standard)'
10431043
),
@@ -1253,7 +1253,7 @@ def setup_count_args(
12531253
metavar='{standard,nac,kite,kite:10xFB}',
12541254
help=(
12551255
'Type of workflow. '
1256-
'Use `nac` for RNA velocity or single-nucleus RNA-seq reads. '
1256+
'Use `nac` to specify a nac index for producing mature/nascent/ambiguous matrices. '
12571257
'Use `kite` for feature barcoding. '
12581258
'Use `kite:10xFB` for 10x Genomics Feature Barcoding technology. '
12591259
'(default: standard)'
@@ -1301,14 +1301,14 @@ def setup_count_args(
13011301
required_nac.add_argument(
13021302
'-c1',
13031303
metavar='T2C',
1304-
help='Path to cDNA transcripts-to-capture',
1304+
help='Path to mature transcripts-to-capture',
13051305
type=str,
13061306
required=workflow in {'nac'}
13071307
)
13081308
required_nac.add_argument(
13091309
'-c2',
13101310
metavar='T2C',
1311-
help='Path to intron transcripts-to-captured',
1311+
help='Path to nascent transcripts-to-captured',
13121312
type=str,
13131313
required=workflow in {'nac'}
13141314
)

kb_python/ref.py

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -282,7 +282,12 @@ def kallisto_index(
282282
command += ['--d-list-overhang', dlist_overhang]
283283
if temp_dir != 'tmp':
284284
command += ['-T', temp_dir]
285-
command += [fasta_path]
285+
if ',' in fasta_path:
286+
fasta_paths = fasta_path.split(',')
287+
for fp in fasta_paths:
288+
command += [fp]
289+
else:
290+
command += [fasta_path]
286291
run_executable(command)
287292
return {'index': index_path}
288293

@@ -303,11 +308,15 @@ def get_dlist_fasta(fasta_path: str = None, temp_dir: str = 'tmp') -> str:
303308
if "://" not in fasta_path: # Not a URL
304309
return fasta_path
305310
new_fasta_path = get_temporary_filename(temp_dir)
311+
fasta_path_array = [fasta_path]
312+
if fasta_path.count("://") > 1:
313+
fasta_path_array = fasta_path.split(",")
306314
logger.info(f'Extracting {fasta_path} into {new_fasta_path}')
307-
with ngs.fasta.Fasta(fasta_path, 'r') as f_in:
308-
with ngs.fasta.Fasta(new_fasta_path, 'w') as f_out:
309-
for entry in f_in:
310-
f_out.write(entry)
315+
with ngs.fasta.Fasta(new_fasta_path, 'w') as f_out:
316+
for fp in fasta_path_array:
317+
with ngs.fasta.Fasta(fp, 'r') as f_in:
318+
for entry in f_in:
319+
f_out.write(entry)
311320
return new_fasta_path
312321

313322

@@ -803,7 +812,7 @@ def ref_custom(
803812

804813
if not glob.glob(f'{index_path}*') or overwrite:
805814
index_result = kallisto_index(
806-
' '.join(fasta_paths),
815+
','.join(fasta_paths),
807816
index_path,
808817
k=k or 31,
809818
threads=threads,

kb_python/utils.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -711,8 +711,8 @@ def overlay_anndatas(
711711
spliced_intersection = adata_spliced[obs_idx][:, var_idx]
712712
unspliced_intersection = adata_unspliced[obs_idx][:, var_idx]
713713
a_layers = {
714-
'spliced': spliced_intersection.X,
715-
'unspliced': unspliced_intersection.X
714+
'mature': spliced_intersection.X,
715+
'nascent': unspliced_intersection.X
716716
}
717717
ambiguous_intersection = None
718718
if adata_ambiguous is not None:

tests/test_utils.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -227,7 +227,7 @@ def test_overlay_anndatas(self):
227227
self.unspliced_genes_path
228228
)
229229
adata = utils.overlay_anndatas(adata_spliced, adata_unspliced)
230-
self.assertEqual({'spliced', 'unspliced'}, set(adata.layers.keys()))
230+
self.assertEqual({'mature', 'nascent'}, set(adata.layers.keys()))
231231

232232
def test_sum_anndatas(self):
233233
adata_spliced = utils.import_matrix_as_anndata(

0 commit comments

Comments
 (0)