[Bioperl-l] program that search databais

Aaron J Mackey ajm6q@virginia.edu
Tue, 3 Oct 2000 11:38:19 -0400 (EDT)


  This message is in MIME format.  The first part should be readable text,
  while the remaining parts are likely unreadable without MIME-aware tools.
  Send mail to mime@docserver.cac.washington.edu for more info.

---2138111441-92958057-970587499=:75456
Content-Type: TEXT/PLAIN; charset=US-ASCII


A few people have asked for this info, so I'm copying the list.  Excuse
the slightly offtopic conversation.

References describing exact calculations of pI from residue content:

       Ribeiro JM. Sillero A.
       A program to calculate the isoelectric point of macromolecules.
       Computers in Biology & Medicine. 21(3):131-41, 1991.

       Ribeiro JM. Sillero A.
       An algorithm for the computer calculation of the coefficients of a
       polynomial that allows determination of isoelectric points of
       proteins and other macromolecules.
       Computers in Biology & Medicine. 20(4):235-42, 1990.

       Sillero A. Ribeiro JM.
       Isoelectric points of proteins: theoretical determination.
       Analytical Biochemistry. 179(2):319-25, 1989 Jun.

Attached is a slightly-cruddy c program implementing their algorithm
(alas, I never got around to doing it in Perl ...)

Please feel free to send me questions.

-Aaron

On Mon, 2 Oct 2000, Aaron J Mackey wrote:

> 
> I once wrote a pI solver in Perl using a method to explicitly solve for
> pI.  But it turns out it's much better to simply 'slide' from pH 0 to pH
> 14 and see where the electric charge function goes from negative to
> positive.  While less elegant, it's much faster (and you can play tricks
> with numerical derivatives near zero to get an accurate value, if you'd
> like).
> 
> I'll send you the references and my code, if you're interested.
> 
> -Aaron
> 
> On Mon, 2 Oct 2000, Tsvika wrote:
> 
> > Hi all,
> > 
> > I am writing a Perl program that search proteins  database, and
> > find matches according predicted Molecular Wight (MW) versus MW
> > from results of Mass spectrometry. Also, the program takes short
> > amino acid sequence (tag) and looks at the N-term or C-term as
> > you like. The program has MW tolerance (+/-X%), and uses regexp
> > for the tag input. The program is fully functional, and I used it
> > on C.elegans wormpep25 successfully.
> > Now I want to add the P.I., isoelectric point, option. So, like
> > MW, one can try to find matches according to the P.I. results of
> > first dimension of 2D gel versus the predicted P.I.
> > I would appreciate if you could help me with P.I. calculations,
> > and algorithms. Also, I would like to hear if you think it is a
> > start for Proteomics applications in bioperl?
> > 
> > Tsvika.
> > 
> 
> 

-- 
 o ~   ~   ~   ~   ~   ~  o
/ Aaron J Mackey           \
\  Dr. Pearson Laboratory  / 
 \ University of Virginia  \     
 /  (804) 924-2821          \
 \  amackey@virginia.edu    /
  o ~   ~   ~   ~   ~   ~  o


---2138111441-92958057-970587499=:75456
Content-Type: TEXT/PLAIN; charset=US-ASCII; name="pI.c"
Content-Transfer-Encoding: BASE64
Content-ID: <Pine.A41.4.21.0010031138190.75456@node13.unix.Virginia.EDU>
Content-Description: pI.c
Content-Disposition: attachment; filename="pI.c"

I2luY2x1ZGUgPHN0ZGlvLmg+DQojaW5jbHVkZSA8c3RkbGliLmg+DQojaW5j
bHVkZSA8c3RyaW5nLmg+DQojaW5jbHVkZSA8bWF0aC5oPg0KDQpzdHJ1Y3Qg
c2VxX3N0ciB7DQogIGNoYXIgKmlkOw0KICBjaGFyICpkZXNjOw0KICBmbG9h
dCBwSTsNCiAgaW50IHJlc2NvdW50WzIzXTsNCiAgaW50IE1XOw0KICBpbnQg
bGVuZ3RoOw0KfTsNCg0Kdm9pZCBzZXR1cF9jb2VmZihkb3VibGUgKioqYm94
ZXMsIGludCBucmVzLCBpbnQgbnBvcywgZG91YmxlICpwS2FzKTsNCnZvaWQg
Y2FsY19jb2VmZihkb3VibGUgKipib3hlcywgaW50ICpjb3VudHMsIGRvdWJs
ZSAqKmNvZWZmcywgaW50IG5yZXMsIGludCBucG9zKTsNCmRvdWJsZSBzb2x2
ZV9jb2VmZihkb3VibGUgKmNvZWZmcywgaW50IG5yZXMpOw0KZG91YmxlIGNh
bGNfcG9seShkb3VibGUgeCwgZG91YmxlICpjb2VmZiwgaW50IG0pOw0KZG91
YmxlIGNhbGNfZGVyKGRvdWJsZSB4LCBkb3VibGUgKmNvZWZmLCBpbnQgbSk7
DQp2b2lkIGR1bXBfc2VxKEZJTEUgKmZwb3V0LCBzdHJ1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