Skip to content

Commit

Permalink
Merge pull request #96 from brentp/hash
Browse files Browse the repository at this point in the history
improve svtyper speed by ~30%
  • Loading branch information
ernfrid authored Sep 13, 2018
2 parents 070e78b + b43902c commit a59ad33
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
3 changes: 2 additions & 1 deletion svtyper/classic.py
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,8 @@ def sv_genotype(bam_string,
if b.endswith('.bam'):
bam_list.append(pysam.AlignmentFile(b, mode='rb'))
elif b.endswith('.cram'):
bam_list.append(pysam.AlignmentFile(b, mode='rc', reference_filename=ref_fasta))
bam_list.append(pysam.AlignmentFile(b,
mode='rc',reference_filename=ref_fasta,format_options=["required_fields=7167"]))
else:
sys.stderr.write('Error: %s is not a valid alignment file (*.bam or *.cram)\n' % b)
exit(1)
Expand Down
5 changes: 4 additions & 1 deletion svtyper/parsers.py
Original file line number Diff line number Diff line change
Expand Up @@ -723,6 +723,9 @@ def close(self):
# from a single molecule
# ==================================================

def rhash(r):
return hash((r.query_name, r.flag))

class SamFragment(object):
def __init__(self, read, lib):
self.lib = lib
Expand All @@ -744,7 +747,7 @@ def is_primary(self, read):

def add_read(self, read):
# ensure we don't add the same read twice
read_hash = read.__hash__()
read_hash = rhash(read)
if read_hash in self.read_set:
return
else:
Expand Down

0 comments on commit a59ad33

Please sign in to comment.