title: Trouble with creating a list of protein fragment sequences that corresponds with a list of their weights
body: <p>This my code so far:</p>
  <pre><code>def weightcombinations(sequence, fragments):                            
  #Calculating sequence weight
    for seq_rec in sequence:                                   
      seq_weight = 0.0                                                                                                               
      for i in seq_rec.seq:                                    
        seq_weight += SeqUtils.molecular_weight(i, &quot;protein&quot;, circular = True)  
  #Calculating the fragment weights  
      nums = []                                                
      for a in fragments:                                      
        fragment_weights = 0.0                                 
        for aa in a.seq:                                       
          fragment_weights += SeqUtils.molecular_weight(aa, 'protein', circular = True) 
        nums.append(round(fragment_weights, 2))                
  #Creating list of weight combinations and list with the right combination of weights that sum to the seq_weight  
      weights_array = []                                       
      combs = [] 
      frags = []                                      
      if len(nums) &gt; 0:                                                     
        for r in range(0,len(nums)+1):                         
            weights_array += list(combinations(nums, r))       
        for item in weights_array:                             
            if sum(item) == round(seq_weight, 2):                           
                combs.append(item)                             
  #Print result    
      print(&quot;The protein sequence: &quot; + seq_rec.seq)
      print(&quot;The molecular weight: &quot; + str(round(seq_weight, 2)) + &quot; Da.&quot;) 
      print(&quot; &quot;)                                       
      print(&quot;The possible combinations of fragment weights that may cover the protein sequence without overlap are: &quot;)
      for row in combs:                                        
        print(*row, sep = &quot;, &quot;)
  
  weightcombinations(seq_list3, seq_list4)
  
    
  </code></pre>
  <p>The output looks like this:</p>
  <pre><code>The protein sequence: IEEATHMTPCYELHGLRWVQIQDYAINVMQCL
  The molecular weight: 3788.36 Da.
   
  The possible combinations of fragment weights that may cover the protein sequence without overlap are: 
  397.47, 2267.58, 475.63, 647.68
  </code></pre>
  <p>I was wondering how I could create a list of fragments that correspond with the combination of weights at the end of the output?
  Something like this:</p>
  <pre><code>The protein sequence: IEEATHMTPCYELHGLRWVQIQDYAINVMQCL
  The molecular weight: 3788.36 Da.
   
  The possible combinations of fragments that may cover the protein sequence without overlap are: 
  ['AINV', 'IEEATHMTPCYELHGLRWV', 'MQCL', 'QIQDY']
  and their respective molecular weights:
  397.47, 2267.58, 475.63, 647.68
  </code></pre>
  <p>My intention was to append the correct sequences in the &quot;frags&quot; list. Or could there be a possibility to make a dictionary of the sequence as the key and the weight as the value?
  I'm still pretty new to Python, so anything will help.
  Thanks in advance and iff I need to give extra information, I'll comment back as fast as possible!</p>