comparison BSseeker2/bs_align/bs_align_utils.py @ 1:8b26adf64adc draft default tip

V2.0.5
author weilong-guo
date Tue, 05 Nov 2013 01:55:39 -0500
parents e6df770c0e58
children
comparison
equal deleted inserted replaced
0:e6df770c0e58 1:8b26adf64adc
52 Success & return! 52 Success & return!
53 ======== 53 ========
54 54
55 """ 55 """
56 56
57 def RemoveAdapter ( read, adapter, no_mismatch ) : 57 # Remove the adapter from 3' end
58 def RemoveAdapter ( read, adapter, no_mismatch, rm_back=0) :
58 lr = len(read) 59 lr = len(read)
59 la = len(adapter) 60 la = len(adapter)
61 # Check the empty adapter, namely, the reads start with the 2nd base of adapter,
62 # not including the 'A' base in front of the adapter.
63 if adapter[2:] == read[0:(la-1)] :
64 return ""
65
60 for i in xrange( lr - no_mismatch ) : 66 for i in xrange( lr - no_mismatch ) :
61 read_pos = i 67 read_pos = i
62 adapter_pos = 0 68 adapter_pos = 0
63 count_no_mis = 0 69 count_no_mis = 0
64 while (adapter_pos < la) and (read_pos < lr) : 70 while (adapter_pos < la) and (read_pos < lr) :
72 else : 78 else :
73 read_pos = read_pos + 1 79 read_pos = read_pos + 1
74 adapter_pos = adapter_pos + 1 80 adapter_pos = adapter_pos + 1
75 # while_end 81 # while_end
76 82
83 # Cut the extra bases before the adapter
84 # --C|CG G-- => --CNN+A+<adapter>
85 # --G GC|C-- --GGC
77 if adapter_pos == la or read_pos == lr : 86 if adapter_pos == la or read_pos == lr :
78 return read[:i] 87 if i <= rm_back :
88 return ''
89 else :
90 return read[:(i-rm_back)]
79 # for_end 91 # for_end
80 return read 92 return read
81 93
82 94
83 def Remove_5end_Adapter ( read, adapter, no_mismatch) : 95 def Remove_5end_Adapter ( read, adapter, no_mismatch) :