How to get output of each protein id and it's molecular weight

Viewed 37

I wrote this sequence but I get id and list of all molecular weight for all proteins with each id, and I need to calculate for each sequence the sum of all amino acid in it

   from Bio import SeqIO
   from collections import Counter
   import pandas as pd


   df=pd.read_csv("H:\\proteins_15_22535.csv")

     weights = {'A': 71.04, 'C': 103.01, 'D': 115.03, 'E': 129.04, 'F': 147.07,
       'G': 57.02, 'H': 137.06, 'I': 113.08, 'K': 128.09, 'L': 113.08,
       'M': 131.04, 'N': 114.04, 'P': 97.05, 'Q': 128.06, 'R': 156.10,
       'S': 87.03, 'T': 101.05, 'V': 99.07, 'W': 186.08, 'Y': 163.06 }
    A=[]
    counter=[]
    for sequence in SeqIO.parse("H:\\yeast.fasta","fasta"):
    ID=sequence.id
    protein_seq=sequence.seq
    pcnt=Counter(sequence.seq)
    A.append(sequence.id)
    counter.append(pcnt)
    for i ,j in zip(A,counter):
    
    C = []

    for dict in counter:
        d = {}
        for key,val in dict.items():
            d.update({key:dict[key] * weights[key]})
            C.append(d)
    mwt=[]
    wt=0
    for dict in C:
        wt=sum(dict.values())
        mwt.append(wt)
        
    print(i,mwt)      

this is the result NP_001018029.1 [7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 7591.79, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 39258.01000000001, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 12712.73, 6274.4400000000005, 6274.4400000000005, 6274.4400000000005, 6274.4400000000005, 6274.4400000000005, 6274.4400000000005, 6274.4400000000005, 6274.4400000000005, 6274.4400000000005, 6274.4400000000005, 6274.4400000000005, 6274.44000000000 but i need NP_001018029.1 7591.79

0 Answers
Related