Ar an t-aonú lá déag de mí Deireadh Fómhair, scríobh Sirano Dhe-Paganon:
Wow; thank you! I've been looking for this for over a year.
I can make it work for one line of protein sequence, but what would be
spectacular is if I can apply it to automatically calculate countless
lines of protein sequences. For example, I normally need to calculate 10
to 100 proteins. Normally these protein sequences are associated with a
tag or a name: the name is followed by a tab and then the protein
sequence (see below). So I would paste them into the scratch buffer, then
execute a command to replace just the protein sequence with the molecular
weight value, leaving the tag intact. for example:
Ah, okay, you should have said so in the first place :-) . Some more USMLE
procrastination from me, then:
(defun protein-weight-region (start end &optional buffer)
(interactive "*r")
(goto-char start)
;; The regular expression describes a line comprising a series of non-tab
;; characters (the tag), followed by a tab, followed by a series of
;; uppercase Roman-alphabet characters (the protein's amino acids),
;; followed by optional trailing whitespace. The backslashed parentheses
;; delimit the protein, and the protein text is accessed using
;; (match-string 1).
(while (re-search-forward "^[^\t]+\t\\([A-Z]+\\)[ \t]*$" end t)
(goto-char (match-end 1))
(insert (format "%S" (protein-weight-string (match-string 1))))
(delete-region (match-beginning 1) (match-end 1))))
--
“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