Dec-20-2017, 08:39 PM
Hello!!
I am coding what should be an easy program, to calculate few things. But, unfortunately, the things are not going as I planned.
This is my code:
[python]
seq_T4 ='MILKI...FEDVFGDFHEVTGL'
y = 0
w = 0
f = 0
num_aa = 0
for aa in seq_T4.lower():
num_aa += 1
if aa == 'y':
y += 1
elif aa == 'w':
w += 1
elif aa == 'f':
f += 1
aa_fluo = y + w + f
ratio = format((aa_fluo / num_aa),'.5f')
print ('the protein as', num_aa, 'aa, and therefore MW of roughly kDa', (num_aa*650)/1000)
print ('the number or Tyrosine is:', y)
print ('the number or Tryptophan is:', w)
print ('the number or Phenylalanine is:', f)
print ('the Fluorescent aa / total aa is % ', ratio)
[/pyhton]
output:
('the protein as', 487, 'aa, and therefore MW of roughly kDa', 316)
('the number or Tyrosine is:', 20)
('the number or Tryptophan is:', 5)
('the number or Phenylalanine is:', 18)
('the Fluorescent aa / total aa is % ', '0.00000')
The problem is that the ratio doesn't give the expected number. It look like Python does not know how to divide. I have tried to do the division in the shell and it work properly, but when I ask to do it in this code doesn't work.
I am running this version of Ipython :
Python 2.7.12 (default, Nov 20 2017, 18:23:56)
Type "copyright", "credits" or "license" for more information.
IPython 2.4.1 -- An enhanced Interactive Python.
It is running on Ubuntu bash shell for windows 10
Thank you