1

到目前为止,这是我所拥有的:提示用户输入两个序列似乎有错误。

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()
4

2 回答 2

1

在我看来,而不是(input("Enter the RNA sequences")==(sequence1, sequence2)你应该有这样的东西:

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

在这种情况下,你不需要函数有参数,你可以做def matchSequences().

如果使用参数,请删除带有输入的行,保留原来def matchSequences(sequence1, sequence2)的,而不是仅仅这样做:

matchSequences()

做这个:

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

或这个:

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

(请参阅问题以了解*此处的操作。此外,这里是文档str.split。)

于 2013-11-03T15:26:58.537 回答
0

您可以尝试以下方法:

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

其中一对序列被格式化:

AAAA.CCCC
于 2013-11-03T15:33:35.180 回答