# first define the sequence series

sALenght=len(SerieA)

 

# Loop the series and use all functions at once for [n,m) bases complementarity

def allCompCheck (SerieA,sALenght,SerieTagsA):

    for i in range (n,m):

       print '------ ',i,' bases complementarity ------'

       for j in range (0,sALenght):

           sequenceA=SerieA[j]  #appoint 1st sequence and avoid self and overlapped checking

           SerieTagA=SerieTagsA[j] #assign the oligo tags

           nextSequenceA=j+1

           for k in range (nextSequenceA,sALenght):

               sequenceB=SerieA[k]  #appoint 2nd sequence

               SerieTagB=SerieTagsA[k] #assign the oligo tags

               revSequenceB=sequenceB[::-1] #reverse the 2nd sequence

               if 1>0:

                    compLetters={'a':'T', 'A':'T', 'c':'G', 'C':'G', 'g':'C', 'G':'C', 't':'A', 'T':'A'}

                    revCompSequenceB=''

                    for letter in revSequenceB:

                        if letter in compLetters:

                           revCompSequenceB=revCompSequenceB+compLetters[letter]  #reverse complementary of the 2nd sequence

                    checkNumber=0

                    revCompSequenceBLenght=len(revCompSequenceB)

                    revCompFound=0

                    while checkNumber<=(revCompSequenceBLenght-i): #break the sequence

                       revCompSequenceBPart=revCompSequenceB[checkNumber:checkNumber+i]

                       hitNumber=sequenceA.find(revCompSequenceBPart) #find the complementarity

                        if hitNumber>=0:

                            revCompFound=1

                            #print "There is complementarity in",hitNumber+1,"places"

                        checkNumber+=1

                    if revCompFound==1:

                        #print sequenceA,'has complementary part in ',sequenceB

                        print SerieTagA,'has complementary part in ',SerieTagB

                    #else:

                    #    print sequenceA,'has no complementary part in ',sequenceB