bioinformatics - Perl program to calculate neibouring residues from a pdb file -
this program extract neighboring residues within 4.5 angstrom. have resolved program atom numbers. these want extract
- the residue numbers,
- residue name,
- atom № and
- atom name.
i output data in tabular form can directly copy results. i'm stuck , require extract fields atom numbers obtained in $close_atomno
, , how use program multiple pdb files , different catalytic residues in 1 go.
any appreciated.
#!/usr/bin/perl use list::util qw(sum); use data::dumper qw(dumper); use 5.010; "enter residue no."; chomp(my $r_no = <stdin>); (@all_pos, @all_data, @matching_pos, @matching_data); $residue_file = "neighbouring_residues.txt"; open $out_fh1, '>', $residue_file or die "can't open $residue_file: $!"; "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; @fields = split; push @all_pos, [ @fields[6 .. 8] ]; push @all_data, [ @fields[1 .. 3, 5] ]; if( $fields[6] eq $r_no) { $_; push @matching_pos, [ @fields[6 .. 8] ]; push @matching_data, [ @fields[1 .. 3, 5] ]; } } $out_fh1 "neighbouring residues @ position $r_no in 4.5a region are:"; %close_atoms; matching_atom: $i1 ( 0 .. $#matching_pos ) { $matching_atom = $matching_data[$i1][1]; $matching_atom eq $_ , next matching_atom qw/n ca o c/; $i2 ( 0 .. $#all_pos ) { ($close_atomno, $close_residueno) = @{$all_data[$i2]}[0, 3]; $dist = distance($matching_pos[$i1], $all_pos[$i2]); if($dist < 4.5 , $close_residueno != $r_no) { $close_atoms{$close_atomno} = 1; } } } sub distance { sqrt sum map {$_**2} map {$_[0][$_] - $_[1][$_]} 0 .. $#{$_[0]} }; @close_atoms = keys %close_atoms; $out_fh1 "@close_atoms"; $m (0 .. $#close_atoms) { $out_fh1 $all_pos[$m];# here problem want residue details according $close_atomno } "result in $residue_file";
this typical input file:
atom 9 n glu 1 35.540 1.925 27.662 1.00 19.70 n atom 10 ca glu 1 35.626 1.018 28.802 1.00 20.96 c atom 11 c glu 1 34.264 0.794 29.444 1.00 20.22 c
with columns in order:
- atom
- atom number
- atom name
- residue name
- chain
- residue number
- x coord
- y coord
- z coord
- irrelevant
- irrelevant
- irrelevant
use warnings; use strict; $base_r_no = $argv[0]; open in, "<$argv[1]" or die; @atoms_data = map {[split]} grep {/^atom/} <in>; foreach $base_atom (grep {($$_[2] !~ /^n|ca|o|c$/) && ($$_[5] eq $base_r_no)} @atoms_data) { foreach $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 ); }
as multiple pdb files - cat files 1 file , hand script.
Comments
Post a Comment