def SW(s1,s2): """Return (alignment string, sw score). sequences are taken as read - no complementing or reversing. returns ('',-1) if there is no alignment. Score is an integer using the PAM47 matrix. """ if type(s1) != StringType or type(s2) != StringType: raise AttributeError, "s1 and s2 must be strings" sizeDiff = len(s1)-len(s2) if sizeDiff > 0: s2+='x'*sizeDiff elif sizeDiff < 0: s1+='x'*abs(sizeDiff) s2=sequence.reverse(s2) sLen = len(s1) outBuffer = ctypes.create_string_buffer(sLen*5) __aos.SW(ctypes.c_char_p(s1), ctypes.c_char_p(s2), ctypes.c_int(1), ctypes.c_int(sLen), outBuffer) outLines = outBuffer.value.split('\n') #print outLines if len(outLines) > 3: alignment = '\n'.join(outLines[0:2]) score = int(outLines[2]) return (alignment,score) else: return ('',-1)
def energy(s1,s2): """Return melting energy for association of s1/s2. """ if type(s1) != StringType or type(s2) != StringType: raise AttributeError, "s1 and s2 must be strings" if len(s2) != len(s1): raise SequenceLengthError, "s1 and s2 are different lengths." s2=sequence.reverse(s2) return __aos.energy(ctypes.c_char_p(s1),ctypes.c_char_p(s2),ctypes.c_int(0))
action="store_true", dest="complement", help="Complement sequence", default=False) parser.add_option( "-b", "--reverseComplement", "--revComp", action="store_true", dest="reverseComplement", help="Reverse complement sequence", default=False) options, args = parser.parse_args(sys.argv) iFilename = args[1] start = int(args[2]) end = int(args[3]) header,seq = fasta.load(iFilename) s = seq[start-1:end] h = '%s %i-%i' % (header,start,end) if options.reverse: s = sequence.reverse(s) h += '(r)' elif options.complement: s = sequence.complement(s) h += '(c)' elif options.reverseComplement: s = sequence.reverse_complement(s) h += '(rc)' fasta.pretty(h, s, width=options.width)
help="Complement sequence", default=False) parser.add_option("-b", "--reverseComplement", "--revComp", action="store_true", dest="reverseComplement", help="Reverse complement sequence", default=False) options, args = parser.parse_args(sys.argv) iFilename = args[1] start = int(args[2]) end = int(args[3]) header, seq = fasta.load(iFilename) s = seq[start - 1:end] h = '%s %i-%i' % (header, start, end) if options.reverse: s = sequence.reverse(s) h += '(r)' elif options.complement: s = sequence.complement(s) h += '(c)' elif options.reverseComplement: s = sequence.reverse_complement(s) h += '(rc)' fasta.pretty(h, s, width=options.width)