diff 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
line wrap: on
line diff
--- a/BSseeker2/bs_align/bs_align_utils.py	Fri Jul 12 18:47:28 2013 -0400
+++ b/BSseeker2/bs_align/bs_align_utils.py	Tue Nov 05 01:55:39 2013 -0500
@@ -54,9 +54,15 @@
 
 """
 
-def RemoveAdapter ( read, adapter, no_mismatch ) :
+# Remove the adapter from 3' end
+def RemoveAdapter ( read, adapter, no_mismatch, rm_back=0) :
     lr = len(read)
     la = len(adapter)
+    # Check the empty adapter, namely, the reads start with the 2nd base of adapter,
+    # not including the 'A' base in front of the adapter.
+    if adapter[2:] == read[0:(la-1)] :
+        return ""
+
     for i in xrange( lr - no_mismatch ) :
         read_pos = i
         adapter_pos = 0
@@ -74,8 +80,14 @@
                     adapter_pos = adapter_pos + 1
         # while_end
 
+        # Cut the extra bases before the adapter
+        #     --C|CG G--  => --CNN+A+<adapter>
+        #     --G GC|C--     --GGC
         if adapter_pos == la or read_pos == lr :
-            return read[:i]
+            if i <= rm_back :
+                return ''
+            else :
+                return read[:(i-rm_back)]
     # for_end
     return read