Ar an t-aonú lá déag de mí Deireadh Fómhair, scríobh Sirano Dhe-Paganon:
In xemacs, I would like to calculate the molecular weight of
proteins, each
of which is listed in a separate line, as shown below for example in the
input section (note the email truncated the lines to 256 characters i
think). I would like to replace the protein sequence with the molecular
weight of the protein. To calculate the molecular weight of each protein,
the molecular weight of all residues of that protein are added (the
molecular weights of each residue is predefined in the table below).
Can someone point me in the right direction or provide lisp code for
analogous examples?
The below works for me; it provides a command, protein-weight-region, which
you can call with M-x protein-weight-region RET once you’ve selected the
protein you’re interested in. The floating point results I see are distinct
from yours, though (admittedly not outside the bounds of what is expected
with differing floating-point implementations)--how did you generate them? I
get the following on a 64-bit FreeBSD machine:
Protein weight is 291100.060900003
Protein weight is 387105.6932000049
Protein weight is 86877.96760000028
Protein weight is 35232.1955
Protein weight is 112854.0969000004
Protein weight is 122608.5762000004
Code:
(defvar residue-weight-alist '((?A . 071.0788)
(?R . 156.1875)
(?N . 114.1038)
(?D . 115.0886)
(?C . 103.1388)
(?E . 129.1155)
(?Q . 128.1307)
(?G . 057.0519)
(?H . 137.1411)
(?I . 113.1594)
(?L . 113.1594)
(?K . 128.1741)
(?M . 131.1926)
(?F . 147.1766)
(?P . 097.1167)
(?S . 087.0782)
(?T . 101.1051)
(?W . 186.2132)
(?Y . 163.1760)
(?V . 099.1326)))
(defun residue-weight (residue-char)
(or (cdr (assq residue-char residue-weight-alist))
(error 'invalid-argument "Not a known residue code" residue-char)))
(defun protein-weight-string (protein-string)
(reduce #'+ protein-string :key #'residue-weight))
(defun protein-weight-region (start end &optional buffer)
(interactive "r")
(let ((weight
(protein-weight-string (replace-in-string
(buffer-substring start end buffer)
"[^A-Z]" ""))))
(message "Protein weight is %S" weight)
weight))
[...]
output:
291118.08
387123.71
86895.98
35250.21
112872.11
122626.59
--
“Apart from the nine-banded armadillo, man is the only natural host of
Mycobacterium leprae, although it can be grown in the footpads of mice.”
-- Kumar & Clark, Clinical Medicine, summarising improbable leprosy research
_______________________________________________
XEmacs-Beta mailing list
XEmacs-Beta(a)xemacs.org
http://lists.xemacs.org/mailman/listinfo/xemacs-beta