Skip to content

Commit

Permalink
Read class is fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
kopardev committed May 24, 2021
1 parent e1cd916 commit bd0dc18
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions workflow/scripts/filter_bam_for_linear_reads.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,10 +6,10 @@


class Read:
def __init__(self,alignments=[],read1exists=False,read2exists=False):
self.alignments=alignments
self.read1exists=read1exists
self.read2exists=read2exists
def __init__(self):
self.alignments=list()
self.read1exists=False
self.read2exists=False

def append_alignment(self,alignment):
self.alignments.append(alignment)
Expand All @@ -36,6 +36,7 @@ def is_valid_read(self):
inBAM = pysam.AlignmentFile(args.inputBAM, "rb")
outBAM = pysam.AlignmentFile(args.outputBAM, "wb", template=inBAM)
reads = defaultdict(lambda: Read())
# reads = dict()

# get a list of the chimeric readids
with open(args.junctions, 'r') as junc_f:
Expand All @@ -51,7 +52,10 @@ def is_valid_read(self):
if not read.is_proper_pair or read.is_secondary or read.is_supplementary or read.is_unmapped:
continue
qname = read.query_name
# if not qname in reads:
# reads[qname]=Read()
reads[qname].append_alignment(read)
# print(qname,len(reads[qname].alignments))
output_rids=set(reads.keys())-set(rids)
for rid in output_rids:
if reads[rid].is_valid_read():
Expand Down

0 comments on commit bd0dc18

Please sign in to comment.