Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The integer value for the sequence AFDE is (65 times 128^3) (70 times 128^2) (68

ID: 3825689 • Letter: T

Question

The integer value for the sequence AFDE is (65 times 128^3) (70 times 128^2) (68 times 128^1)+ (69 times 128^0) = 137470533 Write a function in Python to convert a given protein sequence of length 4 into an integer. Write a function in Python to convert a given integer into a protein sequence of length 4. If the given integer cannot produce a valid protein sequence, you have to give an error message. Write a program to convert the protein sequences form the file "AASequence1.txt" into their respective integers and store them into a direct addressing table. Use an array data structure of 1-byte integers (dtype = numpy.uint8 in Python) or Booleans (dtype = numpy, bool_in Python) because we just need to store the presence or absence of a particular sequence in each cell of the array).

Explanation / Answer

''' method/Function to obtain an integer value from the given A,F,D,E values '''
def getintseqfromsequence(A,F,D,E):
print("Integer Value",(A*(128 ** 3) + (F*(128 ** 2)) + (D*(128 ** 1)) + (E*(128 ** 0))))
return (A*(128 ** 3) + (F*(128 ** 2)) + (D*(128 ** 1)) + (E*(128 ** 0)))


'''Method/Function to get A,F,D,E values from the given integer value'''
def getsequencefromint(num):
try:
A = num // (128 ** 3)
print("A", A)
num = num - (A*(128 ** 3))
F = num // (128 ** 2)
print("F", F)
num = num - (F*(128 ** 2))
D = num // (128 ** 1)
print("D", D)
num = num - (D*(128 ** 1))
E = num // (128 ** 0)
print("E", E)
except:
print("Unable to get a proper Sequence")

if __name__ == '__main__':
A = int(input("Enter A value: "))
F = int(input("Enter F value: "))
D = int(input("Enter D value: "))
E = int(input("Enter E value: "))
x = getintseqfromsequence(A,F,D,E)
getsequencefromint(x)

# I haven't implemented the last method (4) because i din find any input file/format in the question. The other two methods are working fine.

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote