Skip to content

Commit 0398e6c

Browse files
using ProteinAnaylsis from biopython to cacluate MW, works but decimal places are off
1 parent ef92cce commit 0398e6c

File tree

1 file changed

+10
-2
lines changed

1 file changed

+10
-2
lines changed

scripts/generate_reviews_files.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
import csv
33
import pandas as pd
44
import sys
5+
from Bio.SeqUtils.ProtParam import ProteinAnalysis
56

67
'''
78
Write a script to create the files for the Case Final Reports
@@ -57,9 +58,16 @@ def main():
5758
peptides = pd.read_csv(args.c, sep="\t")
5859
peptides = peptides.drop(['cterm_7mer_gravy_score', 'cysteine_count', 'n_terminal_asparagine', 'asparagine_proline_bond_count',
5960
'difficult_n_terminal_residue', 'c_terminal_cysteine', 'c_terminal_proline', 'max_7mer_gravy_score'], axis=1)
60-
peptides = peptides.rename(columns={"id":"ID", "peptide_sequence":"CANDIDATE NEOANTIGEN AMINO ACID SEQUENCE WITH FLANKING RESIDUES"})
6161
peptides["RESTRICTING HLA ALLELE"] = " "
62-
peptides["CANDIDATE NEOANTIGEN AMINO ACID SEQUENCE MW (CLIENT)"] = " "
62+
63+
# Define a function to calculate molecular weight
64+
def calculate_molecular_weight(peptide):
65+
analyzed_seq = ProteinAnalysis(peptide)
66+
return analyzed_seq.molecular_weight()
67+
68+
peptides["CANDIDATE NEOANTIGEN AMINO ACID SEQUENCE MW (CLIENT)"] = peptides["peptide_sequence"].apply(calculate_molecular_weight)
69+
70+
peptides = peptides.rename(columns={"id":"ID", "peptide_sequence":"CANDIDATE NEOANTIGEN AMINO ACID SEQUENCE WITH FLANKING RESIDUES"})
6371
peptides["Comments"] = " "
6472
peptides["CANDIDATE NEOANTIGEN"] = peptides["ID"].apply(lambda x: '.'.join(x.split('.')[:3]))
6573
peptides["CANDIDATE NEOANTIGEN"] = args.samp + "." + peptides["CANDIDATE NEOANTIGEN"]

0 commit comments

Comments
 (0)