Skip to content

Commit

Permalink
adding comments
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredgk committed Mar 12, 2021
1 parent 31715cf commit 24c9399
Show file tree
Hide file tree
Showing 2 changed files with 614 additions and 282 deletions.
19 changes: 6 additions & 13 deletions pgpipe/genome_region.py
Original file line number Diff line number Diff line change
Expand Up @@ -118,15 +118,11 @@ def __len__(self):
def containsRecord(self, rec):
k1 = self.getChromKey()
kr = getChromKey(rec.chrom)
#print ("region:",k1,", record:",kr)
if k1 != kr:
if keyComp(k1,kr):
#return 'before'
return 'after'
return 'before'
#return 'after'
comp_pos = rec.pos-1
## print(comp_pos,self.start,self.end)
if comp_pos < self.start:
return 'before'
if comp_pos >= self.end:
Expand All @@ -143,7 +139,6 @@ def toStr(self, zeroho=False, zeroclosed=False, sep=':'):
elif zeroclosed:
end -= 1
return str(self.chrom)+sep+str(start)+sep+str(end)
#return str(start)+sep+str(end)+sep+str(self.chrom)

def getReference(self, refseq):
return refseq.fetch(self.chrom,self.start,self.end)
Expand All @@ -154,7 +149,7 @@ def getReference(self, refseq):
class RegionList:

def __init__(self, filename=None, genestr=None, reglist=None,
zeroclosed=False, zeroho=False,
zeroclosed=False, zeroho=True,
colstr=None, sortlist=True, checkoverlap=None,
sortmethod=None, sortorder=None, chromfilter=None,
list_template=None, randomize=False,keep_full_line=False):
Expand Down Expand Up @@ -316,6 +311,11 @@ def initRegion(self,la):
start -= 1
elif self.zeroclosed:
end += 1
if start < 0:
raise Exception('Region start coordinate is less than 0')
if end < 0:
raise Exception('Region end coordinate is less than 0')
#Add exception if end is after start?
fullline = (('\t'.join(la)) if self.keep_full_line else None)
self.regions.append(Region(start,end,chrom,fullline))

Expand Down Expand Up @@ -447,15 +447,8 @@ def subtractBed(stat_list, filter_list):
stat_region = stat_list.regions[stat_idx]
filter_region = filter_list.regions[filter_idx]
while stat_idx < len(stat_list.regions):
#try:
# print (stat_list.regions[stat_idx].toStr(),filter_list.regions[filter_idx].toStr())
#except:
# break
#print (stat_list.regions[stat_idx].toStr())
while filter_idx < len(filter_list.regions) and stat_list.regions[stat_idx].end > filter_list.regions[filter_idx].start:
#print (filter_list.regions[filter_idx].toStr())
if stat_list.regions[stat_idx].start < filter_list.regions[filter_idx].end:
#print ("drop "+str(stat_idx))
drop_list[stat_idx] = True
break
filter_idx+=1
Expand Down

0 comments on commit 24c9399

Please sign in to comment.