Beispiel #1
0
 def test_args(self):
     result = color("red bold")
     self.assertEqual(result, "\033[31;1m")
     result = color("red, bold")
     self.assertEqual(result, "\033[31;1m")
     result = color(["red", "bold"])
     self.assertEqual(result, "\033[31;1m")
def printReadingFrames(num, compStrandDNA, mRNA, protein, metStart, metIn,
                       stopEnd, stopIn):
    # param num: reading frame number
    # param compStrandDNA: DNA template strand (matching gene of interest)
    # param compStrandmRNA: mRNA complement strand (matching gene of interest)
    # param protein: amino acids of gene of interest
    # param metStart: Met at the start of gene
    # param metIn: Met in gene
    # param stopEnd: stop codon at the end of gene
    # param stopIn: stop codon in gene
    # type num: integer
    # type compStrandDNA: string
    # type mRNA: string
    # type protein: string
    # type metStart: boolean
    # type metIn: boolean
    # type stopEnd: boolean
    # type stopIn: boolean

    read = ""

    # beginning of reading frame
    read += "Reading Frame #{}\n".format(num)
    read += "RNA length: %i\n" % len(compStrandDNA)

    # add color to mRNA
    mRNAList = list(mRNA)
    for letter in mRNAList:
        letterIndex = mRNAList.index(letter)
        if letter == "A":
            mRNAList[letterIndex] = color('cyan') + letter + color('reset')
        elif letter == "U":
            mRNAList[letterIndex] = color('blue') + letter + color('reset')
        elif letter == "C":
            mRNAList[letterIndex] = color('bold red') + letter + color('reset')
        elif letter == "G":
            mRNAList[letterIndex] = color('bold magenta') + letter + color(
                'reset')
    mRNA = ''.join(mRNAList)

    # continued beginning
    read += "\tRNA:\t\t%s\n" % mRNA
    lines = "|  " * (len(compStrandDNA) // 3)
    read += "\t\t\t\t %s\n" % lines

    read += "\tProtein:\t%s\n\n" % protein

    # summary for Met at start
    if metStart == True:
        read += "There is a Met at the start site.\n"
    else:
        read += "There is no Met at the start site.\n"

    # summary for stop at end
    if stopEnd == True:
        read += "There is a stop at the end.\n"
    else:
        read += "There is no stop at the end.\n"

    # summary for Met inside strand
    if metIn == True:
        read += "There is at least one Met somewhere other than at the start.\n"
    else:
        read += "There are no Mets other than at the start.\n"

    # summary for stop inside strand
    if stopIn == True:
        read += "There is at least one stop interrupting the gene."
    else:
        read += "There are no interrupting stops."

    return read
Beispiel #3
0
 def test_env(self):
     with patch.dict("os.environ", {"ANSI_COLORS_DISABLED": "1"}):
         result = color("red")
     self.assertEqual(result, "")
Beispiel #4
0
 def test_arg(self):
     result = color("red")
     self.assertEqual(result, "\033[31m")
Beispiel #5
0
 def test_bad(self):
     with self.assertRaisesRegex(ValueError, r"invalid attribute name.*"):
         color("infrared")
def printReadingFrames(num, compStrandDNA, mRNA, protein, metStart, metIn, stopEnd, stopIn):
# param num: reading frame number
# param compStrandDNA: DNA template strand (matching gene of interest)
# param compStrandmRNA: mRNA complement strand (matching gene of interest)
# param protein: amino acids of gene of interest
# param metStart: Met at the start of gene
# param metIn: Met in gene
# param stopEnd: stop codon at the end of gene
# param stopIn: stop codon in gene
# type num: integer
# type compStrandDNA: string
# type mRNA: string
# type protein: string
# type metStart: boolean
# type metIn: boolean
# type stopEnd: boolean
# type stopIn: boolean

    read = ""

    # beginning of reading frame
    read += "Reading Frame #{}\n".format(num)
    read += "RNA length: %i\n" % len(compStrandDNA)

    # add color to mRNA
    mRNAList = list(mRNA)
    for letter in mRNAList:
        letterIndex = mRNAList.index(letter)
        if letter == "A":
            mRNAList[letterIndex] = color('cyan') + letter + color('reset')
        elif letter == "U":
            mRNAList[letterIndex] = color('blue') + letter + color('reset')
        elif letter == "C":
            mRNAList[letterIndex] = color('bold red') + letter + color('reset')
        elif letter == "G":
            mRNAList[letterIndex] = color('bold magenta') + letter + color('reset')
    mRNA = ''.join(mRNAList)

    # continued beginning
    read += "\tRNA:\t\t%s\n" % mRNA
    lines = "|  " * (len(compStrandDNA) // 3)
    read += "\t\t\t\t %s\n" % lines

    read += "\tProtein:\t%s\n\n" % protein

    # summary for Met at start
    if metStart == True:
        read += "There is a Met at the start site.\n"
    else:
        read += "There is no Met at the start site.\n"

    # summary for stop at end
    if stopEnd == True:
        read += "There is a stop at the end.\n"
    else:
        read += "There is no stop at the end.\n"

    # summary for Met inside strand
    if metIn == True:
        read += "There is at least one Met somewhere other than at the start.\n"
    else:
        read += "There are no Mets other than at the start.\n"

    # summary for stop inside strand
    if stopIn == True:
        read += "There is at least one stop interrupting the gene."
    else:
        read += "There are no interrupting stops."

    return read