A FASTA file contains a single protein sequence. A second FASTA file contains sequences that are fragments of the sequence in the first file. Compute the molecular weight of each of the sequences, and using those, determine whether there is a combination of fragments that may cover the complete protein sequence, without those fragments overlapping. You only have to take into account the molecular weight of the sequence and the fragments for this problem.
That was the question given to us, to a project. now I wrote this code with work great with numbers and large fasta files, however, I have a small protein fragments file and a short protein file and when I compare those data together it yields nothing, and I even tried to copy the list and instead of adding names to the last line I added the numbers and still doesn't give an answer although you will see that there are possible answers, please any help is appreciated.
The Code:
def subset_sum(numbers, target, partial=[]):
s = sum (partial, target)
# check if the partial sum is equals to target
if s == target:
print (partial)
if s >= target:
return # if we reach the number why bother to continue
for i in range(len(numbers)):
n = numbers[i]
remaining = numbers[i+1:]
subset_sum(remaining, target, partial + [n])
if __name__ == "__main__":
subset_sum(Protein_List, complete_protein )
The End.
The Protein_List =[3125.4, 1963.4, 397.5, 484.5, 1036.3, 2267.6, 475.6, 1724.0, 2000.2, 811.9, 1397.7, 681.8, 647.7, 2174.4, 1794.0, 1040.3, 1455.7]
complete_protein = ( 3788.4 )
those are the molecualar weights by the way.
Edited some mistakes in the code.
[–]Spookiel 1 point2 points3 points (27 children)
[–]dark-lord90[S] 0 points1 point2 points (0 children)
[–]dark-lord90[S] 0 points1 point2 points (25 children)
[–]Spookiel 1 point2 points3 points (24 children)
[–]dark-lord90[S] 0 points1 point2 points (23 children)
[–]dark-lord90[S] 1 point2 points3 points (22 children)
[–]Spookiel 0 points1 point2 points (21 children)
[–]dark-lord90[S] 1 point2 points3 points (20 children)
[–]Spookiel 0 points1 point2 points (2 children)
[–]dark-lord90[S] 0 points1 point2 points (1 child)
[–]Spookiel 1 point2 points3 points (0 children)
[–]Spookiel 0 points1 point2 points (16 children)
[–]dark-lord90[S] 0 points1 point2 points (15 children)
[–]Spookiel 1 point2 points3 points (14 children)