So I have a file of amino acids that I am trying to read mdvfmkglskakegvvaaaektkqgvaeaagktkegvlyvgsktkegvvhgvatvaektk eqvtnvggavvtgvtavaqktvegagsiaaatgfvkkdqlgkneegapqegiledmpvdp dneayempseegyqdyepea
and I have a list of uppercase letters called aminoacids. The problem is that I cannot read the sequence because the letters are lowercase. I have been trying to make it uppercase. There is no trouble reading the file and I thought I had successfully converted its contents into a string (but maybe I haven't?).
aminoacids = ['A','C','D','E','F','G','H','I','K','L','M','N','P','Q','R','S','T','V','W','Y'] content1 = fh.readline() #first line, which is not the sequence #print content1 charline1 = len(content1)-1 #number of characters in the first line #print charline1 contentall = fh.readlines() #each line is converted into a string and put into a list #print contentall numlines = len(contentall) #number of elements in list = number of lines, not the first one #print numlines contentjoined = ''.join(contentall) #list elements are combined, but this includes new lines as characters contentjoined = contentjoined.translate(None, "\n") contentjoined = contentjoined.translate(None,''.join([i for i in contentjoined if i not in aminoacids])) contentjoined = contentjoined.upper() print contentjoined numaa = len(contentjoined) print numaa #this shouldn't be zero but it is Why does this not work? What can I do to fix it? I am in a with right now...that hasn't been a problem before, but is it now? Numaa is 0, when it shouldn't be. I realize that I can just add lowercase letters to my list but there should be a more "pythonic" way of fixing this.