Skip to content

Commit

Permalink
add extensions to tmp files
Browse files Browse the repository at this point in the history
  • Loading branch information
readmanchiu committed Jul 19, 2024
1 parent 4068c91 commit c2897b0
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -70,4 +70,5 @@ v1.5.1
- bugfix: size and copy range of alleles only include "full" supporting reads even if partials were included, but "partial" reads will be reported in support counts
- bugfix: allele motif equivalence checked to perform proper tallying for determining consensus motif in variant
- used read name as tiebreaker for choosing support read sequence as ALT
- add extensions (`.fa`, `.blastn`, `.bed`) to temporary files to help debugging
- `MOTIF` renamed to `RU`, `COPIES` to `REF` in VCF fields
6 changes: 3 additions & 3 deletions src/ins.py
Original file line number Diff line number Diff line change
Expand Up @@ -456,7 +456,7 @@ def create_tmp_bed(self, ins_list, include_read=False):
for ins in ins_list:
ins_bed += '{}\n'.format(INS.to_bed(ins, include_read=include_read))

ins_bed_file = create_tmp_file(ins_bed)
ins_bed_file = create_tmp_file(ins_bed, '.bed')
self.tmp_files.add(ins_bed_file)

return ins_bed_file
Expand All @@ -469,7 +469,7 @@ def merge(self, ins_list, d=50):
ins_all = BedTool(ins_bed_file)
ins_merged = ins_all.sort().merge(d=d, c='4,5', o='distinct,count_distinct')
if self.debug:
ins_merged_file = create_tmp_file('')
ins_merged_file = create_tmp_file('', '.bed')
ins_merged.saveas(ins_merged_file)
print('ins merged {}'.format(ins_merged_file))

Expand Down Expand Up @@ -516,7 +516,7 @@ def get_examine_regions(self, bam, chroms, chunk_size=1000000, regions_bed_file=
chrom_spans = ''
for chrom in sorted(chroms):
chrom_spans += '{}\n'.format('\t'.join(map(str, [chrom, 0, chrom_lens[chrom]])))
chrom_bed_file = create_tmp_file(chrom_spans)
chrom_bed_file = create_tmp_file(chrom_spans, '.bed')
self.tmp_files.add(chrom_bed_file)

chrom_bed = BedTool(chrom_bed_file)
Expand Down
4 changes: 2 additions & 2 deletions src/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,8 @@ def combine_batch_results(batch_results, data_type):

return all_results

def create_tmp_file(content):
fd, path = tempfile.mkstemp()
def create_tmp_file(content, ext=None):
fd, path = tempfile.mkstemp(suffix=ext)
try:
with os.fdopen(fd, 'w') as out:
out.write(content)
Expand Down

0 comments on commit c2897b0

Please sign in to comment.