> i search a function f(a,b) that gives 1 if a is "contained" in b with
> any sub strings interposed.

If I understand it right, it should be something
like this:

def blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB):
  intNoOfCharsFound = 0
  intPtrToBeginOfSubsectionOfB = 0
  intLenA = len(strA)
  intLenB = len(strB)
  blnStrAinB = False
  for chrA in strA:
    blnFoundChrA = False
    # print chrA
    for indxToB in range(intPtrToBeginOfSubsectionOfB, intLenB):
      if(chrA == strB[indxToB]):
        intNoOfCharsFound += 1
        # print "   ",chrA, strB[indxToB], indxToB
        intPtrToBeginOfSubsectionOfB = indxToB + 1
        blnFoundChrA = True
        break
      #:if
    #:for
    if(intNoOfCharsFound == intLenA):
      blnStrAinB = True
      print "sequence '%s' found in '%s'"%(strA, strB)
      break
    #:if
    if(blnFoundChrA == False):
      break
    #:if
  #:for
  if  blnStrAinB == False:
      print "sequence '%s' not in '%s'"%(strA, strB)
  #:if
#:def

strA = "0101"
strB = "000011110100"
blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB)

strA = "010101"
strB = "000011110100"
blnFindCharSequenceAevenIfSpreadOverEntireStringB(strA, strB)

Note: code above is intended to help clarify things only,
so that a bunch of examples can be tested.
If you need production quality code, maybe someone else
can provide it.

Is it what you are looking for?

By the way:
it looks to me like a standard problem while
comparing DNA sequences, so I suppose
that there are ready to use fast libraries
providing such kind of function.

Claudio

<[EMAIL PROTECTED]> schrieb im Newsbeitrag
news:[EMAIL PROTECTED]
> hi everyone.
> a problem:
> two binary strings, a="0101" b="000011110100";
> i search a function f(a,b) that gives 1 if a is "contained" in b with
> any sub strings interposed.
> in this example a in contained cause 000<01>111<01>00 but also
> 0<0>001111<101>00"
>  but also <0>0001111<101>00 but also 000<0>1111<01>0<0> etc....
> any idea?
> Thanx in advance.
> Giorgi Borghi
>



-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to