-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathconv_ncs.pl
executable file
·117 lines (97 loc) · 2.15 KB
/
conv_ncs.pl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
#!/usr/bin/perl
if(@ARGV!=1){
print "$0 [file]\n";
exit;
}
($file,$path)=@ARGV;
@B=firstfile("$file");
$cnt=0;
foreach my $l (@B){
@MTX=() if($$l[0] eq "new_operator");
if($$l[0] eq "rota_matrix"){
push @MTX,($$l[1],$$l[2],$$l[3]);
#print "@MTX\n";
}
if($$l[0] eq "tran_orth"){
$cnt++;
printf("REMARK 350 BIOMT1%4d%10.6f%10.6f%10.6f%15.5f\n",$cnt,$MTX[0],$MTX[1],$MTX[2],$$l[1]);
printf("REMARK 350 BIOMT2%4d%10.6f%10.6f%10.6f%15.5f\n",$cnt,$MTX[3],$MTX[4],$MTX[5],$$l[2]);
printf("REMARK 350 BIOMT3%4d%10.6f%10.6f%10.6f%15.5f\n",$cnt,$MTX[6],$MTX[7],$MTX[8],$$l[3]);
}
}
#@key = sort { $hash{$a} <=> $hash{$b} || $a <=> $b} keys %hash;
sub firstfile{
my $cnt=0;
my @A;
open(IN,$_[0]) or die;
while(<IN>){
next if(/^#/);
chomp;
my $item;
@{$item}=split(/[\s\t]+/,$_);
push @A, $item
}
close(IN);
return @A;
}
sub onetothree{
%amin123 = ("W"=>"TRP","F"=>"PHE","Y"=>"TYR","L"=>"LEU","I"=>"ILE","V"=>"VAL","M"=>"MET","A"=>"ALA","G"=>"GLY","P"=>"PRO","C"=>"CYS","T"=>"THR","S"=>"SER","Q"=>"GLN","N"=>"ASN","E"=>"GLU","D"=>"ASP","H"=>"HIS","K"=>"LYS","R"=>"ARG");
%amin321 = ("TRP"=>"W","PHE"=>"F","TYR"=>"Y","LEU"=>"L","ILE"=>"I","VAL"=>"V","MET"=>"M","ALA"=>"A","GLY"=>"G","PRO"=>"P","CYS"=>"C","THR"=>"T","SER"=>"S","GLN"=>"Q","ASN"=>"N","GLU"=>"E","ASP"=>"D","HIS"=>"H","LYS"=>"K","ARG"=>"R");
}
sub firstfile_line{
my $cnt=0;
my @A;
open(IN,$_[0]) or die;
while(<IN>){
next if(/^#/);
chomp;
push @A, $_;
}
close(IN);
return @A;
}
sub readpdb{
my $cnt=0;
my @A;
my ($x,$y,$z);
my ($file)=@_;
open(IN,$file) or die;
while(<IN>){
next unless(/^ATOM/);
chomp;
$x=substr($_,30,8);
$y=substr($_,38,8);
$z=substr($_,46,8);
my $atm=substr($_,13,3);
my $res=substr($_,17,3);
my $rnum=substr($_,22,4);
#my $m_tag=substr($_,17,9);
my $m_tag=substr($_,13,13);
my $item;
@{$item}=($res,$atm,$x,$y,$z,$rnum,$m_tag);
push @A, $item;
}
close(IN);
return @A;
}
sub Ave{
my $inp=$_[0];
my $n=0;
my $sum=0;
foreach $l (@{$inp}){
$sum+=$l;
$n++;
}
return ($sum/$n)
}
sub Std{
my $inp=$_[0];
my $n=0;
my $sum=0;
my $ave=Ave($inp);
foreach $l (@{$inp}){
$sum+=($l-$ave)*($l-$ave);
$n++;
}
return sqrt($sum/$n)
}