Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/perl
- #
- #
- # For calculating decay rates
- # tested using Hydrogen Exchange data
- #
- # Input file format should be:
- # <residue #> <value 1> <value 2> ...
- # One value for each time in @timeses
- #
- # Obvi needs Algorithm::CurveFit Module
- #
- # This is old code no hating
- #
- # ./hxrates <input file>
- #
- use Algorithm::CurveFit;
- @timeses = (0.01,0.02,0.04,0.075,0.1,0.15,0.175,0.2,0.25 );
- $x = $z =0;
- open(HXCH, $ARGV[0]);
- @hx = <HXCH>;
- #print $timeses[0]; die;
- foreach $line(@hx) {
- @vols = split(/ /,$line);
- $res = $vols[0];
- shift(@vols);
- foreach $val(@vols) {
- if($val != -10) {
- $val =~ s/\n//;
- $hxvols{$res}->{$x} = $val;
- #print "$hxvols{ $res }{ $x } : $hxvols{ $res }{ $x }{ times }\n";
- $x++;
- $z++;
- }
- else{
- $z++;
- }
- }
- $x=0;
- $z=0;
- } #foreach
- foreach $key (sort keys %hxvols) {
- $a=0;
- #for($y=0; $y <= $num; $y++){
- foreach $y (sort keys %{ $hxvols{$key} }){
- $yval[$a] = $hxvols{$key}{$y};
- $xval[$a] = $timeses[$y];
- if($yval[$a] != -1){
- #print "Y: $yval[$a]\n";
- $a++;
- }
- else{
- pop(@yval);
- pop(@xval);
- }
- #print "$key :: $yval[$y] :: $xval[$y]\n";
- }
- #initialize conditions
- @parameters = ( ['n',1,0.00001],['k',10,0.00001] );
- #print "$key @yval :: @xval\n";
- #exponential with offset
- my $formul = 'n *(1 - exp(-k * x))';
- $rate = Algorithm::CurveFit->curve_fit(
- formula => $formul,
- params => \@parameters,
- variable => 'x',
- xdata => \@xval,
- ydata => \@yval,
- max_iterations => '10000'
- );
- print "$key $parameters[0][1] $parameters[1][1]\n\n";
- }
- close(HXCH);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement