From 1f1a62431b53a29b5ef54b40fd984ed8ccf7db1d Mon Sep 17 00:00:00 2001 From: fransua Date: Sun, 12 Jul 2020 23:01:14 +0200 Subject: [PATCH 1/2] read_bam_frag: removed unused code super slowing everything... back to normal --- _pytadbit/parsers/hic_bam_parser.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/_pytadbit/parsers/hic_bam_parser.py b/_pytadbit/parsers/hic_bam_parser.py index 4a9b4bd0..88b9658a 100644 --- a/_pytadbit/parsers/hic_bam_parser.py +++ b/_pytadbit/parsers/hic_bam_parser.py @@ -374,13 +374,6 @@ def _read_bam_frag(inbam, filter_exclude, all_bins, sections1, sections2, refs = bamfile.references bam_start = start - 2 bam_start = max(0, bam_start) - section_pos = [] - for sec in sections1: - if sec not in section_pos: - section_pos.append(sec[0]) - for sec in sections2: - if sec not in section_pos: - section_pos.append(sec[0]) try: dico = {} for r in bamfile.fetch(region=region, @@ -677,7 +670,7 @@ def read_bam(inbam, filter_exclude, resolution, ncpus=8, if ncpus == 1: read_bam_frag(inbam, filter_exclude, all_bins, bins_dict1, bins_dict2, rand_hash, - resolution, tmpdir, region, b, e,) + resolution, tmpdir, region, b, e) else: procs.append(pool.apply_async( read_bam_frag, args=(inbam, filter_exclude, all_bins, From 99ac094d9eb5325b9baa0ebcb01a97ea11628121 Mon Sep 17 00:00:00 2001 From: fransua Date: Fri, 4 Sep 2020 14:19:49 +0200 Subject: [PATCH 2/2] faster sam parsing --- _pytadbit/parsers/sam_parser.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/_pytadbit/parsers/sam_parser.py b/_pytadbit/parsers/sam_parser.py index 4954847e..e88a149a 100644 --- a/_pytadbit/parsers/sam_parser.py +++ b/_pytadbit/parsers/sam_parser.py @@ -108,7 +108,7 @@ def parse_sam(f_names1, f_names2=None, out_file1=None, out_file2=None, if mapper.lower()=='gem': condition = lambda x: x[1][0][0] != 'N' elif mapper.lower() in ['bowtie', 'bowtie2']: - condition = lambda x: 'XS' in dict(x) + condition = lambda x: 'XS' == x[0][0] else: warn('WARNING: unrecognized mapper used to generate file\n') condition = lambda x: x[1][1] != 1