dimanche 1 mai 2016

large if/elif statement only returning with the first "if" as though it was true, no matter what. Python

Here is what I am working with. I added a couple print functions in the loop to make sure that everything is working properly and it is, all up until it calls the defined function. Once it reaches that point, it simply returns as if the first if statement is true no matter what, even if i change the statement to !=, it gives the same result. It seems to be completely ignoring the if statement entirely. What am I missing? I am working with python 2.7.

#Genome Analysis tool

#Importing Stuffs

#Creating Usefull functions

#.#Asseses codon in an RNA sequence (Uses U instead of T)
def codon_RNA(text):
    if text == "UUU" or "UUC":
        return "Phe"
    elif text == "UUA" or "UUG" or "CUU" or "CUC" or "CUA" or "CUG":
        return "Leu"
    elif text == "AUU" or "AUC" or "AUA":
        return "Ile"
    elif text == "AUG":
        return "Met"
    elif text == "GUU" or "GUC" or "GUA" or "GUG":
        return "Val"
    elif text == "UCU" or "UCC" or "UCA" or "UCG" or "AGU" or "AGC":
        return "Ser"
    elif text == "CCU" or "CCC" or "CCA" or "CCA" or "CCG":
        return "Pro"
    elif text == "ACU" or "ACC" or "ACA" or "ACG":
        return "Thr"
    elif text == "GCU" or "GCC" or "GCA" or "GCG":
        return "Ala"
    elif text == "UAU" or "UAC":
        return "Tyr"
    elif text == "UAA" or "UAG" or "UGA":
        return "|STOP| "
    elif text == "CAU" or "CAC":
        return "His"
    elif text == "CAA" or "CAG":
        return "Gln"
    elif text == "AAU" or "AAC":
        return "Asn"
    elif text == "AAA" or "AAG":
        return "Lys"
    elif text == "GAU" or "GAC":
        return "Asp"
    elif text == "GAA" or "GAG":
        return "Glu"
    elif text == "UGU" or "UGC":
        return "Cys"
    elif text == "UGG":
        return "Trp"
    elif text == "CGU" or "CGC" or "CGA" or "CGG" or "AGA" or "AGG":
        return "Arg"
    elif text == "GGU" or "GGC" or "GGA" or "GGG":
        return "Gly"
    else:
        return null


#Setting up the variables

genome = "ACUCGAUCAGCUAGCUAGCAUGCACUCGAUACGCGCUAUAUAGCUAGCUAGCAUAGCUACGAUCGAUGCUAGUGUGUGUUACCUAAUAAUAAUUAAUUAAUUAAUUAA"


#Breaking down into codons
""" Loop as long as 1/3 of the sequence breaks each chunk into an amino acid    """

count = len(genome)/3

print count

for i in range(0,count):    
    temp = genome[3*i:3*i+3]
    print temp
    print i
    print codon_RNA(temp)

Aucun commentaire:

Enregistrer un commentaire