<jupyter_start><jupyter_text>Execute protein sequences from a FASTA file<jupyter_code>from pprint import pprint
import requests, io
%run ../../chemw/mw.py

# examining a FASTA file from the Codons PyPI module
protein = Proteins()
protein.mass(fasta_link = 'https://github.com/freiburgermsu/codons/raw/main/examples/MERS/central_dogma/MERS_proteins.fasta')

print('\n\nresultant calculations', '\n', '='*30)
pprint(protein.fasta_protein_masses)
with open('protein.fasta', 'w') as out:
    out.write(protein.fasta)<jupyter_output>C:\Users\<NAME>\Dropbox\My PC (DESKTOP-M302P50)\Documents\UVic Civil Engineering\PHREEQC\mw\chemw\mw.py:108: DeprecationWarning: invalid escape sequence \.
  if re.search('(\.0$)', str(stoich)):
C:\Users\<NAME>\Dropbox\My PC (DESKTOP-M302P50)\Documents\UVic Civil Engineering\PHREEQC\mw\chemw\mw.py:119: DeprecationWarning: invalid escape sequence \.
  mass_sigfigs = len(re.sub('\.', '', str(mass)))
C:\Users\<NAME>\Dropbox\My PC (DESKTOP-M302P50)\Documents\UVic Civil Engineering\PHREEQC\mw\chemw\mw.py:476: DeprecationWarning: invalid escape sequence \w
  self.raw_protein_mass = 0
C:\Users\<NAME>\Dropbox\My PC (DESKTOP-M302P50)\Documents\UVic Civil Engineering\PHREEQC\mw\chemw\mw.py:494: DeprecationWarning: invalid escape sequence \-
  self.protein_mass = calc_protein_mass(amino_acids)
C:\Users\<NAME>\Dropbox\My PC (DESKTOP-M302P50)\Documents\UVic Civil Engineering\PHREEQC\mw\chemw\mw.py:568: DeprecationWarning: invalid escape sequenc[...]<jupyter_text>Comparison with BioPython<jupyter_code>from Bio.SeqUtils import molecular_weight
%run ../../chemw/mw.py

# https://web.expasy.org/cgi-bin/peptide_mass/peptide-mass.pl
# https://biopython.org/docs/1.75/api/Bio.SeqUtils.html

for seq in protein.fasta_protein_masses:
    bio_mass = molecular_weight(seq, 'protein')
    print(f'The ChemW mass of {protein.fasta_protein_masses[seq]} versus the BioPython mass of {bio_mass}.\n')<jupyter_output>The ChemW mass of 565150 versus the BioPython mass of 486067.00810000766.

The ChemW mass of 173830 versus the BioPython mass of 149468.45780000047.

The ChemW mass of 13078 versus the BioPython mass of 11240.552999999994.

The ChemW mass of 14188 versus the BioPython mass of 12242.736799999991.

The ChemW mass of 32976 versus the BioPython mass of 28562.697000000036.

The ChemW mass of 29259 versus the BioPython mass of 25241.71560000003.

The ChemW mass of 10813 versus the BioPython mass of 9354.136499999997.

The ChemW mass of 28464 versus the BioPython mass of 24536.550700000014.

The ChemW mass of 52454 versus the BioPython mass of 45031.72000000002.<jupyter_text>Execute protein sequences from a string<jupyter_code># from chemw import Proteins
%run ../../chemw/mw.py

sequence = 'LFCTHGLERVVQCLWHKRCCSTRLKSLLLRGCANC*'
protein = Proteins()
protein_mw = protein.mass(sequence)<jupyter_output>>Protein - 36_residues - 4661.4_amu
LFCTHGLERVVQCLWHKRCCSTRLKSLLLRGCANC*
{'fraction_non_alphanumeric': 0.11382393397524071, 'fraction_numerical': 0.08631361760660247, 'mean_word_length': 5.337690631808279, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 16, 'https://': 3, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 5, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '206895', 'license': 'MIT', 'n_tokens_mistral': 1278, 'n_tokens_neox': 1016, 'n_words': 239, 'path': 'examples/Proteins/protein_sequences.ipynb', 'repo_name': 'freiburgermsu/compound_masses', 'size': '2963'}