这是一个提取4.5埃范围内相邻残留物的程序。我已经将程序解析为原子数。从这些我想提取
我想以表格形式输出这些数据,以便我可以直接复制结果。但现在我陷入困境并需要帮助来提取我在$close_atomno
中获得的原子数字段,以及如何将程序用于多个pdb文件和不同的催化残留物。
感谢任何帮助。
#!/usr/bin/perl
use List::Util qw(sum);
use Data::Dumper qw(Dumper);
use 5.010;
say "enter residue no.";
chomp(my $r_no = <STDIN>);
my (@all_pos, @all_data, @matching_pos, @matching_data);
my $residue_file = "neighbouring_residues.txt";
open my $out_fh1, '>', $residue_file or die "Can't open $residue_file: $!";
say "enter file name";
chomp(my $infile_name = <STDIN>);
open IN, '<', $infile_name or die "Can't open $infile_name: $!";
LINE: while (<IN>) {
chomp;
/^ATOM/ or next LINE;
my @fields = split;
push @all_pos, [ @fields[6 .. 8] ];
push @all_data, [ @fields[1 .. 3, 5] ];
if( $fields[6] eq $r_no) {
say $_;
push @matching_pos, [ @fields[6 .. 8] ];
push @matching_data, [ @fields[1 .. 3, 5] ];
}
}
say $out_fh1 "Neighbouring residues at position $r_no in the 4.5A region are:";
my %close_atoms;
MATCHING_ATOM:
for my $i1 ( 0 .. $#matching_pos ) {
my $matching_atom = $matching_data[$i1][1];
$matching_atom eq $_ and next MATCHING_ATOM for qw/N CA O C/;
for my $i2 ( 0 .. $#all_pos ) {
my ($close_atomno, $close_residueno) = @{$all_data[$i2]}[0, 3];
my $dist = distance($matching_pos[$i1], $all_pos[$i2]);
if($dist < 4.5 and $close_residueno != $r_no) {
$close_atoms{$close_atomno} = 1;
}
}
}
sub distance { sqrt sum map {$_**2} map {$_[0][$_] - $_[1][$_]} 0 .. $#{$_[0]} };
my @close_atoms = keys %close_atoms;
say $out_fh1 "@close_atoms";
for my $m (0 .. $#close_atoms) {
say $out_fh1 $all_pos[$m];# here is problem i want residue details according to $close_atomno
}
say "result in $residue_file";
这是一个典型的输入文件:
ATOM 9 N GLU A 1 35.540 1.925 27.662 1.00 19.70 N
ATOM 10 CA GLU A 1 35.626 1.018 28.802 1.00 20.96 C
ATOM 11 C GLU A 1 34.264 0.794 29.444 1.00 20.22 C
按此顺序列:
答案 0 :(得分:1)
use warnings;
use strict;
my $base_r_no = $ARGV[0];
open IN, "<$ARGV[1]" or die;
my @atoms_data = map {[split]} grep {/^ATOM/} <IN>;
foreach my $base_atom (grep {($$_[2] !~ /^N|CA|O|C$/) && ($$_[5] eq $base_r_no)} @atoms_data) {
foreach my $matched_atom (grep {dist($base_atom,$_) < 4.5} @atoms_data) {
print join("\t",@{$matched_atom})."\n";
}
}
sub dist {
return sqrt( ($$_[1][5]-$$_[0][5])**2 + ($$_[1][6]-$$_[0][6])**2 + ($$_[1][7]-$$_[0][7])**2 );
}
对于多个pdb文件 - 我只是将所有文件都捕获到一个文件中并将其交给脚本。