Skip to content

Commit 70a12c1

Browse files
authored
Merge pull request #62 from cbrueffer/pyssw_fixes
Fix operation with custom weight matrices
2 parents de052a7 + 49f04c8 commit 70a12c1

File tree

1 file changed

+13
-8
lines changed

1 file changed

+13
-8
lines changed

src/pyssw.py

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ def main(args):
191191
dRc = {}
192192
dEle2Int = {}
193193
dInt2Ele = {}
194-
if False == args.bProtien:
194+
if False == args.bProtein:
195195
# init DNA score matrix
196196
if not args.sMatrix:
197197
lEle = ['A', 'C', 'G', 'T', 'N']
@@ -209,7 +209,7 @@ def main(args):
209209
else:
210210
lScore[i*nEleNum+j] = -args.nMismatch
211211
else:
212-
lEle, dEle2Int, dInt2Ele, lScore = ssw.read_matrix(args.sMatrix)
212+
lEle, dEle2Int, dInt2Ele, lScore = ssw_lib.read_matrix(args.sMatrix)
213213
else:
214214
# load AA score matrix
215215
if not args.sMatrix:
@@ -222,10 +222,15 @@ def main(args):
222222
lScore = ssw_lib.lBlosum50
223223
else:
224224
# assume the format of the input score matrix is the same as that of http://www.ncbi.nlm.nih.gov/Class/FieldGuide/BLOSUM62.txt
225-
lEle, dEle2Int, dInt2Ele, lScore = ssw.read_matrix(args.sMatrix)
225+
lEle, dEle2Int, dInt2Ele, lScore = ssw_lib.read_matrix(args.sMatrix)
226226

227+
<<<<<<< pyssw_fixes
228+
if args.bBest and args.bProtein:
229+
print >> sys.stderr, 'Reverse complement alignment is not available for protein sequences.'
230+
=======
227231
if args.bBest and args.bProtien:
228232
sys.stderr.write('Reverse complement alignment is not available for protein sequences.\n')
233+
>>>>>>> master
229234

230235
# translate score matrix to ctypes
231236
mat = (len(lScore) * ct.c_int8) ()
@@ -250,7 +255,7 @@ def main(args):
250255
qNum = to_int(sQSeq, lEle, dEle2Int)
251256
qProfile = ssw.ssw_init(qNum, ct.c_int32(len(sQSeq)), mat, len(lEle), 2)
252257
# build rc query profile
253-
if args.bBest and not args.bProtien:
258+
if args.bBest and not args.bProtein:
254259
sQRcSeq = ''.join([dRc[x] for x in sQSeq[::-1]])
255260
qRcNum = to_int(sQRcSeq, lEle, dEle2Int)
256261
qRcProfile = ssw.ssw_init(qRcNum, ct.c_int32(len(sQSeq)), mat, len(lEle), 2)
@@ -264,7 +269,7 @@ def main(args):
264269
res = align_one(ssw, qProfile, rNum, len(sRSeq), args.nOpen, args.nExt, nFlag, nMaskLen)
265270
# align rc query
266271
resRc = None
267-
if args.bBest and not args.bProtien:
272+
if args.bBest and not args.bProtein:
268273
resRc = align_one(ssw, qRcProfile, rNum, len(sRSeq), args.nOpen, args.nExt, nFlag, nMaskLen)
269274

270275
# build cigar and trace back path
@@ -343,7 +348,7 @@ def main(args):
343348

344349

345350
ssw.init_destroy(qProfile)
346-
if args.bBest and not args.bProtien:
351+
if args.bBest and not args.bProtein:
347352
ssw.init_destroy(qRcProfile)
348353

349354

@@ -355,14 +360,14 @@ def main(args):
355360
parser.add_argument('-x', '--nMismatch', type=int, default=2, help='a positive integer as the score for a mismatch in genome sequence alignment. [default: 2]')
356361
parser.add_argument('-o', '--nOpen', type=int, default=3, help='a positive integer as the penalty for the gap opening in genome sequence alignment. [default: 3]')
357362
parser.add_argument('-e', '--nExt', type=int, default=1, help='a positive integer as the penalty for the gap extension in genome sequence alignment. [default: 1]')
358-
parser.add_argument('-p', '--bProtien', action='store_true', help='Do protein sequence alignment. Without this option, the ssw_test will do genome sequence alignment. [default: False]')
363+
parser.add_argument('-p', '--bProtein', action='store_true', help='Do protein sequence alignment. Without this option, pyssw will do genome sequence alignment. [default: False]')
359364
parser.add_argument('-a', '--sMatrix', default='', help='a file for either Blosum or Pam weight matrix. [default: Blosum50]')
360365
parser.add_argument('-c', '--bPath', action='store_true', help='Return the alignment path. [default: False]')
361366
parser.add_argument('-f', '--nThr', default=0, help='a positive integer. Only output the alignments with the Smith-Waterman score >= N.')
362367
parser.add_argument('-r', '--bBest', action='store_true', help='The best alignment will be picked between the original read alignment and the reverse complement read alignment. [default: False]')
363368
parser.add_argument('-s', '--bSam', action='store_true', help='Output in SAM format. [default: no header]')
364369
parser.add_argument('-header', '--bHeader', action='store_true', help='If -s is used, include header in SAM output.')
365-
parser.add_argument('target', help='targe file')
370+
parser.add_argument('target', help='target file')
366371
parser.add_argument('query', help='query file')
367372
if len(sys.argv) == 1:
368373
parser.print_help()

0 commit comments

Comments
 (0)