Calculation of the pI of proteins according to Skoog and Wichman lazarus / 61-Beginners ---------------------------------------------------------------------- s_bue · 2019-04-25 13:49 I wanted to try a script by Skoog and Wichman to calculate the pI of proteins. Unfortunately I'm not good at programming (had just a basic fpc course 10 years back in school). From all I remembered and logical thinking I thought I could fix the script but if I run it, it still doesn't work properly. If I run it with Lazarus it closes the script without giving a result. If I run it with the https://www.onlinegdb.com/online_pascal_compiler it sometimes calculates pI's but is far off the results I get from https://web.expasy.org/cgi-bin/compute_pi/pi_tool . For example imagine a protein consisting out of all the charged amino acids arg, asp, cys, glu, his, lys, tyr all of them only once and the total peptide consisting only out of these 7 chains it calculates a pI of 1.967. If I enter the order RDCEHKY (short forms of the amino acid short forms  ) in expasy it comes to a pI of 6.74. It would be so nice if somebody could check the code and probably tell me if there is some major mistake or what might be the problem or even fix it  If sb. needs the paper from Skoog and Wichman let me know ! PROGRAM Iso_point; CONST    pKa3_arg=12.5; pKa3_asp=3.9; pKa3_cys=8.3;    pKa3_glu=4.3; pKa3_his=6.0; pKa3_lys=10.5;    pKa3_tyr=10.1;    Max_chains=5;    Max_iterations=100;    pH1=1;   pH2=14;   Accuracy=0.0005;    All = 'alaargasnaspcysglngluglyhisileleulysmetpheproserthrtrptyrval'; TYPE   Str3 = String[3];    Str80 = String[80];    Aminoacid = ARRAY [1..Max_chains] OF REAL;    Turn = ARRAY [1..Max_iterations] OF REAL;    N_values = ARRAY [1..20] OF REAL;    C_values = ARRAY [1..20] OF REAL; VAR   Name : Str80;    Test : Str3;    Num_arg, Num_asp, Num_cys,    Num_glu, Num_his, Num_lys,    Num_tyr, Num_chains : INTEGER;    N_term,    C_term : Aminoacid;    Test_pH,    Charge : Turn;    TermN, TermC : REAL;    Number, N : INTEGER;    NtermpK : N_values;    CtermpK : C_values;    Sum,Temp : REAL; FUNCTION Neg_charge (pK_value : REAL;          pH : Turn) : REAL; BEGIN Neg_charge:=(exp(2.3026*((pH[N])-(pK_value))))/(1+exp(2.3026*((pH[N])- (pK_value)))); END; {Neg_charge} FUNCTION Pos_charge (pK_value : REAL;          pH : Turn) : REAL; BEGIN    Pos_charge:=(1/(exp(2.3026*(((pH[N])-(pK_value))))+1)); END; {Pos_charge} PROCEDURE Findend; BEGIN NtermpK[1]:=9.9; NtermpK[2]:=9.0; NtermpK[3]:=8.8; NtermpK[4]:=9.8;    NtermpK[5]:=10.8; NtermpK[6]:=9.1; NtermpK[7]:=9.7; NtermpK[8]:=9.8;    NtermpK[9]:=9.2; NtermpK[10]:=9.8; NtermpK[11]:=9.7; NtermpK[12]:=9.0;    NtermpK[13]:=9.3; NtermpK[14]:=9.2; NtermpK[15]:=10.6; NtermpK[16]:=9.2;    NtermpK[17]:=9.1; NtermpK[18]:=9.4; NtermpK[19]:=9.1; NtermpK[20]:=9.7;    CtermpK[1]:=2.4; CtermpK[2]:=2.2; CtermpK[3]:=2.1; CtermpK[4]:=2.1;    CtermpK[5]:=1.7; CtermpK[6]:=2.2; CtermpK[7]:=2.2; CtermpK[8]:=2.4;    CtermpK[9]:=1.8; CtermpK[10]:=2.3; CtermpK[11]:=2.3; CtermpK[12]:=2.2;    CtermpK[13]:=2.1; CtermpK[14]:=2.2; CtermpK[15]:=2.0; CtermpK[16]:=2.2;    CtermpK[17]:=2.1; CtermpK[18]:=2.4; CtermpK[19]:=2.2; CtermpK[20]:=2.3; Number:=Pos(Test,All);    Number:=(Number+2) DIV 3;    TermN:=NtermpK[Number];    TermC:=CtermpK[Number];     END; {Findend} PROCEDURE Check (VAR Instr : Str3); VAR Count : INTEGER; BEGIN    FOR count:= 1 TO 3 DO IF Instr[count] IN ['A'..'Z'] THEN    Instr[count] := CHR(ORD(Instr[count])+32); END; {Check} PROCEDURE Input; VAR n : 1..Max_chains; BEGIN    Write('Name of protein/peptide: ');    Readln(Name);    Writeln;    Writeln('Please, enter the number of charged amino acids');    Write('arg: '); Readln(Num_arg);    Write('asp: '); Readln(Num_asp);    Write('cys: '); Readln(Num_cys);    Write('glu: '); Readln(Num_glu);    Write('his: '); Readln(Num_his);    Write('lys: '); Readln(Num_lys);    Write('tyr: '); Readln(Num_tyr);    Writeln;    Write('Number of polypeptide chains: ');    Readln(Num_chains);    FOR n:=1 TO Num_chains DO    BEGIN       Write('Chain',n:2,' N-terminal amino acid: ');       Readln(Test);       Check(Test);       Findend;       C_term[n]:=TermC;    END; END; {Input} Procedure Find_charge; VAR I : 1..Max_chains; BEGIN Sum:=0; Sum:=Sum-(Num_asp)*(Neg_charge(pKa3_asp,Test_pH)); Sum:=Sum-(Num_glu)*(Neg_charge(pKa3_glu,Test_pH)); Sum:=Sum-(Num_cys)*(Neg_charge(pKa3_cys,Test_pH)); Sum:=Sum-(Num_tyr)*(Neg_charge(pKa3_tyr,Test_pH)); Sum:=Sum+(Num_his)*(Pos_charge(pKa3_his,Test_pH)); Sum:=Sum+(Num_lys)*(Pos_charge(pKa3_lys,Test_pH)); Sum:=Sum+(Num_arg)*(Pos_charge(pKa3_arg,Test_pH)); FOR i:=1 to Num_chains DO BEGIN    Temp:=(Pos_charge(N_term,Test_pH));       Sum:=Sum+Temp;       Temp:=(Neg_charge(C_term,Test_pH));       Sum:=Sum-Temp;       Temp:=Sum; END; Charge[N]:=Temp; END; {find_charge} PROCEDURE Iterate; VAR Factor, Diff : REAL; BEGIN N:=1; Test_pH[N]:=pH1; Find_charge; N:=2; Test_pH[N]:=pH2; Find_charge; REPEAT N:=N+1; BEGIN  Factor:=((Test_pH[N-1])-(Test_pH[N-2]))/((Charge[N-1])-(Charge[N- 2]));  Test_pH[N]:=(Test_pH[N-1])-(Charge[N-1]*Factor);  Find_charge;  Temp:=(Charge[N])-(Charge[N-1]);  Diff:=ABS(Temp); END;    UNTIL (Diff)<=(Accuracy);    Writeln;    Writeln('Isoelectric point calculated to pH= ',Test_pH[N]:5:3);    Writeln;    Writeln('Accuracy= ',Accuracy:7:5,' pH units');    Writeln('Number of iterations= ',N); END; {Iterate} BEGIN {main}    Input;    Iterate; END. ---------------------------------------------------------------------- Bart · 2019-04-25 16:04 Please put your code inside [ code ] [ /code ] tages (without the spaces, they are there to fool the forum software). Now part of the code is in Italic, problay because you used [ i ] as an index (again, without the spaces), which the forum software treats as "start italic". Bart ---------------------------------------------------------------------- lucamar · 2019-04-25 16:43 Quote from: Bart on April 25, 2019, 06:04:35 pm[...] without the spaces, they are there to fool the forum software [...] You don't need to do that; instead use:   [nobbc][code][/code][/nobbc] More work for you but clearer for the (new) readers ---------------------------------------------------------------------- Bart · 2019-04-25 17:22 Quote from: lucamar on April 25, 2019, 06:43:14 pmYou don't need to do that; instead use:   [nobbc][code][/code][/nobbc] Never knew that. I made a note of this for my self for future reference. Thanks! Bart ---------------------------------------------------------------------- Bart · 2019-04-25 17:27 Quote from: s_bue on April 25, 2019, 03:49:12 pmIf sb. needs the paper from Skoog and Wichman let me know ! How on earth are we able to comment on your code, if we do not know the correct algorithm at all? Bart ---------------------------------------------------------------------- Bart · 2019-04-25 17:54 I compiled your code: QuoteCompile Project, Mode: Debug, Target: isopoint.exe: Success, Warnings: 1, Hints: 1 isopoint.lpr(20,2) Warning: Variable "N_term" read but nowhere assigned isopoint.lpr(24,2) Note: Local variable "TermN" is assigned but never used Maybe fix those warnings first? Bart ---------------------------------------------------------------------- lucamar · 2019-04-25 18:22 Quote from: Bart on April 25, 2019, 07:22:44 pmQuote from: lucamar on April 25, 2019, 06:43:14 pmYou don't need to do that; instead use:   [nobbc][code][/code][/nobbc] Never knew that. I made a note of this for my self for future reference. Thanks! Bart It pays to read the docs https://wiki.simplemachines.org/smf/Bulletin_board_code ---------------------------------------------------------------------- s_bue · 2019-04-25 23:46 Sorry, it was my first post in this forum wasn't aware about how to post stuff properly Quote from: Bart on April 25, 2019, 06:04:35 pmPlease put your code inside [ code ] [ /code ] tages (without the spaces, they are there to fool the forum software). Now part of the code is in Italic, problay because you used [ i ] as an index (again, without the spaces), which the forum software treats as "start italic". Bart Code: [Select]PROGRAM Iso_point; CONST pKa3_arg=12.5; pKa3_asp=3.9; pKa3_cys=8.3; pKa3_glu=4.3; pKa3_his=6.0; pKa3_lys=10.5; pKa3_tyr=10.1; Max_chains=5; Max_iterations=100; pH1=1; pH2=14; Accuracy=0.0005; All = 'alaargasnaspcysglngluglyhisileleulysmetpheproserthrtrptyrval'; TYPE Str3 = String[3]; Str80 = String[80]; Aminoacid = ARRAY [1..Max_chains] OF REAL; Turn = ARRAY [1..Max_iterations] OF REAL; N_values = ARRAY [1..20] OF REAL; C_values = ARRAY [1..20] OF REAL; VAR Name : Str80; Test : Str3; Num_arg, Num_asp, Num_cys, Num_glu, Num_his, Num_lys, Num_tyr, Num_chains : INTEGER; N_term, C_term : Aminoacid; Test_pH, Charge : Turn; TermN, TermC : REAL; Number, N : INTEGER; NtermpK : N_values; CtermpK : C_values; Sum,Temp : REAL; FUNCTION Neg_charge (pK_value : REAL; pH : Turn) : REAL; BEGIN Neg_charge:=(exp(2.3026*((pH[N])-(pK_value))))/(1+exp(2.3026*((pH[N])- (pK_value)))); END; {Neg_charge} FUNCTION Pos_charge (pK_value : REAL; pH : Turn) : REAL; BEGIN Pos_charge:=(1/(exp(2.3026*(((pH[N])-(pK_value))))+1)); END; {Pos_charge} PROCEDURE Findend; BEGIN NtermpK[1]:=9.9; NtermpK[2]:=9.0; NtermpK[3]:=8.8; NtermpK[4]:=9.8; NtermpK[5]:=10.8; NtermpK[6]:=9.1; NtermpK[7]:=9.7; NtermpK[8]:=9.8; NtermpK[9]:=9.2; NtermpK[10]:=9.8; NtermpK[11]:=9.7; NtermpK[12]:=9.0; NtermpK[13]:=9.3; NtermpK[14]:=9.2; NtermpK[15]:=10.6; NtermpK[16]:=9.2; NtermpK[17]:=9.1; NtermpK[18]:=9.4; NtermpK[19]:=9.1; NtermpK[20]:=9.7; CtermpK[1]:=2.4; CtermpK[2]:=2.2; CtermpK[3]:=2.1; CtermpK[4]:=2.1; CtermpK[5]:=1.7; CtermpK[6]:=2.2; CtermpK[7]:=2.2; CtermpK[8]:=2.4; CtermpK[9]:=1.8; CtermpK[10]:=2.3; CtermpK[11]:=2.3; CtermpK[12]:=2.2; CtermpK[13]:=2.1; CtermpK[14]:=2.2; CtermpK[15]:=2.0; CtermpK[16]:=2.2; CtermpK[17]:=2.1; CtermpK[18]:=2.4; CtermpK[19]:=2.2; CtermpK[20]:=2.3; Number:=Pos(Test,All); Number:=(Number+2) DIV 3; TermN:=NtermpK[Number]; TermC:=CtermpK[Number];     END; {Findend} PROCEDURE Check (VAR Instr : Str3); VAR Count : INTEGER; BEGIN FOR count:= 1 TO 3 DO IF Instr[count] IN ['A'..'Z'] THEN Instr[count] := CHR(ORD(Instr[count])+32); END; {Check} PROCEDURE Input; VAR n : 1..Max_chains; BEGIN Write('Name of protein/peptide: '); Readln(Name); Writeln; Writeln('Please, enter the number of charged amino acids'); Write('arg: '); Readln(Num_arg); Write('asp: '); Readln(Num_asp); Write('cys: '); Readln(Num_cys); Write('glu: '); Readln(Num_glu); Write('his: '); Readln(Num_his); Write('lys: '); Readln(Num_lys); Write('tyr: '); Readln(Num_tyr); Writeln; Write('Number of polypeptide chains: '); Readln(Num_chains); FOR n:=1 TO Num_chains DO BEGIN Write('Chain',n:2,' N-terminal amino acid: '); Readln(Test); Check(Test); Findend; C_term[n]:=TermC; END; END; {Input} Procedure Find_charge; VAR I : 1..Max_chains; BEGIN Sum:=0; Sum:=Sum-(Num_asp)*(Neg_charge(pKa3_asp,Test_pH)); Sum:=Sum-(Num_glu)*(Neg_charge(pKa3_glu,Test_pH)); Sum:=Sum-(Num_cys)*(Neg_charge(pKa3_cys,Test_pH)); Sum:=Sum-(Num_tyr)*(Neg_charge(pKa3_tyr,Test_pH)); Sum:=Sum+(Num_his)*(Pos_charge(pKa3_his,Test_pH)); Sum:=Sum+(Num_lys)*(Pos_charge(pKa3_lys,Test_pH)); Sum:=Sum+(Num_arg)*(Pos_charge(pKa3_arg,Test_pH)); FOR i:=1 to Num_chains DO BEGIN Temp:=(Pos_charge(N_term[i],Test_pH)); Sum:=Sum+Temp; Temp:=(Neg_charge(C_term[i],Test_pH)); Sum:=Sum-Temp; Temp:=Sum; END; Charge[N]:=Temp; END; {find_charge} PROCEDURE Iterate; VAR Factor, Diff : REAL; BEGIN N:=1; Test_pH[N]:=pH1; Find_charge; N:=2; Test_pH[N]:=pH2; Find_charge; REPEAT N:=N+1; BEGIN  Factor:=((Test_pH[N-1])-(Test_pH[N-2]))/((Charge[N-1])-(Charge[N- 2]));  Test_pH[N]:=(Test_pH[N-1])-(Charge[N-1]*Factor);  Find_charge;  Temp:=(Charge[N])-(Charge[N-1]);  Diff:=ABS(Temp); END; UNTIL (Diff)<=(Accuracy); Writeln; Writeln('Isoelectric point calculated to pH= ',Test_pH[N]:5:3); Writeln; Writeln('Accuracy= ',Accuracy:7:5,' pH units'); Writeln('Number of iterations= ',N); END; {Iterate} BEGIN {main} Input; Iterate; END. ---------------------------------------------------------------------- s_bue · 2019-04-25 23:51 Quote from: Bart on April 25, 2019, 07:54:08 pmI compiled your code: QuoteCompile Project, Mode: Debug, Target: isopoint.exe: Success, Warnings: 1, Hints: 1 isopoint.lpr(20,2) Warning: Variable "N_term" read but nowhere assigned isopoint.lpr(24,2) Note: Local variable "TermN" is assigned but never used Maybe fix those warnings first? Bart I think maybe N_term is TermN ... might make sense I'll change this and make it all to N_term ---------------------------------------------------------------------- JLWest · 2019-04-25 23:59 Wow - Well this looks impossible so you brain-e-acks should have the answer to this one in 20 min. @Bart I ask question all the time without a clue about the   algo- whatever. My answer to this problem would be 'No! I gave up at the line: 'All = 'alaargasnaspcysglngluglyhisileleulysmetpheproserthrtrptyrval'; Hope this isn't used like:  if  alaargasnaspcysglngluglyhisileleulysmetpheproserthrtrptyrval = -1 then exit; end; I do check in on post and read code to try to get better. ---------------------------------------------------------------------- VTwin · 2019-04-26 01:28 Quote from: JLWest on April 26, 2019, 01:59:32 amI gave up at the line: 'All = 'alaargasnaspcysglngluglyhisileleulysmetpheproserthrtrptyrval'; Those are all the amino acids, alanine to valine. @s_bue Please post a link to the Skoog and Wichman paper. I did a library search without success. Also, do you have an example of input with correct output? It is not clear to me from your post, and the link you give does not work. ---------------------------------------------------------------------- lucamar · 2019-04-26 03:03 Quote from: VTwin on April 26, 2019, 03:28:52 am@s_bue Please post a link to the Skoog and Wichman paper. He did better: attached it to his post Although it's a little hard to read the code ... ---------------------------------------------------------------------- Lutz Mändle · 2019-04-26 04:43 @s_bue You forgot some lines in the for loop of the input procedure. The complete for loop should go as this: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   FOR n:=1 TO Num_chains DO  BEGIN    Write('Chain',n:2,' N-terminal amino acid: ');    Readln(Test);    Check(Test);    Findend;    N_term[n]:=TermN;    Write('Chain',n:2,' C-terminal amino acid: ');    Readln(Test);    Check(Test);    Findend;    C_term[n]:=TermC;  END; ---------------------------------------------------------------------- valdir.marcos · 2019-04-26 05:37 Quote from: s_bue on April 25, 2019, 03:49:12 pmI wanted to try a script by Skoog and Wichman to calculate the pI of proteins. Unfortunately I'm not good at programming (had just a basic fpc course 10 years back in school). From all I remembered and logical thinking I thought I could fix the script but if I run it, it still doesn't work properly. If I run it with Lazarus it closes the script without giving a result. If I run it with the https://www.onlinegdb.com/online_pascal_compiler it sometimes calculates pI's but is far off the results I get from https://web.expasy.org/cgi-bin/compute_pi/pi_tool . For example imagine a protein consisting out of all the charged amino acids arg, asp, cys, glu, his, lys, tyr all of them only once and the total peptide consisting only out of these 7 chains it calculates a pI of 1.967. If I enter the order RDCEHKY (short forms of the amino acid short forms  ) in expasy it comes to a pI of 6.74. It would be so nice if somebody could check the code and probably tell me if there is some major mistake or what might be the problem or even fix it  If sb. needs the paper from Skoog and Wichman let me know ! PROGRAM Iso_point; CONST    pKa3_arg=12.5; pKa3_asp=3.9; pKa3_cys=8.3;    pKa3_glu=4.3; pKa3_his=6.0; pKa3_lys=10.5;    pKa3_tyr=10.1;    Max_chains=5;    Max_iterations=100;    pH1=1;   pH2=14;   Accuracy=0.0005;    All = 'alaargasnaspcysglngluglyhisileleulysmetpheproserthrtrptyrval'; TYPE   Str3 = String[3];    Str80 = String[80];    Aminoacid = ARRAY [1..Max_chains] OF REAL;    Turn = ARRAY [1..Max_iterations] OF REAL;    N_values = ARRAY [1..20] OF REAL;    C_values = ARRAY [1..20] OF REAL; VAR   Name : Str80;    Test : Str3;    Num_arg, Num_asp, Num_cys,    Num_glu, Num_his, Num_lys,    Num_tyr, Num_chains : INTEGER;    N_term,    C_term : Aminoacid;    Test_pH,    Charge : Turn;    TermN, TermC : REAL;    Number, N : INTEGER;    NtermpK : N_values;    CtermpK : C_values;    Sum,Temp : REAL; FUNCTION Neg_charge (pK_value : REAL;          pH : Turn) : REAL; BEGIN Neg_charge:=(exp(2.3026*((pH[N])-(pK_value))))/(1+exp(2.3026*((pH[N])- (pK_value)))); END; {Neg_charge} FUNCTION Pos_charge (pK_value : REAL;          pH : Turn) : REAL; BEGIN    Pos_charge:=(1/(exp(2.3026*(((pH[N])-(pK_value))))+1)); END; {Pos_charge} PROCEDURE Findend; BEGIN NtermpK[1]:=9.9; NtermpK[2]:=9.0; NtermpK[3]:=8.8; NtermpK[4]:=9.8;    NtermpK[5]:=10.8; NtermpK[6]:=9.1; NtermpK[7]:=9.7; NtermpK[8]:=9.8;    NtermpK[9]:=9.2; NtermpK[10]:=9.8; NtermpK[11]:=9.7; NtermpK[12]:=9.0;    NtermpK[13]:=9.3; NtermpK[14]:=9.2; NtermpK[15]:=10.6; NtermpK[16]:=9.2;    NtermpK[17]:=9.1; NtermpK[18]:=9.4; NtermpK[19]:=9.1; NtermpK[20]:=9.7;    CtermpK[1]:=2.4; CtermpK[2]:=2.2; CtermpK[3]:=2.1; CtermpK[4]:=2.1;    CtermpK[5]:=1.7; CtermpK[6]:=2.2; CtermpK[7]:=2.2; CtermpK[8]:=2.4;    CtermpK[9]:=1.8; CtermpK[10]:=2.3; CtermpK[11]:=2.3; CtermpK[12]:=2.2;    CtermpK[13]:=2.1; CtermpK[14]:=2.2; CtermpK[15]:=2.0; CtermpK[16]:=2.2;    CtermpK[17]:=2.1; CtermpK[18]:=2.4; CtermpK[19]:=2.2; CtermpK[20]:=2.3; Number:=Pos(Test,All);    Number:=(Number+2) DIV 3;    TermN:=NtermpK[Number];    TermC:=CtermpK[Number];     END; {Findend} PROCEDURE Check (VAR Instr : Str3); VAR Count : INTEGER; BEGIN    FOR count:= 1 TO 3 DO IF Instr[count] IN ['A'..'Z'] THEN    Instr[count] := CHR(ORD(Instr[count])+32); END; {Check} PROCEDURE Input; VAR n : 1..Max_chains; BEGIN    Write('Name of protein/peptide: ');    Readln(Name);    Writeln;    Writeln('Please, enter the number of charged amino acids');    Write('arg: '); Readln(Num_arg);    Write('asp: '); Readln(Num_asp);    Write('cys: '); Readln(Num_cys);    Write('glu: '); Readln(Num_glu);    Write('his: '); Readln(Num_his);    Write('lys: '); Readln(Num_lys);    Write('tyr: '); Readln(Num_tyr);    Writeln;    Write('Number of polypeptide chains: ');    Readln(Num_chains);    FOR n:=1 TO Num_chains DO    BEGIN       Write('Chain',n:2,' N-terminal amino acid: ');       Readln(Test);       Check(Test);       Findend;       C_term[n]:=TermC;    END; END; {Input} Procedure Find_charge; VAR I : 1..Max_chains; BEGIN Sum:=0; Sum:=Sum-(Num_asp)*(Neg_charge(pKa3_asp,Test_pH)); Sum:=Sum-(Num_glu)*(Neg_charge(pKa3_glu,Test_pH)); Sum:=Sum-(Num_cys)*(Neg_charge(pKa3_cys,Test_pH)); Sum:=Sum-(Num_tyr)*(Neg_charge(pKa3_tyr,Test_pH)); Sum:=Sum+(Num_his)*(Pos_charge(pKa3_his,Test_pH)); Sum:=Sum+(Num_lys)*(Pos_charge(pKa3_lys,Test_pH)); Sum:=Sum+(Num_arg)*(Pos_charge(pKa3_arg,Test_pH)); FOR i:=1 to Num_chains DO BEGIN    Temp:=(Pos_charge(N_term,Test_pH));       Sum:=Sum+Temp;       Temp:=(Neg_charge(C_term,Test_pH));       Sum:=Sum-Temp;       Temp:=Sum; END; Charge[N]:=Temp; END; {find_charge} PROCEDURE Iterate; VAR Factor, Diff : REAL; BEGIN N:=1; Test_pH[N]:=pH1; Find_charge; N:=2; Test_pH[N]:=pH2; Find_charge; REPEAT N:=N+1; BEGIN  Factor:=((Test_pH[N-1])-(Test_pH[N-2]))/((Charge[N-1])-(Charge[N- 2]));  Test_pH[N]:=(Test_pH[N-1])-(Charge[N-1]*Factor);  Find_charge;  Temp:=(Charge[N])-(Charge[N-1]);  Diff:=ABS(Temp); END;    UNTIL (Diff)<=(Accuracy);    Writeln;    Writeln('Isoelectric point calculated to pH= ',Test_pH[N]:5:3);    Writeln;    Writeln('Accuracy= ',Accuracy:7:5,' pH units');    Writeln('Number of iterations= ',N); END; {Iterate} BEGIN {main}    Input;    Iterate; END. There are some mistakes on your source code. My attached example for Lazarus compiles, but it needs correct values for input and output for testing it. Just curious, after 3 decades since 1986, is this calculus still valid? Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; // Calculation of the pI of proteins according to Skoog and Wichman// https://forum.lazarus.freepascal.org/index.php/topic,45188.0.html // Book:// TRAC: Trends in Analytical Chemistry, Volume 5// edited by C. J. W. Brooks, A. F. Fell, R. W. Frei// https://books.google.com.br/boo ks?id=vIPNCgAAQBAJ&pg=PA83&lpg=PA83&dq=%22Isoelectric+point+determinat ion+of+polypeptides%22&source=bl&ots=P6U2JITr8G&sig=ACfU3U1_-- _v_3rglRuY7k93XmUXRNOqOg&hl=pt-BR&sa=X&ved=2ahUKEwiFmoer7uzhAhVBLLkGHR ffBakQ6AEwAHoECAAQAQ#v=onepage&q=%22Isoelectric%20point%20determinatio n%20of%20polypeptides%22&f=false {$mode objfpc}{$H+} interface uses  Classes, SysUtils, FileUtil, Forms, Controls, Graphics, Dialogs, StdCtrls; const   pKa3_arg       = 12.5;   pKa3_asp       = 3.9;   pKa3_cys       = 8.3;   pKa3_glu       = 4.3;   pKa3_his       = 6.0;   pKa3_lys       = 10.5;   pKa3_tyr       = 10.1;   Max_chains   = 5;   Max_iterations = 100;   pH1            = 1;   pH2            = 14;   Accuracy       = 0.0005;   All = 'alaargasnaspcysglngluglyhisileleulysmetpheproserthrtrptyrval'; type  Str3      = String[3];  Str80     = String[80];  Aminoacid = ARRAY [1..Max_chains] OF Double;  Turn      = ARRAY [1..Max_iterations] OF Double;  N_values  = ARRAY [1..20] OF Double;  C_values  = ARRAY [1..20] OF Double; type   { TForm1 }   TForm1 = class(TForm)    Button1: TButton;    Edit1: TEdit;    Edit10: TEdit;    Edit11: TEdit;    Edit12: TEdit;    Edit2: TEdit;    Edit3: TEdit;    Edit4: TEdit;    Edit5: TEdit;    Edit6: TEdit;    Edit7: TEdit;    Edit8: TEdit;    Edit9: TEdit;    Label1: TLabel;    Label10: TLabel;    Label11: TLabel;    Label12: TLabel;    Label13: TLabel;    Label14: TLabel;    Label2: TLabel;    Label3: TLabel;    Label4: TLabel;    Label5: TLabel;    Label6: TLabel;    Label7: TLabel;    Label8: TLabel;    Label9: TLabel;    procedure Button1Click(Sender: TObject);  private   public   end; var  Form1: TForm1;   Name: Str80;  Test: Str3;   Num_arg,  Num_asp,  Num_cys,  Num_glu,  Num_his,  Num_lys,  Num_tyr,  Num_chains: Integer;   N_term, C_term: Aminoacid;  Test_pH, Charge: Turn;  TermN, TermC: Double;   Number, N: Integer;   NtermpK: N_values;  CtermpK: C_values;  Sum, Temp: Double; implementation {$R *.lfm} function Neg_charge (pK_value: Double; pH: Turn): Double;begin  Neg_charge:=(exp(2.3026*((pH[N])- (pK_value))))/(1+exp(2.3026*((pH[N])-(pK_value))));end; {Neg_charge}  function Pos_charge (pK_value: Double; pH: Turn): Double;begin  Pos_charge := (1/(exp(2.3026*(((pH[N])-(pK_value))))+1));end; {Pos_charge}  procedure Findend;begin  NtermpK[01] := 9.9;  NtermpK[02] := 9.0;  NtermpK[03] := 8.8;  NtermpK[04] := 9.8;  NtermpK[05] := 10.8;  NtermpK[06] := 9.1;  NtermpK[07] := 9.7;  NtermpK[08] := 9.8;  NtermpK[09] := 9.2;  NtermpK[10] := 9.8;  NtermpK[11] := 9.7;  NtermpK[12] := 9.0;  NtermpK[13] := 9.3;  NtermpK[14] := 9.2;  NtermpK[15] := 10.6;  NtermpK[16] := 9.2;  NtermpK[17] := 9.1;  NtermpK[18] := 9.4;  NtermpK[19] := 9.1;  NtermpK[20] := 9.7;   CtermpK[01] := 2.4;  CtermpK[02] := 2.2;  CtermpK[03] := 2.1;  CtermpK[04] := 2.1;  CtermpK[05] := 1.7;  CtermpK[06] := 2.2;  CtermpK[07] := 2.2;  CtermpK[08] := 2.4;  CtermpK[09] := 1.8;  CtermpK[10] := 2.3;  CtermpK[11] := 2.3;  CtermpK[12] := 2.2;  CtermpK[13] := 2.1;  CtermpK[14] := 2.2;  CtermpK[15] := 2.0;  CtermpK[16] := 2.2;  CtermpK[17] := 2.1;  CtermpK[18] := 2.4;  CtermpK[19] := 2.2;  CtermpK[20] := 2.3;   Number := Pos(Test, All);  Number := (Number+2) DIV 3;  TermN  := NtermpK[Number];  TermC  := CtermpK[Number];end; {Findend}  PROCEDURE Check (VAR Instr : Str3);var  Count: Integer;begin   FOR Count := 1 TO 3 DO     IF Instr[Count] IN ['A'..'Z'] THEN       Instr[Count] := CHR(ORD(Instr[Count])+32);end; {Check}  procedure Input;var  n : 1..Max_chains;BEGIN  // Write('Name of protein/peptide: ');  // Readln(Name);  Name := Form1.Edit1.Text;  // Writeln;  // Writeln('Please, enter the number of charged amino acids');  // Write('arg: '); Readln(Num_arg);  Num_arg := StrToInt(Form1.Edit2.Text);  // Write('asp: '); Readln(Num_asp);  Num_asp := StrToInt(Form1.Edit3.Text);  // Write('cys: '); Readln(Num_cys);  Num_cys := StrToInt(Form1.Edit4.Text);  // Write('glu: '); Readln(Num_glu);  Num_glu := StrToInt(Form1.Edit5.Text);  // Write('his: '); Readln(Num_his);  Num_his := StrToInt(Form1.Edit6.Text);  // Write('lys: '); Readln(Num_lys);  Num_lys := StrToInt(Form1.Edit7.Text);  // Write('tyr: '); Readln(Num_tyr);  Num_tyr := StrToInt(Form1.Edit8.Text);  // Writeln;  // Write('Number of polypeptide chains: ');  // Readln(Num_chains);  Num_chains := StrToInt(Form1.Edit9.Text);  FOR n := 1 TO Num_chains DO  begin    // Write('Chain',n:2,' N-terminal amino acid: ');    // Readln(Test);    Test := InputBox('Inform Chain ', 'Chain ' + RightStr('0' + IntToStr(n),2) + ' N-terminal amino acid:', 'abc');    Check(Test);  Findend;    C_term[n] := TermC;    N_term[n] := TermN;      // Write('Chain',n:2,' C-terminal amino acid: ');    // Readln(Test);    Test := InputBox('Inform Chain ', 'Chain ' + RightStr('0' + IntToStr(n),2) + ' C-terminal amino acid:', 'abc');    Check(Test);  Findend;    C_term[n] := TermC;    // ***************************************  end;end; {Input}  procedure Find_charge;var  i: 1..Max_chains;begin  Sum := 0;  Sum := Sum - (Num_asp)*(Neg_charge(pKa3_asp,Test_pH));  Sum := Sum - (Num_glu)*(Neg_charge(pKa3_glu,Test_pH));  Sum := Sum - (Num_cys)*(Neg_charge(pKa3_cys,Test_pH));  Sum := Sum - (Num_tyr)*(Neg_charge(pKa3_tyr,Test_pH));  Sum := Sum + (Num_his)*(Pos_charge(pKa3_his,Test_pH));  Sum := Sum + (Num_lys)*(Pos_charge(pKa3_lys,Test_pH));  Sum := Sum + (Num_arg)*(Pos_charge(pKa3_arg,Test_pH));  FOR i := 1 to Num_chains DO  begin    Temp :=(Pos_charge(N_term[i], Test_pH));    Sum  := Sum +Temp;    Temp := (Neg_charge(C_term[i], Test_pH));    Sum  := Sum - Temp;    Temp := Sum;  end;  Charge[N] := Temp;end; {find_charge}  procedure Iterate;var  Factor, Diff: Double;BEGIN  N        := 1;  Test_pH[N] := pH1;  Find_charge;   N          := 2;  Test_pH[N] := pH2;  Find_charge;  REPEAT    N := N+ 1;    begin      Factor     := ((Test_pH[N-1])-(Test_pH[N-2]))/((Charge[N-1])-(Charge[N-2]));      Test_pH[N] := (Test_pH[N-1])-(Charge[N-1]*Factor);      Find_charge;       Temp := (Charge[N])-(Charge[N-1]);      Diff := ABS(Temp);    end;  UNTIL (Diff)<=(Accuracy);   // Writeln;  // Writeln('Isoelectric point calculated to pH = ', Test_pH[N]:5:3);  Form1.Edit10.Text := FormatFloat('00000.000', Test_pH[N]);  // Writeln;  // Writeln('Accuracy = ', Accuracy:7:5, ' pH units');  Form1.Edit11.Text := FormatFloat('0000000.00000', Accuracy);  // Writeln('Number of iterations = ', N);  Form1.Edit12.Text := IntToStr(N);end; {Iterate} { TForm1 } procedure TForm1.Button1Click(Sender: TObject);begin  Input;  Iterate;end; end. ---------------------------------------------------------------------- s_bue · 2019-04-26 11:27 Quote from: valdir.marcos on April 26, 2019, 07:37:58 amThere are some mistakes on your source code. My attached example for Lazarus compiles, but it needs correct values for input and output for testing it. Just curious, after 3 decades since 1986, is this calculus still valid? My supervisor and a prof. requested to calculate it like that (because they say it's accurate) but as I tried out two sequences it shows major differences to the ones you get from https://web.expasy.org/compute_pi/  (which is common practice). Here you just insert the letters for the amino acids if you want to double check: Alanin                   Ala   A    Arginin               Arg   R    Asparagin               Asn   N    Asparaginsäure      Asp   D    Cystein               Cys   C    Glutamin               Gln   Q    Glutaminsäure       Glu   E    Glycin               Gly   G Histidin               His   H    Isoleucin               Ile   I    Leucin               Leu   L    Lysin                       Lys   K    Methionin               Met   M    Phenylalanin       Phe   F    Prolin               Pro   P    Serin                       Ser   S    Threonin               Thr   T    Tryptophan       Trp   W    Tyrosin               Tyr   Y    Valin                       Val   V I tried with Bradykinin (ArgProProGlyPheSerProPheArg --> RPPGFSPFR ) calculated by lazarus: pI 9.605 calculated by expasy: 12.00 Also I tried with a C-Phycocyaninbetasubunit (MetPheAspAlaPheThrLysVal ValSerGlnAlaAspThrArgGlyGluMetLeuSerThrAlaGlyIleAsp --> MFDAFTKVVS QADTRGEMLS TAQID) calculated by lazarus was something really high while expasy comes to: 4.23 If you want to get amino acid sequences you can find all of them at https://www.uniprot.org/ I don't know your knowledge about Peptides the N terminus starts at the left hand side and the C terminus at the right hand side just in case you want to check the code by yourself.  Now I have some questions. Might it be that the sequences are too big because max_chains is set to 5? Also it is quite difficult to enter the number of tyrosins because it's on the bottom of the box. How do I move it further up? Last but not least I want to change the way the program asks for the c and n subunits (first all the n subunits and afterwards all c subunits) is that possible? Thank you all so far! It's really a great help! ---------------------------------------------------------------------- VTwin · 2019-04-26 13:26 Quote from: lucamar on April 26, 2019, 05:03:45 amAlthough it's a little hard to read the code ... Indeed!  In my experience, not uncommon in 1980-90's scientific literature though. Now you are required to provide a github link, avoids tedious retyping and typos. ---------------------------------------------------------------------- Bart · 2019-04-26 14:01 For starters I don't even understand the input questions. At some point it asked me for a number: I answered 1 and the whole program just crashed. So, if I want to test bradykinine, what should be the anwers to the input questions? Same for the other examples (with expected output) you gave. Bart ---------------------------------------------------------------------- valdir.marcos · 2019-04-26 15:23 Quote from: s_bue on April 26, 2019, 01:27:30 pmQuote from: valdir.marcos on April 26, 2019, 07:37:58 amThere are some mistakes on your source code. My attached example for Lazarus compiles, but it needs correct values for input and output for testing it. Just curious, after 3 decades since 1986, is this calculus still valid? My supervisor and a prof. requested to calculate it like that (because they say it's accurate) but as I tried out two sequences it shows major differences to the ones you get from https://web.expasy.org/compute_pi/  (which is common practice). Here you just insert the letters for the amino acids if you want to double check: Alanin                   Ala   A    Arginin               Arg   R    Asparagin               Asn   N    Asparaginsäure      Asp   D    Cystein               Cys   C    Glutamin               Gln   Q    Glutaminsäure       Glu   E    Glycin               Gly   G Histidin               His   H    Isoleucin               Ile   I    Leucin               Leu   L    Lysin                       Lys   K    Methionin               Met   M    Phenylalanin       Phe   F    Prolin               Pro   P    Serin                       Ser   S    Threonin               Thr   T    Tryptophan       Trp   W    Tyrosin               Tyr   Y    Valin                       Val   V I tried with Bradykinin (ArgProProGlyPheSerProPheArg --> RPPGFSPFR ) calculated by lazarus: pI 9.605 calculated by expasy: 12.00 Also I tried with a C-Phycocyaninbetasubunit (MetPheAspAlaPheThrLysVal ValSerGlnAlaAspThrArgGlyGluMetLeuSerThrAlaGlyIleAsp --> MFDAFTKVVS QADTRGEMLS TAQID) calculated by lazarus was something really high while expasy comes to: 4.23 If you want to get amino acid sequences you can find all of them at https://www.uniprot.org/ I don't know your knowledge about Peptides the N terminus starts at the left hand side and the C terminus at the right hand side just in case you want to check the code by yourself.  Now I have some questions. Might it be that the sequences are too big because max_chains is set to 5? Also it is quite difficult to enter the number of tyrosins because it's on the bottom of the box. How do I move it further up? Last but not least I want to change the way the program asks for the c and n subunits (first all the n subunits and afterwards all c subunits) is that possible? Thank you all so far! It's really a great help!  Be aware that I just took your source code, put it on Lazarus, compared it to your pdf file's source code and fixed it until it got compiled. I don't know enough Bio-informatics to fix its logic. It seems you are going too fast... First, on my viewpoint, you should learn a bit more of Free Pascal and Lazarus. Second, you should learn how to debug your programs. Third, you should understand the Skoog and Wichman's algorithm to calculate the pI of proteins to the level of performing it using only paper and pencil. And finally, you should double check my solution to fix its errors and logic. As an example, you could start here: Devstructor.com/DelphiTutorialsTk https://www.youtube.com/channel/UCGT_qnRHoLnmrUxZrgaDSUQ And here: http://wiki.lazarus.freepascal.org/Main_Page https://forum.lazarus.freepascal.org/index.php?action=search And here: Tutorials https://forum.lazarus.freepascal.org/index.php/topic,42003.0.html Best Tutorial https://forum.lazarus.freepascal.org/index.php/topic,45078.msg317864.h tml#msg317864 Pascal Books https://forum.lazarus.freepascal.org/index.php/topic,43921.0.html New user introduction https://forum.lazarus.freepascal.org/index.php/topic,43494.0.html Conversion from Delphi https://forum.lazarus.freepascal.org/index.php/topic,42231.msg294453.h tml#msg294453 Book recommendation on programming language concepts and design ? https://forum.lazarus.freepascal.org/index.php/topic,42156.0.html ---------------------------------------------------------------------- Bart · 2019-04-27 13:27 Quote from: s_bue on April 25, 2019, 03:49:12 pmFor example imagine a protein consisting out of all the charged amino acids arg, asp, cys, glu, his, lys, tyr all of them only once and the total peptide consisting only out of these 7 chains it calculates a pI of 1.967. So that peptide would be arg-asp-cys-glu-his-lys-tyr ? Quote from: s_bue on April 25, 2019, 03:49:12 pmIf I enter the order RDCEHKY (short forms of the amino acid short forms  ) in expasy it comes to a pI of 6.74. It seems that if I enter this in any order of amino-acids, the result is always the same. Does that make sense? Bart ---------------------------------------------------------------------- Bart · 2019-04-27 13:49 Quote from: valdir.marcos on April 26, 2019, 07:37:58 amCode: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i unit Unit1; // Calculation of the pI of proteins according to Skoog and Wichman// https://forum.lazarus.freepascal.org/index.php/topic,45188.0 .html...end. I refactored your code a bit. Used SpinEdits for input. Removed unnecessary Temp variable. Replaced Check() with LowerCase. Renamed Input to GetInput (because CodeTools don't agree with it) Remove "C_term[n] := TermC" after the first Findend call in GetInput, because this is not there in the original sourcecode Did a sanity check in Findend (any input for Test would be processed) Input could be made more robust by letting the user select aminoacids from a dropdownlist instead of a free text edit field. However: I have no idea what all the input variables mean whatsoever. The original code is horrible. Global variables all over the place. Why does it compute an answer if all the numbers of aminoacids are set to zero? @TS: how would I enter  Bradykinin (ArgProProGlyPheSerProPheArg) into the attached program (GUI version, see attachment) or the original one? I have absolutely no idea. Bart ---------------------------------------------------------------------- Bart · 2019-04-28 11:35 Refactored some more. No more global variables! Procedures that use the form are now method of the form. Renamed some procedures. Made the NtermpK and CtermpK constant arrays. As a result the code flow is better to follow. Still, I have absolutely no idea how it is supposed to work. It will make testing a bit easier though. Bart ---------------------------------------------------------------------- Bart · 2019-04-28 12:01 @topic starter: since the (original) code gives results that differ from your reference tool, it might be worth while to check if the Skkog and Wichman article has ever been quoted or folowed up. The original code as it appeared in that article may be flawed and perhaps corrected later on? Bart ---------------------------------------------------------------------- Bart · 2019-04-28 12:18 Later research seems to have used the calculations of Skoog and Wichman. See: http://www.prodoric.de/download/hiller03.pdf (Section: Materials and Methods) or https://www.google.com/url?sa=t&rct=j&q=&esr c=s&source=web&cd=31&ved=2ahUKEwi2k9a84vLhAhWKr6QKHUpDB7g4HhAWMAB6BAgA EAI&url=https%3A%2F%2Fpermegear.com%2F%3Fmdocs- file%3D8621&usg=AOvVaw0UmDnZ4ksa_NjBUICxWsYN (section 3.1). So, their seems to be some validity of this program? Bart ---------------------------------------------------------------------- engkin · 2019-04-28 12:44 On the other hand, based on ExPASy's docs: Quote1-Protein pI is calculated using pK values of amino acids described in Bjellqvist et al., which were defined by examining polypeptide migration between pH 4.5 to 7.3 in an immobilised pH gradient gel environment with 9.2M and 9.8M urea at 15°C or 25°C. Prediction of protein pI for highly basic proteins is yet to be studied and it is possible that current Compute pI/Mw predictions may not be adequate for this purpose. 2-The buffer capacity of a protein will affect the accuracy of its predicted pI, with poor buffer capacity leading to greater error in prediction (Bjellqvist et al.). Because of this, pI predictions for small proteins can be problematic. ---------------------------------------------------------------------- engkin · 2019-04-29 22:08 There are 20 amino acids. I suggest changing TAminoAcidEnums to include them all: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i   TAminoAcidEnums = (Ala, Arg, Asn, Asp, Cys, Gln, Glu, Gly, His, Ile, Leu, Lys, Met, Phe, Pro, Ser, Thr, Trp, Tyr, Val); One letter code for amino acids could be used to count them: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function Amino1ToCounts(AStr: String): TAminoAcidCounts;var  LChar: Char;begin  Result := Default(TAminoAcidCounts);  for LChar in AStr do  begin    case LChar of    'A':inc(Result[Ala]);    'R':inc(Result[Arg]);    'N':inc(Result[Asn]);    'D':inc(Result[Asp]);    'C':inc(Result[Cys]);    'Q':inc(Result[Gln]);    'E':inc(Result[Glu]);    'G':inc(Result[Gly]);    'H':inc(Result[His]);    'I':inc(Result[Ile]);    'L':inc(Result[Leu]);    'K':inc(Result[Lys]);    'M':inc(Result[Met]);    'F':inc(Result[Phe]);    'P':inc(Result[Pro]);    'S':inc(Result[Ser]);    'T':inc(Result[Thr]);    'W':inc(Result[Trp]);    'Y':inc(Result[Tyr]);    'V':inc(Result[Val]);    else       // Maybe report an error    end;  end;end; Would be nice to provide a way to switch between one letter and three letters encoding, Amino3To1 and Amino1To3: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i function Amino3To1(AStr: string):string;var  i:integer;  LStr: string;begin  Result := '';  i := 1;  while i < Length(AStr) do  begin    LStr := lowercase(copy(AStr, i, 3));    case LStr of    'ala':Result := Result + 'A';    'arg':Result := Result + 'R';    'asn':Result := Result + 'N';    'asp':Result := Result + 'D';    'cys':Result := Result + 'C';    'gln':Result := Result + 'Q';    'glu':Result := Result + 'E';    'gly':Result := Result + 'G';    'his':Result := Result + 'H';    'ile':Result := Result + 'I';    'leu':Result := Result + 'L';    'lys':Result := Result + 'K';    'met':Result := Result + 'M';    'phe':Result := Result + 'F';    'pro':Result := Result + 'P';    'ser':Result := Result + 'S';    'thr':Result := Result + 'T';    'trp':Result := Result + 'W';    'tyr':Result := Result + 'Y';    'val':Result := Result + 'V';    else       Result := Result + '?';    end;    inc(i,3);  end;end; function Amino1To3(AStr: string):string;var  i:integer;begin  Result := '';  for i := 1 To Length(AStr) do  begin    case AStr[i] of    'A':Result := Result + 'Ala';    'R':Result := Result + 'Arg';    'N':Result := Result + 'Asn';    'D':Result := Result + 'Asp';    'C':Result := Result + 'Cys';    'Q':Result := Result + 'Gln';    'E':Result := Result + 'Glu';    'G':Result := Result + 'Gly';    'H':Result := Result + 'His';    'I':Result := Result + 'Ile';    'L':Result := Result + 'Leu';    'K':Result := Result + 'Lys';    'M':Result := Result + 'Met';    'F':Result := Result + 'Phe';    'P':Result := Result + 'Pro';    'S':Result := Result + 'Ser';    'T':Result := Result + 'Thr';    'W':Result := Result + 'Trp';    'Y':Result := Result + 'Tyr';    'V':Result := Result + 'Val';     else       Result := Result + '???';    end;  end;end; It seems that only seven of them (arg, asp, cys, glu, his, lys, tyr) hold a charge (positive in red). Which mean instead of: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i    pKa3_arg       = 12.5;   pKa3_asp       = 3.9;   pKa3_cys       = 8.3;   pKa3_glu       = 4.3;   pKa3_his       = 6.0;   pKa3_lys       = 10.5;   pKa3_tyr       = 10.1; An array could be used, most if its elements are zeros, and three are positive values. Probably not needed. Edit: Code: Pascal  [Select][+][-]window.onload = function(){var x1 = document.getElementById("main_content_section"); if (x1) { var x = document.getElementsByClassName("geshi");for (var i = 0; i     alanine,                     ala, A    arginine,                    arg, R    asparagine,                  asn, N    aspartic acid,             asp, D  //asparagine or aspartic acid, asx, B    cysteine,                  cys, C    glutamic,                    glu, E    glutamine,                   gln, Q  //glutamine or glutamic acid,  glx, Z    glycine,                     gly, G    histidine,                 his, H    isoleucine,                  ile, I    leucine,                   leu, L    lysine,                      lys, K    methionine,                  met, M    phenylalanine,               phe, F    proline,                     pro, P    serine,                    ser, S    threonine,                   thr, T    tryptophan,                trp, W    tyrosine,                    tyr, Y    valine,                      val, V ---------------------------------------------------------------------- howardpc · 2019-04-30 16:09 Quote from: Bart on April 27, 2019, 03:27:00 pmIt seems that if I enter this in any order of amino-acids, the result is always the same. Does that make sense? Yes, the order of the amino acid in the peptide sequence is immaterial. Wherever it sits in the chain, if it has a charged side chain, it makes the same contribution to the overall charge. I've included a few pre-built peptide/protein examples in the attached project, and three different sources for the experimentally obtained pKa values. Although there are slight variations between the sets of data, it rarely makes more than a difference of 0.1 to the theoretical pI calculated value. Nevertheless, I think the calculated pI value should only ever have 2 significant digits. Values such as 8.53 have a false precision, not warranted by the spread of experimental values for the pKa data among the masses of published tables for these determinations. The visualisation of the amino acid sequence in the attached project is shown starting at the NH2 end and ending at the COOH end. Of course, if these molecules are in aqueous solution, they most likely exist as zwitterions, and should then  be shown as H3N+... ...COO- ---------------------------------------------------------------------- Bart · 2019-05-01 12:13 I did dsome more refactoring on the original code: Separated all calculation related stuff into a separate unitRenamed alsmost all types.The type TAminoAcid now in fact represents an aminoacid (as an emum)Redesigned C_Term and N_Term array into an array of records.Got rid of all global viriablesExposed only those types the end user needsExposed aminoacid names for convenienceRedesigned the GUIMade a custom dialog that asks for terminating aminoacids (foolproof input)Use (Float)SpinEdits for input variables Bart ---------------------------------------------------------------------- JLWest · 2019-05-01 17:39 @Bart Wow Downloaded to look at the code. A Lot neater than mine. Nice, Very nice. ---------------------------------------------------------------------- Bart · 2019-05-01 21:21 One more adjustment. The internal type TpK_Values is now an array[TAminoAcid] of Double, instead of arra[1..20]. Bart ---------------------------------------------------------------------- s_bue · 2019-05-05 17:42 Quote from: Bart on May 01, 2019, 11:21:32 pmOne more adjustment. The internal type TpK_Values is now an array[TAminoAcid] of Double, instead of arra[1..20]. Bart WOW That's such a great job you did there, and all the others as well! In fact I started trying to do more by myself but I had a tough week at work  and therefore not a lot of time. Now I come back to the topic to ask more questions and look at this! Thanks a lot everyone! ---------------------------------------------------------------------- s_bue · 2019-05-05 17:52 Quote from: Bart on April 28, 2019, 02:01:40 pm@topic starter: since the (original) code gives results that differ from your reference tool, it might be worth while to check if the Skkog and Wichman article has ever been quoted or folowed up. The original code as it appeared in that article may be flawed and perhaps corrected later on? Bart Actual it's meant to give different results but pI's varying 3 entire pH units seem unlikely. It should be closer to the pI's you get from measurements than the entirely theoretical pH's. I'll check this week if this method is closer or Expasy is closer to the ones we measure in the lab.