88http://creativecommons.org/licenses/by-nc-sa/3.0/
99"""
1010
11- __version__ = "1.2 "
11+ __version__ = "1.3 "
1212
1313import sys
1414import os
@@ -1450,13 +1450,19 @@ def processMafFile(self, resultFile):
14501450 read_seq = block [2 ].split ()[- 1 ]
14511451 read_len = len (read_seq )
14521452 read_qual = block [3 ].split ()[- 1 ]
1453- # strand = self.findStrandFromAlignment(chr, ref_start, read_seq, read_len)
1454- strand = block [2 ].split ()[4 ]
1453+ strand = self .findStrandFromAlignment (chr , ref_start , read_seq , read_len )
1454+ # strand = block[2].split()[4]
14551455 if strand == '+' or strand == '-' :
14561456 lines = self .extractMcContextsByOneRead (chr , strand , mismap_prob , ref_seq , ref_start , read_seq , read_qual , read_len )
14571457 for line in lines :
14581458 fout .write (line )
1459- logging .debug ("processMafFile: a maf block is successfully captured." )
1459+ logging .debug ("processMafFile: a maf block(%s) is successfully captured." % strand )
1460+ elif strand == '+-' :
1461+ for st in ('+' , '-' ):
1462+ lines = self .extractMcContextsByOneRead (chr , st , mismap_prob , ref_seq , ref_start , read_seq , read_qual , read_len )
1463+ for line in lines :
1464+ fout .write (line )
1465+ logging .debug ("processMafFile: a maf block(%s) is successfully captured." % strand )
14601466 else :
14611467 logging .debug ("processMafFile: a maf block does not show strand-specific info." )
14621468 else :
@@ -1592,10 +1598,10 @@ def findStrandFromAlignment(self, chr, ref_start, read_seq, read_len):
15921598 ref_seq = self .refGenomeBuf [chr ]
15931599 for i in range (read_len ):
15941600 j = ref_start + i
1595- if ref_seq [j ]== 'C' and ( read_seq [i ]== 'C' or read_seq [ i ] == 'T' ) :
1601+ if ref_seq [j ]== 'C' and read_seq [i ]== 'T' :
15961602 plus_sup += 1
15971603 base_size += 1
1598- elif ref_seq [j ]== 'G' and ( read_seq [i ]== 'G' or read_seq [ i ] == 'A' ) :
1604+ elif ref_seq [j ]== 'G' and read_seq [i ]== 'A' :
15991605 minus_sup += 1
16001606 base_size += 1
16011607 elif (ref_seq [j ]!= '-' and read_seq [i ]!= '-' ) and ref_seq [j ]!= read_seq [i ]:
@@ -1612,6 +1618,8 @@ def findStrandFromAlignment(self, chr, ref_start, read_seq, read_len):
16121618 # if minus_sup > plus_sup and mismatch_rate < 0.05:
16131619 if minus_sup > plus_sup :
16141620 return '-'
1621+ if plus_sup == minus_sup :
1622+ return '+-'
16151623 return '.'
16161624
16171625
0 commit comments