1

Here is what I have so far: There seems to be an error in prompting the user for two sequences.

def matchSequences(sequence1, sequence2):

    numMatches = 0

    (input("Enter the RNA sequences")==(sequence1, sequence2)

    for i in range(0,len(sequence1))

        if sequence1[i] == A and i in sequence2[i] == U
            numMatches = numMatches+1
        if sequence1[i] == C and i in sequence2[i] == G
            numMatches = numMatches+1
        if sequence1[i] == G and i in sequence2[i] == C
            numMatches = numMatches+1
        if sequence1[i] == U and i in sequence2[i] == A
            numMatches = numMatches+1
        elif numMatches == numMatches+0:


            for i in range (sequence1, sequence2)
                if i in sequence1[i]:
                    numMatches == numMatches+1
                elif numMatches == numMatches+0:
                    return numMatches

matchSequences()
Brian Tompsett - 汤莱恩
  • 5,753
  • 72
  • 57
  • 129
  • 1
    You appear to be missing a closing `)` in the line `(input("Enter the RNA sequences")==(sequence1, sequence2)` Also please specify what you mean by "There seems to be an error" - Is there an actual error message (if yes post it)? Is the result different from what you expect (if yes, what do you expect and what is happening)? – UnholySheep Nov 03 '13 at 15:24
  • Yup, fixed it. But there's still an error: Traceback (most recent call last): File "E:\Assignment5.py", line 26, in matchSequences() TypeError: matchSequences() missing 2 required positional arguments: 'sequence1' and 'sequence2' – user2948778 Nov 03 '13 at 15:27
  • As that error message is telling you, you have defined your function as taking two parameters (sequence1 and sequence2) but you are trying to call it without passing those two parameters – UnholySheep Nov 03 '13 at 15:28

2 Answers2

1

It seems to me that instead of (input("Enter the RNA sequences")==(sequence1, sequence2) you should have something like this:

sequence1, sequence2 = input("Enter the RNA sequences, seperated by a comma: ").split(",")

In this case, you don't need the function to have parameters, you can just do def matchSequences().

If you want to use parameters, remove the line with input, keep your original def matchSequences(sequence1, sequence2) and instead of just doing this:

matchSequences()

do this:

first_sequence = input("Enter the first sequence: ")
second_sequence = input("Enter the second sequence: ")
matchSequences(first_sequence, second_sequence)

or this:

matchSequences(*input("Enter the RNA sequences, seperated by a comma: ").split(","))

(See this question for what * is doing here. Also, here are the docs for str.split.)

Community
  • 1
  • 1
rlms
  • 10,650
  • 8
  • 44
  • 61
0

You could try something like:

sequences = tuple(seq for seq in raw_input().split("."))

Where a pair of sequences is formatted:

AAAA.CCCC
LiavK
  • 702
  • 6
  • 20