Skip to content
Merged
Show file tree
Hide file tree
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
16 changes: 7 additions & 9 deletions singlecellmultiomics/universalBamTagger/bamtagmultiome.py
Original file line number Diff line number Diff line change
Expand Up @@ -333,18 +333,15 @@ def tag_multiome_multi_processing(
small_contig_threshold = 100000

job_gen = [[('*',None,None,None,None),],]
current = []
small_contigs_jobs = []
for contig,contig_len in get_contigs_with_reads(input_bam_path, True):
if contig_len<small_contig_threshold:
current.append( (contig,None,None,None,None) )
small_contigs_jobs.append( (contig,None,None,None,None) )
else:
if len(current)>1:
job_gen.append(current)
current=[]
else:
job_gen.append([ (contig,None,None,None,None), ])
if len(current)>1:
job_gen.append(current)
job_gen.append([ (contig,None,None,None,None), ])
if len(small_contigs_jobs)>0:
job_gen.append(small_contigs_jobs)

#job_gen = [[('*',None,None,None,None),],] + [ [(contig,None,None,None,None),] for contig,contig_len in get_contigs_with_reads(input_bam_path, True) if contig!='*' ]


Expand Down Expand Up @@ -375,6 +372,7 @@ def tag_multiome_multi_processing(
additional_args= additional_args,
max_time_per_segment=max_time_per_segment)


# Create header bam:
temp_header_bam_path = f'{temp_folder}/{uuid.uuid4()}_header.bam'
with pysam.AlignmentFile(input_bam_path) as input_bam:
Expand Down
16 changes: 12 additions & 4 deletions singlecellmultiomics/universalBamTagger/tagging.py
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,15 @@ def timeout_check_function(iteration, mol_iter, reads ):
'time_start': time_start}


def task_to_alias(kwargs):
if kwargs.get('contig') is None:
return 'all'
contig = kwargs['contig'].replace('*', 'star')
if kwargs.get('start') is None:
return contig
if kwargs.get('end') is None:
return contig + '-' + kwargs['start']
return contig + '-' + kwargs['start'] + '-' + kwargs['end']

def run_tagging_tasks(args: tuple):
""" Run tagging for one or more tasks
Expand All @@ -169,11 +178,10 @@ def run_tagging_tasks(args: tuple):

(alignments_path, temp_dir, timeout_time), arglist = args

target_file = f"{temp_dir}/{uuid4()}.bam"
while os.path.exists(target_file):
print(f'Collision at {target_file}')
target_file = f"{temp_dir}/{uuid4()}.bam"

target_file_prefix = '_'.join( [task_to_alias(kwargs) for kwargs in arglist[:2]]) + (f'_{len(arglist)-2}more' if len(arglist) > 2 else '' )
target_file = f"{temp_dir}/{target_file_prefix}.bam"
assert not os.path.exists(target_file), f'File {target_file} already exists'

timeout_tasks = []
total_molecules = 0
Expand Down
2 changes: 1 addition & 1 deletion singlecellmultiomics/version.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
__version__ = '0.1.44'
__version__ = '0.1.45'

Loading