The Molecular Graphics Laboratory Forum

AutoDock, AutoLigand, MGLTools, Vina, PyRx and more.
It is currently Fri Sep 22, 2017 3:00 pm

All times are UTC




Post new topic Reply to topic  [ 1 post ] 
Author Message
PostPosted: Wed Nov 30, 2016 11:20 am 
Offline
Micromolar User
Micromolar User
User avatar

Joined: Tue Sep 21, 2010 10:56 am
Posts: 34
I wrote Perl script to automatically generate box around target.
Maybe it will be useful for somebody else.
It reads pdbqt file with target and writes Vina configuration file with box and pdb file with same box, tested it on Chimera.
Code:
#!/usr/bin/perl
#autobox
#Generate box for AutoDock Vina automatically
#
#V.R.

use List::Util qw( min max );

die "Usage ./autobox.pl FILE.pdbqt\n" if(!defined($ARGV[0]));
open($fh, $ARGV[0]) or die "Could not open file '$filename' $!";
 
while (my $row = <$fh>) {
        if ($row =~ m/^ATOM/) {
                #print "$row";
                @line = split(/ +/, $row);
                push @x, $line[6];
                push @y, $line[7];
                push @z, $line[8];
  }
}
close $fh;

$maxx = max(@x);
$maxy = max(@y);
$maxz = max(@z);
$minx = min(@x);
$miny = min(@y);
$minz = min(@z);

#print "max(x): ", $maxx, "\n";
#print "max(y): ", $maxy, "\n";
#print "max(z): ", $maxz, "\n";
#print "min(x): ", $minx, "\n";
#print "min(y): ", $miny, "\n";
#print "min(z): ", $minz, "\n";

$size_x = ($maxx - $minx)/2;
$size_y = ($maxy - $miny)/2;
$size_z = ($maxz - $minz)/2;
$center_x = $maxx - $size_x;
$center_y = $maxy - $size_y;
$center_z = $maxz - $size_z;

open(my $fh, '>', 'box.pdb') or die "Could not open file '$filename' $!";
print $fh ("
HEADER    CORNERS OF BOX
REMARK    CENTER (X Y Z)   $center_x  $center_y  $center_z
REMARK    DIMENSIONS (X Y Z)   $size_x  $size_y  $size_z
ATOM      1  DUA BOX     1     $minx  $miny  $minz
ATOM      2  DUB BOX     1     $maxx  $miny  $minz
ATOM      3  DUC BOX     1     $maxx  $miny  $maxz
ATOM      4  DUD BOX     1     $minx  $miny  $maxz
ATOM      5  DUE BOX     1     $minx  $maxy  $minz
ATOM      6  DUF BOX     1     $maxx  $maxy  $minz
ATOM      7  DUG BOX     1     $maxx  $maxy  $maxz
ATOM      8  DUH BOX     1     $minx  $maxy  $maxz
CONECT    1    2    4    5
CONECT    2    1    3    6
CONECT    3    2    4    7
CONECT    4    1    3    8
CONECT    5    1    6    8
CONECT    6    2    5    7
CONECT    7    3    6    8
CONECT    8    4    5    7
");
close $fh;

open(my $fh, '>', 'conf.txt') or die "Could not open file '$filename' $!";
print $fh ("
center_x = $center_x
center_y = $center_y
center_z = $center_z
size_x = $size_x
size_y = $size_y
size_z = $size_z
");
close $fh;


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 1 post ] 

All times are UTC


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
POWERED_BY
Translated by MaĆ«l Soucaze © 2009 phpBB.fr