-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathCigarOp.py
executable file
·65 lines (56 loc) · 2.56 KB
/
CigarOp.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
#=========================================================================
# This is OPEN SOURCE SOFTWARE governed by the Gnu General Public
# License (GPL) version 3, as described at www.opensource.org.
# 2018 William H. Majoros ([email protected])
#=========================================================================
from __future__ import (absolute_import, division, print_function,
unicode_literals, generators, nested_scopes, with_statement)
from builtins import (bytes, dict, int, list, object, range, str, ascii,
chr, hex, input, next, oct, open, pow, round, super, filter, map, zip)
from Interval import Interval
ADVANCE_QUERY=set(["M","I","S","H","=","X"])
ADVANCE_REF=set(["M","D","N","=","X"])
#=========================================================================
# Attributes:
# length : integer
# interval1 : Interval (in sequence 1 = query)
# interval2 : Interval (in sequence 2 = reference)
# op : M(or =/X)/I/D/S:
# consumes
# query ref
# M 0 alignment match (can be a sequence match or mismatch) yes yes
# I 1 insertion to the reference yes no
# D 2 deletion from the reference no yes
# N 3 skipped region from the reference no yes
# S 4 soft clipping (clipped sequences present in SEQ) yes no
# H 5 hard clipping (clipped sequences NOT present in SEQ) no no
# P 6 padding (silent deletion from padded reference) no no
# = 7 sequence match yes yes
# X 8 sequence mismatch yes yes
# Instance Methods:
# op=CigarOp("M",135)
# bool=op.advanceInQuery() # matches, insertions, etc.
# bool=op.advanceInRef() # matches, deletions, etc.
# op=op.getOp()
# L=op.getLength()
# interval=op.getQueryInterval() # sequence 1
# interval=op.getRefInterval() # sequence 2
#=========================================================================
class CigarOp:
def __init__(self,op,L):
self.op=op
self.length=L
self.interval1=None
self.interval2=None
def getQueryInterval(self):
return self.interval1
def getRefInterval(self):
return self.interval2
def getOp(self):
return self.op
def getLength(self):
return self.length
def advanceInQuery(self):
return self.op in ADVANCE_QUERY
def advanceInRef(self):
return self.op in ADVANCE_REF