#!/usr/bin/perl -wT # perl -T valpred3d.pl -infile SDH_HUMAN.pdb # Valpred Windows Program Copyright © 2010 Lawrence K. Lee. All rights reserved. # Valpred Perl Program Copyright © 2010 Emma M. Rath. All rights reserved. # Soon this program will be released under an open source software license such as GNU General Public License or # Creative Commons license for Free Software Foundation's GNU General Public License at creativecommons.org # This perl program can be run on the command line in batch mode, # or on a web page as a cgi script on a web server. # References : # # Lawrence K. Lee, Noeris K. Salam, Hong Wing Lee, Emma M. Rath and W. Bret Church (in preparation) # 'Transmembrane helix analysis using threading approaches' # # James U. Bowie, Roland Lüthy, David Eisenberg (1991) # 'A Method to Identify Protein Sequences that Fold into a Known Three-Dimensional Structure' # Science, 253, 164-170 # # Roland Lüthy, James U. Bowie, David Eisenberg (1992) # 'Assessment of protein models with three-dimensional profiles' # Nature, 356, 83-85 # # Siavoush Dastmalchi, Michael B. Morris and W. Bret Church (2001) # 'Modelling of the structural features of integral-membrane proteins using REPIMPS # (Reverse-Environment Prediction of Integral Membrane Protein Structure)' # Protein Science, 10, 1529-1538 use warnings; use strict; use diagnostics; use Getopt::Long; use Math::Complex; use Math::Trig; use GD; use GD::Text; use GD::Graph::lines; use CGI; use Data::Dumper; $Data::Dumper::Purity = 1; # print "var x = " . Dumper( $x ) . "\n"; # debug # my $wait_for_key_press = ; # debug # $CGI::POST_MAX = 1024 * 5000; # adjust as needed (1024 * 5000 = 5MB) # $CGI::DISABLE_UPLOADS = 0; # 1 disables uploads, 0 enables uploads # global constants # in Residue.h, enum SecStruct{ use constant SHEET => 0; # SHEET = 0, use constant HELIX => 1; # HELIX = 1, use constant OTHER => 2; # OTHER = 2, # in Residue.h, enum ResCode{ use constant ALA => 7; # ALA = 7, use constant ARG => 19; # ARG = 19, use constant ASN => 14; # ASN = 14, use constant ASP => 16; # ASP = 16, use constant CYS => 10; # CYS = 10, use constant GLN => 13; # GLN = 13, use constant GLU => 15; # GLU = 15, use constant GLY => 8; # GLY = 8, use constant HIS => 17; # HIS = 17, use constant ILE => 4; # ILE = 4, use constant LEU => 3; # LEU = 3, use constant LYS => 18; # LYS = 18, use constant MET => 6; # MET = 6, use constant PHE => 1; # PHE = 1, use constant PRO => 9; # PRO = 9, use constant SER => 12; # SER = 12, use constant THR => 11; # THR = 11, use constant TRP => 0; # TRP = 0, use constant TYR => 2; # TYR = 2, use constant VAL => 5; # VAL = 5, use constant UNK => 21; # UNK = 21 use constant PI => 3.1415926535897932384626433832795; # define PI 3.1415926535897932384626433832795f; # in Atom.h, enum AtomType{ use constant C_Ali => 0; # C_Ali = 0, // Aliphatic C use constant C_Car => 1; # C_Car = 1, // Carboxyl or Carbonyl use constant C_Aro => 2; # C_Aro = 2, // Aromatic C use constant N_All => 3; # N_All = 3, // All Nitrogen use constant O_All => 4; # O_All = 4, // All Oxygen use constant S_Oxy => 5; # S_Oxy = 5, // Sulfur and thiol S of S-S bridge use constant S_Red => 6; # S_Red = 6 // SH or S-CH3 etc my %charToRes; set_charToRes(); my %assignResType; set_assignResType(); my %Residue_SecStruct; my %Residue_ResCode; my %Residue_EnvCode; set_Residue_constants(); my @SCGlyXGly_array; my $SCGlyXGly = \@SCGlyXGly_array; set_Value_constants(); my $atom_default_values = Atom_default_values(); my %amino_acid_pdbs_hash; my $amino_acid_pdbs = \%amino_acid_pdbs_hash; my %hetatm_radii_hash; my $hetatm_radii = \%hetatm_radii_hash; my $path_to_files_Sphere_Points = 'Sphere_Points'; my $path_to_files_Amino_Acids = 'Amino_Acids'; my $path_to_files_Valpred_Files = 'Valpred_Files'; my $program_options; # global variables my $analyser; #C++ Analyser my $structure; #C++ Structure my $helices; #C++ Range my $sheets; #C++ Range my $input_infile; my $input_inscoresfile; my $input_sasares; my $input_ignorehet; my $input_flag_help; my $input_flag_h; my $input_debug_flag; my $input_file_name_for_output_files = 'valpred_perl_program'; my $stats; my %stats_hash; $stats = \%stats_hash; my $debug = ''; #=============================================================================== #========== MAIN PROGRAM LOGIC ========================= #=============================================================================== my $program_mode = ''; my $cgi_query = new CGI; init(); program_get_input(); if ($program_mode eq 'cgi-display-form') { program_display_html_form(); } elsif ($program_mode eq 'cgi-output-graph') { program_output_html_graph(); } elsif ($program_mode eq 'cgi-output') { program_output_html_results(); } else { # $program_mode eq 'command-line' program_output_command_line(); } #=============================================================================== # // Allocates environment categories and scores to residues sub Analyser_doProfile { #C++ void Analyser::doProfile(void) my @show_aacode = ("TRP","PHE","TYR","LEU","ILE","VAL","MET","ALA","GLY","PRO","CYS","THR","SER","GLN","ASN","GLU","ASP","HIS","LYS","ARG"," ","UNK"); my @show_envcode = ("B1a","B1b","B1","B2a","B2b","B2","B3a","B3b","B3","P1a","P1b","P1","P2a","P2b","P2","Ea","Eb","E","unknown"); $structure = $analyser->{'st'}; my $st_dot_allResidues_dot_size = $#{$structure->{'allResidues'}} + 1; for (my $i = 0; $i < $st_dot_allResidues_dot_size; $i++ ) { # for(unsigned int i = 0;i < st.allResidues.size(); i++){ # //soluble analysis if ( $structure->{'allResidues'}->[$i]->{'areaBuried'} < $analyser->{'ABLow'} ) { # if(st.allResidues[i].areaBuried < ABLow){ if ( $structure->{'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'Ea'};# st.allResidues[i].profEnv = Ea; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'Eb'};# st.allResidues[i].profEnv = Eb; } else { $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'E'}; # st.allResidues[i].profEnv = E; } } elsif ( $structure->{'allResidues'}->[$i]->{'areaBuried'} < $analyser->{'ABHigh'} ) { # else if(st.allResidues[i].areaBuried < ABHigh){ if ( $structure->{'allResidues'}->[$i]->{'fractionPolar'} < $analyser->{'FPPartial'} ) { # if(st.allResidues[i].fractionPolar {'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'P1a'}; # st.allResidues[i].profEnv = P1a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'P1b'}; # st.allResidues[i].profEnv = P1b; } else { $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'P1'}; # st.allResidues[i].profEnv = P1; } } if ( $structure->{'allResidues'}->[$i]->{'fractionPolar'} >= $analyser->{'FPPartial'} ) { # if(st.allResidues[i].fractionPolar >=FPPartial){ if ( $structure->{'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'P2a'}; # st.allResidues[i].profEnv = P2a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'P2b'}; # st.allResidues[i].profEnv = P2b; } else { $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'P2'}; # st.allResidues[i].profEnv = P2; } } } else { if ( $structure->{'allResidues'}->[$i]->{'fractionPolar'} < $analyser->{'FPBLow'} ) { # if(st.allResidues[i].fractionPolar {'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'B1a'}; # st.allResidues[i].profEnv = B1a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'B1b'}; # st.allResidues[i].profEnv = B1b; } else { $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'B1'}; # st.allResidues[i].profEnv = B1; } } elsif ( $structure->{'allResidues'}->[$i]->{'fractionPolar'} < $analyser->{'FPBHigh'} ) { # else if(st.allResidues[i].fractionPolar {'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'B2a'}; # st.allResidues[i].profEnv = B2a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'B2b'}; # st.allResidues[i].profEnv = B2b; } else { $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'B2'}; # st.allResidues[i].profEnv = B2; } } else { if ( $structure->{'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'B3a'}; # st.allResidues[i].profEnv = B3a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'B3b'}; # st.allResidues[i].profEnv = B3b; } else { $structure->{'allResidues'}->[$i]->{'profEnv'} = $Residue_EnvCode{'B3'}; # st.allResidues[i].profEnv = B3; } } } # repimps analysis my $temp1 = $structure->{'allResidues'}->[$i]->{'aaCode'}; if ( $SCGlyXGly->[$temp1] < $analyser->{'ABLow'} ) { # if(SCGlyXGly[st.allResidues[i].aaCode] < ABLow){ if ( $structure->{'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'Ea'}; # st.allResidues[i].repEnv = Ea; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'Eb'}; # st.allResidues[i].repEnv = Eb; } else { $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'E'}; # st.allResidues[i].repEnv = E; } } elsif ( $SCGlyXGly->[$temp1] < $analyser->{'ABHigh'} ) { # else if(SCGlyXGly[st.allResidues[i].aaCode] < ABHigh){ if ( $structure->{'allResidues'}->[$i]->{'repimpsFP'} < 0.67 ) { # if(st.allResidues[i].repimpsFP <0.67){ if ($structure->{'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'P1a'}; # st.allResidues[i].repEnv = P1a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'P1b'}; # st.allResidues[i].repEnv = P1b; } else { $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'P1'}; # st.allResidues[i].repEnv = P1; } } if ( $structure->{'allResidues'}->[$i]->{'repimpsFP'} >= $analyser->{'FPPartial'} ) { # if(st.allResidues[i].repimpsFP >=FPPartial){ if ( $structure->{'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'P2a'}; # st.allResidues[i].repEnv = P2a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'P2b'}; # st.allResidues[i].repEnv = P2b; } else { $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'P2'}; # st.allResidues[i].repEnv = P2; } } } else { if ( $structure->{'allResidues'}->[$i]->{'repimpsFP'} < $analyser->{'FPBLow'} ) { # if(st.allResidues[i].repimpsFP {'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'B1a'}; # st.allResidues[i].repEnv = B1a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'B1b'}; # st.allResidues[i].repEnv = B1b; } else { $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'B1'}; # st.allResidues[i].repEnv = B1; } } elsif ( $structure->{'allResidues'}->[$i]->{'repimpsFP'} < $analyser->{'FPBHigh'} ) { # else if(st.allResidues[i].repimpsFP {'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'B2a'}; # st.allResidues[i].repEnv = B2a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'B2b'}; # st.allResidues[i].repEnv = B2b; } else { $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'B2'}; # st.allResidues[i].repEnv = B2; } } else { if ( $structure->{'allResidues'}->[$i]->{'SS'} == HELIX ) { # if(st.allResidues[i].SS == HELIX){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'B3a'}; # st.allResidues[i].repEnv = B3a; } elsif ( $structure->{'allResidues'}->[$i]->{'SS'} == SHEET ) { # else if(st.allResidues[i].SS == SHEET){ $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'B3b'}; # st.allResidues[i].repEnv = B3b; } else { $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'B3'}; # st.allResidues[i].repEnv = B3; } } } if ( $structure->{'allResidues'}->[$i]->{'aaCode'} == UNK ) { # if (st.allResidues[i].aaCode == UNK){ $structure->{'allResidues'}->[$i]->{'scores'}->[0] = 0.0; # st.allResidues[i].scores[0] = 0.0f; $structure->{'allResidues'}->[$i]->{'scores'}->[1] = 0.0; # st.allResidues[i].scores[1] = 0.0f; $structure->{'allResidues'}->[$i]->{'repEnv'} = $Residue_EnvCode{'unknown'}; # st.allResidues[i].repEnv = unknown; } else { # st.allResidues[i].scores[0] = scores[st.allResidues[i].profEnv][st.allResidues[i].aaCode]; my $temp1 = $structure->{'allResidues'}->[$i]->{'profEnv'}; my $temp2 = $structure->{'allResidues'}->[$i]->{'aaCode'}; $structure->{'allResidues'}->[$i]->{'scores'}->[0] = $analyser->{'scores'}->[$temp1][$temp2]; # st.allResidues[i].scores[1] = scores[st.allResidues[i].repEnv][st.allResidues[i].aaCode]; my $temp3 = $structure->{'allResidues'}->[$i]->{'repEnv'}; my $temp4 = $structure->{'allResidues'}->[$i]->{'aaCode'}; $structure->{'allResidues'}->[$i]->{'scores'}->[1] = $analyser->{'scores'}->[$temp3][$temp4]; } # //change when writing overall score handler!! # //st.aveResScore += st.allResidues[i].scores[0]; } # //st.aveResScore /= st.allResidues.size(); } sub Analyser_findCloseAtoms { #C++ void Analyser::findCloseAtoms() $structure = $analyser->{'st'}; # calculate xyzextremities for the protein atoms my $st_dot_allAtoms_dot_size = $#{$structure->{'allAtoms'}} + 1; for (my $i = 0; $i < $st_dot_allAtoms_dot_size; $i++) { if ($structure->{'allAtoms'}->[$i]->{'coords'}->{'x'} < $structure->{'xyzExtremities'}->[0]->{'f1'}) { $structure->{'xyzExtremities'}->[0]->{'f1'} = $structure->{'allAtoms'}->[$i]->{'coords'}->{'x'}; } if ($structure->{'allAtoms'}->[$i]->{'coords'}->{'x'} > $structure->{'xyzExtremities'}->[0]->{'f2'}) { $structure->{'xyzExtremities'}->[0]->{'f2'} = $structure->{'allAtoms'}->[$i]->{'coords'}->{'x'}; } if ($structure->{'allAtoms'}->[$i]->{'coords'}->{'y'} < $structure->{'xyzExtremities'}->[1]->{'f1'}) { $structure->{'xyzExtremities'}->[1]->{'f1'} = $structure->{'allAtoms'}->[$i]->{'coords'}->{'y'}; } if ($structure->{'allAtoms'}->[$i]->{'coords'}->{'y'} > $structure->{'xyzExtremities'}->[1]->{'f2'}) { $structure->{'xyzExtremities'}->[1]->{'f2'} = $structure->{'allAtoms'}->[$i]->{'coords'}->{'y'}; } if ($structure->{'allAtoms'}->[$i]->{'coords'}->{'z'} < $structure->{'xyzExtremities'}->[2]->{'f1'}) { $structure->{'xyzExtremities'}->[2]->{'f1'} = $structure->{'allAtoms'}->[$i]->{'coords'}->{'z'}; } if ($structure->{'allAtoms'}->[$i]->{'coords'}->{'z'} > $structure->{'xyzExtremities'}->[2]->{'f2'}) { $structure->{'xyzExtremities'}->[2]->{'f2'} = $structure->{'allAtoms'}->[$i]->{'coords'}->{'z'}; } } # ///recalculate xyzextremities to include hetatoms my $st_dot_hetAtoms_dot_size = $#{$structure->{'hetAtoms'}} + 1; if ($analyser->{'ignoreHet'} == 0) { # if(!ignoreHet){ for (my $h = 0; $h < $st_dot_hetAtoms_dot_size; $h++) { # for(unsigned int h = 0; h < st.hetAtoms.size(); h++){ if ($structure->{'hetAtoms'}->[$h]->{'coords'}->{'x'} < $structure->{'xyzExtremities'}->[0]->{'f1'}) { # if(st.hetAtoms[h].coords.x < st.xyzExtremities[0].f1){ $structure->{'xyzExtremities'}->[0]->{'f1'} = $structure->{'hetAtoms'}->[$h]->{'coords'}->{'x'}; # st.xyzExtremities[0].f1 = st.hetAtoms[h].coords.x; } if ($structure->{'hetAtoms'}->[$h]->{'coords'}->{'x'} > $structure->{'xyzExtremities'}->[0]->{'f2'}) { # if(st.hetAtoms[h].coords.x > st.xyzExtremities[0].f2){ $structure->{'xyzExtremities'}->[0]->{'f2'} = $structure->{'hetAtoms'}->[$h]->{'coords'}->{'x'}; # st.xyzExtremities[0].f2 = st.hetAtoms[h].coords.x; } if ($structure->{'hetAtoms'}->[$h]->{'coords'}->{'y'} < $structure->{'xyzExtremities'}->[1]->{'f1'}) { # if(st.hetAtoms[h].coords.y < st.xyzExtremities[1].f1){ $structure->{'xyzExtremities'}->[1]->{'f1'} = $structure->{'hetAtoms'}->[$h]->{'coords'}->{'y'}; # st.xyzExtremities[1].f1 = st.hetAtoms[h].coords.y; } if ($structure->{'hetAtoms'}->[$h]->{'coords'}->{'y'} > $structure->{'xyzExtremities'}->[1]->{'f2'}) { # if(st.hetAtoms[h].coords.y > st.xyzExtremities[1].f2){ $structure->{'xyzExtremities'}->[1]->{'f2'} = $structure->{'hetAtoms'}->[$h]->{'coords'}->{'y'}; # st.xyzExtremities[1].f2 = st.hetAtoms[h].coords.y; } if ($structure->{'hetAtoms'}->[$h]->{'coords'}->{'z'} < $structure->{'xyzExtremities'}->[2]->{'f1'}) { # if(st.hetAtoms[h].coords.z < st.xyzExtremities[2].f1){ $structure->{'xyzExtremities'}->[2]->{'f1'} = $structure->{'hetAtoms'}->[$h]->{'coords'}->{'z'}; # st.xyzExtremities[2].f1 = st.hetAtoms[h].coords.z; } if ($structure->{'hetAtoms'}->[$h]->{'coords'}->{'z'} > $structure->{'xyzExtremities'}->[2]->{'f2'}) { # if(st.hetAtoms[h].coords.z > st.xyzExtremities[2].f2){ $structure->{'xyzExtremities'}->[2]->{'f2'} = $structure->{'hetAtoms'}->[$h]->{'coords'}->{'z'}; # st.xyzExtremities[2].f2 = st.hetAtoms[h].coords.z; } } } # //cubing the atoms for faster processing// # noOfXCubes = (int)((st.xyzExtremities[0].f2 - st.xyzExtremities[0].f1) /cubeSize) + 1; $analyser->{'noOfXCubes'} = int (($structure->{'xyzExtremities'}->[0]->{'f2'} - $structure->{'xyzExtremities'}->[0]->{'f1'}) / $analyser->{'cubeSize'}) + 1; # noOfYCubes = (int)((st.xyzExtremities[1].f2 - st.xyzExtremities[1].f1) / cubeSize) + 1; $analyser->{'noOfYCubes'} = int (($structure->{'xyzExtremities'}->[1]->{'f2'} - $structure->{'xyzExtremities'}->[1]->{'f1'}) / $analyser->{'cubeSize'}) + 1; # noOfZCubes = (int)((st.xyzExtremities[2].f2 - st.xyzExtremities[2].f1) / cubeSize) + 1; $analyser->{'noOfZCubes'} = int (($structure->{'xyzExtremities'}->[2]->{'f2'} - $structure->{'xyzExtremities'}->[2]->{'f1'}) / $analyser->{'cubeSize'}) + 1; my $cubes; # vector *cubes = new vector[noOfXCubes * noOfYCubes * noOfZCubes]; my $XYZ = $analyser->{'noOfXCubes'} * $analyser->{'noOfYCubes'} * $analyser->{'noOfZCubes'}; for (my $init_index = 0; $init_index < $XYZ; $init_index++) { my @atom_vector; $cubes->[$init_index] = \@atom_vector; } if ($analyser->{'ignoreHet'} == 0) { # if(!ignoreHet){ $st_dot_hetAtoms_dot_size = $#{$structure->{'hetAtoms'}} + 1; for (my $e = 0; $e < $st_dot_hetAtoms_dot_size; $e++) { # for (unsigned int e = 0 ; e < st.hetAtoms.size(); e++){ # cubes[xyzToIndex( (int)((st.hetAtoms[e].coords.x - st.xyzExtremities[0].f1)/ cubeSize), # (int)((st.hetAtoms[e].coords.y - st.xyzExtremities[1].f1)/ cubeSize), # (int)((st.hetAtoms[e].coords.z - st.xyzExtremities[2].f1)/ cubeSize) )].push_back(&(st.hetAtoms[e])); my $v1 = int (($structure->{'hetAtoms'}->[$e]->{'coords'}->{'x'} - $structure->{'xyzExtremities'}->[0]->{'f1'}) / $analyser->{'cubeSize'}); my $v2 = int (($structure->{'hetAtoms'}->[$e]->{'coords'}->{'y'} - $structure->{'xyzExtremities'}->[1]->{'f1'}) / $analyser->{'cubeSize'}); my $v3 = int (($structure->{'hetAtoms'}->[$e]->{'coords'}->{'z'} - $structure->{'xyzExtremities'}->[2]->{'f1'}) / $analyser->{'cubeSize'}); my $v4 = Analyser_xyzToIndex( $v1, $v2, $v3 ); my $push_back_index = $#{$cubes->[$v4]} + 1; $cubes->[$v4]->[$push_back_index] = $structure->{'hetAtoms'}->[$e]; } } for (my $e = 0; $e < $st_dot_allAtoms_dot_size; $e++) { # for (unsigned int e = 0 ; e < st.allAtoms.size(); e++){ # cubes[xyzToIndex( (int)((st.allAtoms[e].coords.x - st.xyzExtremities[0].f1)/ cubeSize), # (int)((st.allAtoms[e].coords.y - st.xyzExtremities[1].f1)/ cubeSize), # (int)((st.allAtoms[e].coords.z - st.xyzExtremities[2].f1)/ cubeSize) )].push_back(&(st.allAtoms[e])); my $v1 = int (($structure->{'allAtoms'}->[$e]->{'coords'}->{'x'} - $structure->{'xyzExtremities'}->[0]->{'f1'}) / $analyser->{'cubeSize'}); my $v2 = int (($structure->{'allAtoms'}->[$e]->{'coords'}->{'y'} - $structure->{'xyzExtremities'}->[1]->{'f1'}) / $analyser->{'cubeSize'}); my $v3 = int (($structure->{'allAtoms'}->[$e]->{'coords'}->{'z'} - $structure->{'xyzExtremities'}->[2]->{'f1'}) / $analyser->{'cubeSize'}); my $v4 = Analyser_xyzToIndex( $v1, $v2, $v3 ); my $push_back_index = $#{$cubes->[$v4]} + 1; $cubes->[$v4]->[$push_back_index] = $structure->{'allAtoms'}->[$e]; } for (my $x = 0; $x < $analyser->{'noOfXCubes'}; $x++) { # for (unsigned int x = 0; x < noOfXCubes; x++){ for (my $y = 0; $y < $analyser->{'noOfYCubes'}; $y++) { # for (unsigned int y = 0; y < noOfYCubes; y++){ for (my $z = 0; $z < $analyser->{'noOfZCubes'}; $z++) { # for (unsigned int z = 0; z < noOfZCubes; z++){ my $closeCubes = Analyser_getSurroundingCubes( $x, $y, $z, $cubes ); # vector closeCubes = getSurroundingCubes(x,y,z,cubes); my $xyzToIndex = Analyser_xyzToIndex( $x, $y, $z ); my $print_close_size = $#{$closeCubes} + 1; my $currentCube = $cubes->[ $xyzToIndex ]; # vector currentCube = cubes[xyzToIndex(x,y,z)]; my $currentCube_dot_size = $#{$currentCube} + 1; for (my $i = 0; $i < $currentCube_dot_size; $i++) { # for (unsigned int i = 0; i < currentCube.size(); i++){ my $closeCubes_dot_size = $#{$closeCubes} + 1; for (my $j = 0; $j < $closeCubes_dot_size; $j++) { # for (unsigned int j = 0; j < closeCubes.size(); j++){ # float xyzDistance = (currentCube[i]->coords - closeCubes[j]->coords).lengthSqr(); my $v1 = Vec3_subtract_Vec3( $currentCube->[$i]->{'coords'}, $closeCubes->[$j]->{'coords'} ); my $xyzDistance = Vec3_lengthSqr( $v1 ); # float solventDistance =(currentCube[i]->solventRadii + # closeCubes[j]->solventRadii) * # (currentCube[i]->solventRadii + # closeCubes[j]->solventRadii); my $solventDistance = ($currentCube->[$i]->{'solventRadii'} + $closeCubes->[$j]->{'solventRadii'}) * ($currentCube->[$i]->{'solventRadii'} + $closeCubes->[$j]->{'solventRadii'}); if ($xyzDistance < $solventDistance) { # if (xyzDistance < solventDistance){ # currentCube[i]->closeAtoms.push_back(closeCubes[j]); my $push_back_index = $#{$currentCube->[$i]->{'closeAtoms'}} + 1; $currentCube->[$i]->{'closeAtoms'}->[$push_back_index] = $closeCubes->[$j]; # currentCube[i]->distances.push_back(xyzDistance); $push_back_index = $#{$currentCube->[$i]->{'distances'}} + 1; $currentCube->[$i]->{'distances'}->[$push_back_index] = $xyzDistance; } } $currentCube_dot_size = $#{$currentCube} + 1; for (my $k = $i + 1; $k < $currentCube_dot_size; $k++) { # for (unsigned int k = i + 1; k < currentCube.size(); k++){ # float xyzDistance = (currentCube[i]->coords - currentCube[k]->coords).lengthSqr(); my $v1 = Vec3_subtract_Vec3( $currentCube->[$i]->{'coords'}, $currentCube->[$k]->{'coords'} ); my $xyzDistance = Vec3_lengthSqr( $v1 ); # float solventDistance =(currentCube[i]->solventRadii + # currentCube[k]->solventRadii) * # (currentCube[i]->solventRadii + # currentCube[k]->solventRadii); my $solventDistance = ($currentCube->[$i]->{'solventRadii'} + $currentCube->[$k]->{'solventRadii'}) * ($currentCube->[$i]->{'solventRadii'} + $currentCube->[$k]->{'solventRadii'}); if ($xyzDistance < $solventDistance) { # if (xyzDistance < solventDistance){ # currentCube[i]->closeAtoms.push_back(currentCube[k]); my $push_back_index = $#{$currentCube->[$i]->{'closeAtoms'}} + 1; $currentCube->[$i]->{'closeAtoms'}->[$push_back_index] = $currentCube->[$k]; # currentCube[i]->distances.push_back(xyzDistance); $push_back_index = $#{$currentCube->[$i]->{'distances'}} + 1; $currentCube->[$i]->{'distances'}->[$push_back_index] = $xyzDistance; # currentCube[k]->closeAtoms.push_back(currentCube[i]); $push_back_index = $#{$currentCube->[$k]->{'closeAtoms'}} + 1; $currentCube->[$k]->{'closeAtoms'}->[$push_back_index] = $currentCube->[$i]; # currentCube[k]->distances.push_back(xyzDistance); $push_back_index = $#{$currentCube->[$k]->{'distances'}} + 1; $currentCube->[$k]->{'distances'}->[$push_back_index] = $xyzDistance; } } my $v = $currentCube->[$i]->{'closeAtoms'}; my $d = $currentCube->[$i]->{'distances'}; my $currentCube_i_distances_dot_size = $#{$currentCube->[$i]->{'distances'}} + 1; # quickSort(currentCube[i]->closeAtoms, # currentCube[i]->distances, # 0, # (int)currentCube[i]->distances.size()-1); Analyser_quickSort( $v, $d, 0, $currentCube_i_distances_dot_size - 1 ); $currentCube->[$i]->{'closeAtoms'} = $v; $currentCube->[$i]->{'distances'} = $d; } } } } $analyser->{'st'} = $structure; } sub Analyser_getSurroundingCubes { #C++ vector Analyser::getSurroundingCubes(int x, int y, int z, vector *a){ my $x = shift; my $y = shift; my $z = shift; my $a = shift; my $cubeIndices; # vector cubeIndices; # //x series # //if (xyzToIndex(x, y, z) > 0){ # // for (unsigned int i = 0; i < a[xyzToIndex(x, y, z)].size(); i++){ # // cubeIndices.push_back(a[xyzToIndex(x, y, z)][i]); # // } # //} my $xyzToIndex = Analyser_xyzToIndex( $x, $y, $z+1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x, y, z+1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x, y, z+1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x, y, z+1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x, $y, $z-1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x , y , z-1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x, y, z-1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x, y, z-1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x, $y+1, $z ); if ($xyzToIndex > 0) { # if (xyzToIndex(x, y+1, z) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x, y+1, z)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x, y+1, z)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x, $y+1, $z+1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x, y+1, z+1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x, y+1, z+1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x, y+1, z+1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x, $y+1, $z-1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x, y+1, z-1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x, y+1, z-1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x, y+1, z-1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x, $y-1, $z ); if ($xyzToIndex > 0) { # if (xyzToIndex(x, y-1, z) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x, y-1, z)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x, y-1, z)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x, $y-1, $z+1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x, y-1, z+1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x, y-1, z+1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x, y-1, z+1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x, $y-1, $z-1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x, y-1, z-1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x, y-1, z-1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x, y-1, z-1)][i]);} } } # //x+1 series $xyzToIndex = Analyser_xyzToIndex( $x+1, $y, $z ); if ($xyzToIndex > 0) { # if (xyzToIndex(x+1, y, z) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x+1, y, z)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x+1, y, z)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x+1, $y, $z+1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x+1, y, z+1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x+1, y, z+1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x+1, y, z+1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x+1, $y, $z-1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x+1 , y , z-1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x+1 , y , z-1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x+1 , y , z-1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x+1, $y+1, $z ); if ($xyzToIndex > 0) { # if (xyzToIndex(x+1, y+1, z) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x+1, y+1, z)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x+1, y+1, z)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x+1, $y+1, $z+1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x+1, y+1, z+1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x+1, y+1, z+1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x+1, y+1, z+1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x+1, $y+1, $z-1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x+1, y+1, z-1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x+1, y+1, z-1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x+1, y+1, z-1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x+1, $y-1, $z ); if ($xyzToIndex > 0) { # if (xyzToIndex(x+1, y-1, z) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x+1, y-1, z)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x+1, y-1, z)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x+1, $y-1, $z+1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x+1, y-1, z+1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x+1, y-1, z+1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x+1, y-1, z+1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x+1, $y-1, $z-1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x+1, y-1, z-1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x+1, y-1, z-1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x+1, y-1, z-1)][i]);} } } # //x-1 series $xyzToIndex = Analyser_xyzToIndex( $x-1, $y, $z ); if ($xyzToIndex > 0) { # if (xyzToIndex(x-1, y, z) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x-1, y, z)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x-1, y, z)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x-1, $y, $z+1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x-1, y, z+1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x-1, y, z+1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x-1, y, z+1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x-1, $y, $z-1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x-1 , y , z-1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x-1 , y , z-1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x-1 , y , z-1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x-1, $y+1, $z ); if ($xyzToIndex > 0) { # if (xyzToIndex(x-1, y+1, z) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x-1, y+1, z)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x-1, y+1, z)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x-1, $y+1, $z+1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x-1, y+1, z+1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x-1, y+1, z+1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x-1, y+1, z+1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x-1, $y+1, $z-1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x-1, y+1, z-1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x-1, y+1, z-1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x-1, y+1, z-1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x-1, $y-1, $z ); if ($xyzToIndex > 0) { # if (xyzToIndex(x-1, y-1, z) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x-1, y-1, z)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x-1, y-1, z)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x-1, $y-1, $z+1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x-1, y-1, z+1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x-1, y-1, z+1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x-1, y-1, z+1)][i]);} } } $xyzToIndex = Analyser_xyzToIndex( $x-1, $y-1, $z-1 ); if ($xyzToIndex > 0) { # if (xyzToIndex(x-1, y-1, z-1) > 0){ my $a_xyzToIndex_dot_size = $#{$a->[$xyzToIndex]} + 1; for (my $i = 0; $i < $a_xyzToIndex_dot_size; $i++ ) { # for (unsigned int i = 0; i < a[xyzToIndex(x-1, y-1, z-1)].size(); i++){ my $push_back_index = $#{$cubeIndices} + 1; $cubeIndices->[$push_back_index] = $a->[$xyzToIndex]->[$i]; # cubeIndices.push_back(a[xyzToIndex(x-1, y-1, z-1)][i]);} } } return $cubeIndices; # return cubeIndices; } sub Analyser_new { # // Construction/Destruction $analyser->{'cubeSize'} = 7; # float Analyser::cubeSize = 7.0f; $analyser->{'ABHigh'} = 114; # float Analyser::ABHigh = 114.0f; $analyser->{'ABLow'} = 40; # float Analyser::ABLow = 40.0f; $analyser->{'FPBHigh'} = 0.58; # float Analyser::FPBHigh = 0.58f; $analyser->{'FPBLow'} = 0.45; # float Analyser::FPBLow = 0.45f; $analyser->{'FPPartial'} = 0.67; # float Analyser::FPPartial = 0.67f; # //profiles scoring table # float Analyser::scores[18][20] = { # {1.11f,1.28f,0.27f,1.30f,1.11f,0.74f,1.26f,-0.77f,-2.22f,-1.56f,-0.43f,-1.72f,-2.43f,-1.38f,-1.76f,-2.15f,-2.48f,-0.34f,-1.37f,-1.80}, //B1alpha # {0.92f,0.96f,0.17f,1.07f,1.50f,1.18f,0.51f,-1.05f,-2.35f,-0.77f,-0.45f,-1.27f,-2.56f,-2.03f,-2.18f,-1.59f,-1.80f,-2.26f,-3.04f,-1.52}, //B1beta # {0.96f,1.40f,0.52f,1.06f,0.93f,1.00f,0.91f,-0.54f,-2.78f,0.59f,-0.59f,-1.41f,-2.99f,-0.84f,-2.61f,-2.01f,-2.63f,-0.61f,-2.78f,-2.35}, //B1 # # {1.01f,0.87f,0.86f,0.71f,0.55f,0.41f,1.02f,-0.65f,-2.04f,-0.97f,0.15f,-0.67f,-1.33f,0.16f,-0.48f,-0.58f,-0.80f,0.82f,-0.94f,-0.11}, //B2alpha # {0.83f,1.32f,1.30f,0.36f,1.08f,0.81f,0.49f,-1.52f,-2.22f,-0.86f,-0.72f,-1.14f,-0.82f,-0.79f,-0.26f,-0.20f,-2.08f,-0.05f,-0.83f,-0.41}, //B2beta # {1.62f,1.04f,1.14f,0.77f,0.81f,0.66f,1.00f,-0.81f,-1.71f,-0.07f,-0.62f,-1.03f,-1.23f,-0.87f,-0.56f,-1.13f,-1.7f,0.54f,-2.12f,-0.44}, //B2 # # {0.86f,-0.22f,0.50f,0.16f,-0.02f,-0.29f,0.87f,-0.44f,-1.09f,-1.11f,-1.38f,-0.69f,-1.01f,0.16f,-0.07f,0.09f,-0.43f,0.61f,0.56f,1.10}, //B3alpha # {0.07f,0.37f,1.09f,0.14f,0.26f,0.16f,-0.68f,-1.08f,-2.29f,-0.01f,-0.79f,-0.10f,-0.71f,0.52f,-0.33f,-0.42f,-0.76f,0.80f,0.35f,0.84}, //B3beta # {1.12f,0.71f,1.25f,0.29f,-0.54f,-0.40f,0.23f,-0.87f,-0.61f,-0.11f,-0.98f,-0.48f,-0.61f,0.10f,0.09f,-0.46f,-0.83f,1.04f,0.08f,0.71}, //B3 # # {-1.29f,-0.85f,-0.88f,-0.30f,-0.06f,0.30f,-0.42f,0.76f,-0.46f,-0.41f,0.95f,0.39f,0.47f,-0.32f,-0.58f,-0.43f,-0.28f,-0.91f,-0.50f,-0.51}, //P1alpha # {0.34f,-0.61f,-0.09f,-0.81f,0.09f,0.44f,-0.40f,0.59f,-0.22f,-0.65f,1.28f,0.95f,0.49f,-2.38f,-0.92f,-0.68f,-0.61f,-0.53f,-2.01f,-0.89}, //P1beta # {-1.25f,-1.29f,-1.40f,-0.33f,-0.28f,-0.09f,-0.90f,0.49f,-0.39f,0.64f,1.29f,0.55f,0.59f,-0.57f,-0.26f,-0.59f,0.34f,-1.21f,-0.72f,-0.88}, //P1 # # {-1.09f,-1.35f,-0.55f,-0.46f,-0.59f,-0.62f,-0.27f,-0.02f,-0.58f,-0.25f,-0.70f,-0.13f,-0.38f,0.62f,-0.02f,0.2f,0.29f,0.17f,0.66f,0.56}, //P2alpha # {-0.71f,-0.56f,-0.30f,-1.33f,-0.35f,0.08f,-0.76f,-0.52f,-0.87f,-1.01f,-0.87f,0.79f,0.49f,0.10f,0.00f,0.41f,-0.03f,-0.49f,0.55f,0.19}, //P2beta # {-0.42f,-0.84f,-0.43f,-0.68f,-0.94f,-0.74f,-0.83f,-0.25f,-0.42f,0.44f,-0.81f,0.08f,0.17f,0.25f,0.51f,0.28f,0.51f,0.20f,0.47f,0.24}, //P2 # # {-1.26f,-1.81f,-1.70f,-1.37f,-2.36f,-1.25f,-0.90f,0.44f,0.63f,0.05f,-0.17f,-0.20f,0.16f,0.29f,0.32f,0.60f,0.44f,-0.06f,0.07f,-0.20}, //Ealpha # {0.81f,-0.83f,-0.03f,-1.60f,-1.39f,-1.66f,-0.62f,0.14f,1.75f,-0.88f,-0.04f,-0.17f,0.65f,-0.12f,0.01f,-0.37f,-0.30f,-0.76f,-1.54f,-1.12}, //Ebeta # {-2.06f,-1.63f,-1.04f,-1.14f,-1.63f,0.80f,-1.30f,0.14f,1.10f,0.25f,-0.35f,0.08f,0.34f,-0.03f,0.41f,0.04f,0.23f,-0.41f,-0.10f,-0.41} # }; $analyser->{'scores'} = [ [1.11,1.28,0.27,1.30,1.11,0.74,1.26,-0.77,-2.22,-1.56,-0.43,-1.72,-2.43,-1.38,-1.76,-2.15,-2.48,-0.34,-1.37,-1.80], # //B1alpha [0.92,0.96,0.17,1.07,1.50,1.18,0.51,-1.05,-2.35,-0.77,-0.45,-1.27,-2.56,-2.03,-2.18,-1.59,-1.80,-2.26,-3.04,-1.52], # //B1beta [0.96,1.40,0.52,1.06,0.93,1.00,0.91,-0.54,-2.78,0.59,-0.59,-1.41,-2.99,-0.84,-2.61,-2.01,-2.63,-0.61,-2.78,-2.35], # //B1 [1.01,0.87,0.86,0.71,0.55,0.41,1.02,-0.65,-2.04,-0.97,0.15,-0.67,-1.33,0.16,-0.48,-0.58,-0.80,0.82,-0.94,-0.11], # //B2alpha [0.83,1.32,1.30,0.36,1.08,0.81,0.49,-1.52,-2.22,-0.86,-0.72,-1.14,-0.82,-0.79,-0.26,-0.20,-2.08,-0.05,-0.83,-0.41], # //B2beta [1.62,1.04,1.14,0.77,0.81,0.66,1.00,-0.81,-1.71,-0.07,-0.62,-1.03,-1.23,-0.87,-0.56,-1.13,-1.7,0.54,-2.12,-0.44], # //B2 [0.86,-0.22,0.50,0.16,-0.02,-0.29,0.87,-0.44,-1.09,-1.11,-1.38,-0.69,-1.01,0.16,-0.07,0.09,-0.43,0.61,0.56,1.10], # //B3alpha [0.07,0.37,1.09,0.14,0.26,0.16,-0.68,-1.08,-2.29,-0.01,-0.79,-0.10,-0.71,0.52,-0.33,-0.42,-0.76,0.80,0.35,0.84], # //B3beta [1.12,0.71,1.25,0.29,-0.54,-0.40,0.23,-0.87,-0.61,-0.11,-0.98,-0.48,-0.61,0.10,0.09,-0.46,-0.83,1.04,0.08,0.71], # //B3 [-1.29,-0.85,-0.88,-0.30,-0.06,0.30,-0.42,0.76,-0.46,-0.41,0.95,0.39,0.47,-0.32,-0.58,-0.43,-0.28,-0.91,-0.50,-0.51], # //P1alpha [0.34,-0.61,-0.09,-0.81,0.09,0.44,-0.40,0.59,-0.22,-0.65,1.28,0.95,0.49,-2.38,-0.92,-0.68,-0.61,-0.53,-2.01,-0.89], # //P1beta [-1.25,-1.29,-1.40,-0.33,-0.28,-0.09,-0.90,0.49,-0.39,0.64,1.29,0.55,0.59,-0.57,-0.26,-0.59,0.34,-1.21,-0.72,-0.88], # //P1 [-1.09,-1.35,-0.55,-0.46,-0.59,-0.62,-0.27,-0.02,-0.58,-0.25,-0.70,-0.13,-0.38,0.62,-0.02,0.2,0.29,0.17,0.66,0.56], # //P2alpha [-0.71,-0.56,-0.30,-1.33,-0.35,0.08,-0.76,-0.52,-0.87,-1.01,-0.87,0.79,0.49,0.10,0.00,0.41,-0.03,-0.49,0.55,0.19], # //P2beta [-0.42,-0.84,-0.43,-0.68,-0.94,-0.74,-0.83,-0.25,-0.42,0.44,-0.81,0.08,0.17,0.25,0.51,0.28,0.51,0.20,0.47,0.24], # //P2 [-1.26,-1.81,-1.70,-1.37,-2.36,-1.25,-0.90,0.44,0.63,0.05,-0.17,-0.20,0.16,0.29,0.32,0.60,0.44,-0.06,0.07,-0.20], # //Ealpha [0.81,-0.83,-0.03,-1.60,-1.39,-1.66,-0.62,0.14,1.75,-0.88,-0.04,-0.17,0.65,-0.12,0.01,-0.37,-0.30,-0.76,-1.54,-1.12], # //Ebeta [-2.06,-1.63,-1.04,-1.14,-1.63,0.80,-1.30,0.14,1.10,0.25,-0.35,0.08,0.34,-0.03,0.41,0.04,0.23,-0.41,-0.10,-0.41] ]; # ////for cubing atoms/// $analyser->{'noOfXCubes'} = 0; # unsigned int noOfXCubes; $analyser->{'$noOfYCubes'} = 0; # unsigned int noOfYCubes; $analyser->{'$noOfZCubes'} = 0; # unsigned int noOfZCubes; $analyser->{'st'} = $structure; # public: Structure st; return; } sub Analyser_partition { #C++ int Analyser::partition(vector & v,vector &d, int start, int end) my $v = shift; my $d = shift; my $start = shift; my $end = shift; use constant RAND_MAX => 32767; my $r = rand( RAND_MAX ); # int r = rand(); $r = $r % ($end - $start); # r = r%(end - start); $r = $r + $start; # r = r + start; my $partition = $d->[$r]; # float partition = d[r]; my $buffer; # float buffer; my $atomBuffer; # Atom* atomBuffer; my $s = $start - 1; # register int s = start-1; my $e = $end + 1; # register int e = end+1; while (1) { # while(true){ $e--; # do { e--; } while ($d->[$e] > $partition) { # while(d[e] > partition); $e--; } $s++; # do { s++; } while ($d->[$s] < $partition) { # while(d[s] < partition); $s++; } if ($s < $e) { # if(s < e){ $buffer = $d->[$s]; # buffer = d[s]; $d->[$s] = $d->[$e]; # d[s] = d[e]; $d->[$e] = $buffer; # d[e] = buffer; $atomBuffer = $v->[$s]; # atomBuffer = v[s]; $v->[$s] = $v->[$e]; # v[s] = v[e]; $v->[$e] = $atomBuffer; # v[e] = atomBuffer; } else { return $e; # return e; } } return -1; #return -1; } sub Analyser_quickSort { #C++ void Analyser::quickSort(vector &v, vector &d, int start, int end) my $v = shift; my $d = shift; my $start = shift; my $end = shift; if ($start < $end) { # if( start < end ) my $boundary = Analyser_partition( $v, $d, $start, $end ); # int boundary = partition(v,d,start,end); Analyser_quickSort( $v, $d, $start, $boundary ); # quickSort( v, d, start, boundary ); Analyser_quickSort( $v, $d, $boundary + 1, $end ); # quickSort( v, d, boundary + 1, end ); } } sub Analyser_SASA { #C++ void Analyser::SASA(int resolution) # Description of the PROFILES3D algorithm # ======================================= # # PROFILES3D is an algorithm that measures the compatibility of an amino acid sequence with a 3D protein structure, # producing an overall compatibility score (Bowie et al. 1991). # There is an extended version, called VERIFY3D, that plots a sliding window of PROFILES3D scores # for the residues in a sequence being compared to its proposed 3D structure, # in order to assess that 3D protein model (Lüthy et al. 1992). # It is assumed that the protein structure is for a water-soluble protein found in an aqueous environment. # The steps involved in calculating PROFILES3D scores are explained in Bowie et al. (1991) # and are briefly explained below. # # STEP 1 : For each residue in the 3D structure: # (i) calculate the total area of the side chain that is buried by other protein atoms; # (ii) calculate the fraction of the side chain area that is covered by polar atoms or water; and # (iii) read what the secondary structure (alpha helix, beta sheet or coil) is for that residue. # These calculations involve finding the solvent accessible surface area (SASA) # of the residue's side chain atoms in this particular 3D structure. # They also involve calculating the surface area of the side chain that is buried, # which is calculated by comparing the SASA in this protein # to what it is in the Gly-X-Gly tripeptides of Eisenberg et al. (1989). # # STEP 2 : Assign an environment class to each residue, # given the surface area and hydropathy of exposed and buried side chains, # as calculated in step 1, and given its secondary structure. # This converts a 3D protein structure into a 1D sequence of environment classes in place of amino acid residues. # ENVIRONMENT CLASS CODE ENVIRONMENT CLASS DESCRIPTION # B1 buried; covered by non-polar atoms # B2 buried; covered by polar and non-polar atoms # B3 buried; covered by polar atoms or water # P1 partially exposed; covered by non-polar atoms # P2 partially exposed; covered by polar atoms or water # E exposed # # STEP 3 : Make the PROFILES3D 3D structure profile for this 3D protein structure # (Gribskov et al. 1987; Gribskov et al. 1990). # For each residue in the protein, use its environment class to assign a score to each of the 20 amino acids. # The score is read from the precompiled PROFILES3D 3D-1D scoring table. # The score indicates how likely it is that the amino acid could exist in this position in the 3D structure. # For example, it is unlikely that a charged residue will be found buried in a nonpolar environment. # This produces a table that is similar to the PAM mutation data matrix of Dayhoff et al. (1978), # with a column for each of the 20 amino acids, # but where the rows represent positions in a 3D structure rather than being a list of the 20 amino acids. # # STEP 4 : For a given amino acid sequence for which you wish to see how compatible it is with the 3D structure # for which the PROFILES3D table has just been built, calculate the compatibility. # For each residue in the PROFILES3D table, observe what amino acid from the sequence is found in this residue position, # read off the PROFILES3D score for this amino acid, and add the score to the running total compatibility score. # The PROFILES3D method allows for insertions and deletions, # and so the dynamic programming algorithm (Needleman and Wunsch 1970; Smith and Waterman 1981) # needs to be used to find the optimal alignment of the sequence with the PROFILES3D table. # # THE PROFILES 3D-1D SCORING TABLE : # The 3D-1D scoring table contains the generally observed probabilities of finding each of the 20 amino acids # in each of the PROFILES3D environments classes and protein secondary structure types. # These were derived from 16 protein structures that were known as of 1991, # and aligned homologous sequences available at that time (Bowie et al. 1991; Lüthy et al. 1991). # Description of the REPIMPS algorithm # ==================================== # # REPIMPS = reverse-environment prediction of integral membrane protein structure # # REPIMPS is an algorithm that measures the compatibility of an amino acid sequence # with a 3D protein structure of an integral membrane protein, # producing an overall compatibility score (Dastmalchi et al. 2001). # It works in the same way as the PROFILES3D method, # except that the exposed surface area of a residue is considered to be exposed to a hydrophobic solvent # instead of being exposed to a hydrophilic aqueous environment. # Dastmalchi et al. (2001) describe an algorithm for correcting the buried and aqueous phase side chains # calculated for PROFILES3D so that they can be used in the REPIMPS model of hydrophobic solvent # to calculate compatibility of a sequence to a membrane protein 3D structure. # The REPIMPS method also describes how to predict the position of transmembrane segments in an amino acid sequence # (Dastmalchi et al. 2001). The sequence is folded into a single, long alpha helix, # with side chains automatically placed in a favorable rotamer. # The compatibility of each residue to a lipid alpha-helical environment is scored. # A sliding window of residue compatilibility scores with a smoothing function # is used to smooth the consecutive residue scores to a curve. # The particular combination of functions and parameters described in the Dastmalchi et al. (2001) paper # is a power spectrum of the fourier analysis at 100°, which corresponds to the periodicity of an alpha-helix, # and using a sliding window of 17 residues, # which is an average residue length of the transmembrane portion of transmembrane helices. # Transmembrane helices are predicted to occur where there are peaks in the curves # of smoothed residue compatibility scores, # as these are the areas with a high compatibility to the hydrophobic lipid environoment of the REPIMPS model. # Solvent Accessible Surface Area (SASA) algorithm # ================================================ # # A method for calculating the van der Waals surface of a protein molecule # was described by Lee and Richards (1971). In their calculations, # for each atom a sphere is centred at the atom's position, # and the atom is considered to have a radius equal to the sum of that of the atom and that of the solvent molecule. # The protein molecule's surface area is computed as the locus of the center of a solvent molecule # as it rolls over the protein making the maximum contact possible in the given 3D structure. # The Lee and Richards method involves modelling protein molecule slices. # Each slice traces the line of the molecule's surface at that cross-section slice. # The Shrake and Rupley method (Shrake and Rupley 1973) describes having “test points” # on the surface of each atom of each residue, # and testing whether the test point falls inside the radius of another atom. # Shrake and Rupley (1973) use a set of 92 test points per atom, # that are nearly uniformly distributed around the surface area of the atom. # Hydrogen atoms are ignored (because there are so many of them, and because they are so small # that they are considered to make only a small dint in the surface area of the atom they are bonded to). # Cubing algorithm # ================ # # The solvent accessible surface area (SASA) calculations for a 3D protein # require calculating how much of each atom is buried by other atoms in the protein. # If there are n atoms, then comparing each atom's coordinates to every other atom's coordinates # will take on the order of n2 amount of time # (or more precisely, the time is proportional n(n-1)/2 (Katz and Levinthal 1972)). # Using a cubing algorithm will reduce the number of comparisons necessary and thus reduce the processing time to do it. # The 3D protein is divided into 3D cubes. To identify buried surface areas, # each atom is compared only to atoms in its own cube and to atoms in the 26 neighbouring cubes to this atom's cube. # This "cube-testing" procedure was first developed at the Massachusetts Institute of Technology (Levinthal 1966) # and is used extensively in computer programs dealing with distances and energies of atoms in molecules. # To further speed up the calculations, these neighbouring atoms and neighbouring cube atoms are sorted by distance. # The Quicksort algorithm is a sorting method that could be used. # On average, Quicksort takes n log n amount of time, depending on how unsorted or reverse sorted the set of data is. # References # ========== # # Bowie,J.U., Lüthy,R. and Eisenberg,D. (1991) A method to identify protein sequences that fold into a known three-dimensional structure. Science, 253, 164-170. # Dastmalchi,S., Morris,M.B. and Church,W.B. (2001) Modelling of the structural features of integral-membrane proteins using REPIMPS. Protein Science 10, 1529-1538. # Dayhoff,M.O., Schwartz,R.M. and Orcutt,B.C. (1978) A model of evolutionary change in proteins. In Dayhoff,M.O. (ed) Atlas of Protein Sequence and Structure vol 5 suppl 3 (pp.345-352) Washington, DC: National Biomedical Research Foundation. # Eisenberg,D., Wesson,M. and Yamashita,M. (1989) Interpretation of protein folding and binding with atomic solvation parameters. Chemica Scripta 29A, 217-221. # Gribskov,M., McLachlan,A.D. and Eisenberg,D. (1987) Profile analysis: Detection of distantly related proteins. Biochemistry 84, 4355-4358. # Gribskov,M., Lüthy,R. and Eisenberg,D. (1990) Profile Analysis. Methods in Enzymology 183, 146-159. # Lee,B. and Richards,F.M. (1971) The Interpretation of Protein Structures: Estimation of Static Accessibility. Journal of Molecular Biology 55, 379-490. # Levinthal,C. (1966) Molecular model-building by computer. Scientific American. 214, 42-52. # Luthy,R., McLachlan,A.D. and Eisenberg,D. (1991) Secondary structure-based profiles: Use of structure-conserving scoring tables in searching protein sequence databases for structural similarities. Proteins: Structure, Function, and Genetics 10, 229-239. # Luthy,R., Bowie,J.U. and Eisenberg,D. (1992) Assessment of protein models with three-dimensional profiles. Nature, 356, 83-85. # Needleman,S.B. and Wunsch,C.D. (1970) A general method applicable to the search for similarities in the amino acid sequence of two proteins. Journal of Molecular Biology 48, 443. # Shrake,A. and Rupley,J.A. (1973) Environment and exposure to solvent of protein atoms lysozyme and insulin. Journal of Molecular Biology 79, 361-371. # Smith,T.F. and Waterman,M.S. (1981) Identification of common molecular subsequences. Advances in Applied Mathematics 2, 482. # for each point on the surface of a residue: # if the point is not buried, then it is a surface point and it is considered to be a polar point # if the point is buried, then it is a surface point, # and it is considered to be a polar point only if it really is polar (truly-polar) # for each residue : # 'solventSurface' solvent surface area = the surface area of this residue when not in a structure/helix # = add up the surface area of each atom in this residue when in this particular amino acid # surfPoints = surface point, whether or not it is buried in this particular helix or 3D protein structure # ASA = accessible surface area = ASA for this residue in this particular helix or 3D protein structure # = ( (num points - num buried points) / num points ) * solvent surface area # = ( num not-buried points / num points ) * 'solventSurface' solvent surface area # exp_SC_points = exposed-to-polar-environment side chain points # = buried polar points + all not buried points (because assumed to be in polar environment0 # all_SC_points = all side chain points = CA.surface_points + surface_points of each side chain atom # = all not buried points + all buried points # side_ASA = side chain ASA = CA.ASA + ASA of each side chain atom, # in this particular helix or 3D protein structure # areaBuried = side chain GlyXGly - side chain ASA # fractionPolar = fraction polar of side chain = exposed side chain points / all side chain points # = exposed-to-polar-environment side chain points / all side chain surface (whether buried or not, whether polar all not) # = (buried polar side chain points + all not buried points) / all side chain points # repimpsFP = repimps fraction polar = fraction polar - (side chain ASA / side chain GlyXGly) # = fraction polar - fraction of non-buried ASA compared to a free standing residue having no other residue atoms in the 3D structure or helix covering this residue's side chains # = ( (buried polar side chain points + all not buried points) / all side chain points) # - fraction of non-buried ASA compared to a free standing residue # repimpsFP : should = exposed-to-polar-environment side chain points / all side chain surface (whether buried or not, whether polar all not) # = buried polar side chain points / all side chain points # repimpsFP numerator does not include any of the non-buried side chain points, # because they are now assumed to be exposed to non-polar solvent and are not polar, # and so not included in the polar fraction for repimps. # (side chain ASA / side chain GlyXGly) is the fraction that is exposed to solvent. # In fractionPolar, it is assumed to be polar - exposed to polar solvent. # But in repimpsFP, it is assumed to be non-polar - exposed to non-polar solvent. # So remove this now-non-polar fraction from the fractionPolar total fraction, # to give the remaining reimpsFP polar fraction # as being only the fraction of the side chain that is buried AND polar. # Here is the key for how PROFILES3D and REPIMPS assume the side chain residues look like : # # = : a buried residue # . : a non-buried residue # + : a polar residue # : a non-polar residue # # # Here is how PROFILES3D assumes the side chain residues look like : # # buried vs. non-buried : ==============.....................................====================== # polar vs. non-polar : ++ +++++++++++++++++++++++++++++++++++++ ++ ++ # # # Here is how REPIMPS assumes the side chain residues look like : # # buried vs. non-buried : ==============.....................................====================== # polar vs. non-polar : ++ ++ ++ # # # As shown above, polar buried vs. non-polar buried residues are the same. # But for the solvent-accessible residues, # PROFILES3D assumes they are polar and REPIMPS assumes they are non-polar. # There currently is a problem with the implementation of this algorithm. # Sometimes we a negative number for "Area Buried". # Area-buried = side-chain-Gly-X-Gly-area - side-chain-ASA. # Side-chain-ASA was calculated from counting the number of points buried versus the number of points # (these are points evenly distributed around the sphere), # and multiplying that by the solvent-surface for that type of atom. # The solvent-surface was calculated as the sum of all the ASA of the side-chain atoms and alpha-carbon. # And the atom ASA are calculated as 4*pi*radius*radius # The side-chain-Gly-X-Gly-area are hard-coded, and the side-chain-ASA are calculated as above, # and that calculation doesn't take into account the overlap of atoms in the residue. # So for the bigger residues, when the residue is not buried # and so the side-chain-ASA is the full side-chain-ASA # (and hasn't been reduced by the buried versus all-points fraction), # then the calculated side-chain-ASA is larger than the Gly-X-Gly, # and thus the subtraction leads to a negative number. my $resolution = shift; $structure = $analyser->{'st'}; # ////////////local variables////////////////// my $genVec; #C++ vector # vector genVec; //vector template my $isBuried = 0; # bool isBuried = false; # Analyser::logFile<<"Creating structure "<{'allResidues'}} + 1; for (my $r = 0; $r < $st_dot_allResidues_dot_size; $r++ ) { # for (unsigned int r = 0; r < st.allResidues.size(); r++){ $structure->{'allResidues'}->[$r]->{'main_ASA'} = 0; # st.allResidues[r].main_ASA = 0.0; $structure->{'allResidues'}->[$r]->{'side_ASA'} = 0; # st.allResidues[r].side_ASA = 0.0; $structure->{'allResidues'}->[$r]->{'all_SC_points'} = 0; # st.allResidues[r].all_SC_points = 0; $structure->{'allResidues'}->[$r]->{'exp_SC_points'} = 0; # st.allResidues[r].exp_SC_points = 0; } $structure->{'ASA'} = 0; # st.ASA = 0.0; my $genVec_dot_size = $#{$genVec} + 1; my $no_of_points = $genVec_dot_size; # const unsigned int no_of_points = (int)genVec.size(); # ProgDlg prog; # prog.Create(IDD_PROGRESS); # prog.ShowWindow(SW_SHOWNORMAL); # prog.setText("Calculating solvent accessible surface area..."); # ///////calculating SASA/////////// my $st_dot_allAtoms_dot_size = $#{$structure->{'allAtoms'}} + 1; for (my $i = 0; $i < $st_dot_allAtoms_dot_size; $i++ ) { # for (unsigned int i = 0; i < st.allAtoms.size(); i++){ my $buried = 0; # int buried = 0; $structure->{'allAtoms'}->[$i]->{'polarPoints'} = 0; # st.allAtoms[i].polarPoints = 0; $structure->{'allAtoms'}->[$i]->{'surfPoints'} = 0; # st.allAtoms[i].surfPoints = 0; my $genVec_dot_size = $#{$genVec} + 1; for (my $v = 0; $v < $genVec_dot_size; $v++ ) { # for (unsigned int v = 0; v < genVec.size(); v++){ # // to specify point l(t) = C + bt vector in parametric form # // C is the centre of the atom, b is the generic vector # // t is the time or radial length # ////////////////////////////////////////////////////////// my $temp1 = Vec3_multiply_number( $genVec->[$v], $structure->{'allAtoms'}->[$i]->{'solventRadii'} ); my $p = Vec3_add_Vec3( $structure->{'allAtoms'}->[$i]->{'coords'}, $temp1 ); # Vec3f p = st.allAtoms[i].coords + # (genVec[v] * st.allAtoms[i].solventRadii); my $st_dot_allAtoms_dot_closeAtoms_dot_size = $#{$structure->{'allAtoms'}->[$i]->{'closeAtoms'}} + 1; for (my $j = 0; ($j < $st_dot_allAtoms_dot_closeAtoms_dot_size) && (!$isBuried); $j++ ) { # for(unsigned int j = 0; j < st.allAtoms[i].closeAtoms.size() # && !isBuried; j++){ my $term1 = $structure->{'allAtoms'}->[$i]->{'closeAtoms'}->[$j]->{'coords'}; my $temp2 = Vec3_subtract_Vec3( $p, $term1 ); my $temp2sqr = Vec3_lengthSqr( $temp2 ); my $term2 = $structure->{'allAtoms'}->[$i]->{'closeAtoms'}->[$j]->{'solventRadii'}; my $temp3 = $term2 * $term2; if ( $temp2sqr < $temp3 ) { # if ((p - st.allAtoms[i].closeAtoms[j]->coords).lengthSqr() # < st.allAtoms[i].closeAtoms[j]->solventRadii * # st.allAtoms[i].closeAtoms[j]->solventRadii){ $buried++; # buried++; $isBuried = 1; # isBuried = true; my $term4 = $structure->{'allAtoms'}->[$i]->{'closeAtoms'}->[$j]->{'resSeq'}; if ( $structure->{'allAtoms'}->[$i]->{'resSeq'} != $term4 ) { # if( st.allAtoms[i].resSeq != # st.allAtoms[i].closeAtoms[j]->resSeq ){ $structure->{'allAtoms'}->[$i]->{'surfPoints'} += 1; #st.allAtoms[i].surfPoints++; my $term5 = $structure->{'allAtoms'}->[$i]->{'closeAtoms'}->[$j]->{'isPolar'}; if ( $term5 ) { # if (st.allAtoms[i].closeAtoms[j]->isPolar){ $structure->{'allAtoms'}->[$i]->{'polarPoints'} += 1; # st.allAtoms[i].polarPoints++; } } } } if (!$isBuried) { # if (!isBuried){ $structure->{'allAtoms'}->[$i]->{'polarPoints'} += 1; # st.allAtoms[i].polarPoints++; $structure->{'allAtoms'}->[$i]->{'surfPoints'} += 1; # st.allAtoms[i].surfPoints++; } $isBuried = 0; # isBuried = false; } # st.allAtoms[i].ASA = ( ((float)no_of_points - (float)buried) / (float)no_of_points ) # * st.allAtoms[i].solventSurface; $structure->{'allAtoms'}->[$i]->{'ASA'} = ( ($no_of_points - $buried) / $no_of_points ) * $structure->{'allAtoms'}->[$i]->{'solventSurface'}; } my $atomIndex; # unsigned int atomIndex; //copy of index for convenience $st_dot_allResidues_dot_size = $#{$structure->{'allResidues'}} + 1; for (my $t = 0; $t < $st_dot_allResidues_dot_size; $t++ ) { # for (unsigned int t = 0; t < st.allResidues.size(); t++){ my $haha = $structure->{'allResidues'}->[$t]; # Residue haha = st.allResidues[t]; # //////main chain ASA//// if ( Residue_checkMainChain( $structure->{'allResidues'}->[$t] ) ) { # if(st.allResidues[t].checkMainChain()){ my $temp1 = $structure->{'allResidues'}->[$t]->{'C'}; $structure->{'allResidues'}->[$t]->{'main_ASA'} += $structure->{'allAtoms'}->[$temp1]->{'ASA'}; # st.allResidues[t].main_ASA += st.allAtoms[st.allResidues[t].C].ASA; my $temp2 = $structure->{'allResidues'}->[$t]->{'O'}; $structure->{'allResidues'}->[$t]->{'main_ASA'} += $structure->{'allAtoms'}->[$temp2]->{'ASA'}; #st.allResidues[t].main_ASA += st.allAtoms[st.allResidues[t].O].ASA; my $temp3 = $structure->{'allResidues'}->[$t]->{'N'}; $structure->{'allResidues'}->[$t]->{'main_ASA'} += $structure->{'allAtoms'}->[$temp3]->{'ASA'}; # st.allResidues[t].main_ASA += st.allAtoms[st.allResidues[t].N].ASA; # //alpha carbon is taken as part of a side chain my $temp4 = $structure->{'allResidues'}->[$t]->{'CA'}; $structure->{'allResidues'}->[$t]->{'side_ASA'} += $structure->{'allAtoms'}->[$temp4]->{'ASA'}; # st.allResidues[t].side_ASA += st.allAtoms[st.allResidues[t].CA].ASA; $structure->{'allResidues'}->[$t]->{'all_SC_points'} += $structure->{'allAtoms'}->[$temp4]->{'surfPoints'}; # st.allResidues[t].all_SC_points += st.allAtoms[st.allResidues[t].CA].surfPoints; $structure->{'allResidues'}->[$t]->{'exp_SC_points'} += $structure->{'allAtoms'}->[$temp4]->{'polarPoints'}; # st.allResidues[t].exp_SC_points += st.allAtoms[st.allResidues[t].CA].polarPoints; } else { # //print error in log file here, missing main chain atoms # logFile << "Warning!! - residue "<{'allResidues'}->[$t]->{'name'} . " missing main chain atoms. Scores may be incorrect\n"; $structure->{'allResidues'}->[$t]->{'all_SC_points'} = 1; # st.allResidues[t].all_SC_points = 1; $structure->{'allResidues'}->[$t]->{'exp_SC_points'} = 1; # st.allResidues[t].exp_SC_points = 1; } $haha = $structure->{'allResidues'}->[$t]; # haha = st.allResidues[t]; # ///////handling side chain atoms////////// my $st_dot_allResidues_dot_sideChains_dot_size = $#{$structure->{'allResidues'}->[$t]->{'sideChains'}} + 1; for (my $s = 0; $s < $st_dot_allResidues_dot_sideChains_dot_size; $s++ ) { # for (unsigned int s = 0; s < st.allResidues[t].sideChains.size(); s++){ my $atomIndex = $structure->{'allResidues'}->[$t]->{'sideChains'}->[$s]; # atomIndex = st.allResidues[t].sideChains[s]; $structure->{'allResidues'}->[$t]->{'side_ASA'} += $structure->{'allAtoms'}->[$atomIndex]->{'ASA'}; # st.allResidues[t].side_ASA += st.allAtoms[atomIndex].ASA; $structure->{'allResidues'}->[$t]->{'exp_SC_points'} += $structure->{'allAtoms'}->[$atomIndex]->{'polarPoints'}; # st.allResidues[t].exp_SC_points += st.allAtoms[atomIndex].polarPoints; $structure->{'allResidues'}->[$t]->{'all_SC_points'} += $structure->{'allAtoms'}->[$atomIndex]->{'surfPoints'}; # st.allResidues[t].all_SC_points += st.allAtoms[atomIndex].surfPoints; } if ($structure->{'allResidues'}->[$t]->{'aaCode'} == UNK) { # if (st.allResidues[t].aaCode == UNK){ $structure->{'allResidues'}->[$t]->{'areaBuried'} = 0; # st.allResidues[t].areaBuried = 0.0f; $structure->{'allResidues'}->[$t]->{'fractionPolar'} = 0; # st.allResidues[t].fractionPolar = 0.0f; $structure->{'allResidues'}->[$t]->{'repimpsFP'} = 0; # st.allResidues[t].repimpsFP = 0.0f; # //print log file error here, unknown residue type # logFile << "Warning!! Unknown residue type, residue: "<{'allResidues'}->[$t]->{'resSeq'} . " chain: " . $structure->{'allResidues'}->[$t]->{'chainID'} . "\n"; } else{ # st.allResidues[t].areaBuried = SCGlyXGly[st.allResidues[t].aaCode] - # st.allResidues[t].side_ASA ; my $temp4 = $structure->{'allResidues'}->[$t]->{'aaCode'}; $structure->{'allResidues'}->[$t]->{'areaBuried'} = $SCGlyXGly->[$temp4] - $structure->{'allResidues'}->[$t]->{'side_ASA'}; # st.allResidues[t].fractionPolar = (float)st.allResidues[t].exp_SC_points / # (float)st.allResidues[t].all_SC_points ; $structure->{'allResidues'}->[$t]->{'fractionPolar'} = $structure->{'allResidues'}->[$t]->{'exp_SC_points'} / $structure->{'allResidues'}->[$t]->{'all_SC_points'}; # st.allResidues[t].repimpsFP = st.allResidues[t].fractionPolar - # st.allResidues[t].side_ASA / # SCGlyXGly[st.allResidues[t].aaCode]; $temp4 = $structure->{'allResidues'}->[$t]->{'aaCode'}; $structure->{'allResidues'}->[$t]->{'repimpsFP'} = $structure->{'allResidues'}->[$t]->{'fractionPolar'} - $structure->{'allResidues'}->[$t]->{'side_ASA'} / $SCGlyXGly->[$temp4]; } $haha = $structure->{'allResidues'}->[$t]; # haha = st.allResidues[t]; $structure->{'ASA'} += $structure->{'allResidues'}->[$t]->{'main_ASA'}; # st.ASA += st.allResidues[t].main_ASA; $structure->{'ASA'} += $structure->{'allResidues'}->[$t]->{'side_ASA'}; # st.ASA += st.allResidues[t].side_ASA; } # prog.DestroyWindow(); $analyser->{'st'} = $structure; return; } sub Analyser_setOverallScores { #C++ void Analyser::setOverallScores(void) $structure = $analyser->{'st'}; $structure->{'scoreTotal'} = 0; # st.scoreTotal = 0.0f; my $st_dot_allResidues_dot_size = $#{$structure->{'allResidues'}} + 1; for ( my $i = 0; $i < $st_dot_allResidues_dot_size; $i++ ) { # for(unsigned int i = 0; i < st.allResidues.size(); i++){ my $this_residue_profiles3d_score = $structure->{'allResidues'}->[$i]->{'scores'}->[0]; my $this_residue_repimps_score = $structure->{'allResidues'}->[$i]->{'scores'}->[1]; if ($this_residue_profiles3d_score >= $this_residue_repimps_score) { $structure->{'allResidues'}->[$i]->{'scores'}->[2] = $this_residue_profiles3d_score; } else { $structure->{'allResidues'}->[$i]->{'scores'}->[2] = $this_residue_repimps_score; } $structure->{'scoreTotal'} += $structure->{'allResidues'}->[$i]->{'scores'}->[2]; # st.scoreTotal+=st.allResidues[i].scores[2]; } $structure->{'aveResScore'} = $structure->{'scoreTotal'} / $st_dot_allResidues_dot_size; # st.aveResScore = st.scoreTotal/st.allResidues.size(); $analyser->{'st'} = $structure; return; } sub Analyser_xyzToIndex { #C++ int Analyser::xyzToIndex(int x, int y, int z){ my $x = shift; my $y = shift; my $z = shift; if (($x < 0) || ($y < 0) || ($z < 0) || # if (x < 0 || y < 0 || z < 0 || ($x >= $analyser->{'noOfXCubes'}) || ($y >= $analyser->{'noOfYCubes'}) || ($z >= $analyser->{'noOfZCubes'})) { # x >= noOfXCubes || y >= noOfYCubes ||z >= noOfZCubes){ return -1; # return -1; } # return z*noOfXCubes*noOfYCubes + noOfXCubes*y + x; my $rtn_var = ($z * $analyser->{'noOfXCubes'} * $analyser->{'noOfYCubes'}) + ($analyser->{'noOfXCubes'} * $y) + $x; return $rtn_var; } sub Atom_default_values { my $atom; # //initialise Wan Der Waals radii with default values $atom->{ 'CARadii' } = 2; # float Atom::CARadii = 2.0f; $atom->{ 'CRadii' } = 1.5; # float Atom::CRadii = 1.5f; $atom->{ 'ORadii' } = 1.4; # float Atom::ORadii = 1.4f; $atom->{ 'NRadii' } = 1.5; # float Atom::NRadii = 1.5f; $atom->{ 'SolventRadii' } = 1.4; # float Atom::SolventRadii = 1.4f; $atom->{ 'S_ALL' } = 1.85; # float Atom::S_ALL = 1.85f; $atom->{ 'C_ARO' } = 1.85; # float Atom::C_ARO = 1.85f; # //Initialise Solvent Sphere Surface with Default Values 4*pi*r^2 my $pi4 = 4 * PI; # float Atom::CASurface = 4.0f * pi * (CARadii + SolventRadii) * (CARadii + SolventRadii); $atom->{ 'CASurface' } = $pi4 * ($atom->{ 'CARadii' } + $atom->{ 'SolventRadii' }) * ($atom->{ 'CARadii' } + $atom->{ 'SolventRadii' }); # float Atom::CSurface = 4.0f * pi * (CRadii + SolventRadii) * (CRadii + SolventRadii); $atom->{ 'CSurface' } = $pi4 * ($atom->{ 'CRadii' } + $atom->{ 'SolventRadii' }) * ($atom->{ 'CRadii' } + $atom->{ 'SolventRadii' }); # float Atom::OSurface = 4.0f * pi * (ORadii + SolventRadii) * (ORadii + SolventRadii); $atom->{ 'OSurface' } = $pi4 * ($atom->{ 'ORadii' } + $atom->{ 'SolventRadii' }) * ($atom->{ 'ORadii' } + $atom->{ 'SolventRadii' }); # float Atom::NSurface = 4.0f * pi * (NRadii + SolventRadii) * (NRadii + SolventRadii); $atom->{ 'NSurface' } = $pi4 * ($atom->{ 'NRadii' } + $atom->{ 'SolventRadii' }) * ($atom->{ 'NRadii' } + $atom->{ 'SolventRadii' }); # float Atom::C_ARO_Surface = 4.0f * pi * (C_ARO + SolventRadii) * (C_ARO + SolventRadii); $atom->{ 'C_ARO_Surface' } = $pi4 * ($atom->{ 'C_ARO' } + $atom->{ 'SolventRadii' }) * ($atom->{ 'C_ARO' } + $atom->{ 'SolventRadii' }); # float Atom::S_ALL_Surface = 4.0f * pi * (S_ALL + SolventRadii) * (S_ALL + SolventRadii); $atom->{ 'S_ALL_Surface' } = $pi4 * ($atom->{ 'S_ALL' } + $atom->{ 'SolventRadii' }) * ($atom->{ 'S_ALL' } + $atom->{ 'SolventRadii' }); return $atom; } sub Atom_new { #C++ Atom::Atom() my %atom_hash; my $atom = \%atom_hash; $atom->{ 'polarPoints' } = 0; # polarPoints = 0; $atom->{ 'surfPoints' } = 0; # surfPoints = 0; $atom->{ 'coords' }->{ 'x' } = 0; # coords.x = 0.0f; $atom->{ 'coords' }->{ 'y' } = 0; $atom->{ 'coords' }->{ 'z' } = 0; $atom->{ 'isHet' } = 0; # isHet = false; $atom->{ 'name' } = ''; $atom->{ 'aType' } = ''; $atom->{ 'aaCode' } = ''; # //initialise Wan Der Waals radii with default values $atom->{ 'CARadii' } = $atom_default_values->{ 'CARadii' }; # float Atom::CARadii = 2.0f; $atom->{ 'CRadii' } = $atom_default_values->{ 'CRadii' }; # float Atom::CRadii = 1.5f; $atom->{ 'ORadii' } = $atom_default_values->{ 'ORadii' }; # float Atom::ORadii = 1.4f; $atom->{ 'NRadii' } = $atom_default_values->{ 'NRadii' }; # float Atom::NRadii = 1.5f; $atom->{ 'SolventRadii' } = $atom_default_values->{ 'SolventRadii' }; # float Atom::SolventRadii = 1.4f; $atom->{ 'S_ALL' } = $atom_default_values->{ 'S_ALL' }; # float Atom::S_ALL = 1.85f; $atom->{ 'C_ARO' } = $atom_default_values->{ 'C_ARO' }; # float Atom::C_ARO = 1.85f; # //Initialise Solvent Sphere Surface with Default Values 4*pi*r^2 # float Atom::CASurface = 4.0f * pi * (CARadii + SolventRadii) * (CARadii + SolventRadii); $atom->{ 'CASurface' } = $atom_default_values->{ 'CASurface' }; # float Atom::CSurface = 4.0f * pi * (CRadii + SolventRadii) * (CRadii + SolventRadii); $atom->{ 'CSurface' } = $atom_default_values->{ 'CSurface' }; # float Atom::OSurface = 4.0f * pi * (ORadii + SolventRadii) * (ORadii + SolventRadii); $atom->{ 'OSurface' } = $atom_default_values->{ 'OSurface' }; # float Atom::NSurface = 4.0f * pi * (NRadii + SolventRadii) * (NRadii + SolventRadii); $atom->{ 'NSurface' } = $atom_default_values->{ 'NSurface' }; # float Atom::C_ARO_Surface = 4.0f * pi * (C_ARO + SolventRadii) * (C_ARO + SolventRadii); $atom->{ 'C_ARO_Surface' } = $atom_default_values->{ 'C_ARO_Surface' }; # float Atom::S_ALL_Surface = 4.0f * pi * (S_ALL + SolventRadii) * (S_ALL + SolventRadii); $atom->{ 'S_ALL_Surface' } = $atom_default_values->{ 'S_ALL_Surface' }; return $atom; #C++ Atom } # //sets the atom type and the corresponding radii and surface areas sub Atom_setAtomType { #C++ void Atom::setAtomType(Residue &r, unsigned int i) my $atom = shift; #C++ Atom my $r = shift; #C++ Residue my $i = shift; #C++ unsigned int if ($atom->{'name'} eq '') { # if (name.empty()){ return; # return; } # ////main chain atoms/////// if ($atom->{'name'} eq 'N') { # if ( name == "N" ){ $atom->{'aType'} = N_All; # aType = N_All; $r->{'N'} = $i; # r.N = i; } elsif ($atom->{'name'} eq 'CA') { # else if ( name == "CA" ){ $atom->{'aType'} = C_Ali; # aType = C_Ali; $r->{'CA'} = $i; # r.CA = i; } elsif ($atom->{'name'} eq 'C') { # else if ( name == "C" ){ $atom->{'aType'} = C_Car; # aType = C_Car; $r->{'C'} = $i; # r.C = i; } elsif ($atom->{'name'} eq 'O') { # else if ( name == "O" ){ $atom->{'aType'} = O_All; # aType = O_All; $r->{'O'} = $i; # r.O = i; # ///////side chain atoms////////// } else { # else { my $push_back_index = $#{$r->{'sideChains'}} + 1; $r->{'sideChains'}->[$push_back_index] = $i; # r.sideChains.push_back(i); if ( substr($atom->{'name'},0,1) eq 'O') { # if (name[0] == 'O'){ $atom->{'aType'} = O_All; # aType = O_All; } elsif ( substr($atom->{'name'},0,1) eq 'N') { # else if (name[0] == 'N'){ $atom->{'aType'} = N_All; # aType = N_All; } else { # else{ if ($atom->{'aType'} eq '') { # if (aType == NULL){ $atom->{'aType'} = C_Car; # aType = C_Car; } Atom_setSCType( $atom, $r ); # setSCType(r); } } Atom_setRadii( $atom ); # setRadii(); } sub Atom_setRadii { #C++ void Atom::setRadii() my $atom = shift; #C++ Atom # switch (aType){ if ($atom->{'aType'} eq C_Ali) { # case C_Ali: $atom->{'solventRadii'} = $atom->{'CARadii'} + $atom->{'SolventRadii'}; # solventRadii = CARadii + SolventRadii; $atom->{'solventSurface'} = $atom->{'CASurface'}; # solventSurface = CASurface; # //4.pi.r^2 $atom->{'isPolar'} = 0; # isPolar = false; # break; } elsif ($atom->{'aType'} eq C_Car) { # case C_Car: $atom->{'solventRadii'} = $atom->{'CRadii'} + $atom->{'SolventRadii'}; # solventRadii = CRadii + SolventRadii; $atom->{'solventSurface'} = $atom->{'CSurface'}; # solventSurface = CSurface; # //4.pi.r^2 $atom->{'isPolar'} = 0; # isPolar = false; # break; # //edited } elsif ($atom->{'aType'} eq C_Aro) { # case C_Aro: $atom->{'solventRadii'} = $atom->{'C_ARO'} + $atom->{'SolventRadii'}; # solventRadii = C_ARO + SolventRadii; $atom->{'solventSurface'} = $atom->{'C_ARO_Surface'}; # solventSurface = C_ARO_Surface; # //4.pi.r^2 $atom->{'isPolar'} = 0; # isPolar = false; # break; } elsif ($atom->{'aType'} eq N_All) { # case N_All: $atom->{'solventRadii'} = $atom->{'NRadii'} + $atom->{'SolventRadii'}; # solventRadii = NRadii + SolventRadii; $atom->{'solventSurface'} = $atom->{'NSurface'}; # solventSurface = NSurface; # //4.pi.r^2 $atom->{'isPolar'} = 1; # isPolar = true; # break; } elsif ($atom->{'aType'} eq O_All) { # case O_All: $atom->{'solventRadii'} = $atom->{'ORadii'} + $atom->{'SolventRadii'}; # solventRadii = ORadii + SolventRadii; $atom->{'solventSurface'} = $atom->{'OSurface'}; # solventSurface = OSurface; # //4.pi.r^2 $atom->{'isPolar'} = 1; # isPolar = true; # break; } elsif ($atom->{'aType'} eq S_Oxy) { # case S_Oxy: $atom->{'solventRadii'} = $atom->{'S_ALL'} + $atom->{'SolventRadii'}; # solventRadii = S_ALL + SolventRadii; $atom->{'solventSurface'} = $atom->{'S_ALL_Surface'}; # solventSurface = S_ALL_Surface; # //4.pi.r^2 $atom->{'isPolar'} = 0; # isPolar = false; # break; } elsif ($atom->{'aType'} eq S_Red) { # case S_Red: $atom->{'solventRadii'} = $atom->{'S_ALL'} + $atom->{'SolventRadii'}; # solventRadii = S_ALL + SolventRadii; $atom->{'solventSurface'} = $atom->{'S_ALL_Surface'}; # solventSurface = S_ALL_Surface; # //4.pi.r^2 $atom->{'isPolar'} = 0; # isPolar = false; # break; # //edited } else { # default: $atom->{'solventRadii'} = 3.4; # solventRadii = 3.4f; $atom->{'solventSurface'} = 4 * PI * $atom->{'solventRadii'} * $atom->{'solventRadii'}; # solventSurface = 4.0f*pi*solventRadii*solventRadii; # break; } } sub Atom_setSCType { #C++ void Atom::setSCType(Residue &r) my $atom = shift; #C++ Atom my $r = shift; #C++ Residue # switch(r.aaCode){ # /* case ALA: # aType = C_Ali; # break;*/ if ($r->{'aaCode'} eq ARG) { # case ARG: if ($atom->{'name'} eq 'CZ') { # if(name == "CZ"){ $atom->{'aType'} = C_Aro; # aType = C_Aro; } else { # else{ $atom->{'aType'} = C_Ali; # aType = C_Ali; } # break; } elsif ($r->{'aaCode'} eq ASN) { # case ASN: if ($atom->{'name'} eq 'CG') { # if (name == "CG"){ $atom->{'aType'} = C_Car; # aType = C_Car; } else { # else{ $atom->{'aType'} = C_Ali; # aType = C_Ali; } # break; } elsif ($r->{'aaCode'} eq ASP) { # case ASP: if ($atom->{'name'} eq 'CG') { # if (name == "CG"){ $atom->{'aType'} = C_Car; # aType = C_Car; } else { # else{ $atom->{'aType'} = C_Ali; # aType = C_Ali; } # break; } elsif ($r->{'aaCode'} eq CYS) { # case CYS: if ($atom->{'name'} eq 'SG') { # if (name == "SG"){ $atom->{'aType'} = S_Red; # aType = S_Red; } else { # else{ $atom->{'aType'} = C_Ali; # aType = C_Ali; } # break; } elsif ($r->{'aaCode'} eq GLN) { # case GLN: if ($atom->{'name'} eq 'CD') { # if (name == "CD"){ $atom->{'aType'} = C_Car; # aType = C_Car; } else { # else{ $atom->{'aType'} = C_Ali; # aType = C_Ali; } # break; } elsif ($r->{'aaCode'} eq GLU) { # case GLU: if ($atom->{'name'} eq 'CD') { # if (name == "CD"){ $atom->{'aType'} = C_Car; # aType = C_Car; } else { # else{ $atom->{'aType'} = C_Ali; # aType = C_Ali; } # break; } elsif ($r->{'aaCode'} eq GLY) { # case GLY: my $break = 1; # break; } elsif ($r->{'aaCode'} eq HIS) { # case HIS: if ($atom->{'name'} eq 'CB') { # if (name == "CB"){ $atom->{'aType'} = C_Ali; # aType = C_Ali; } else { # else{ $atom->{'aType'} = C_Aro; # aType = C_Aro; } # break; } elsif ($r->{'aaCode'} eq ILE) { # case ILE: $atom->{'aType'} = C_Ali; # aType = C_Ali; # break; } elsif ($r->{'aaCode'} eq LEU) { # case LEU: $atom->{'aType'} = C_Ali; # aType = C_Ali; # break; } elsif ($r->{'aaCode'} eq LYS) { # case LYS: $atom->{'aType'} = C_Ali; # aType = C_Ali; # break; } elsif ($r->{'aaCode'} eq MET) { # case MET: if ($atom->{'name'} eq 'SD') { # if (name == "SD"){ $atom->{'aType'} = S_Oxy; # aType = S_Oxy; } else { # else{ $atom->{'aType'} = C_Ali; # aType = C_Ali; } # break; } elsif ($r->{'aaCode'} eq PHE) { # case PHE: if ($atom->{'name'} eq 'CB') { # if (name == "CB"){ $atom->{'aType'} = C_Ali; # aType = C_Ali; } else { # else{ $atom->{'aType'} = C_Aro; # aType = C_Aro; } # break; } elsif ($r->{'aaCode'} eq PRO) { # case PRO: $atom->{'aType'} = C_Ali; # aType = C_Ali; # break } elsif ($r->{'aaCode'} eq SER) { # case SER: $atom->{'aType'} = C_Ali; # aType = C_Ali; # break } elsif ($r->{'aaCode'} eq THR) { # case THR: $atom->{'aType'} = C_Ali; # aType = C_Ali; # break } elsif ($r->{'aaCode'} eq TRP) { # case TRP: if ($atom->{'name'} eq 'CB') { # if (name == "CB"){ $atom->{'aType'} = C_Ali; # aType = C_Ali; } else { # else{ $atom->{'aType'} = C_Aro; # aType = C_Aro; } # break; } elsif ($r->{'aaCode'} eq TYR) { # case TYR: if ($atom->{'name'} eq 'CB') { # if (name == "CB"){ $atom->{'aType'} = C_Ali; # aType = C_Ali; } else { # else{ $atom->{'aType'} = C_Aro; # aType = C_Aro; } # break; } elsif ($r->{'aaCode'} eq VAL) { # case VAL: $atom->{'aType'} = C_Ali; # aType = C_Ali; # break } else { # default: $atom->{'aType'} = C_Car; # aType = C_Car; # break } } sub CChartView_OnDraw { #C++ void CChartView::OnDraw(CDC* pDC) # The $chart_coords string that this subroutine returns, # contains the scores and TMS data information, # for the lines that were specified in the input options (default is PROFILES3D, REPIMPS, not BOTH, and TMS), # ready for a graph to be created from it. # The data is all in one long line, so that it can be passed as a hidden field in an HTML form. # It looks like this : # OPTIONS,0,1,1,10,blue,Profiles 3D,:::::OPTIONS,1,1,1,10,red,REPIMPS,:::::OPTIONS,2,0,1,10,black,Overall,:::::OPTIONS,3,0,3,10,black,Transmembrane Segments,:::::NUM_RESIDUES,160,:::::NUM_CHAINS,1,:::::CHAIN,0,160,0,:::::LINE,0,:::::DATA,-0.432,-0.333333333333333,-0.195714285714286,-0.22875,-0.254444444444444,-0.185,-0.146,-0.197,-0.264,-0.167,-0.167,-0.229,-0.338,-0.229,-0.234,-0.261,-0.147,-0.085,0.021,-0.032,0.008,-0.055,-0.06,-0.079,0.016,0.062,0.043,0.071,0.00699999999999998,-0.072,-0.112,-0.14,-0.059,-0.109,-0.278,-0.478,-0.568,-0.568,-0.485,-0.344,-0.353,-0.262,-0.248,-0.304,-0.225,-0.044,0.062,-0.033,-0.033,-0.00500000000000003,0.025,0.134,0.134,0.225,0.134,0.031,-0.049,-0.053,-0.141,-0.129,-0.06,-0.169,-0.322,-0.46,-0.307,-0.373,-0.396,-0.302,-0.233,-0.309,-0.373,-0.452,-0.28,-0.226,-0.179,-0.01,-0.104,-0.198,-0.267,-0.372,-0.372,-0.293,-0.465,-0.347,-0.461,-0.551,-0.384,-0.285,-0.385,-0.385,-0.49,-0.534,-0.487,-0.506,-0.392,-0.582,-0.632,-0.66,-0.716,-0.528,-0.54,-0.575,-0.533,-0.533,-0.552,-0.362,-0.298,-0.334,-0.262,-0.46,-0.385,-0.197,-0.357,-0.381,-0.363,-0.297,-0.392,-0.423,-0.251,-0.099,-0.172,-0.36,-0.124,-0.127,-0.227,-0.227,-0.11,-0.015,-0.034,0.00900000000000003,0.164,0.333,0.222,0.192,0.286,0.246,0.219,0.124,0.124,0.018,0.015,-0.00900000000000001,-0.005,-0.127,-0.154,-0.185,-0.27,-0.262,-0.357,-0.338,-0.401,-0.392,-0.297,-0.13,-0.179,-0.148,-0.113333333333333,-0.07375,-0.0114285714285714,0.0316666666666667,:::::LINE,1,:::::DATA,0.14,0.195,0.101428571428571,0.25125,0.367777777777778,0.407,0.101,0.387,0.617,0.354,0.354,0.437,0.613,0.437,0.127,0.017,0.151,0.0680000000000001,0.07,0.337,0.173,0.154,-0.156,-0.034,0.222,0.21,0.332,0.361,0.324,0.268,0.432,0.451,0.705,0.74,0.738,0.914,0.968,0.968,0.883,0.856,0.753,0.753,0.755,0.718,0.774,0.72,0.375,0.119,0.119,0.148,-0.0350000000000001,-0.211,-0.211,-0.423,-0.423,-0.388,-0.134,0.073,-0.037,-0.293,-0.061,0.115,0.15,0.399,0.316,0.279,0.025,0.037,0.269,0.488,0.451,0.395,0.238,0.154,0.061,-0.041,0.304,0.292,0.06,0.095,0.095,0.151,0.308,0.235,0.101,0.259,0.203,0.252,0.482,0.482,0.517,0.513,0.476,0.598,0.732,0.713,0.678,0.649,0.703,0.583,0.639,0.587,0.552,0.552,0.674,0.693,0.73,0.722,0.705,0.879,0.823,0.703,0.484,0.193,-0.021,-0.366,-0.622,-0.841,-0.998,-1.16,-1.106,-0.986,-0.986,-0.805,-0.62,-0.62,-0.577,-0.321,-0.199,-0.38,-0.723,-0.721,-0.514,-0.441,-0.668,-0.414,-0.238,-0.494,-0.494,-0.149,0.032,-0.259,-0.466,-0.377,-0.225,-0.444,-0.353,-0.388,-0.644,-0.648,-0.484,-0.297,-0.145,-0.449,-0.601,-0.601,-0.812222222222222,-0.645,-0.48,-0.77,:::::LINE,3,:::::DATA,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,:::::TITLE,,,,,>KCSA_STRLI Voltage-gated potassium channel::::: # OPTIONS,0,1,1,10,blue,Profiles 3D,:::::OPTIONS,1,1,1,10,red,REPIMPS,:::::OPTIONS,2,0,1,10,black,Overall,:::::OPTIONS,3,0,3,10,black,Transmembrane Segments,:::::NUM_RESIDUES,160,:::::NUM_CHAINS,1,:::::CHAIN,0,160,0,:::::LINE,0,:::::DATA,-0.4,-0.3,:::::LINE,1,:::::DATA,0.14,0.195,0.1,:::::LINE,3,:::::DATA,0,1,1,:::::TITLE,,,,,>KCSA_STRLI Voltage-gated potassium channel::::: my $chart_coords = ''; my $output_data = ''; $chart_coords .= 'GRAPH_RESIDUE_WIDTH,' . $program_options->{'graph_residue_width'} . ':::::'; $chart_coords .= 'GRAPH_HEIGHT,' . $program_options->{'graph_height'} . ':::::'; # my @option_name = ('line_id','showGraph','weight','mov_avg','colour0','colour1','colour2','colour_name','legend_name','y_value','smooth'); for ( my $ln = 0; $ln <= $program_options->{'option_max_index'}; $ln++ ) { if ($program_options->{'lnOpt'}->[$ln]->{'showGraph'} == 1) { $chart_coords .= 'OPTIONS,' . $ln . ','; for ( my $n = 0; $n <= $#{$program_options->{'option_name'}}; $n++ ) { my $n_value = $program_options->{'option_name'}->[$n]; $chart_coords .= $program_options->{'lnOpt'}->[$ln]->{$n_value} . ','; } $chart_coords .= ':::::'; } } $structure = $analyser->{'st'}; my $chains = $structure->{'chains'}; # calculate total number of residues to be graphed my $noOfRes = 0; my $chains_dot_size = $#{$chains} + 1; for ( my $r = 0; $r < $chains_dot_size; $r++ ) { my $getResChain = Structure_getResChain_Range( $chains->[$r] ); my $getResChain_dot_size = $#{$getResChain} + 1; $noOfRes += $getResChain_dot_size; } $chart_coords .= 'NUM_RESIDUES,' . $noOfRes . ',:::::'; my @graph_data; my @graph_data_x_axis; for ( my $d = 0; $d < $noOfRes; $d++ ) { $graph_data_x_axis[$d] = $d; } $graph_data[0] = \@graph_data_x_axis; my $graph_data_line_index = 0; my @graph_colors; my @graph_legend; my $graph_colors_index = -1; my $graph_legend_index = -1; my @chain_length; my @chain_start_position; # Build up the contents of $chart_coords, which will be passed to the actual graph-drawing subroutine. # Here is an example of the contents of $chart_coords : # OPTIONS,0,1,1,10,blue,Profiles 3D,::::: # OPTIONS,1,1,1,10,red,REPIMPS,::::: # OPTIONS,2,0,1,10,black,Both,::::: # OPTIONS,3,1,1,10,black,Transmembrane Segments,::::: # NUM_RESIDUES,160,::::: # NUM_CHAINS,2,::::: # CHAIN,0,80,0,::::: # LINE,0,:::::DATA,-0.432,-0.333333333333333,-0.195714285714286,-0.22875,-0.254444444444444,-0.185,-0.146,-0.197,-0.264,-0.167,-0.167,-0.229,-0.338,-0.229,-0.234,-0.261,-0.147,-0.085,0.021,-0.032,0.008,-0.055,-0.06,-0.079,0.016,0.062,0.043,0.071,0.00699999999999998,-0.072,-0.112,-0.14,-0.059,-0.109,-0.278,-0.478,-0.568,-0.568,-0.485,-0.344,-0.353,-0.262,-0.248,-0.304,-0.225,-0.044,0.062,-0.033,-0.033,-0.00500000000000003,0.025,0.134,0.134,0.225,0.134,0.031,-0.049,-0.053,-0.141,-0.129,-0.06,-0.169,-0.322,-0.46,-0.307,-0.373,-0.396,-0.302,-0.233,-0.309,-0.373,-0.452,-0.28,-0.226,-0.179,-0.01,0.0366666666666667,-0.00750000000000001,-0.0714285714285714,-0.05,::::: # LINE,1,:::::DATA,0.14,0.195,0.101428571428571,0.25125,0.367777777777778,0.407,0.101,0.387,0.617,0.354,0.354,0.437,0.613,0.437,0.127,0.017,0.151,0.0680000000000001,0.07,0.337,0.173,0.154,-0.156,-0.034,0.222,0.21,0.332,0.361,0.324,0.268,0.432,0.451,0.705,0.74,0.738,0.914,0.968,0.968,0.883,0.856,0.753,0.753,0.755,0.718,0.774,0.72,0.375,0.119,0.119,0.148,-0.0350000000000001,-0.211,-0.211,-0.423,-0.423,-0.388,-0.134,0.073,-0.037,-0.293,-0.061,0.115,0.15,0.399,0.316,0.279,0.025,0.037,0.269,0.488,0.451,0.395,0.238,0.154,0.061,-0.041,0.193333333333333,0.16875,0.0842857142857143,0.0333333333333333,::::: # LINE,3,:::::DATA,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,::::: # CHAIN,1,80,80,::::: # LINE,0,:::::DATA,-0.204,-0.225,-0.371428571428571,-0.1875,-0.264444444444444,-0.271,-0.166,-0.012,0.00400000000000001,0.00400000000000003,0.076,-0.021,0.095,-0.00099999999999999,0.197,0.0670000000000001,0.084,0.104,-0.139,-0.109,-0.303,-0.0929999999999999,-0.0759999999999999,-0.076,-0.172,-0.0419999999999999,-0.036,-0.062,-0.024,-0.263,-0.158,-0.128,-0.371,-0.444,-0.515,-0.541,-0.643,-0.739,-0.504,-0.496,-0.616,-0.646,-0.499,-0.561,-0.445,-0.445,-0.429,-0.327,-0.423,-0.298,-0.228,-0.294,-0.346,-0.17,-0.317,-0.25,-0.123,-0.225,-0.225,-0.262,-0.324,-0.397,-0.345,-0.529,-0.407,-0.503,-0.591,-0.562,-0.664,-0.721,-0.633,-0.523,-0.412,-0.242,-0.317,-0.27,-0.263333333333333,-0.2225,-0.128571428571429,0,::::: # LINE,1,:::::DATA,0.744,0.796666666666667,0.82,0.66875,0.333333333333333,0.406,0.4,0.397,0.438,0.438,0.483,0.468,0.472,0.56,0.756,0.743,0.698,0.708,0.748,0.609,0.615,0.624,0.579,0.579,0.667,0.68,0.674,0.67,0.626,0.805,0.799,0.66,0.37,0.12,-0.0129999999999999,-0.32,-0.604,-0.894,-1.029,-1.23,-1.19,-1.051,-1.051,-0.911,-0.768,-0.768,-0.811,-0.527,-0.439,-0.579,-0.92,-0.971,-0.684,-0.568,-0.862,-0.606,-0.273,-0.557,-0.557,-0.25,-0.11,-0.36,-0.647,-0.562,-0.293,-0.583,-0.532,-0.498,-0.782,-0.797,-0.63,-0.395,-0.126,-0.527,-0.796,-0.796,-1.00222222222222,-0.87625,-0.665714285714286,-0.928333333333333,::::: # LINE,3,:::::DATA,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,::::: # TITLE,,,,,>chain1::::: # ///Draw Charts/// $chains_dot_size = $#{$chains} + 1; $chart_coords .= 'NUM_CHAINS,' . $chains_dot_size . ',:::::'; for ( my $c = 0; $c < $chains_dot_size; $c++ ) { my $res = Structure_getResChain_Range( $chains->[$c] ); my $res_dot_size = $#{$res} + 1; $chain_length[$c] = $#{$res} + 1; if ($c == 0) { $chain_start_position[$c] = 0; } else { $chain_start_position[$c] = $chain_start_position[$c - 1] + $chain_length[$c - 1]; } $chart_coords .= 'CHAIN,' . $c . ',' . $chain_length[$c] . ',' . $chain_start_position[$c] . ',:::::'; for ( my $ln = 0; $ln <= $program_options->{'option_max_index'}; $ln++ ) { # for (unsigned int ln = 0; ln < 3; ln++){ if ($program_options->{'lnOpt'}->[$ln]->{'showGraph'} == 1) { $chart_coords .= 'LINE,' . $ln . ',:::::DATA,'; if ($ln == $program_options->{'lnOpt_index'}->{'PROFILES3D-LINE'}) { for ( my $i = 0; $i < $res_dot_size; $i++ ) { $chart_coords .= $res->[$i]->{'scores'}->[0] . ','; } } elsif ($ln == $program_options->{'lnOpt_index'}->{'REPIMPS-LINE'}) { for ( my $i = 0; $i < $res_dot_size; $i++ ) { $chart_coords .= $res->[$i]->{'scores'}->[1] . ','; } } $chart_coords .= ':::::'; } } } my $graph_title = "PDB FILE"; $graph_title =~ s/\r//g; $graph_title =~ s/\n//g; $chart_coords .= 'TITLE,,,,,' . $graph_title . ':::::'; # has ,,,,, instead of , as the delimiter in case there is a comma in the actual title return $chart_coords; } sub convert_code_3to1 { my $code3 = shift; my $code1 = 'X'; my %code_3to1; $code_3to1{'ALA'} = 'A'; $code_3to1{'ARG'} = 'R'; $code_3to1{'ASN'} = 'N'; $code_3to1{'ASP'} = 'D'; $code_3to1{'CYS'} = 'C'; $code_3to1{'GLN'} = 'Q'; $code_3to1{'GLU'} = 'E'; $code_3to1{'GLY'} = 'G'; $code_3to1{'HIS'} = 'H'; $code_3to1{'ILE'} = 'I'; $code_3to1{'LEU'} = 'L'; $code_3to1{'LYS'} = 'K'; $code_3to1{'MET'} = 'M'; $code_3to1{'PHE'} = 'F'; $code_3to1{'PRO'} = 'P'; $code_3to1{'SER'} = 'S'; $code_3to1{'THR'} = 'T'; $code_3to1{'TRP'} = 'W'; $code_3to1{'TYR'} = 'Y'; $code_3to1{'VAL'} = 'V'; $code_3to1{'UNK'} = 'X'; if (defined($code_3to1{$code3})) { $code1 = $code_3to1{$code3}; } return $code1; } sub CProtSumView_OnDraw { #C++ void CProtSumView::OnDraw(CDC* pDC) $structure = $analyser->{'st'}; # Structure *s = &(pDoc->a.st); my $output_line = ''; $output_line .= "Protein summary :\n"; # lineOut("Protein summary for " + CString(pDoc->a.fileName.c_str()) + ":",pDC); $output_line .= "\n"; $output_line .= "PDB FILE\n"; $output_line .= "\n"; my $s_arrow_chains_dot_size = $#{$structure->{'chains'}} + 1; $output_line .= "Number of chains: " . $s_arrow_chains_dot_size . "\n"; # lineOut("Number of chains: " + iToStr(s->chains.size()),pDC); my $s_arrow_allResidues_dot_size = $#{$structure->{'allResidues'}} + 1; $output_line .= "Number of Residues: " . $s_arrow_allResidues_dot_size . "\n"; # lineOut("Number of Residues: " + iToStr(s->allResidues.size()),pDC); $output_line .= "Total Solvent Accessible Surface Area: " . $structure->{'ASA'} . "\n"; # lineOut("Total Solvent Accessible Surface Area: " + fToStr(s->ASA),pDC); $output_line .= "Average Residue Score: " . $structure->{'aveResScore'} . "\n"; # lineOut("Average Residue Score: " + fToStr(s->aveResScore),pDC); $output_line .= "\n\n"; if ($program_mode eq 'cgi-output') { print $output_line; } else { # $program_mode eq 'command-line' $output_line .= "Input parameters that were used :\n"; $output_line .= "\tSASA RESOLUTION (Index for Solvent Accessible Surface Area (SASA) resolution) = " . $program_options->{'SASARes'} . "\n"; $output_line .= "\tIgnore hetatoms (HETATM) = " . $program_options->{'IgnoreHetAtoms'} . "\n"; $output_line .= "\n"; # open output file my $summary_output_file = "$input_file_name_for_output_files.valpred_summary.txt"; open( SUMOUTFILE, ">$summary_output_file") or die "Cannot open $summary_output_file for writing : $!\n"; print SUMOUTFILE $output_line; close SUMOUTFILE; } } sub CTableView_fillTable { #C++ void CTableView::fillTable(void) # if $program_mode eq 'command-line' my $field_start = ""; my $field_end = ","; my $line_start = ""; my $line_end = "\n"; my $table_start = ""; my $table_end = ""; my $br_line_end = "\n"; if ($program_mode eq 'cgi-output') { $field_start = ""; $field_end = ""; $line_start = ""; $line_end = "\n"; $table_start = ""; $table_end = "
\n"; $br_line_end = "
\n"; } my $calc_output = $table_start; # Legend : # Area Buried = Area Buried # Fraction Polar= Fraction "polar" according to PROFILES3D (ie. fraction of the surface area of the side chain plus alpha-carbon that is either not-buried, or is buried and almost touching another atom that is considered to be polar) # REPIMPS FP = Fraction "non-polar" according to REPIMPS (ie. fraction of the surface area of the side chain plus alpha-carbon that is either not-buried, or is buried and almost touching another atom that is considered to be not polar) # Main SASA = Main chain SASA (solvent accessible surface area) # Side SASA = Side chain SASA (solvent accessible surface area) # Side not-buried polar ASA = Exposed (not buried) polar side chain SASA # SASA = SASA (solvent accessible surface area) # void CTableView::OnInitialUpdate() my $calc_hdr = $line_start; $calc_hdr .= $field_start . "Index" . $field_end; # ListCtrl.InsertColumn(0,"Index",LVCFMT_LEFT,30,0 ); $calc_hdr .= $field_start . "Residue" . $field_end; # ListCtrl.InsertColumn(1,"Residue" ,LVCFMT_LEFT,40,1 ); $calc_hdr .= $field_start . "Chain" . $field_end; # ListCtrl.InsertColumn(2,"Chain" ,LVCFMT_LEFT,40,1 ); $calc_hdr .= $field_start . "No." . $field_end; # ListCtrl.InsertColumn(3,"No." ,LVCFMT_LEFT,60,2 ); $calc_hdr .= $field_start . "Area Buried" . $field_end; # ListCtrl.InsertColumn(4,"Area Buried" ,LVCFMT_LEFT,80,3 ); $calc_hdr .= $field_start . "Fraction Polar" . $field_end; # ListCtrl.InsertColumn(5,"Fraction Polar" ,LVCFMT_LEFT,80,4 ); $calc_hdr .= $field_start . "REPIMPS FP" . $field_end; # ListCtrl.InsertColumn(6,"REPIMPS FP" ,LVCFMT_LEFT,70,5 ); $calc_hdr .= $field_start . "Category" . $field_end; # ListCtrl.InsertColumn(7,"Category" ,LVCFMT_LEFT,60 ,6); $calc_hdr .= $field_start . "REPIMPS Cat" . $field_end; # ListCtrl.InsertColumn(8,"REPIMPS Cat" ,LVCFMT_LEFT,70 ,7); $calc_hdr .= $field_start . "Main SASA" . $field_end; # ListCtrl.InsertColumn(9,"Main SASA" ,LVCFMT_LEFT,70 ,8); $calc_hdr .= $field_start . "Side SASA" . $field_end; # ListCtrl.InsertColumn(10,"Side SASA" ,LVCFMT_LEFT,70 ,9); $calc_hdr .= $field_start . "Side not-buried polar ASA" . $field_end; $calc_hdr .= $field_start . "SASA" . $field_end; # ListCtrl.InsertColumn(11,"SASA" ,LVCFMT_LEFT,60 ,10); $calc_hdr .= $field_start . "Solvent Score" . $field_end; # ListCtrl.InsertColumn(12,"Solvent Score" ,LVCFMT_LEFT,60 ,11); $calc_hdr .= $field_start . "REPIMPS Score" . $field_end; # ListCtrl.InsertColumn(13,"REPIMPS Score" ,LVCFMT_LEFT,60 ,12); $calc_hdr .= $field_start . "Overall Score" . $field_end; # ListCtrl.InsertColumn(14,"Overall Score" ,LVCFMT_LEFT,60 ,13); $calc_hdr .= $field_start . "is transmembrane" . $field_end; # ListCtrl.InsertColumn(15,"is transmembrane," ,LVCFMT_LEFT,60 ,13); $calc_hdr .= $line_end; $calc_output .= $calc_hdr; my $r = $analyser->{'st'}->{'allResidues'}; # vector &r = GetDocument()->a.st.allResidues; my $i; # unsigned int i; my $r_dot_size = $#{$r} + 1; for ( $i = 0; $i < $r_dot_size; $i++ ) { # for (i = 0; i < r.size(); i++){ my $calc_line = $line_start; $calc_line .= $field_start . $i . $field_end; # buff.Format("%d",i); $calc_line .= $field_start . $r->[$i]->{'name'} . $field_end; # ListCtrl.SetItemText(i, 1, r[i].name.c_str()); $calc_line .= $field_start . $r->[$i]->{'chainID'} . $field_end; # ListCtrl.SetItemText(i, 2, CString(r[i].chainID)); $calc_line .= $field_start . $r->[$i]->{'resSeq'} . $field_end; # buffer.Format("%d",r[i].resSeq); $calc_line .= $field_start . $r->[$i]->{'areaBuried'} . $field_end; # buffer.Format("%f",r[i].areaBuried); $calc_line .= $field_start . $r->[$i]->{'fractionPolar'} . $field_end; # buffer.Format("%f",r[i].fractionPolar); $calc_line .= $field_start . $r->[$i]->{'repimpsFP'} . $field_end; # buffer.Format("%f",r[i].repimpsFP); $calc_line .= $field_start . "profEnv" . $field_end; # buffer = "profEnv"; $calc_line .= $field_start . "repimpsEnv" . $field_end; # buffer = "repimpsEnv"; $calc_line .= $field_start . $r->[$i]->{'main_ASA'} . $field_end; # buffer.Format("%f",r[i].main_ASA); $calc_line .= $field_start . $r->[$i]->{'side_ASA'} . $field_end; # buffer.Format("%f",r[i].side_ASA); my $sasa = $r->[$i]->{'main_ASA'} + $r->[$i]->{'side_ASA'}; # buffer.Format("%f",r[i].main_ASA + r[i].side_ASA); $calc_line .= $field_start . $sasa . $field_end; $calc_line .= $field_start . $r->[$i]->{'scores'}->[0] . $field_end; # buffer.Format("%f",r[i].scores[0]); $calc_line .= $field_start . $r->[$i]->{'scores'}->[1] . $field_end; # buffer.Format("%f",r[i].scores[1]); $calc_line .= $field_start . $r->[$i]->{'scores'}->[2] . $field_end; # buffer.Format("%f",r[i].scores[2]); $calc_line .= $field_start . $r->[$i]->{'isTransMem'} . $field_end; # buffer.Format("%d",(int)(r[i].isTransMem)); $calc_line .= $line_end; $calc_output .= $calc_line; } $calc_output .= $table_end; $calc_output .= $br_line_end . $br_line_end; $calc_output .= "Legend :" . $br_line_end; $calc_output .= "Area Buried = Area Buried" . $br_line_end; $calc_output .= "Fraction Polar = Fraction \"polar\" according to PROFILES3D (ie. fraction of the surface area of the side chain plus alpha-carbon that is either not-buried, or is buried and almost touching another atom that is considered to be polar)" . $br_line_end; $calc_output .= "REPIMPS FP = Fraction \"non-polar\" according to REPIMPS (ie. fraction of the surface area of the side chain plus alpha-carbon that is either not-buried, or is buried and almost touching another atom that is considered to be not polar)" . $br_line_end; $calc_output .= "Main SASA = Main chain SASA (solvent accessible surface area)" . $br_line_end; $calc_output .= "Side SASA = Side chain SASA (solvent accessible surface area)" . $br_line_end; $calc_output .= "Side not-buried polar ASA = Exposed (not buried) polar side chain SASA" . $br_line_end; $calc_output .= "SASA = SASA (solvent accessible surface area)" . $br_line_end; $calc_output .= $br_line_end . $br_line_end; if ($program_mode eq 'cgi-output') { print $calc_output; } else { # $program_mode eq 'command-line' # open output file my $calculations_output_file = "$input_file_name_for_output_files.valpred_calculations.txt"; open( CALCOUTFILE, ">$calculations_output_file") or die "Cannot open $calculations_output_file for writing : $!\n"; print CALCOUTFILE $calc_output; close CALCOUTFILE; } } sub draw_chart_from_coords { my $chart_coords = shift; my $control_flag_for_output_files = shift; my $noOfRes = 0; my $chains_dot_size = 0; my @chain_length; my @chain_start_position; my $graph_title = ''; my @chart_coords_lines = split( /:::::/, $chart_coords ); my $c = -1; my $ln = -1; my @chart_coords_scores; foreach my $chart_coords_line (@chart_coords_lines) { my @bits = split( /,/, $chart_coords_line ); if ($bits[0] eq 'NUM_RESIDUES') { $noOfRes = trim($bits[1]); } elsif ($bits[0] eq 'NUM_CHAINS') { $chains_dot_size = trim($bits[1]); } elsif ($bits[0] eq 'CHAIN') { $c = trim($bits[1]); $chain_length[$c] = trim($bits[2]); $chain_start_position[$c] = trim($bits[3]); } elsif ($bits[0] eq 'LINE') { $ln = trim($bits[1]); } elsif ($bits[0] eq 'DATA') { for ( my $i2 = 1; $i2 < @bits; $i2++ ) { my $i = $i2 - 1; $chart_coords_scores[$c][$ln][$i] = trim($bits[$i2]); } } elsif ($bits[0] eq 'TITLE') { my @bits2 = split( /,,,,,/, $chart_coords_line ); # has ,,,,, instead of , as the delimiter in case there is a comma in the actual title $graph_title = trim($bits2[1]); } elsif ($bits[0] eq 'GRAPH_RESIDUE_WIDTH') { $program_options->{'graph_residue_width'} = trim($bits[1]); } elsif ($bits[0] eq 'GRAPH_HEIGHT') { $program_options->{'graph_height'} = trim($bits[1]); } } my @graph_data; my @graph_data_line_id; my @graph_data_line_smooth; my @graph_data_x_axis; for (my $d = 0; $d < $noOfRes; $d++) { $graph_data_x_axis[$d] = $d + 1; } my $graph_data_line_index = 0; $graph_data[0] = \@graph_data_x_axis; $graph_data_line_id[0] = 'X-AXIS'; $graph_data_line_smooth[0] = 0; my @graph_colors; my @graph_legend; # ///Draw Charts/// for ( $c = 0; $c < $chains_dot_size; $c++ ) { my @continuous_lines = ('PROFILES3D-LINE','REPIMPS-LINE'); for ( my $o = 0; $o < @continuous_lines; $o++ ) { my $ln_name = $continuous_lines[$o]; my $ln = $program_options->{'lnOpt_index'}->{$ln_name}; if ( $program_options->{'lnOpt'}->[$ln]->{'showGraph'} == 1 ) { $graph_data_line_index++; my $graph_data_residue_index = $chain_start_position[$c]; $graph_colors[$graph_data_line_index-1] = $program_options->{'lnOpt'}->[$ln]->{'colour_name'}; if ($c == 0) { $graph_legend[$graph_data_line_index-1] = $program_options->{'lnOpt'}->[$ln]->{'legend_name'}; } $graph_data_line_id[$graph_data_line_index] = $program_options->{'lnOpt'}->[$ln]->{'line_id'}; $graph_data_line_smooth[$graph_data_line_index] = $program_options->{'lnOpt'}->[$ln]->{'smooth'}; for ( my $i = 0; $i < $chain_length[$c]; $i++ ) { $graph_data[$graph_data_line_index][$graph_data_residue_index] = $chart_coords_scores[$c][$ln][$i]; $graph_data_residue_index++; } } } } # 1 residue is 10 pixels wide my $graph_width = $noOfRes * $program_options->{'graph_residue_width'}; if ($graph_width < 600) { # make sure the graph plot is wider than the legend, $graph_width = 600; # otherwise GD/Graph/axestype.pm will crash. } my $graph_height = $program_options->{'graph_height'}; # $graph_width = $noOfRes * 20; # 10 or 5 # $graph_height = 800; # 600 or 200 my $graph_object = new GD::Graph::lines( $graph_width, $graph_height ); my $graph_y_max_value = 2; # 2 my $graph_y_min_value = -2; # -2 my $num_duplications = 1; # make the graph lines look a more like a histogram than pointy, # by duplicating all values 4 times my @new_graph_data; $graph_data_line_index = -1; foreach my $graph_line_array_ref (@graph_data) { $graph_data_line_index++; my @graph_line_array = @$graph_line_array_ref; my @new_graph_line_array; my $line_id = $graph_data_line_id[$graph_data_line_index]; if ($graph_data_line_smooth[$graph_data_line_index] == 1 ) { my @temp_graph_line_array = @graph_line_array; $temp_graph_line_array[@temp_graph_line_array] = $graph_line_array[(@graph_line_array-1)]; for (my $i = 0; $i < @graph_line_array; $i++) { if ($i < ($noOfRes-1)) { if (defined($temp_graph_line_array[$i])) { my $diff = ($temp_graph_line_array[$i+1] - $temp_graph_line_array[$i]) / 4; $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i]; $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i] + $diff; $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i] + ($diff * 2); $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i] + ($diff * 3); } else { # the value is undef, due to making room for chains before this chain $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i]; $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i]; $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i]; $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i]; } } else { # the value is undef, that was padded out to stop the graph from being less wide than the legend, which would cause a crash $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i]; $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i]; $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i]; $new_graph_line_array[@new_graph_line_array] = $temp_graph_line_array[$i]; } } } else { foreach my $graph_line_point (@graph_line_array) { $new_graph_line_array[@new_graph_line_array] = $graph_line_point; $new_graph_line_array[@new_graph_line_array] = $graph_line_point; $new_graph_line_array[@new_graph_line_array] = $graph_line_point; $new_graph_line_array[@new_graph_line_array] = $graph_line_point; } } $new_graph_data[@new_graph_data] = \@new_graph_line_array; } @graph_data = @new_graph_data; $num_duplications = 4; my $requested_x_label_skip = 2; my $graph_x_label_skip = $requested_x_label_skip * $num_duplications; $graph_object->set( # x_label => '', # y_label => '', title => $graph_title, y_max_value => $graph_y_max_value, y_min_value => $graph_y_min_value, y_tick_number => 4, box_axis => 0, line_width => 3, zero_axis_only => 1, x_label_position => 0, y_label_position => 0, x_label_skip => $graph_x_label_skip, # x_tick_offset => 0, # y_label_skip => 0, transparent => 0, legend_placement => 'B', ); $graph_object->set_legend(@graph_legend); $graph_object->set(dclrs=>\@graph_colors); $graph_object->set_legend_font(['verdana', 'arial', gdGiantFont], 12); $graph_object->plot(\@graph_data); my $ext = $graph_object->export_format; if ($program_mode eq 'cgi-output-graph') { # Apparently we need to do this on Windows or the image will be garbled, and it doesn't hurt on Unix/Linux/etc. binmode STDOUT; print $cgi_query->header("Content-type: image/gif"); print $graph_object->gd->$ext(); } else { # $program_mode eq 'command-line' if ($control_flag_for_output_files == 1) { my $graph_output_file_1 = "$input_file_name_for_output_files.valpred_graph.$ext"; open( GRFOUTFILE1, ">$graph_output_file_1") or die "Cannot open $graph_output_file_1 for writing : $!\n"; binmode GRFOUTFILE1; print GRFOUTFILE1 $graph_object->gd->$ext(); close GRFOUTFILE1; } } } # // find the angle, in radian between 2 vectors. sub geometry_angle { #C++ inline Type angle(Vec3 v1, Vec3 v2) my $v1 = shift; my $v2 = shift; my $bit1 = Vec3_dot_Vec3( $v1, $v2 ); my $bit2 = Vec3_length( $v1 ); my $bit3 = Vec3_length( $v2 ); my $cosAngle = $bit1 / $bit2 / $bit3; # Type cosAngle = v1.dot(v2)/v1.length()/v2.length(); if ($cosAngle >= 1) { # if (cosAngle >= 1) { // sometimes fail due to rounding errors return 0; # return 0; } my $acos = acos( $cosAngle ); return $acos; # return acos(cosAngle); } # // find the torsion angle, in radian between v1 and v2 with respect to axis u # // according to the right hand rule sub geometry_torsion { #C++ Type torsion(Vec3 v1, Vec3 v2, Vec3 u) my $v1 = shift; my $v2 = shift; my $u = shift; $u = Vec3_normalize( $u ); # u.normalize(); $v1 = Vec3_cross( $v1, $u ); # v1 = v1.cross(u); $v2 = Vec3_cross( $v2, $u ); # v2 = v2.cross(u); my $a = geometry_angle( $v1, $v2 ); # double a = angle(v1, v2); # // ensures that right hand rule is obeyed my $cross = Vec3_cross( $v1, $v2 ); # Vec3 cross = v1.cross(v2); $cross = Vec3_normalize( $cross ); # cross.normalize(); $cross = Vec3_subtract_Vec3( $cross, $u ); # cross -= u; my $cross_length = Vec3_length( $cross ); if ($cross_length > 1) { # if (cross.length() > 1) $a = $a * -1; # a = -a; } return $a; # return a; } # // transformation Matrix representing the transformation relationship between # // model 3 points to the actual 3 points sub geometry_xformMat { #C++ Mat44 xformMat(const Vec3& from_p1, const Vec3& from_p2, const Vec3& from_p3, # const Vec3& p1, const Vec3& p2, const Vec3& p3) my $from_p1 = shift; #C++ const Vec3& my $from_p2 = shift; #C++ const Vec3& my $from_p3 = shift; #C++ const Vec3& my $p1 = shift; #C++ const Vec3& my $p2 = shift; #C++ const Vec3& my $p3 = shift; #C++ const Vec3& my $p1_p2 = Vec3_subtract_Vec3( $p2, $p1 ); # Vec3 p1_p2 = p2 - p1; my $from_p1_p2 = Vec3_subtract_Vec3( $from_p2, $from_p1 ); # Vec3 from_p1_p2 = from_p2 - from_p1; my $trans = Mat44_new(); # Mat44 trans; my $param1 = Vec3_multiply_number( $from_p1, -1 ); $trans = mat44impl_translate( $trans, $param1 ); # trans.translate(-from_p1); my $axis = Vec3_cross( $from_p1_p2, $p1_p2 ); # Vec3 axis = from_p1_p2.cross(p1_p2); my $m = Mat44_new(); # Mat44 m; my $param2 = geometry_torsion( $from_p1_p2, $p1_p2, $axis ); $m = Mat44_rotate( $m, $param2, $axis ); # m.rotate(torsion(from_p1_p2, p1_p2, axis), axis); $trans = Mat44_multiply_Mat44( $m, $trans ); # trans = m*trans; my $from_p1_p3 = Mat44_multVec3d( $trans, $from_p3 ); # Vec3 from_p1_p3 = trans.multVec3d(from_p3); my $p1_p3 = Vec3_subtract_Vec3( $p3, $p1 ); # Vec3 p1_p3 = p3 - p1; $p1_p2 = Vec3_normalize( $p1_p2 ); # p1_p2.normalize(); my $param3 = geometry_torsion( $from_p1_p3, $p1_p3, $p1_p2 ); $m = Mat44_rotate( $m, $param3, $p1_p2 ); # m.rotate(torsion(from_p1_p3, p1_p3, p1_p2), p1_p2); $trans = Mat44_multiply_Mat44( $m, $trans ); # trans = m*trans; $m = mat44impl_translate( $m, $p1 ); # m.translate(p1); $trans = Mat44_multiply_Mat44( $m, $trans ); # trans = m*trans; return $trans; # return trans; } sub get_html_program_options { my $params = $cgi_query->Vars; if (defined($params->{'option_SASARes'})) { $program_options->{'SASARes'} = trim($params->{'option_SASARes'}); } if (defined($params->{'IgnoreHetAtoms'})) { $program_options->{'IgnoreHetAtoms'} = trim($params->{'option_IgnoreHetAtoms'}); } if (defined($params->{'option_graph_residue_width'})) { $program_options->{'graph_residue_width'} = trim($params->{'option_graph_residue_width'}); } if (defined($params->{'option_graph_height'})) { $program_options->{'graph_height'} = trim($params->{'option_graph_height'}); } my @option_lines = ('PROFILES3D-LINE','REPIMPS-LINE'); my @option_attributes = ('showGraph','colour_name','legend_name','smooth'); for ( my $o = 0; $o < @option_lines; $o++ ) { my $option_name = $option_lines[$o]; my $ln = $program_options->{'lnOpt_index'}->{$option_name}; my $html_display_option_name = $program_options->{'lnOpt'}->[$ln]->{'legend_name'} . ' : '; for ( my $n = 0; $n < @option_attributes; $n++ ) { my $option_attribute = $option_attributes[$n]; my $param_name = 'option_' . $ln . '_' . $option_attribute; if (defined($params->{$param_name})) { my $param_value = trim($params->{$param_name}); my $param_ok = 0; if ($n eq 'showGraph') { if (($param_value == 0) || ($param_value == 1)) { # is it boolean? $param_ok = 1; } } elsif ($n eq 'weight') { if ($param_value =~ /^(\d+\.?\d*|\.\d+)$/) { # is it a +ve numeric? $param_ok = 1; } } elsif ($n eq 'mov_avg') { if ($param_value =~ /^(\d+)$/) { # is it a +ve integer? $param_ok = 1; } } else { $param_ok = 1; } if ($param_ok == 1) { $program_options->{'lnOpt'}->[$ln]->{$option_attribute} = $param_value; } } } } } sub hard_coded_amino_acid_pdb { my $amino_acid = shift; $amino_acid = uc $amino_acid; my @pdb_lines; if ($amino_acid eq 'ALA') { @pdb_lines = ( 'ATOM 1 N ALA 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA ALA 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C ALA 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O ALA 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB ALA 1 -0.540 1.211 0.775 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'ARG') { @pdb_lines = ( 'ATOM 1 N ARG 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA ARG 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C ARG 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O ARG 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB ARG 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG ARG 1 -0.246 1.169 2.263 1.00 0.00', 'ATOM 7 CD ARG 1 -1.062 2.210 3.012 1.00 0.00', 'ATOM 8 NE ARG 1 -0.692 3.571 2.633 1.00 0.00', 'ATOM 9 CZ ARG 1 0.313 4.249 3.176 1.00 0.00', 'ATOM 10 NH1 ARG 1 1.054 3.693 4.124 1.00 0.00', 'ATOM 11 NH2 ARG 1 0.575 5.484 2.768 1.00 0.00', 'TER '); } elsif ($amino_acid eq 'ASN') { @pdb_lines = ( 'ATOM 1 N ASN 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA ASN 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C ASN 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O ASN 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB ASN 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG ASN 1 -0.292 1.100 2.264 1.00 0.00', 'ATOM 7 OD1 ASN 1 -0.082 0.009 2.791 1.00 0.00', 'ATOM 8 ND2 ASN 1 -0.317 2.236 2.949 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'ASP') { @pdb_lines = ( 'ATOM 1 N ASP 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA ASP 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C ASP 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O ASP 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB ASP 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG ASP 1 -0.292 1.100 2.264 1.00 0.00', 'ATOM 7 OD1 ASP 1 0.119 0.013 2.723 1.00 0.00', 'ATOM 8 OD2 ASP 1 -0.510 2.103 2.976 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'CYS') { @pdb_lines = ( 'ATOM 1 N CYS 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA CYS 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C CYS 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O CYS 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB CYS 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 SG CYS 1 -0.143 1.198 2.551 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'GLN') { @pdb_lines = ( 'ATOM 1 N GLN 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA GLN 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C GLN 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O GLN 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB GLN 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG GLN 1 -0.246 1.168 2.264 1.00 0.00', 'ATOM 7 CD GLN 1 -0.791 2.380 2.994 1.00 0.00', 'ATOM 8 OE1 GLN 1 -0.973 3.444 2.403 1.00 0.00', 'ATOM 9 NE2 GLN 1 -1.055 2.221 4.286 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'GLU') { @pdb_lines = ( 'ATOM 1 N GLU 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA GLU 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C GLU 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O GLU 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB GLU 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG GLU 1 -0.246 1.168 2.264 1.00 0.00', 'ATOM 7 CD GLU 1 -0.791 2.380 2.994 1.00 0.00', 'ATOM 8 OE1 GLU 1 -1.225 3.337 2.319 1.00 0.00', 'ATOM 9 OE2 GLU 1 -0.785 2.373 4.244 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'GLY') { @pdb_lines = ( 'ATOM 1 N GLY 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA GLY 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C GLY 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O GLY 1 -1.535 -0.689 -1.687 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'HIS') { @pdb_lines = ( 'ATOM 1 N HIS 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA HIS 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C HIS 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O HIS 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB HIS 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG HIS 1 -0.205 1.187 2.232 1.00 0.00', 'ATOM 7 ND1 HIS 1 -0.760 0.280 3.108 1.00 0.00', 'ATOM 8 CD2 HIS 1 0.624 1.962 2.970 1.00 0.00', 'ATOM 9 CE1 HIS 1 -0.286 0.500 4.322 1.00 0.00', 'ATOM 10 NE2 HIS 1 0.555 1.512 4.266 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'ILE') { @pdb_lines = ( 'ATOM 1 N ILE 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA ILE 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C ILE 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O ILE 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB ILE 1 -0.564 1.215 0.759 1.00 0.00', 'ATOM 6 CG1 ILE 1 -0.195 1.136 2.242 1.00 0.00', 'ATOM 7 CG2 ILE 1 -2.080 1.261 0.641 1.00 0.00', 'ATOM 8 CD1 ILE 1 -0.500 2.399 3.016 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'LEU') { @pdb_lines = ( 'ATOM 1 N LEU 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA LEU 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C LEU 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O LEU 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB LEU 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG LEU 1 -0.230 1.244 2.271 1.00 0.00', 'ATOM 7 CD1 LEU 1 -0.690 2.559 2.881 1.00 0.00', 'ATOM 8 CD2 LEU 1 -0.943 0.111 2.992 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'LYS') { @pdb_lines = ( 'ATOM 1 N LYS 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA LYS 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C LYS 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O LYS 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB LYS 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG LYS 1 -0.246 1.169 2.263 1.00 0.00', 'ATOM 7 CD LYS 1 -0.805 2.395 2.967 1.00 0.00', 'ATOM 8 CE LYS 1 -0.514 2.357 4.458 1.00 0.00', 'ATOM 9 NZ LYS 1 -1.057 3.553 5.160 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'MET') { @pdb_lines = ( 'ATOM 1 N MET 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA MET 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C MET 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O MET 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB MET 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG MET 1 -0.246 1.168 2.264 1.00 0.00', 'ATOM 7 SD MET 1 -0.893 2.607 3.136 1.00 0.00', 'ATOM 8 CE MET 1 -2.643 2.222 3.171 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'PHE') { @pdb_lines = ( 'ATOM 1 N PHE 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA PHE 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C PHE 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O PHE 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB PHE 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG PHE 1 -2.033 1.242 0.879 1.00 0.00', 'ATOM 7 CD1 PHE 1 -2.693 0.470 1.820 1.00 0.00', 'ATOM 8 CD2 PHE 1 -2.784 2.046 0.041 1.00 0.00', 'ATOM 9 CE1 PHE 1 -4.071 0.501 1.919 1.00 0.00', 'ATOM 10 CE2 PHE 1 -4.162 2.079 0.136 1.00 0.00', 'ATOM 11 CZ PHE 1 -4.806 1.307 1.077 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'PRO') { @pdb_lines = ( 'ATOM 1 N PRO 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA PRO 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C PRO 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O PRO 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB PRO 1 -0.344 1.256 0.803 1.00 0.00', 'ATOM 6 CG PRO 1 0.835 1.435 1.733 1.00 0.00', 'ATOM 7 CD PRO 1 2.018 1.062 0.857 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'SER') { @pdb_lines = ( 'ATOM 1 N SER 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA SER 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C SER 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O SER 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB SER 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 OG SER 1 -0.192 1.129 2.144 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'THR') { @pdb_lines = ( 'ATOM 1 N THR 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA THR 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C THR 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O THR 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB THR 1 -0.564 1.215 0.759 1.00 0.00', 'ATOM 6 OG1 THR 1 -0.209 1.123 2.145 1.00 0.00', 'ATOM 7 CG2 THR 1 -2.080 1.261 0.641 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'TRP') { @pdb_lines = ( 'ATOM 1 N TRP 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA TRP 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C TRP 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O TRP 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB TRP 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG TRP 1 -2.030 1.237 0.876 1.00 0.00', 'ATOM 7 CD1 TRP 1 -2.794 0.683 1.862 1.00 0.00', 'ATOM 8 CD2 TRP 1 -2.940 1.855 -0.042 1.00 0.00', 'ATOM 9 NE1 TRP 1 -4.126 0.916 1.618 1.00 0.00', 'ATOM 10 CE2 TRP 1 -4.241 1.635 0.453 1.00 0.00', 'ATOM 11 CE3 TRP 1 -2.781 2.571 -1.231 1.00 0.00', 'ATOM 12 CZ2 TRP 1 -5.379 2.105 -0.202 1.00 0.00', 'ATOM 13 CZ3 TRP 1 -3.909 3.037 -1.879 1.00 0.00', 'ATOM 14 CH2 TRP 1 -5.196 2.804 -1.365 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'TYR') { @pdb_lines = ( 'ATOM 1 N TYR 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA TYR 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C TYR 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O TYR 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB TYR 1 -0.536 1.207 0.772 1.00 0.00', 'ATOM 6 CG TYR 1 -2.044 1.244 0.882 1.00 0.00', 'ATOM 7 CD1 TYR 1 -2.708 0.472 1.826 1.00 0.00', 'ATOM 8 CD2 TYR 1 -2.799 2.052 0.041 1.00 0.00', 'ATOM 9 CE1 TYR 1 -4.084 0.499 1.932 1.00 0.00', 'ATOM 10 CE2 TYR 1 -4.176 2.093 0.133 1.00 0.00', 'ATOM 11 CZ TYR 1 -4.818 1.316 1.080 1.00 0.00', 'ATOM 12 OH TYR 1 -6.189 1.349 1.180 1.00 0.00', 'TER'); } elsif ($amino_acid eq 'VAL') { @pdb_lines = ( 'ATOM 1 N VAL 1 1.458 0.000 0.000 1.00 0.00', 'ATOM 2 CA VAL 1 0.000 0.000 0.000 1.00 0.00', 'ATOM 3 C VAL 1 -0.551 0.000 -1.422 1.00 0.00', 'ATOM 3 O VAL 1 -1.535 -0.689 -1.687 1.00 0.00', 'ATOM 5 CB VAL 1 -0.564 1.215 0.759 1.00 0.00', 'ATOM 6 CG1 VAL 1 -2.080 1.261 0.641 1.00 0.00', 'ATOM 7 CG2 VAL 1 -0.199 1.138 2.234 1.00 0.00', 'TER'); } my $pdb_lines_ref = \@pdb_lines; return $pdb_lines_ref; } sub hard_coded_hetatm_radii { $hetatm_radii->{'B'} = 1.65; $hetatm_radii->{'C'} = 1.7; $hetatm_radii->{'F'} = 1.47; $hetatm_radii->{'H'} = 1.2; $hetatm_radii->{'I'} = 1.98; $hetatm_radii->{'K'} = 2.75; $hetatm_radii->{'N'} = 1.55; $hetatm_radii->{'O'} = 1.52; $hetatm_radii->{'P'} = 1.8; $hetatm_radii->{'S'} = 1.8; $hetatm_radii->{'U'} = 1.86; $hetatm_radii->{'A'} = 1.85; $hetatm_radii->{'AG'} = 1.72; $hetatm_radii->{'AR'} = 1.88; $hetatm_radii->{'AU'} = 1.66; $hetatm_radii->{'BR'} = 1.85; $hetatm_radii->{'CD'} = 1.58; $hetatm_radii->{'CL'} = 1.75; $hetatm_radii->{'CU'} = 1.4; $hetatm_radii->{'GA'} = 1.87; $hetatm_radii->{'GE'} = 1.98; $hetatm_radii->{'HE'} = 1.4; $hetatm_radii->{'HG'} = 1.55; $hetatm_radii->{'IN'} = 1.93; $hetatm_radii->{'KR'} = 2.02; $hetatm_radii->{'LI'} = 1.82; $hetatm_radii->{'MG'} = 1.73; $hetatm_radii->{'NA'} = 2.27; $hetatm_radii->{'NE'} = 1.54; $hetatm_radii->{'NI'} = 1.63; $hetatm_radii->{'PB'} = 2.02; $hetatm_radii->{'PD'} = 1.63; $hetatm_radii->{'PT'} = 1.72; $hetatm_radii->{'SB'} = 2.12; $hetatm_radii->{'SE'} = 1.9; $hetatm_radii->{'SI'} = 2.1; $hetatm_radii->{'SN'} = 2.16; $hetatm_radii->{'SN'} = 2.17; $hetatm_radii->{'TE'} = 2.06; $hetatm_radii->{'TL'} = 1.96; $hetatm_radii->{'XE'} = 2.16; $hetatm_radii->{'ZN'} = 1.39;} sub hard_coded_sphere_points { # hard coded from resolution = 2, file = ./Sphere_Points/maxvol.3.252.txt my $points_string = ""; $points_string .= "252\n"; $points_string .= "0.364416027907\n0.839162952267\n0.403740632272\n0.659046753775\n0.741815371905\n0.123965036782\n0.585553996265\n0.731343352236\n0.349661863232\n0.679618729744\n"; $points_string .= "0.555611950811\n0.478971546438\n0.525731112119\n0.850650808352\n0.000000000000\n0.000000000000\n0.525731112119\n-0.850650808352\n-0.525731112119\n0.850650808352\n"; $points_string .= "0.000000000000\n0.000000000000\n0.525731112119\n0.850650808352\n0.850650808352\n0.000000000000\n0.525731112119\n-0.850650808352\n0.000000000000\n0.525731112119\n"; $points_string .= "0.000000000000\n-0.525731112119\n0.850650808352\n-0.850650808352\n0.000000000000\n-0.525731112119\n-0.525731112119\n-0.850650808352\n0.000000000000\n0.850650808352\n"; $points_string .= "0.000000000000\n-0.525731112119\n0.525731112119\n-0.850650808352\n0.000000000000\n0.000000000000\n-0.525731112119\n-0.850650808352\n0.403740632174\n0.364416027652\n"; $points_string .= "-0.839162952425\n0.000000001184\n0.334502077164\n-0.942395012918\n0.216102916071\n0.235892133096\n-0.947446268244\n0.219380291097\n0.000000000079\n-0.975639425135\n"; $points_string .= "-0.364416027907\n0.839162952267\n-0.403740632272\n-0.659046753775\n0.741815371905\n-0.123965036782\n-0.585553996265\n0.731343352236\n-0.349661863232\n-0.679618729744\n"; $points_string .= "0.555611950811\n-0.478971546438\n-0.403740632174\n0.364416027652\n0.839162952425\n-0.000000001184\n0.334502077164\n0.942395012918\n-0.216102916071\n0.235892133096\n"; $points_string .= "0.947446268244\n-0.219380291097\n0.000000000079\n0.975639425135\n0.768156660082\n0.589637518944\n0.249525433225\n0.659046754960\n0.741815371173\n-0.123965034866\n"; $points_string .= "0.801656912336\n0.597784405036\n0.000000000039\n0.898999020841\n0.420027474451\n-0.124006778982\n-0.114890594426\n0.993378151216\n-0.000000000158\n-0.458467112030\n"; $points_string .= "0.865780407955\n-0.200579641014\n-0.235892133057\n0.947446268268\n-0.216102916008\n-0.124006779060\n0.898999020889\n-0.420027474324\n-0.249525433481\n0.768156659924\n"; $points_string .= "0.589637519041\n-0.200579641746\n0.458467113946\n0.865780406770\n-0.349661863208\n0.585553996328\n0.731343352197\n-0.555611950684\n0.478971546516\n0.679618729793\n"; $points_string .= "0.589637519041\n-0.249525433481\n0.768156659924\n0.865780406770\n-0.200579641746\n0.458467113946\n0.731343352197\n-0.349661863208\n0.585553996328\n0.679618729793\n"; $points_string .= "-0.555611950684\n0.478971546516\n-0.993378151216\n-0.000000000158\n0.114890594426\n-0.865780407955\n-0.200579641014\n0.458467112030\n-0.947446268268\n-0.216102916008\n"; $points_string .= "0.235892133057\n-0.898999020889\n-0.420027474324\n0.124006779060\n0.768156659924\n0.589637519041\n-0.249525433481\n0.458467113946\n0.865780406770\n-0.200579641746\n"; $points_string .= "0.585553996328\n0.731343352197\n-0.349661863208\n0.478971546516\n0.679618729793\n-0.555611950684\n0.249525433225\n0.768156660082\n0.589637518944\n-0.123965034866\n"; $points_string .= "0.659046754960\n0.741815371173\n0.000000000039\n0.801656912336\n0.597784405036\n-0.124006778982\n0.898999020841\n0.420027474451\n-0.403740632272\n-0.364416027907\n"; $points_string .= "0.839162952267\n-0.123965036782\n-0.659046753775\n0.741815371905\n-0.349661863232\n-0.585553996265\n0.731343352236\n-0.478971546438\n-0.679618729744\n0.555611950811\n"; $points_string .= "0.839162952425\n-0.403740632174\n0.364416027652\n0.942395012918\n-0.000000001184\n0.334502077164\n0.947446268244\n-0.216102916071\n0.235892133096\n0.975639425135\n"; $points_string .= "-0.219380291097\n0.000000000079\n0.403740632272\n0.364416027907\n0.839162952267\n0.123965036782\n0.659046753775\n0.741815371905\n0.349661863232\n0.585553996265\n"; $points_string .= "0.731343352236\n0.478971546438\n0.679618729744\n0.555611950811\n-0.000000000158\n-0.114890594426\n0.993378151216\n-0.200579641014\n-0.458467112030\n0.865780407955\n"; $points_string .= "-0.216102916008\n-0.235892133057\n0.947446268268\n-0.420027474324\n-0.124006779060\n0.898999020889\n0.000000000158\n0.114890594426\n0.993378151216\n0.200579641014\n"; $points_string .= "0.458467112030\n0.865780407955\n0.216102916008\n0.235892133057\n0.947446268268\n0.420027474324\n0.124006779060\n0.898999020889\n-0.364416027652\n0.839162952425\n"; $points_string .= "0.403740632174\n-0.334502077164\n0.942395012918\n0.000000001184\n-0.235892133096\n0.947446268244\n0.216102916071\n-0.000000000079\n0.975639425135\n0.219380291097\n"; $points_string .= "-0.589637518944\n0.249525433225\n-0.768156660082\n-0.741815371173\n-0.123965034866\n-0.659046754960\n-0.597784405036\n0.000000000039\n-0.801656912336\n-0.420027474451\n"; $points_string .= "-0.124006778982\n-0.898999020841\n-0.839162952267\n-0.403740632272\n0.364416027907\n-0.741815371905\n-0.123965036782\n0.659046753775\n-0.731343352236\n-0.349661863232\n"; $points_string .= "0.585553996265\n-0.555611950811\n-0.478971546438\n0.679618729744\n-0.768156659924\n0.589637519041\n0.249525433481\n-0.458467113946\n0.865780406770\n0.200579641746\n"; $points_string .= "-0.585553996328\n0.731343352197\n0.349661863208\n-0.478971546516\n0.679618729793\n0.555611950684\n-0.839162952267\n0.403740632272\n-0.364416027907\n-0.741815371905\n"; $points_string .= "0.123965036782\n-0.659046753775\n-0.731343352236\n0.349661863232\n-0.585553996265\n-0.555611950811\n0.478971546438\n-0.679618729744\n-0.364416027652\n-0.839162952425\n"; $points_string .= "-0.403740632174\n-0.334502077164\n-0.942395012918\n-0.000000001184\n-0.235892133096\n-0.947446268244\n-0.216102916071\n-0.000000000079\n-0.975639425135\n-0.219380291097\n"; $points_string .= "0.589637518944\n0.249525433225\n0.768156660082\n0.741815371173\n-0.123965034866\n0.659046754960\n0.597784405036\n0.000000000039\n0.801656912336\n0.420027474451\n"; $points_string .= "-0.124006778982\n0.898999020841\n0.839162952267\n-0.403740632272\n-0.364416027907\n0.741815371905\n-0.123965036782\n-0.659046753775\n0.731343352236\n-0.349661863232\n"; $points_string .= "-0.585553996265\n0.555611950811\n-0.478971546438\n-0.679618729744\n0.364416027652\n0.839162952425\n-0.403740632174\n0.334502077164\n0.942395012918\n-0.000000001184\n"; $points_string .= "0.235892133096\n0.947446268244\n-0.216102916071\n0.000000000079\n0.975639425135\n-0.219380291097\n0.839162952267\n0.403740632272\n0.364416027907\n0.741815371905\n"; $points_string .= "0.123965036782\n0.659046753775\n0.731343352236\n0.349661863232\n0.585553996265\n0.555611950811\n0.478971546438\n0.679618729744\n0.993378151216\n-0.000000000158\n"; $points_string .= "-0.114890594426\n0.865780407955\n-0.200579641014\n-0.458467112030\n0.947446268268\n-0.216102916008\n-0.235892133057\n0.898999020889\n-0.420027474324\n-0.124006779060\n"; $points_string .= "-0.000000000158\n0.114890594426\n-0.993378151216\n-0.200579641014\n0.458467112030\n-0.865780407955\n-0.216102916008\n0.235892133057\n-0.947446268268\n-0.420027474324\n"; $points_string .= "0.124006779060\n-0.898999020889\n0.364416027652\n-0.839162952425\n0.403740632174\n0.334502077164\n-0.942395012918\n0.000000001184\n0.235892133096\n-0.947446268244\n"; $points_string .= "0.216102916071\n0.000000000079\n-0.975639425135\n0.219380291097\n-0.839162952425\n0.403740632174\n0.364416027652\n-0.942395012918\n0.000000001184\n0.334502077164\n"; $points_string .= "-0.947446268244\n0.216102916071\n0.235892133096\n-0.975639425135\n0.219380291097\n0.000000000079\n-0.249525433225\n-0.768156660082\n0.589637518944\n0.123965034866\n"; $points_string .= "-0.659046754960\n0.741815371173\n-0.000000000039\n-0.801656912336\n0.597784405036\n0.124006778982\n-0.898999020841\n0.420027474451\n-0.589637519041\n0.249525433481\n"; $points_string .= "0.768156659924\n-0.865780406770\n0.200579641746\n0.458467113946\n-0.731343352197\n0.349661863208\n0.585553996328\n-0.679618729793\n0.555611950684\n0.478971546516\n"; $points_string .= "-0.768156659924\n-0.589637519041\n-0.249525433481\n-0.458467113946\n-0.865780406770\n-0.200579641746\n-0.585553996328\n-0.731343352197\n-0.349661863208\n-0.478971546516\n"; $points_string .= "-0.679618729793\n-0.555611950684\n0.249525433481\n-0.768156659924\n0.589637519041\n0.200579641746\n-0.458467113946\n0.865780406770\n0.349661863208\n-0.585553996328\n"; $points_string .= "0.731343352197\n0.555611950684\n-0.478971546516\n0.679618729793\n-0.589637518944\n-0.249525433225\n0.768156660082\n-0.741815371173\n0.123965034866\n0.659046754960\n"; $points_string .= "-0.597784405036\n-0.000000000039\n0.801656912336\n-0.420027474451\n0.124006778982\n0.898999020841\n0.114890594426\n-0.993378151216\n-0.000000000158\n0.458467112030\n"; $points_string .= "-0.865780407955\n-0.200579641014\n0.235892133057\n-0.947446268268\n-0.216102916008\n0.124006779060\n-0.898999020889\n-0.420027474324\n0.993378151216\n0.000000000158\n"; $points_string .= "0.114890594426\n0.865780407955\n0.200579641014\n0.458467112030\n0.947446268268\n0.216102916008\n0.235892133057\n0.898999020889\n0.420027474324\n0.124006779060\n"; $points_string .= "0.403740632174\n-0.364416027652\n0.839162952425\n0.000000001184\n-0.334502077164\n0.942395012918\n0.216102916071\n-0.235892133096\n0.947446268244\n0.219380291097\n"; $points_string .= "-0.000000000079\n0.975639425135\n0.589637518944\n-0.249525433225\n-0.768156660082\n0.741815371173\n0.123965034866\n-0.659046754960\n0.597784405036\n-0.000000000039\n"; $points_string .= "-0.801656912336\n0.420027474451\n0.124006778982\n-0.898999020841\n-0.768156660082\n-0.589637518944\n0.249525433225\n-0.659046754960\n-0.741815371173\n-0.123965034866\n"; $points_string .= "-0.801656912336\n-0.597784405036\n0.000000000039\n-0.898999020841\n-0.420027474451\n-0.124006778982\n0.768156659924\n-0.589637519041\n0.249525433481\n0.458467113946\n"; $points_string .= "-0.865780406770\n0.200579641746\n0.585553996328\n-0.731343352197\n0.349661863208\n0.478971546516\n-0.679618729793\n0.555611950684\n-0.249525433481\n-0.768156659924\n"; $points_string .= "-0.589637519041\n-0.200579641746\n-0.458467113946\n-0.865780406770\n-0.349661863208\n-0.585553996328\n-0.731343352197\n-0.555611950684\n-0.478971546516\n-0.679618729793\n"; $points_string .= "0.249525433481\n0.768156659924\n-0.589637519041\n0.200579641746\n0.458467113946\n-0.865780406770\n0.349661863208\n0.585553996328\n-0.731343352197\n0.555611950684\n"; $points_string .= "0.478971546516\n-0.679618729793\n-0.589637519041\n-0.249525433481\n-0.768156659924\n-0.865780406770\n-0.200579641746\n-0.458467113946\n-0.731343352197\n-0.349661863208\n"; $points_string .= "-0.585553996328\n-0.679618729793\n-0.555611950684\n-0.478971546516\n-0.768156660082\n0.589637518944\n-0.249525433225\n-0.659046754960\n0.741815371173\n0.123965034866\n"; $points_string .= "-0.801656912336\n0.597784405036\n-0.000000000039\n-0.898999020841\n0.420027474451\n0.124006778982\n-0.249525433225\n0.768156660082\n-0.589637518944\n0.123965034866\n"; $points_string .= "0.659046754960\n-0.741815371173\n-0.000000000039\n0.801656912336\n-0.597784405036\n0.124006778982\n0.898999020841\n-0.420027474451\n0.403740632272\n-0.364416027907\n"; $points_string .= "-0.839162952267\n0.123965036782\n-0.659046753775\n-0.741815371905\n0.349661863232\n-0.585553996265\n-0.731343352236\n0.478971546438\n-0.679618729744\n-0.555611950811\n"; $points_string .= "-0.839162952425\n-0.403740632174\n-0.364416027652\n-0.942395012918\n-0.000000001184\n-0.334502077164\n-0.947446268244\n-0.216102916071\n-0.235892133096\n-0.975639425135\n"; $points_string .= "-0.219380291097\n-0.000000000079\n-0.403740632272\n0.364416027907\n-0.839162952267\n-0.123965036782\n0.659046753775\n-0.741815371905\n-0.349661863232\n0.585553996265\n"; $points_string .= "-0.731343352236\n-0.478971546438\n0.679618729744\n-0.555611950811\n0.839162952425\n0.403740632174\n-0.364416027652\n0.942395012918\n0.000000001184\n-0.334502077164\n"; $points_string .= "0.947446268244\n0.216102916071\n-0.235892133096\n0.975639425135\n0.219380291097\n-0.000000000079\n0.249525433225\n-0.768156660082\n-0.589637518944\n-0.123965034866\n"; $points_string .= "-0.659046754960\n-0.741815371173\n0.000000000039\n-0.801656912336\n-0.597784405036\n-0.124006778982\n-0.898999020841\n-0.420027474451\n0.589637519041\n0.249525433481\n"; $points_string .= "-0.768156659924\n0.865780406770\n0.200579641746\n-0.458467113946\n0.731343352197\n0.349661863208\n-0.585553996328\n0.679618729793\n0.555611950684\n-0.478971546516\n"; $points_string .= "-0.993378151216\n0.000000000158\n-0.114890594426\n-0.865780407955\n0.200579641014\n-0.458467112030\n-0.947446268268\n0.216102916008\n-0.235892133057\n-0.898999020889\n"; $points_string .= "0.420027474324\n-0.124006779060\n0.000000000158\n-0.114890594426\n-0.993378151216\n0.200579641014\n-0.458467112030\n-0.865780407955\n0.216102916008\n-0.235892133057\n"; $points_string .= "-0.947446268268\n0.420027474324\n-0.124006779060\n-0.898999020889\n0.364416027907\n-0.839162952267\n-0.403740632272\n0.659046753775\n-0.741815371905\n-0.123965036782\n"; $points_string .= "0.585553996265\n-0.731343352236\n-0.349661863232\n0.679618729744\n-0.555611950811\n-0.478971546438\n-0.364416027907\n-0.839162952267\n0.403740632272\n-0.659046753775\n"; $points_string .= "-0.741815371905\n0.123965036782\n-0.585553996265\n-0.731343352236\n0.349661863232\n-0.679618729744\n-0.555611950811\n0.478971546438\n-0.114890594426\n-0.993378151216\n"; $points_string .= "0.000000000158\n-0.458467112030\n-0.865780407955\n0.200579641014\n-0.235892133057\n-0.947446268268\n0.216102916008\n-0.124006779060\n-0.898999020889\n0.420027474324\n"; $points_string .= "0.114890594426\n0.993378151216\n0.000000000158\n0.458467112030\n0.865780407955\n0.200579641014\n0.235892133057\n0.947446268268\n0.216102916008\n0.124006779060\n"; $points_string .= "0.898999020889\n0.420027474324\n-0.403740632174\n-0.364416027652\n-0.839162952425\n-0.000000001184\n-0.334502077164\n-0.942395012918\n-0.216102916071\n-0.235892133096\n"; $points_string .= "-0.947446268244\n-0.219380291097\n-0.000000000079\n-0.975639425135\n0.768156660082\n-0.589637518944\n-0.249525433225\n0.659046754960\n-0.741815371173\n0.123965034866\n"; $points_string .= "0.801656912336\n-0.597784405036\n-0.000000000039\n0.898999020841\n-0.420027474451\n0.124006778982\n"; my @points_lines = split(/\n/, $points_string); my $points_lines_ref = \@points_lines; return $points_lines_ref; } sub HetAtom_new { #C++ HetAtom::HetAtom(void) my $atom = Atom_new(); $atom->{ 'isHet' } = 1; # isHet = true; $atom->{ 'isPolar' } = 1; # isPolar = true; return $atom; #C++ HetAtom } # // //set the hetero atom type sub HetAtom_setAtomType { #C++ void HetAtom::setAtomType(void) my $atom = shift; #C++ Atom # if(hetAtomRadii.find(name.substr(0,2)) == hetAtomRadii.end()){ # solventRadii = 1.4f + SolventRadii; # } # else{ # solventRadii = hetAtomRadii[name.substr(0,2)] + SolventRadii; # } $atom->{'Radii'} = 1.4; my $hetatm_name = trim(substr($atom->{'name'},0,1)); if (defined($hetatm_radii->{$hetatm_name})) { $atom->{'Radii'} = $hetatm_radii->{$hetatm_name}; } $atom->{'solventRadii'} = $atom->{'Radii'} + $atom->{'SolventRadii'}; if ($atom->{'aType'} eq 'C') { # if(name[1] == 'C'){ $atom->{'isPolar'} = 0; # isPolar = 0; } # solventSurface = 4.0f * pi * solventRadii * solventRadii; $atom->{'solventSurface'} = 4 * PI * $atom->{'solventRadii'} * $atom->{'solventRadii'}; } sub html_code_for_graphics_header { my $title = shift; my $html_code = ''; $html_code .= "
\n" . "\n" . #" style='background-image: url(\"bluegold.gif\");\n" . #" background-attachment: fixed;\n" . #" background-position: top right;\n" . #" background-repeat: no-repeat;'>\n" . " \n" . " \n" . " \n" . "
\n" . " \n" . " \n" . " \n" . " \n" . #" \n" . #" \n" . " \n" . " \n" . "
\n" . " $title\n" . " \n" . #" $title\n" . #" \n" . #" \n" . #" \n" . " \n" . "
\n" . "
\n" . "
\n" . "
\n
"; return $html_code; } sub html_header { print $cgi_query->header(); print #$cgi_query->start_html(-title=>$text_title), "VALPRED 3D\n", '' . "\n", "\n"; my $title = 'VALPRED 3D'; my $output_line = html_code_for_graphics_header($title); print $output_line; } sub init { # initialise the displayed statistics totalled for all sequences in the prediction method $stats->{'qok'} = 0; $stats->{'qhtm_obs'} = 0; $stats->{'qhtm_prd'} = 0; $stats->{'q2'} = 0; $stats->{'q2t_obs'} = 0; $stats->{'q2t_prd'} = 0; $stats->{'q2n_obs'} = 0; $stats->{'q2n_prd'} = 0; # consider a tms to be correctly predicted if 3 residues overlap between the predicted and observed/true segments $stats->{'minimum_overlap'} = 3; # initialise the overall counts that will be used to calculate the displayed statistics $stats->{'stats_num_seqs'} = 0; $stats->{'stats_num_obs_tms_in_this_method'} = 0; $stats->{'stats_num_prd_tms_in_this_method'} = 0; $stats->{'stats_num_correct_obs_tms_in_this_method'} = 0; $stats->{'stats_num_correct_prd_tms_in_this_method'} = 0; $stats->{'stats_num_correct_obs_and_prd_tms_in_this_method'} = 0; $stats->{'stats_num_obs_tms_residues_in_this_method'} = 0; $stats->{'stats_num_prd_tms_residues_in_this_method'} = 0; $stats->{'stats_num_obs_nontms_residues_in_this_method'} = 0; $stats->{'stats_num_prd_nontms_residues_in_this_method'} = 0; $stats->{'stats_num_correct_obs_tms_residues_in_this_method'} = 0; $stats->{'stats_num_correct_prd_tms_residues_in_this_method'} = 0; $stats->{'stats_num_correct_obs_nontms_residues_in_this_method'} = 0; $stats->{'stats_num_correct_prd_nontms_residues_in_this_method'} = 0; $stats->{'stats_ratio_correct_residues_in_this_method'} = 0; hard_coded_hetatm_radii(); } sub Mat44_multiply_Mat44 { #C++ Mat44 Mat44::operator * (const Mat44& A) const // MULTIPLICATION (*) my $M = shift; my $A = shift; # Mat44 NewM( M[0]*A.M[0] + M[4]*A.M[1] + M[8]*A.M[2] + M[12]*A.M[3], // ROW 1 # M[0]*A.M[4] + M[4]*A.M[5] + M[8]*A.M[6] + M[12]*A.M[7], # M[0]*A.M[8] + M[4]*A.M[9] + M[8]*A.M[10] + M[12]*A.M[11], # M[0]*A.M[12] + M[4]*A.M[13] + M[8]*A.M[14] + M[12]*A.M[15], my $NewM = Mat44_new(); $NewM->[0] = $M->[0]*$A->[0] + $M->[4]*$A->[1] + $M->[8]*$A->[2] + $M->[12]*$A->[3]; $NewM->[4] = $M->[0]*$A->[4] + $M->[4]*$A->[5] + $M->[8]*$A->[6] + $M->[12]*$A->[7]; $NewM->[8] = $M->[0]*$A->[8] + $M->[4]*$A->[9] + $M->[8]*$A->[10] + $M->[12]*$A->[11]; $NewM->[12] = $M->[0]*$A->[12] + $M->[4]*$A->[13] + $M->[8]*$A->[14] + $M->[12]*$A->[15]; # M[1]*A.M[0] + M[5]*A.M[1] + M[9]*A.M[2] + M[13]*A.M[3], // ROW 2 # M[1]*A.M[4] + M[5]*A.M[5] + M[9]*A.M[6] + M[13]*A.M[7], # M[1]*A.M[8] + M[5]*A.M[9] + M[9]*A.M[10] + M[13]*A.M[11], # M[1]*A.M[12] + M[5]*A.M[13] + M[9]*A.M[14] + M[13]*A.M[15], $NewM->[1] = $M->[1]*$A->[0] + $M->[5]*$A->[1] + $M->[9]*$A->[2] + $M->[13]*$A->[3]; $NewM->[5] = $M->[1]*$A->[4] + $M->[5]*$A->[5] + $M->[9]*$A->[6] + $M->[13]*$A->[7]; $NewM->[9] = $M->[1]*$A->[8] + $M->[5]*$A->[9] + $M->[9]*$A->[10] + $M->[13]*$A->[11]; $NewM->[13] = $M->[1]*$A->[12] + $M->[5]*$A->[13] + $M->[9]*$A->[14] + $M->[13]*$A->[15]; # M[2]*A.M[0] + M[6]*A.M[1] + M[10]*A.M[2] + M[14]*A.M[3], // ROW 3 # M[2]*A.M[4] + M[6]*A.M[5] + M[10]*A.M[6] + M[14]*A.M[7], # M[2]*A.M[8] + M[6]*A.M[9] + M[10]*A.M[10] + M[14]*A.M[11], # M[2]*A.M[12] + M[6]*A.M[13] + M[10]*A.M[14] + M[14]*A.M[15], $NewM->[2] = $M->[2]*$A->[0] + $M->[6]*$A->[1] + $M->[10]*$A->[2] + $M->[14]*$A->[3]; $NewM->[6] = $M->[2]*$A->[4] + $M->[6]*$A->[5] + $M->[10]*$A->[6] + $M->[14]*$A->[7]; $NewM->[10] = $M->[2]*$A->[8] + $M->[6]*$A->[9] + $M->[10]*$A->[10] + $M->[14]*$A->[11]; $NewM->[14] = $M->[2]*$A->[12] + $M->[6]*$A->[13] + $M->[10]*$A->[14] + $M->[14]*$A->[15]; # M[3]*A.M[0] + M[7]*A.M[1] + M[11]*A.M[2] + M[15]*A.M[3], // ROW 4 # M[3]*A.M[4] + M[7]*A.M[5] + M[11]*A.M[6] + M[15]*A.M[7], # M[3]*A.M[8] + M[7]*A.M[9] + M[11]*A.M[10] + M[15]*A.M[11], # M[3]*A.M[12] + M[7]*A.M[13] + M[11]*A.M[14] + M[15]*A.M[15] ); $NewM->[3] = $M->[3]*$A->[0] + $M->[7]*$A->[1] + $M->[11]*$A->[2] + $M->[15]*$A->[3]; $NewM->[7] = $M->[3]*$A->[4] + $M->[7]*$A->[5] + $M->[11]*$A->[6] + $M->[15]*$A->[7]; $NewM->[11] = $M->[3]*$A->[8] + $M->[7]*$A->[9] + $M->[11]*$A->[10] + $M->[15]*$A->[11]; $NewM->[15] = $M->[3]*$A->[12] + $M->[7]*$A->[13] + $M->[11]*$A->[14] + $M->[15]*$A->[15]; return $NewM; # return(NewM); } # // MAT-POINT MULTIPLICATION _WITHOUT_ PERSP DIV # // (for transforming points in space) # // Assumes matrix is affine, i.e. bottom row is 0,0,0,1 sub Mat44_multVec3d { #C++ Vec3 Mat44::multVec3d(const Vec3& P) const my $M = shift; my $P = shift; # Vec3 NewP( (M[0]*P.x + M[4]*P.y + M[8]*P.z + M[12]), # (M[1]*P.x + M[5]*P.y + M[9]*P.z + M[13]), # (M[2]*P.x + M[6]*P.y + M[10]*P.z + M[14]) ); my $NewP = Vec3_new_set3( 0, 0, 0 ); $NewP->{'x'} = ($M->[0] * $P->{'x'}) + ($M->[4] * $P->{'y'}) + ($M->[8] * $P->{'z'}) + $M->[12]; $NewP->{'y'} = ($M->[1] * $P->{'x'}) + ($M->[5] * $P->{'y'}) + ($M->[9] * $P->{'z'}) + $M->[13]; $NewP->{'z'} = ($M->[2] * $P->{'x'}) + ($M->[6] * $P->{'y'}) + ($M->[10] * $P->{'z'}) + $M->[14]; return $NewP; #C++ Vec3f or Vec3d # return (NewP); } sub Mat44_new { # typedef Mat44 Mat44f; my %mat44_hash; my $mat44 = \%mat44_hash; ## void Mat44::identity() ## M[0]=M[5]=M[10]=M[15]=1; ## M[1]=M[2]=M[3]=M[4]=M[6]=M[7]=M[8]=M[9]=M[11]=M[12]=M[13]=M[14]=0; $mat44->[0] = 1; $mat44->[1] = 0; $mat44->[2] = 0; $mat44->[3] = 0; $mat44->[4] = 0; $mat44->[5] = 1; $mat44->[6] = 0; $mat44->[7] = 0; $mat44->[8] = 0; $mat44->[9] = 0; $mat44->[10] = 1; $mat44->[11] = 0; $mat44->[12] = 0; $mat44->[13] = 0; $mat44->[14] = 0; $mat44->[15] = 1; return $mat44; #C++ Mat44f or Mat44d } sub Mat44_rotate { #C++ void Mat44::rotate(Type RadAng, const Vec3& Axis) my $M = shift; my $RadAng = shift; my $Axis = shift; my $ca = cos( $RadAng ); # Type ca=(Type)cos(RadAng), my $sa = sin( $RadAng ); # sa=(Type)sin(RadAng); if (($Axis->{'x'} == 1) && ($Axis->{'y'} == 0) && ($Axis->{'z'} == 0)) { # if (Axis.x==1 && Axis.y==0 && Axis.z==0) // ABOUT X-AXIS $M->[0] = 1; # M[0]=1; M[4]=0; M[8]=0; M[12]=0; $M->[4] = 0; $M->[8] = 0; $M->[12] = 0; $M->[1] = 0; # M[1]=0; M[5]=ca; M[9]=-sa; M[13]=0; $M->[5] = $ca; $M->[9] = -1 * $sa; $M->[13] = 0; $M->[2] = 0; # M[2]=0; M[6]=sa; M[10]=ca; M[14]=0; $M->[6] = $sa; $M->[10] = $ca; $M->[14] = 0; $M->[3] = 0; # M[3]=0; M[7]=0; M[11]=0; M[15]=1; $M->[7] = 0; $M->[11] = 0; $M->[15] = 1; } elsif (($Axis->{'x'} == 0) && ($Axis->{'y'} == 1) && ($Axis->{'z'} == 0)) { # else if (Axis.x==0 && Axis.y==1 && Axis.z==0) // ABOUT Y-AXIS $M->[0] = $ca; # M[0]=ca; M[4]=0; M[8]=sa; M[12]=0; $M->[4] = 0; $M->[8] = $sa; $M->[12] = 0; $M->[1] = 0; # M[1]=0; M[5]=1; M[9]=0; M[13]=0; $M->[5] = 1; $M->[9] = 0; $M->[13] = 0; $M->[2] = -1 * $sa; # M[2]=-sa; M[6]=0; M[10]=ca; M[14]=0; $M->[6] = 0; $M->[10] = $ca; $M->[14] = 0; $M->[3] = 0; # M[3]=0; M[7]=0; M[11]=0; M[15]=1; $M->[7] = 0; $M->[11] = 0; $M->[15] = 1; } elsif (($Axis->{'x'} == 0) && ($Axis->{'y'} == 0) && ($Axis->{'z'} == 1)) { # else if (Axis.x==0 && Axis.y==0 && Axis.z==1) // ABOUT Z-AXIS $M->[0] = $ca; # M[0]=ca; M[4]=-sa; M[8]=0; M[12]=0; $M->[4] = -1 * $sa; $M->[8] = 0; $M->[12] = 0; $M->[1] = $sa; # M[1]=sa; M[5]=ca; M[9]=0; M[13]=0; $M->[5] = $ca; $M->[9] = 0; $M->[13] = 0; $M->[2] = 0; # M[2]=0; M[6]=0; M[10]=1; M[14]=0; $M->[6] = 0; $M->[10] = 1; $M->[14] = 0; $M->[3] = 0; # M[3]=0; M[7]=0; M[11]=0; M[15]=1; $M->[7] = 0; $M->[11] = 0; $M->[15] = 1; } else { # // ARBITRARY AXIS my $l = Vec3_lengthSqr( $Axis ); # Type l = Axis.lengthSqr(); my $x = $Axis->{'x'}; # Type x, y, z; my $y = $Axis->{'y'}; # x=Axis.x, y=Axis.y, z=Axis.z; my $z = $Axis->{'z'}; if ((($l > 1.0001) || ($l < 0.9999)) && ($l != 0)) { # if (l > Type(1.0001) || l < Type(0.9999) && l!=0) # // needs normalization $l = 1 / sqrt($l); # l=Type(1.0)/sqrt(l); $x = $x * $l; # x*=l; y*=l; z*=l; $y = $y * $l; $z = $z * $l; } my $x2 = $x * $x; # Type x2=x*x, y2=y*y, z2=z*z; my $y2 = $y * $y; my $z2 = $z * $z; $M->[0] = $x2 + $ca * (1 - $x2); # M[0]=x2+ca*(1-x2); $M->[4] = ($x * $y) + $ca * (-1 * $x * $y) + $sa * (-1 * $z); # M[4]=(x*y)+ca*(-x*y)+sa*(-z); $M->[8] = ($x * $z) + $ca * (-1 * $x * $z) + $sa * $y; # M[8]=(x*z)+ca*(-x*z)+sa*y; $M->[1] = ($x * $y) + $ca * (-1 * $x * $y) + $sa * $z; # M[1]=(x*y)+ca*(-x*y)+sa*z; $M->[5] = $y2 + $ca * (1 - $y2); # M[5]=y2+ca*(1-y2); $M->[9] = ($y * $z) + $ca * (-1 * $y * $z) + $sa * (-1 * $x); # M[9]=(y*z)+ca*(-y*z)+sa*(-x); $M->[2] = ($x * $z) + $ca * (-1 * $x * $z) + $sa * (-1 * $y); # M[2]=(x*z)+ca*(-x*z)+sa*(-y); $M->[6] = ($y * $z) + $ca * (-1 * $y * $z) + $sa * $x; # M[6]=(y*z)+ca*(-y*z)+sa*x; $M->[10] = $z2 + $ca * (1 - $z2); # M[10]=z2+ca*(1-z2); $M->[12] = 0; # M[12]=M[13]=M[14]=M[3]=M[7]=M[11]=0; $M->[13] = 0; $M->[14] = 0; $M->[3] = 0; $M->[7] = 0; $M->[11] = 0; $M->[15] = 1; # M[15]=1; } return $M; #C++ Mat44f or Mat44d } # //============================================================================ # // mat44.hpp : 4x4 OpenGL-style matrix template. # //============================================================================ # # // from GLUV # //Author: # //Kenny Hoff , Bill Baxter , # //Wes Hunt , Mark Harris # # //---------------------------------------------------------------------------- # // M[16] = [ 0 4 8 12 ] | 16 floats were used instead of the normal [4][4] # // [ 1 5 9 13 ] | to be compliant with OpenGL. OpenGL uses # // [ 2 6 10 14 ] | premultiplication with column vectors. These # // [ 3 7 11 15 ] | matrices can be fed directly into the OpenGL # // | matrix stack with glLoadMatrix or glMultMatrix. # // # // [ x' y' z' w' ] = [ 0 4 8 12 ] [ x ] # // [ 1 5 9 13 ] * [ y ] # // [ 2 6 10 14 ] [ z ] # // [ 3 7 11 15 ] [ w ] # // # // Loading a [4][4] format matrix directly into the matrix stack (assuming # // premult/col vecs) results in a transpose matrix. M[0]=M[0][0], but # // M[1]!=M[1][0] since M[0][1] would cast to M[1]. # // # // However, if we assumed postmult/row vectors we could use [4][4] format, # // but all transformations in this module would be transposed. # //---------------------------------------------------------------------------- sub mat44impl_translate { # void Mat44::translate(const Vec3& T) my $M = shift; my $T = shift; # M[0]=1; M[4]=0; M[8]=0; M[12]=T.x; # M[1]=0; M[5]=1; M[9]=0; M[13]=T.y; # M[2]=0; M[6]=0; M[10]=1; M[14]=T.z; # M[3]=0; M[7]=0; M[11]=0; M[15]=1; $M->[0] = 1; $M->[1] = 0; $M->[2] = 0; $M->[3] = 0; $M->[4] = 0; $M->[5] = 1; $M->[6] = 0; $M->[7] = 0; $M->[8] = 0; $M->[9] = 0; $M->[10] = 1; $M->[11] = 0; $M->[12] = $T->{'x'}; $M->[13] = $T->{'y'}; $M->[14] = $T->{'z'}; $M->[15] = 1; return $M; } sub output_chart_coords_link { my $chart_coords = shift; my $request_uri = $ENV{'REQUEST_URI'}; my @bits = split(/\//, $request_uri); my $pgm_name = $bits[$#bits]; my $output_line; $output_line .= "
"; $output_line .= "
"; $output_line .= ""; $output_line .= ""; $output_line .= ""; $output_line .= "<== PLEASE NOTE : If you are viewing this from a Windows machine,
"; $output_line .= "your browser may not allow you to view this dynamically generated chart conveniently in the browser.
"; $output_line .= "Instead, it may ask you to download the graph as a file and save it to disk.
"; $output_line .= "When you do this, you may need to rename the ending file extension of the downloaded file to gif (eg. rename the file to valpred.gif),
"; $output_line .= "so that double-clicking this saved file on your disk will display this graph that has been dynamically generated for you."; $output_line .= "
\n\n"; $output_line .= "
\n\n"; print $output_line; } sub PolymerBuilder_assignResType { # void PolymerBuilder::assignResType(Residue &r) # // Checks whether the amino acid lies within the HELIX or # // SHEET ranges. Otherwise allocates their secondary structure # // to OTHER # /////////////////////////////////////////////////////////////// # //for (unsigned int i = 0; i< s.HelixInfo.size();i++){ # if( r.resSeq >= helices.min && # r.resSeq <= helices.max && # helices.ChainID == r.chainID){ # r.SS = HELIX; # } # //} # //for (i = 0; i< s.SheetInfo.size(); i++){ # // if( r.resSeq >= s.SheetInfo[i].min && # // r.resSeq <= s.SheetInfo[i].max && # // s.SheetInfo[i].ChainID == r.chainID){ # // r.SS = SHEET; # // } # //} # Checks whether the amino acid lies within the HELIX or SHEET ranges. # Otherwise allocates their secondary structure to OTHER. my $r = shift; #C++ Residue $r->{'SS'} = OTHER; #if (($r->{'resSeq'} >= $helices->{'min'}) && ($r->{'resSeq'} <= $helices->{'max'}) && ($helices->{'chainID'} eq $r->{'chainID'})) { # if( r.resSeq >= helices.min && # r.resSeq <= helices.max && # helices.ChainID == r.chainID){ # $r->{'SS'} = HELIX; # r.SS = HELIX; #} # if (($r->{'SS'} != HELIX) and ($r->{'SS'} != SHEET)) { # if (r.SS != HELIX && r.SS != SHEET){ # $r->{'SS'} = OTHER; # r.SS = OTHER; # } if ($r->{'name'} eq "ALA") { # if (r.name == "ALA"){ $r->{'aaCode'} = ALA; # r.aaCode = ALA; } elsif ($r->{'name'} eq "ARG") { # else if (r.name == "ARG"){ $r->{'aaCode'} = ARG; # r.aaCode = ARG; } elsif ($r->{'name'} eq "ASN") { # else if (r.name == "ASN"){ $r->{'aaCode'} = ASN; # r.aaCode = ASN; } elsif ($r->{'name'} eq "ASP") { # else if (r.name == "ASP"){ $r->{'aaCode'} = ASP; # r.aaCode = ASP; } elsif ($r->{'name'} eq "CYS") { # else if (r.name == "CYS"){ $r->{'aaCode'} = CYS; # r.aaCode = CYS; } elsif ($r->{'name'} eq "GLN") { # else if (r.name == "GLN"){ $r->{'aaCode'} = GLN; # r.aaCode = GLN; } elsif ($r->{'name'} eq "GLU") { # else if (r.name == "GLU"){ $r->{'aaCode'} = GLU; # r.aaCode = GLU; } elsif ($r->{'name'} eq "GLY") { # else if (r.name == "GLY"){ $r->{'aaCode'} = GLY; # r.aaCode = GLY; } elsif ($r->{'name'} eq "HIS") { # else if (r.name == "HIS"){ $r->{'aaCode'} = HIS; # r.aaCode = HIS; } elsif ($r->{'name'} eq "ILE") { # else if (r.name == "ILE"){ $r->{'aaCode'} = ILE; # r.aaCode = ILE; } elsif ($r->{'name'} eq "LEU") { # else if (r.name == "LEU"){ $r->{'aaCode'} = LEU; # r.aaCode = LEU; } elsif ($r->{'name'} eq "LYS") { # else if (r.name == "LYS"){ $r->{'aaCode'} = LYS; # r.aaCode = LYS; } elsif ($r->{'name'} eq "MET") { # else if (r.name == "MET"){ $r->{'aaCode'} = MET; # r.aaCode = MET; } elsif ($r->{'name'} eq "PHE") { # else if (r.name == "PHE"){ $r->{'aaCode'} = PHE; # r.aaCode = PHE; } elsif ($r->{'name'} eq "PRO") { # else if (r.name == "PRO"){ $r->{'aaCode'} = PRO; # r.aaCode = PRO; } elsif ($r->{'name'} eq "SER") { # else if (r.name == "SER"){ $r->{'aaCode'} = SER; # r.aaCode = SER; } elsif ($r->{'name'} eq "THR") { # else if (r.name == "THR"){ $r->{'aaCode'} = THR; # r.aaCode = THR; } elsif ($r->{'name'} eq "TRP") { # else if (r.name == "TRP"){ $r->{'aaCode'} = TRP; # r.aaCode = TRP; } elsif ($r->{'name'} eq "TYR") { # else if (r.name == "TYR"){ $r->{'aaCode'} = TYR; # r.aaCode = TYR; } elsif ($r->{'name'} eq "VAL") { # else if (r.name == "VAL"){ $r->{'aaCode'} = VAL; # r.aaCode = VAL; } else { # else{ $r->{'aaCode'} = UNK; # r.aaCode = UNK; //Unknown residue } } sub program_build_and_output_results { my $input_lines_pointer = shift; my @input_lines = @{$input_lines_pointer}; Analyser_new(); program_build_structure_from_pdb_file( $input_lines_pointer ); $analyser->{'st'} = $structure; $analyser->{'ignoreHet'} = $program_options->{'IgnoreHetAtoms'}; Analyser_findCloseAtoms(); Analyser_SASA( $program_options->{'SASARes'} ); Analyser_doProfile(); Analyser_setOverallScores(); if ($program_mode eq 'cgi-output') { print "
\n";
	}

	CProtSumView_OnDraw();

	if ($program_mode eq 'cgi-output') {
		print "
\n"; } my $chart_coords = CChartView_OnDraw(); if ($program_mode eq 'command-line') { draw_chart_from_coords( $chart_coords, 1 ); } else { # $program_mode eq 'cgi-script' output_chart_coords_link( $chart_coords ); } CTableView_fillTable(); } sub program_build_structure_from_pdb_file { # ATOM 4726 CE2 TYR A 622 85.569 38.124 138.803 1.00115.05 C # ATOM 4727 CZ TYR A 622 86.737 38.576 139.390 1.00115.85 C # ATOM 4728 OH TYR A 622 86.852 39.904 139.730 1.00116.74 O # ATOM 4729 OXT TYR A 622 84.283 32.238 138.506 1.00111.29 O my $input_lines_pointer = shift; my @input_lines = @{$input_lines_pointer}; my $curr_chain = ''; my $curr_res_num = ''; Structure_new(); my $i = -1; my @chains_array; my $chains = \@chains_array; my @ranges_array; my $ranges = \@ranges_array; $structure->{'chains'} = $ranges; my $res; my $r; foreach my $line (@input_lines) { if (length($line) >= 6) { my $line_id = substr($line,0,6); if ($line_id eq 'ATOM ') { my $chain_id = substr($line,21,1); my $res_num = trim(substr($line,22,4)); my $res_type_3char = substr($line,17,3); my $res_type_1char = convert_code_3to1($res_type_3char); my $create_new_residue = 0; if (($res_num ne $curr_res_num) or ($chain_id ne $curr_chain)) { $create_new_residue = 1; } if ($chain_id ne $curr_chain) { # finish off the previous chain if ($curr_chain ne '') { my $s_dot_allResidues_dot_size = $#{$structure->{'allResidues'}} + 1; $r->{'max'} = $s_dot_allResidues_dot_size - 1; } # create new chain $r = Range_new(); $r->{'chainID'} = $chain_id; $curr_chain = $chain_id; my $s_dot_allResidues_dot_size = $#{$structure->{'allResidues'}} + 1; $r->{'min'} = $s_dot_allResidues_dot_size; $i++; $chains->[$i] = ''; $structure->{'chains'}->[$i] = $r; } if ($create_new_residue == 1) { # create new residue $res = Residue_new(); my $s_dot_allResidues_dot_size = $#{$structure->{'allResidues'}} + 1; $res->{'allResidues_index'} = $s_dot_allResidues_dot_size; my $push_back_index = $#{$structure->{'allResidues'}} + 1; $structure->{'allResidues'}->[$push_back_index] = $res; $curr_res_num = $res_num; $res->{'name'} = $res_type_3char; $res->{'chainID'} = $chain_id; $res->{'chains_index'} = $i; $res->{'resSeq'} = $res_num; PolymerBuilder_assignResType( $res ); } $chains->[$i] = $chains->[$i] . $res_type_1char; my $x = trim(substr($line,30,9)); my $y = trim(substr($line,38,9)); my $z = trim(substr($line,46,9)); my $atom_name = trim(substr($line,13,3)); my $atom_type = trim(substr($line,77,1)); my $atom_num = trim(substr($line,6,5)); my $newAtom = Atom_new(); my %coords; $coords{'x'} = $x; $coords{'y'} = $y; $coords{'z'} = $z; $newAtom->{'coords'} = \%coords; $newAtom->{'name'} = $atom_name; my $s_dot_allAtoms_dot_size = $#{$structure->{'allAtoms'}} + 1; $newAtom->{'atomID'} = $atom_num; $newAtom->{'allAtoms_index'} = $s_dot_allAtoms_dot_size; $newAtom->{'chainID'} = $chain_id; $newAtom->{'allResidues_index'} = $res->{'allResidues_index'}; $newAtom->{'resSeq'} = $res_num; Atom_setAtomType( $newAtom, $res, $s_dot_allAtoms_dot_size ); my $push_back_index = $#{$structure->{'allAtoms'}} + 1; $structure->{'allAtoms'}->[$push_back_index] = $newAtom; } elsif ($line_id eq 'HETATM') { my $chain_id = substr($line,21,1); my $res_num = trim(substr($line,22,4)); my $res_type_3char = substr($line,17,3); my $x = trim(substr($line,30,9)); my $y = trim(substr($line,38,9)); my $z = trim(substr($line,46,9)); my $atom_name = trim(substr($line,13,3)); my $atom_type = trim(substr($line,77,1)); my $atom_num = trim(substr($line,6,5)); my $newAtom = HetAtom_new(); my %coords; $coords{'x'} = $x; $coords{'y'} = $y; $coords{'z'} = $z; $newAtom->{'coords'} = \%coords; $newAtom->{'name'} = $atom_name; $newAtom->{'aType'} = $atom_type; $newAtom->{'resSeq'} = $res_num; HetAtom_setAtomType( $newAtom ); my $push_back_index = $#{$structure->{'hetAtoms'}} + 1; $structure->{'hetAtoms'}->[$push_back_index] = $newAtom; $newAtom->{'hetAtoms_index'} = $push_back_index; $newAtom->{'atomID'} = $atom_num; } } } # finish off the previous chain if ($curr_chain ne '') { my $s_dot_allResidues_dot_size = $#{$structure->{'allResidues'}} + 1; $r->{'max'} = $s_dot_allResidues_dot_size - 1; } } sub program_display_html_form { html_header(); my $request_uri = $ENV{'REQUEST_URI'}; my @bits = split(/\//, $request_uri); my $pgm_name = $bits[$#bits]; my $got_errors = 0; my $err_msg = ''; print "
", " "; if ($got_errors == 1) { print " \n", " ", " \n"; } print " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
", "

$err_msg
Didn't do a search because of input error(s).

", "
\n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", " \n", "
\n", "Please provide a PDB file. Upload the PDB file from your computer.
\n", "Please note that this PDB file is not validated, so make sure that it is a valid PDB file.
\n", "
\n", "
\n", "\n", "\n", "
or
\n", "
\n", "\n", "\n", "\n", "\n", "
Enter the PDB file contents here.
Please note that these PDB file contents are not validated, so make sure that they are valid PDB file contents.
(Provide either a file or enter the contents here, not both.
If both provided, then contents here will be processed instead of uploaded file.)

\n", "
\n", "\n", "
\n", "
\n", "Please note that if your PDB file is too big for this server (ie. more than approx. 250 residues), this server will not give an answer and will either display a blank page or time out. ", "To know what can be done if this happens, please see the explanations below left.
\n", "
\n", "OPTIONS :

\n", " \n"; print " \n", " \n", " \n", " \n"; print " \n", " \n", " \n", " \n"; print " \n", " \n", " \n", " \n"; print " \n", " \n", " \n", " \n"; print " \n"; print " \n", " \n", " \n"; print " \n"; my @option_lines = ('PROFILES3D-LINE','REPIMPS-LINE'); my @option_attributes = ('showGraph','colour_name','legend_name','smooth'); my @option_attributes_display_name = ('Show line','Line colour','Line label','Smooth line'); for ( my $o = 0; $o < @option_lines; $o++ ) { my $option_name = $option_lines[$o]; my $ln = $program_options->{'lnOpt_index'}->{$option_name}; my $html_display_option_name = $program_options->{'lnOpt'}->[$ln]->{'legend_name'} . ' : '; for ( my $n = 0; $n < @option_attributes; $n++ ) { my $option_attribute = $option_attributes[$n]; my $param_name = 'option_' . $ln . '_' . $option_attribute; my $html_display_attribute_name = $option_attributes_display_name[$n]; my $html_input = ''; if ($option_attribute eq 'showGraph') { my $html_display_select_box = "'; $html_input = $html_display_select_box; } elsif ($option_attribute eq 'mov_avg') { # 'Moving average' my $html_input_value = $program_options->{'lnOpt'}->[$ln]->{'mov_avg'}; $html_input = ""; } elsif ($option_attribute eq 'colour_name') { my $html_display_select_box = "'; $html_input = $html_display_select_box; } elsif ($option_attribute eq 'legend_name') { my $html_input_value = $program_options->{'lnOpt'}->[$ln]->{'legend_name'}; $html_input = ""; } elsif ($option_attribute eq 'smooth') { my $html_display_select_box = "'; $html_input = $html_display_select_box; } print " \n", " \n", " \n", " \n", " \n"; $html_display_option_name = ''; } } print "
SASA RESOLUTION : 
(Solvent Assessible Surface Area)
\n", "\n", "
IGNORE HETATOMS : \n", "\n", "
GRAPH RESIDUE WIDTH : \n", "\n", "
GRAPH HEIGHT : \n", "\n", "
DISPLAY OPTIONS :
$html_display_option_name$html_display_attribute_name:\n", "$html_input\n", "
\n", "
\n", "
Notes about running this web page :
\n", "
\n", "If your PDB file has too many residues in it for this server (ie. more than approx. 250 residues), ", "this web page will time out and not display the result (it will display a blank page, or take a long time to process and then eventually time out.).

", "In that case, you can either download this Perl program ", "from http://www.canoz.com/valpred/valpred3d_pl.txt
", "and run it on your own cgi-script perl-enabled web server, ", "or run it in command line mode in your own Perl installation, ", "(Linux Ubuntu 8.04 was used for testing).

", "Your own web server may allow the program to run for longer before timing out.

", "In command line mode, depending on your computer's memory size, you will probably be able to process longer sequences (our Linux testing machine was able to process 1800 residue long sequences).

", "You can also download the Windows version of this program ", "from http://www.canoz.com/valpred/valpred_execution_files_jun2009.zip ", "or from http://www.canoz.com/valpred/valpred_execution_files_jun2009.rar ", "and run it on your Windows PC (Windows XP Home Edition was used for testing).

", "When you need to process sequences that are too long for the machine you are using, then a valid strategy is to break up your sequence into overlapping pieces, run each separately, and visually piece them together.

", "
\n", "

References :
\n", "
\n", "Lawrence K. Lee, Noeris K. Salam, Hong Wing Lee, Emma M. Rath and W. Bret Church (in preparation)
\n", "'Transmembrane helix analysis using threading approaches'
\n", "
\n", "James U. Bowie, Roland Lüthy, David Eisenberg (1991)
\n", "'A Method to Identify Protein Sequences that Fold into a Known Three-Dimensional Structure'
\n", "Science, 253, 164-170
\n", "
\n", "Roland Lüthy, James U. Bowie, David Eisenberg (1992)
\n", "'Assessment of protein models with three-dimensional profiles'
\n", "Nature, 356, 83-85
\n", "
\n", "Siavoush Dastmalchi, Michael B. Morris and W. Bret Church (2001)
\n", "'Modelling of the structural features of integral-membrane proteins using REPIMPS
\n", "(Reverse-Environment Prediction of Integral Membrane Protein Structure)'
\n", "Protein Science, 10, 1529-1538
\n", "

Benchmarking :
\n", "
\n", "This VALPRED program, including both its VALPRED1 and VALPRED2 algorithms,
\n", "have been benchmarked at the Benchmark of Membrane Helix Predictions from Sequence server.
\n", "

Source Code : valpred3d_pl.txt
\n", "
\n", "

COPYRIGHT :
\n", "Valpred Windows Program Copyright © 2010 Lawrence K. Lee. All rights reserved.
\n", "Valpred Perl Program Copyright © 2010 Emma M. Rath. All rights reserved.
\n", "Soon this program will be released under an open source software license such as GNU General Public License or
\n", "Creative Commons license for Free Software Foundation's GNU General Public License at creativecommons.org
\n", "
\n", "
\n", "
\n"; print "
\n"; print $cgi_query->end_html(); } sub program_get_input { set_program_options_defaults(); $program_mode = 'command-line'; if (defined($ENV{'REQUEST_METHOD'})) { if ($ENV{'REQUEST_METHOD'} eq 'POST') { my $params = $cgi_query->Vars; if (defined($params->{'chart_coords'})) { $program_mode = 'cgi-output-graph'; } else { $program_mode = 'cgi-output'; } } else { $program_mode = 'cgi-display-form'; } } else { GetOptions( "infile=s" => \$input_infile, "inscoresfile=s" => \$input_inscoresfile, "sasares=s" => \$input_sasares, "ignorehet=s" => \$input_ignorehet, "help" => \$input_flag_help, "h" => \$input_flag_h, "debug" => \$input_debug_flag ); if (defined($input_sasares)) { if (($input_sasares == 0) || ($input_sasares == 1) || ($input_sasares == 2) || ($input_sasares == 3) || ($input_sasares == 4) || ($input_sasares == 5)) { $program_options->{'SASARes'} = $input_sasares; } } if (defined($input_ignorehet)) { if (($input_ignorehet == 0) || ($input_ignorehet == 1)) { $program_options->{'IgnoreHetAtoms'} = $input_ignorehet; } } } } sub program_output_command_line { my $got_command_line_error = 0; my $command_line_help_text = ''; $command_line_help_text .= "\n"; $command_line_help_text .= "This program is called VALPRED3D, and it validates a 3D structure in PDB format using PROFILES3D and REPIMPS.\n"; $command_line_help_text .= "\n"; $command_line_help_text .= "To run the program in command line mode :\n"; $command_line_help_text .= "\n"; $command_line_help_text .= " perl valpred3d.pl -infile PDB_FILE\n"; $command_line_help_text .= "\n"; $command_line_help_text .= "or :\n"; $command_line_help_text .= "\n"; $command_line_help_text .= " perl valpred3d.pl -infile PDB_FILE -sasares 2 -ignorehet 0\n"; $command_line_help_text .= "\n"; $command_line_help_text .= "Please note that it is also possible to run this program as a cgi-script on a web server.\n"; $command_line_help_text .= "\n"; $command_line_help_text .= "There is a Windows version of this program. "; $command_line_help_text .= "you can download the Windows version of this program from http://www.canoz.com/valpred/valpred_execution_files_jun2009.zip "; $command_line_help_text .= "or from http://www.canoz.com/valpred/valpred_execution_files_jun2009.rar and run it on your Windows PC.\n"; $command_line_help_text .= "\n"; $command_line_help_text .= "References :\n"; $command_line_help_text .= "\n"; $command_line_help_text .= " Lawrence K. Lee, Noeris K. Salam, Hong Wing Lee, Emma M. Rath and W. Bret Church (in preparation)\n"; $command_line_help_text .= " 'Transmembrane helix analysis using threading approaches'\n"; $command_line_help_text .= "\n"; $command_line_help_text .= " James U. Bowie, Roland Lüthy, David Eisenberg (1991)\n"; $command_line_help_text .= " 'A Method to Identify Protein Sequences that Fold into a Known Three-Dimensional Structure'\n"; $command_line_help_text .= " Science, 253, 164-170\n"; $command_line_help_text .= "\n"; $command_line_help_text .= " Roland Lüthy, James U. Bowie, David Eisenberg (1992)\n"; $command_line_help_text .= " 'Assessment of protein models with three-dimensional profiles'\n"; $command_line_help_text .= " Nature, 356, 83-85\n"; $command_line_help_text .= "\n"; $command_line_help_text .= " Siavoush Dastmalchi, Michael B. Morris and W. Bret Church (2001)\n"; $command_line_help_text .= " 'Modelling of the structural features of integral-membrane proteins using REPIMPS\n"; $command_line_help_text .= " (Reverse-Environment Prediction of Integral Membrane Protein Structure)'\n"; $command_line_help_text .= " Protein Science, 10, 1529-1538\n"; $command_line_help_text .= "\n"; $command_line_help_text .= "Copyright :\n"; $command_line_help_text .= "\n"; $command_line_help_text .= " Valpred Windows Program Copyright © 2010 Lawrence K. Lee. All rights reserved.\n"; $command_line_help_text .= " Valpred Perl Program Copyright © 2010 Emma M. Rath. All rights reserved.\n"; $command_line_help_text .= " Soon this program will be released under an open source software license such as GNU General Public License or \n"; $command_line_help_text .= " Creative Commons license for Free Software Foundation's GNU General Public License at creativecommons.org\n"; $command_line_help_text .= "\n"; $command_line_help_text .= "\n"; $command_line_help_text .= "\n"; if (defined($input_infile)) { $input_file_name_for_output_files = $input_infile; $input_file_name_for_output_files = untaint($input_file_name_for_output_files); program_output_command_line_for_infile(); } elsif (defined($input_inscoresfile)) { program_output_command_line_for_inscoresfile(); } elsif ((defined($input_flag_help)) || (defined($input_flag_help))) { print $command_line_help_text; } else { $got_command_line_error = 1; print $command_line_help_text; print "There was no input file specified in command-line mode.\n"; } } sub program_output_command_line_for_infile { # open input file open INFILE, $input_infile or die $!; my @read_input_lines = ; my @input_lines; my $input_lines_pointer = \@input_lines; my $seq_num = 0; foreach my $input_line (@read_input_lines) { chomp($input_line); if ($input_line ne '') { $input_line = trim($input_line); if ($input_line ne '') { push( @input_lines, $input_line ); } } } program_build_and_output_results( $input_lines_pointer ); } sub program_output_html_graph { my $params = $cgi_query->Vars; my $chart_coords = ''; if (defined($params->{'chart_coords'})) { $chart_coords = trim($params->{'chart_coords'}); } set_program_options_defaults(); # read_program_options_defaults_file(); # defaults file from windows version # OPTIONS,3,PROFILES3D-MOV-AVG-1,1,1,10,0,0,255,blue,Profiles 3D (mv.av.1),0,1,::::: # OPTIONS,4,REPIMPS-MOV-AVG-1,1,1,10,255,0,0,red,REPIMPS (mv.av.1),0,1,::::: # OPTIONS,15,TMS,1,1,0,0,0,0,black,Transmembrane Segments,1.7,1,::::: # NUM_RESIDUES,160,:::::NUM_CHAINS,1,:::::CHAIN,0,160,0,::::: # LINE,3,::::: # DATA,-0.185,-0.146,-0.197,-0.264,-0.167,-0.167,-0.229,-0.338,-0.229,-0.234,-0.261,-0.147,-0.085,0.021,-0.032,::::: # LINE,4,::::: # DATA,0.407,0.101,0.387,0.617,0.354,0.354,0.437,0.613,0.437,0.127,0.017,0.151,0.068,0.07,0.337,::::: # LINE,15,::::: # DATA,0,0,0,0,0,0,1,1,1,1,1,1,1,1,1,::::: # TITLE,,,,,>KCSA_STRLI Voltage-gated potassium channel::::: # get any program_options in the $chart_coords input string for ( my $o = 0; $o <= $program_options->{'option_max_index'}; $o++ ) { $program_options->{'lnOpt'}->[$o]->{'showGraph'} = 0; } # my @option_attributes = ('line_id','showGraph','weight','mov_avg','colour0','colour1','colour2','colour_name','legend_name','y_value','smooth'); my @option_attributes = @{$program_options->{'option_name'}}; my @chart_coords_lines = split( /:::::/, $chart_coords ); foreach my $chart_coords_line (@chart_coords_lines) { my @bits = split( /,/, $chart_coords_line ); if ($bits[0] eq 'OPTIONS') { my $ln = ''; if (defined($bits[1])) { $ln = trim($bits[1]); if ($ln =~ /^(\d+)$/) { # is it a +ve integer? for (my $o2 = 2; $o2 < @bits; $o2++ ) { my $o = $o2 - 2; my $value = trim($bits[$o2]); if ($value ne '') { my $option_attribute = $option_attributes[$o]; $program_options->{'lnOpt'}->[$ln]->{$option_attribute} = $value; } } } } # } elsif ($bits[0] eq 'LINE') { # my $ln = ''; # if (defined($bits[1])) { # $ln = trim($bits[1]); # if ($ln =~ /^(\d+)$/) { # is it a +ve integer? # $program_options->{'lnOpt'}->[$ln]->{'showGraph'} = 1; # } # } } } draw_chart_from_coords( $chart_coords, 0 ); } sub program_output_html_results { html_header(); get_html_program_options(); my $params = $cgi_query->Vars; my $got_error = 0; my @input_lines; my $input_lines_pointer = \@input_lines; my $user_provided_pdb_contents = 0; if (defined($params->{'pdb_contents'})) { my $pdb_contents = trim( $params->{'pdb_contents'} ); if ($pdb_contents ne '') { $user_provided_pdb_contents = 1; my @pdb_lines = split(/\n|\r/, $pdb_contents); foreach my $pdb_line (@pdb_lines) { $pdb_line = trim($pdb_line); if ($pdb_line ne '') { push( @input_lines, $pdb_line ); } } } } if ( (defined($params->{'upload_file'})) && ($user_provided_pdb_contents == 0)) { my $upload_file = $cgi_query->param('upload_file'); my $upload_filehandle = $cgi_query->upload('upload_file'); if ($upload_file ne '') { if ($upload_filehandle eq '') { $got_error = 1; print "The upload didn't work. Probably your file is too big - bigger than 5MB.
"; } else { # read the uploaded file my @uploaded_lines; my $user_data = ''; while ( <$upload_filehandle> ) { my $input_line = $_; chomp($input_line); push( @input_lines, $input_line ); } } } } if ($got_error == 0) { my $num_input_lines = @input_lines; if ($num_input_lines < 1) { $got_error = 1; print "No input PDB lines were given. Please upload a PDB file or enter your PDB file contents.
"; } } if ($got_error == 0) { program_build_and_output_results( $input_lines_pointer ); } print "\n"; print $debug; print $cgi_query->end_html(); } sub Range_new { my %r_hash; my $r = \%r_hash; $r->{ 'chainID' } = 0; $r->{ 'min' } = 0; $r->{ 'max' } = 0; # print 'in Range_new : $r = ' . Dumper( $r ); return $r; #C++ Range } sub read_amino_acid_pdbs { my @amino_acids = ('ala','arg','asn','asp','cys','gln','glu','gly','his','ile','leu','lys','met','phe','pro','ser','thr','trp','tyr','val'); foreach my $amino_acid (@amino_acids) { my $amino_acid_capitals = uc $amino_acid; my $filepath = $path_to_files_Amino_Acids . '/' . $amino_acid . '.pdb'; # filepath = currentDir + "/Amino Acids/" + r.name + ".pdb"; my $file_exists = 1; open AAFILE, $filepath or $file_exists = 0; my @pdb_lines; if ($file_exists == 1) { @pdb_lines = ; } else { my $pdb_lines_ref = hard_coded_amino_acid_pdb( $amino_acid ); @pdb_lines = @$pdb_lines_ref; } my $i = 0; foreach my $pdb_line (@pdb_lines) { chomp( $pdb_line ); $pdb_line =~ s/\r//g; # windows file line end = 0D0A = \r\n linux file line end = 0A = \n if (length($pdb_line) >= 66) { # if(buffer.length() < 4 || buffer.substr(0,4) != "ATOM"){ if (substr($pdb_line,0,4) eq 'ATOM') { # if(buffer.substr(0,4) == "ATOM"){ $amino_acid_pdbs->{$amino_acid_capitals}->[$i]->{'recname'} = trim(substr($pdb_line,0,6)); $amino_acid_pdbs->{$amino_acid_capitals}->[$i]->{'serial'} = trim(substr($pdb_line,6,6)); $amino_acid_pdbs->{$amino_acid_capitals}->[$i]->{'name'} = trim(substr($pdb_line,12,4)); # string name = buffer.substr(12,4); eatWhite(name); $amino_acid_pdbs->{$amino_acid_capitals}->[$i]->{'x'} = trim(substr($pdb_line,30,8)); # float x = (float)(atof(buffer.substr(30, 8).c_str())); $amino_acid_pdbs->{$amino_acid_capitals}->[$i]->{'y'} = trim(substr($pdb_line,38,8)); # float y = (float)(atof(buffer.substr(38, 8).c_str())); $amino_acid_pdbs->{$amino_acid_capitals}->[$i]->{'z'} = trim(substr($pdb_line,46,8)); # float z = (float)(atof(buffer.substr(46, 8).c_str())); } } $i++; } } } sub read_program_options_defaults_file { # defaults file from windows version # CChartView::setLineParam, input in Valpred_Files/ChartOptions.opt # CChartView::loadChartOptions # outFile<<"PROFILES\n1\n1\n10\n0\n0\n255\n"; # outFile<<"REPIMPS\n1\n1\n10\n255\n0\n0\n"; # outFile<<"OVERALL\n0\n1\n10\n0\n0\n0\n"; # outFile<<"XAXIS\n1\n20\n1\n0\n0\n \n \n0\n0\n"; # outFile<<"YAXIS\n1\n1.0\n1\n0\n0\n \n \n0\n0\n"; my $filepath = $path_to_files_Valpred_Files . '/ChartOptions.opt'; my $file_exists = 1; open DEFOPTS, $filepath or $file_exists = 0; if ($file_exists == 1) { my @default_options_lines = ; for ( my $o = 0; $o < @default_options_lines; $o++ ) { my $default_options_line = $default_options_lines[$o]; $default_options_line =~ s/\r//g; # windows file line end = 0D0A = \r\n $default_options_line =~ s/\n//g; $default_options_lines[$o] = $default_options_line; } my @option_name_in_ChartOptions_file = ('PROFILES','REPIMPS'); my @option_name_in_this_program = ('PROFILES3D','REPIMPS'); for ( my $o = 0; $o < @option_name_in_ChartOptions_file; $o++ ) { my $ln_name = $option_name_in_this_program[$o]; my $ln = $program_options->{'lnOpt_index'}->{$ln_name}; my $f = $ln * 7; if (defined($default_options_lines[$f + 1])) { $program_options->{'lnOpt'}->[$ln]->{'showGraph'} = $default_options_lines[$f + 1]; } if (defined($default_options_lines[$f + 2])) { $program_options->{'lnOpt'}->[$ln]->{'weight'} = $default_options_lines[$f + 2]; } if (defined($default_options_lines[$f + 3])) { $program_options->{'lnOpt'}->[$ln]->{'mov_avg'} = $default_options_lines[$f + 3]; } if (defined($default_options_lines[$f + 4])) { $program_options->{'lnOpt'}->[$ln]->{'colour0'} = $default_options_lines[$f + 4]; } if (defined($default_options_lines[$f + 5])) { $program_options->{'lnOpt'}->[$ln]->{'colour1'} = $default_options_lines[$f + 5]; } if (defined($default_options_lines[$f + 6])) { $program_options->{'lnOpt'}->[$ln]->{'colour2'} = $default_options_lines[$f + 6]; } } } } sub Residue_checkMainChain { #C++ bool Residue::checkMainChain(){ my $r = shift; if (($r->{'C'} < 0) || ($r->{'CA'} < 0) || ($r->{'N'} < 0) || ($r->{'O'} < 0)) { # if (C < 0 || CA < 0 || N < 0 || O < 0){ return 0; # return false; } return 1; # return true; } sub Residue_new { my %res_hash; my $res = \%res_hash; # ///structural information/// $res->{ 'chainID' } = -1; # char chainID; # // chain Identifier $res->{ 'SS' } = ''; # SecStruct SS; # // secondary structure $res->{ 'resSeq' } = -1; # unsigned int resSeq; # // residue sequence identifier $res->{ 'name' } = ''; # string name; # // residue name $res->{ 'isTransMem' } = -1; # bool isTransMem; $res->{ 'CA' } = -1; # int CA; $res->{ 'C' } = -1; # int C; $res->{ 'N' } = -1; # int N; $res->{ 'O' } = -1; # int O; # // index to main chain atoms my @res_sideChains_array; $res->{ 'sideChains' } = \@res_sideChains_array; # vector sideChains; # // vector of sidechain atoms $res->{ 'aaCode' } = ''; # ResCode aaCode; # //enumeration residue type; # print 'in Residue_new : $res = ' . Dumper( $res ); return $res; #C++ Residue } sub set_assignResType { $assignResType{'ALA'} = ALA; $assignResType{'ARG'} = ARG; $assignResType{'ASN'} = ASN; $assignResType{'CYS'} = CYS; $assignResType{'GLN'} = GLN; $assignResType{'GLU'} = GLU; $assignResType{'GLY'} = GLY; $assignResType{'HIS'} = HIS; $assignResType{'ILE'} = ILE; $assignResType{'LEU'} = LEU; $assignResType{'LYS'} = LYS; $assignResType{'MET'} = MET; $assignResType{'PHE'} = PHE; $assignResType{'PRO'} = PRO; $assignResType{'SER'} = SER; $assignResType{'THR'} = THR; $assignResType{'TRP'} = TRP; $assignResType{'TYR'} = TYR; $assignResType{'VAL'} = VAL; $assignResType{'UNK'} = UNK; return; } sub set_charToRes { $charToRes{'A'} = "ALA"; $charToRes{'R'} = "ARG"; $charToRes{'N'} = "ASN"; $charToRes{'D'} = "ASP"; $charToRes{'C'} = "CYS"; $charToRes{'Q'} = "GLN"; $charToRes{'E'} = "GLU"; $charToRes{'G'} = "GLY"; $charToRes{'H'} = "HIS"; $charToRes{'I'} = "ILE"; $charToRes{'L'} = "LEU"; $charToRes{'K'} = "LYS"; $charToRes{'M'} = "MET"; $charToRes{'F'} = "PHE"; $charToRes{'P'} = "PRO"; $charToRes{'S'} = "SER"; $charToRes{'T'} = "THR"; $charToRes{'W'} = "TRP"; $charToRes{'Y'} = "TYR"; $charToRes{'V'} = "VAL"; return; } sub set_program_options_defaults { $program_options->{'SASARes'} = 2; $program_options->{'IgnoreHetAtoms'} = 0; $program_options->{'graph_residue_width'} = 10; # 10 pixels to be shown per residue $program_options->{'graph_height'} = 600; # 600 pixels high $program_options->{'option_name'}->[0] = 'line_id'; $program_options->{'option_name'}->[1] = 'showGraph'; $program_options->{'option_name'}->[2] = 'weight'; $program_options->{'option_name'}->[3] = 'mov_avg'; $program_options->{'option_name'}->[4] = 'colour0'; $program_options->{'option_name'}->[5] = 'colour1'; $program_options->{'option_name'}->[6] = 'colour2'; $program_options->{'option_name'}->[7] = 'colour_name'; $program_options->{'option_name'}->[8] = 'legend_name'; $program_options->{'option_name'}->[9] = 'y_value'; $program_options->{'option_name'}->[10] = 'smooth'; my $o; # PROFILES3D-LINE $o = 0; $program_options->{'lnOpt_index'}->{'PROFILES3D-LINE'} = $o; $program_options->{'lnOpt'}->[$o]->{'line_id'} = 'PROFILES3D-LINE'; $program_options->{'lnOpt'}->[$o]->{'showGraph'} = 1; $program_options->{'lnOpt'}->[$o]->{'weight'} = 1; $program_options->{'lnOpt'}->[$o]->{'mov_avg'} = 10; $program_options->{'lnOpt'}->[$o]->{'colour0'} = 0; $program_options->{'lnOpt'}->[$o]->{'colour1'} = 0; $program_options->{'lnOpt'}->[$o]->{'colour2'} = 255; $program_options->{'lnOpt'}->[$o]->{'colour_name'} = 'blue'; $program_options->{'lnOpt'}->[$o]->{'legend_name'} = 'Profiles 3D'; $program_options->{'lnOpt'}->[$o]->{'y_value'} = 0; $program_options->{'lnOpt'}->[$o]->{'smooth'} = 0; # REPIMPS-LINE $o = 1; $program_options->{'lnOpt_index'}->{'REPIMPS-LINE'} = $o; $program_options->{'lnOpt'}->[$o]->{'line_id'} = 'REPIMPS-LINE'; $program_options->{'lnOpt'}->[$o]->{'showGraph'} = 1; $program_options->{'lnOpt'}->[$o]->{'weight'} = 1; $program_options->{'lnOpt'}->[$o]->{'mov_avg'} = 10; $program_options->{'lnOpt'}->[$o]->{'colour0'} = 255; $program_options->{'lnOpt'}->[$o]->{'colour1'} = 0; $program_options->{'lnOpt'}->[$o]->{'colour2'} = 0; $program_options->{'lnOpt'}->[$o]->{'colour_name'} = 'red'; $program_options->{'lnOpt'}->[$o]->{'legend_name'} = 'REPIMPS'; $program_options->{'lnOpt'}->[$o]->{'y_value'} = 0; $program_options->{'lnOpt'}->[$o]->{'smooth'} = 0; $program_options->{'option_max_index'} = $o; } sub set_Residue_constants { # constants set in Residue.h $Residue_SecStruct{'SHEET'} = 0; $Residue_SecStruct{'HELIX'} = 1; $Residue_SecStruct{'OTHER'} = 2; $Residue_ResCode{'ALA'} = 7; $Residue_ResCode{'ARG'} = 19; $Residue_ResCode{'ASN'} = 14; $Residue_ResCode{'ASP'} = 16; $Residue_ResCode{'CYS'} = 10; $Residue_ResCode{'GLN'} = 13; $Residue_ResCode{'GLU'} = 15; $Residue_ResCode{'GLY'} = 8; $Residue_ResCode{'HIS'} = 17; $Residue_ResCode{'ILE'} = 4; $Residue_ResCode{'LEU'} = 3; $Residue_ResCode{'LYS'} = 18; $Residue_ResCode{'MET'} = 6; $Residue_ResCode{'PHE'} = 1; $Residue_ResCode{'PRO'} = 9; $Residue_ResCode{'SER'} = 12; $Residue_ResCode{'THR'} = 11; $Residue_ResCode{'TRP'} = 0; $Residue_ResCode{'TYR'} = 2; $Residue_ResCode{'VAL'} = 5; $Residue_ResCode{'UNK'} = 21; $Residue_EnvCode{'B1a'} = 0; $Residue_EnvCode{'B1b'} = 1; $Residue_EnvCode{'B1'} = 2; $Residue_EnvCode{'B2a'} = 3; $Residue_EnvCode{'B2b'} = 4; $Residue_EnvCode{'B2'} = 5; $Residue_EnvCode{'B3a'} = 6; $Residue_EnvCode{'B3b'} = 7; $Residue_EnvCode{'B3'} = 8; $Residue_EnvCode{'P1a'} = 9; $Residue_EnvCode{'P1b'} = 10; $Residue_EnvCode{'P1'} = 11; $Residue_EnvCode{'P2a'} = 12; $Residue_EnvCode{'P2b'} = 13; $Residue_EnvCode{'P2'} = 14; $Residue_EnvCode{'Ea'} = 15; $Residue_EnvCode{'Eb'} = 16; $Residue_EnvCode{'E'} = 17; $Residue_EnvCode{'unknown'} = 18; return; } sub set_Value_constants { # constants set in Value.h # //initialisatiion of side chain GlyXGly values # const float SCGlyXGly[21] = { $SCGlyXGly->[TRP] = 245.263746; # 245.263746f, //TRP $SCGlyXGly->[PHE] = 189.159849; # 189.159849f, //PHE $SCGlyXGly->[TYR] = 208.929577; # 208.929577f, //TYR $SCGlyXGly->[LEU] = 159.793969; # 159.793969f, //LEU $SCGlyXGly->[ILE] = 156.162288; # 156.162288f, //ILE $SCGlyXGly->[VAL] = 123.11399; # 123.11399f, //VAL $SCGlyXGly->[MET] = 172.169566; # 172.169566f, //MET $SCGlyXGly->[ALA] = 60.892862; # 60.892862f, //ALA $SCGlyXGly->[GLY] = 45.032846; # 45.032846f, //GLY $SCGlyXGly->[PRO] = 136.55121; # 136.55121f, //PRO $SCGlyXGly->[CYS] = 98.295329; # 98.295329f, //CYS $SCGlyXGly->[THR] = 108.913991; # 108.913991f, //THR $SCGlyXGly->[SER] = 95.026895; # 95.026895f, //SER $SCGlyXGly->[GLN] = 144.73443; # 144.73443f, //GLN $SCGlyXGly->[ASN] = 125.607472; # 125.607472f, //ASN $SCGlyXGly->[GLU] = 152.160527; # 152.160527f, //GLU $SCGlyXGly->[ASP] = 110.354411; # 110.354411f, //ASP $SCGlyXGly->[HIS] = 152.417666; # 152.417666f, //HIS $SCGlyXGly->[LYS] = 162.613548; # 162.613548f, //LYS $SCGlyXGly->[ARG] = 199.132285; # 199.132285f, //ARG $SCGlyXGly->[UNK] = 0; # 0.000000f, //UNK return; } sub SpherePoints_generate { #C++ void SpherePoints::generate(vector& spherePoints, string path) my $spherePoints = shift; #C++ vector& my $path = shift; #C++ string my $file_exists = 1; open POINTSFILE, $path or $file_exists = 0; # fstream pointsFile(path.c_str()); my @lines; if ($file_exists == 1) { @lines = ; # getline(pointsFile, line); } else { my $points_lines_ref = hard_coded_sphere_points(); @lines = @$points_lines_ref; } $lines[0] =~ s/\r//g; # windows file line end = 0D0A = \r\n linux file line end = 0A = \n my $numPoints = $lines[0]; # int numPoints = atoi(line.c_str()); # spherePoints.resize(numPoints, Vec3f()); my $l = 0; foreach my $line ( @lines ) { chomp( $line ); $line =~ s/\r//g; # windows file line end = 0D0A = \r\n linux file line end = 0A = \n $lines[$l] = $line; $l++; } my $line_upto = 0; for ( my $i = 0; $i < $numPoints; $i++ ) { # for (int i=0; i[$i]->{'x'} = $lines[$line_upto]; # spherePoints[i].x = (float)atof(line.c_str()); $line_upto++; # getline(pointsFile, line); $spherePoints->[$i]->{'y'} = $lines[$line_upto]; # spherePoints[i].y = (float)atof(line.c_str()); $line_upto++; # getline(pointsFile, line); $spherePoints->[$i]->{'z'} = $lines[$line_upto]; # spherePoints[i].z = (float)atof(line.c_str()); } return $spherePoints; #C++ vector& } sub Structure_getResChain_indices { my $index = shift; my $res; $res->{'min'} = -1; $res->{'max'} = -1; my $chains_dot_size = $#{$structure->{'chains'}} + 1; if ($index < $chains_dot_size) { $res->{'min'} = $structure->{'chains'}->[$index]->{'min'}; $res->{'max'} = $structure->{'chains'}->[$index]->{'max'}; return $res; } print "ERROR: Internal error: Chain index not found!\n"; return $res; } sub Structure_getResChain_int { #C++ vector Structure::getResChain(unsigned int index){ my $index = shift; #C++ unsigned int my $res; # vector res; my $chains_dot_size = $#{$structure->{'chains'}} + 1; if ($index < $chains_dot_size) { # if (index < chains.size()){ # for (unsigned int i = chains[index].min; i <= chains[index].max; i++){ for ( my $i = $structure->{'chains'}->[$index]->{'min'}; $i <= $structure->{'chains'}->[$index]->{'max'}; $i++ ) { my $push_back_index = $#{$res} + 1; $res->[$push_back_index] = $structure->{'allResidues'}->[$i]; # res.push_back(&allResidues[i]); } return $res; # return res; } print "ERROR: Internal error: Chain index not found!\n"; # AfxMessageBox("Internal error: Chain index not found!"); return $res; # return res; } sub Structure_getResChain_Range { #C++ vector Structure::getResChain(Range r){ my $r = shift; my @res_array; my $res = \@res_array; #C++ vector res; for ( my $i = $r->{'min'}; $i <= $r->{'max'}; $i++ ) { # for( unsigned int i = r.min; i <= r.max; i++){ my $push_back_index = $#{$res} + 1; $res->[$push_back_index] = $structure->{'allResidues'}->[$i]; # res.push_back(&allResidues[i]); } return $res; # return res; } sub Structure_new { my @s_SheetInfo_array; $structure->{ 'SheetInfo' } = \@s_SheetInfo_array; #C++ vector SheetInfo; my @s_HelixInfo_array; $structure->{ 'HelixInfo' } = \@s_HelixInfo_array; #C++ vector HelixInfo; my @s_allAtoms_array; $structure->{ 'allAtoms' } = \@s_allAtoms_array; #C++ vector allAtoms; my @s_allResidues_array; $structure->{ 'allResidues' } = \@s_allResidues_array; #C++ vector allResidues; my @s_chains_array; $structure->{ 'chains' } = \@s_chains_array; #C++ vector chains; my @s_hetAtoms_array; $structure->{ 'hetAtoms' } = \@s_hetAtoms_array; #C++ vector hetAtoms; # // Construction/Destruction $structure->{'ASA'} = 0; # ASA = 0.0f; # //Total SASA of structure $structure->{'aveResScore'} = 0; # aveResScore = 0.0f; $structure->{'scoreTotal'} = 0; # float scoreTotal; my @xyzExtremities_array; $structure->{'xyzExtremities'} = \@xyzExtremities_array; for (my $i = 0; $i < 3; $i++) { # for (int i = 0; i < 3; i++){ # struct vec2f{ # float f1; # float f2; my $v; # vec2f v; $v->{'f1'} = 0; # v.f1 = 0.0f; # //minimum value $v->{'f2'} = 0; # v.f2 = 0.0f; # //maximum value # vector xyzExtremities; //the maximum and minimum xyz values my $push_back_index = $#{$structure->{'xyzExtremities'}} + 1; $structure->{'xyzExtremities'}->[$push_back_index] = $v; # xyzExtremities.push_back(v); } return; } # Perl trim function to remove whitespace from the start and end of the string sub trim { my $string = shift; $string =~ s/^\s+//; $string =~ s/\s+$//; return $string; } # //========================================================================== # // Vec3.hpp : 3d vector class template. Works for any integer or real type. # //========================================================================== # // from GLUV # // http://www.cs.unc.edu/~walk/software/glvu/html/vec4f_8hpp-source.html # //Author: # //Kenny Hoff , Bill Baxter , # //Wes Hunt , Mark Harris sub untaint { my $path = shift; # user_error("path cannot contain metacharacters") if $path=~/[\n|<>&!;\'\"]/; # extract only legal alphanumerics from the filename # $path =~ m!(/[a-zA-Z/0-9._~\-]+)!; # $path =~ /([\w"-"".""_"]+)/; $path =~ /([a-zA-Z0-9._~\-]+)/; if (defined($1)) { $path = $1; } else { $path = ''; } # user_error("path cannot contain relative directories") # if $path=~m!\.\.!; return $path; } sub Vec3_add_Vec3 { #C++ inline Vec3& operator += (const Vec3& A) my $vec3_1 = shift; my $vec3_2 = shift; my %vec3_new_hash; my $vec3_new = \%vec3_new_hash; # { x+=A.x; y+=A.y; z+=A.z; $vec3_new->{'x'} = $vec3_1->{'x'} + $vec3_2->{'x'}; $vec3_new->{'y'} = $vec3_1->{'y'} + $vec3_2->{'y'}; $vec3_new->{'z'} = $vec3_1->{'z'} + $vec3_2->{'z'}; return $vec3_new; #C++ Vec3f or Vec3d # return *this; } } sub Vec3_cross { #C++ inline Vec3 cross (const Vec3& A) const my $vec3_1 = shift; my $vec3_2 = shift; my %vec3_new_hash; my $vec3_new = \%vec3_new_hash; # Vec3 CrossProd(y*A.z-z*A.y, z*A.x-x*A.z, x*A.y-y*A.x); $vec3_new->{'x'} = ($vec3_1->{'y'} * $vec3_2->{'z'}) - ($vec3_1->{'z'} * $vec3_2->{'y'}); $vec3_new->{'y'} = ($vec3_1->{'z'} * $vec3_2->{'x'}) - ($vec3_1->{'x'} * $vec3_2->{'z'}); $vec3_new->{'z'} = ($vec3_1->{'x'} * $vec3_2->{'y'}) - ($vec3_1->{'y'} * $vec3_2->{'x'}); return $vec3_new; #C++ Vec3f or Vec3d # return(CrossProd); }; } sub Vec3_dot_Vec3 { #C++ inline Type dot (const Vec3& A) const my $vec3_1 = shift; my $vec3_2 = shift; my $vec3_new; # { Type DotProd = x*A.x+y*A.y+z*A.z; $vec3_new = ($vec3_1->{'x'} * $vec3_2->{'x'}) + ($vec3_1->{'y'} * $vec3_2->{'y'}) + ($vec3_1->{'z'} * $vec3_2->{'z'}); return $vec3_new; # return(DotProd); }; } sub Vec3_length { #C++ inline Type length (void) const my $vec3 = shift; # { return ((Type)sqrt(x*x+y*y+z*z)); }; my $vec3_new; $vec3_new = ($vec3->{'x'} * $vec3->{'x'}) + ($vec3->{'y'} * $vec3->{'y'}) + ($vec3->{'z'} * $vec3->{'z'}); $vec3_new = sqrt($vec3_new); return $vec3_new; } sub Vec3_lengthSqr { #C++ inline Type lengthSqr (void) const my $vec3 = shift; # { return (x*x+y*y+z*z); }; my $vec3_new; $vec3_new = ($vec3->{'x'} * $vec3->{'x'}) + ($vec3->{'y'} * $vec3->{'y'}) + ($vec3->{'z'} * $vec3->{'z'}); return $vec3_new; } sub Vec3_multiply_number { #C++ inline Vec3& operator *= (const Type s) my $vec3 = shift; my $s = shift; my %vec3_new_hash; my $vec3_new = \%vec3_new_hash; # { x*=s; y*=s; z*=s; $vec3_new->{'x'} = $vec3->{'x'} * $s; $vec3_new->{'y'} = $vec3->{'y'} * $s; $vec3_new->{'z'} = $vec3->{'z'} * $s; return $vec3_new; #C++ Vec3f or Vec3d # return *this; } } # in C++ vec3h : # static Vec3 ZERO;# typedef Vec3 Vec3f; # typedef Vec3 Vec3d; # template Vec3 Vec3::ZERO = Vec3(0,0,0); # in Perl, apparently all numbers are treated as double, and not as the less precise float, # and the Perl compiler/interpreter is written in C/C++, # so all numbers should end up being represented as C++ double. sub Vec3_new { my %vec3_new_hash; my $vec3_new = \%vec3_new_hash; $vec3_new->{ 'x' } = 0; $vec3_new->{ 'y' } = 0; $vec3_new->{ 'z' } = 0; return $vec3_new; #C++ Vec3f or Vec3d } sub Vec3_new_set1 { my $xyx = shift; my %vec3_new_hash; my $vec3_new = \%vec3_new_hash; $vec3_new->{ 'x' } = $xyx->{ 'x' }; $vec3_new->{ 'y' } = $xyx->{ 'y' }; $vec3_new->{ 'z' } = $xyx->{ 'z' }; return $vec3_new; #C++ Vec3f or Vec3d } sub Vec3_new_set3 { my $x = shift; my $y = shift; my $z = shift; my %vec3_new_hash; my $vec3_new = \%vec3_new_hash; $vec3_new->{ 'x' } = $x; $vec3_new->{ 'y' } = $y; $vec3_new->{ 'z' } = $z; return $vec3_new; #C++ Vec3f or Vec3d } sub Vec3_normalize { #C++ inline Vec3& normalize (void) my $vec3 = shift; my $vec3_new = $vec3; my $L = Vec3_length( $vec3_new ); # { Type L = length(); # // CALCULATE LENGTH if ($L > 0) { # if (L>0) { x/=L; y/=L; z/=L; } # // DIV COMPONENTS BY LENGTH $vec3_new->{'x'} = $vec3_new->{'x'} / $L; $vec3_new->{'y'} = $vec3_new->{'y'} / $L; $vec3_new->{'z'} = $vec3_new->{'z'} / $L; } return $vec3_new; #C++ Vec3f or Vec3d # return *this; } sub Vec3_set3 { my $vec3 = shift; my $x = shift; my $y = shift; my $z = shift; my %vec3_new_hash; my $vec3_new = \%vec3_new_hash; $vec3_new->{ 'x' } = $x; $vec3_new->{ 'y' } = $y; $vec3_new->{ 'z' } = $z; return $vec3_new; #C++ Vec3f or Vec3d } sub Vec3_subtract_Vec3 { my $vec3_1 = shift; my $vec3_2 = shift; my %vec3_new_hash; my $vec3_new = \%vec3_new_hash; $vec3_new->{ 'x' } = $vec3_1->{ 'x' } - $vec3_2->{ 'x' }; $vec3_new->{ 'y' } = $vec3_1->{ 'y' } - $vec3_2->{ 'y' }; $vec3_new->{ 'z' } = $vec3_1->{ 'z' } - $vec3_2->{ 'z' }; return $vec3_new; #C++ Vec3f or Vec3d }